本文整理汇总了Java中javafx.scene.image.ImageView.addEventHandler方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.addEventHandler方法的具体用法?Java ImageView.addEventHandler怎么用?Java ImageView.addEventHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.image.ImageView
的用法示例。
在下文中一共展示了ImageView.addEventHandler方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ViewerAboutDialog
import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public ViewerAboutDialog(Stage stage) {
ImageView image = ImageUtils.createImageView("/icons/spy128.png");
this.setCenter(image);
this.setOnMouseClicked(e -> stage.close());
image.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> {
Task<Void> task = new Task<Void>() {
@Override
protected Void call() throws Exception {
Desktop.getDesktop().browse(URI.create(homeUrl));
return null;
}
};
task.setOnFailed(e -> {
Throwable exception = e.getSource().getException();
if (exception != null) {
Log.error(exception);
ViewerAlert.exceptionAlert(exception);
}
});
new Thread(task).start();
});
}
示例2: createZoomOutHeatMapEventHandler
import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private static EventHandler<Event> createZoomOutHeatMapEventHandler(ImageView heatMap, Scene scene,
int originalIndexInParent) {
return new EventHandler<Event>() {
@Override
public void handle(Event e) {
heatMap.removeEventHandler(MouseEvent.MOUSE_CLICKED, this);
zoomOutAndReset(heatMap);
resetToOriginalIndexInParent(heatMap, originalIndexInParent);
heatMap.addEventHandler(MouseEvent.MOUSE_CLICKED, createZoomInHeatMapEventHandler(heatMap, scene));
}
};
}
示例3: createZoomInHeatMapEventHandler
import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private static EventHandler<Event> createZoomInHeatMapEventHandler(ImageView heatMap, Scene scene) {
return new EventHandler<Event>() {
@Override
public void handle(Event e) {
heatMap.removeEventHandler(MouseEvent.MOUSE_CLICKED, this);
int originalIndexInParent = getOriginalIndexInParent(heatMap);
zoomInAndCenter(heatMap, heatMap.getFitWidth(), heatMap.getFitHeight(), true);
heatMap.addEventHandler(MouseEvent.MOUSE_CLICKED,
createZoomOutHeatMapEventHandler(heatMap, scene, originalIndexInParent));
}
};
}
示例4: BuildHeatChart
import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public static ImageView BuildHeatChart(Stats stats, Scene scene) {
HeatMapUtils.buildHeatMap(stats.getHeatMap());
Image image = new Image("file:" + HeatMapUtils.getHeatMapPath());
ImageView heatMap = new ImageView(image);
heatMap.setPreserveRatio(true);
EventHandler<Event> openHeatMapEvent = createZoomInHeatMapEventHandler(heatMap, scene);
heatMap.addEventHandler(MouseEvent.MOUSE_CLICKED, openHeatMapEvent);
return heatMap;
}