本文整理匯總了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;
}