List of usage examples for javafx.scene.input ScrollEvent ANY
EventType ANY
To view the source code for javafx.scene.input ScrollEvent ANY.
Click Source Link
From source file:Main.java
@Override public void start(Stage stage) throws Exception { ImageView imageView = new ImageView(); ScrollPane scrollPane = new ScrollPane(); DoubleProperty zoomProperty = new SimpleDoubleProperty(200); zoomProperty.addListener(new InvalidationListener() { @Override/* w w w . j a v a 2s .c o m*/ public void invalidated(Observable arg0) { imageView.setFitWidth(zoomProperty.get() * 2); imageView.setFitHeight(zoomProperty.get() * 3); } }); scrollPane.addEventFilter(ScrollEvent.ANY, new EventHandler<ScrollEvent>() { @Override public void handle(ScrollEvent event) { if (event.getDeltaY() > 0) { zoomProperty.set(zoomProperty.get() * 1.2); } else if (event.getDeltaY() < 0) { zoomProperty.set(zoomProperty.get() / 1.1); } } }); imageView.setImage(new Image("http://yourImageURL")); imageView.preserveRatioProperty().set(true); scrollPane.setContent(imageView); stage.setScene(new Scene(scrollPane, 400, 300)); stage.show(); }
From source file:ZoomExample.java
@Override public void start(Stage stage) throws Exception { zoomProperty.addListener(new InvalidationListener() { @Override//ww w . j ava 2 s . c om public void invalidated(Observable arg0) { imageView.setFitWidth(zoomProperty.get() * 4); imageView.setFitHeight(zoomProperty.get() * 3); } }); scrollPane.addEventFilter(ScrollEvent.ANY, new EventHandler<ScrollEvent>() { @Override public void handle(ScrollEvent event) { if (event.getDeltaY() > 0) { zoomProperty.set(zoomProperty.get() * 1.1); } else if (event.getDeltaY() < 0) { zoomProperty.set(zoomProperty.get() / 1.1); } } }); imageView.setImage(new Image("http://yourImageURL")); imageView.preserveRatioProperty().set(true); scrollPane.setContent(imageView); stage.setScene(new Scene(scrollPane, 400, 300)); stage.show(); }
From source file:edu.kit.trufflehog.view.jung.visualization.FXVisualizationViewer.java
public FXVisualizationViewer(INetworkViewPort port) { this.port = port; // create canvas this.setStyle("-fx-background-color: #213245"); for (double divide = .25; divide < 1; divide += .25) { final Line line = new Line(0, 200, this.getWidth(), this.getHeight()); line.setFill(null);//from w w w.j a v a 2s . c o m line.setStroke(Color.web("0x385172")); line.setStrokeWidth(1.3); line.getStrokeDashArray().addAll(5d, 10d); line.startYProperty().bind(this.heightProperty().multiply(divide)); line.endXProperty().bind(this.widthProperty()); line.endYProperty().bind(this.heightProperty().multiply(divide)); this.getChildren().add(line); } for (double divide = .25; divide < 1; divide += .25) { final Line line = new Line(0, 0, this.getWidth(), this.getHeight()); line.setFill(null); line.setStroke(Color.web("0x385172")); line.setStrokeWidth(1.3); line.getStrokeDashArray().addAll(5d, 10d); line.startXProperty().bind(this.widthProperty().multiply(divide)); line.endXProperty().bind(this.widthProperty().multiply(divide)); line.endYProperty().bind(this.heightProperty()); this.getChildren().add(line); } //StackPane spane = new StackPane(); //spane.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); Pane ghost = new Pane(); canvas = new PannableCanvas(ghost); Pane parent = new Pane(); parent.getChildren().add(ghost); parent.getChildren().add(canvas); SceneGestures sceneGestures = new SceneGestures(parent, canvas); addEventFilter(MouseEvent.MOUSE_PRESSED, sceneGestures.getOnMousePressedEventHandler()); addEventFilter(MouseEvent.MOUSE_DRAGGED, sceneGestures.getOnMouseDraggedEventHandler()); addEventFilter(ScrollEvent.ANY, sceneGestures.getOnScrollEventHandler()); new RubberBandSelection(this); // TODO make canvas transparent //canvas.setStyle("-fx-background-color: #1d1d1d"); // we don't want the canvas on the top/left in this example => just // translate it a bit //canvas.setTranslateX(100); //canvas.setTranslateY(100); // create sample nodes which can be dragged nodeGestures = new NodeGestures(); //this.getChildren().add(spane); this.getChildren().add(parent); this.layout = port.getDelegate(); //this.layout.getGraph().getVertices().forEach(v -> Platform.runLater(() -> this.initVertex(v))); //this.layout.getGraph().getEdges().forEach(e -> Platform.runLater(() -> this.initEdge(e))); this.layout.getObservableGraph().addGraphEventListener(e -> { //Platform.runLater(() -> { switch (e.getType()) { case VERTEX_ADDED: final INode node = ((GraphEvent.Vertex<INode, IConnection>) e).getVertex(); Platform.runLater(() -> initVertex(node)); break; case EDGE_ADDED: final IConnection edge = ((GraphEvent.Edge<INode, IConnection>) e).getEdge(); Platform.runLater(() -> initEdge(edge)); break; case VERTEX_CHANGED: break; case EDGE_CHANGED: final IConnection changedEdge = ((GraphEvent.Edge<INode, IConnection>) e).getEdge(); Platform.runLater(() -> changedEdge.getComponent(ViewComponent.class).getRenderer().animate()); break; } //}); }); }
From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java
private void showImage(File file) { try {//www .j a v a 2 s .c o m ImageView iv = new ImageView(new Image(file.toURI().toURL().toString())); iv.setPreserveRatio(true); Stage stage = new Stage(); final DoubleProperty zoomProperty = new SimpleDoubleProperty(200); zoomProperty.addListener(new InvalidationListener() { @Override public void invalidated(javafx.beans.Observable observable) { iv.setFitWidth(zoomProperty.get() * 4); iv.setFitHeight(zoomProperty.get() * 3); } }); ScrollPane sp = new ScrollPane(iv); stage.addEventFilter(ScrollEvent.ANY, new EventHandler<ScrollEvent>() { @Override public void handle(ScrollEvent event) { if (event.getDeltaY() > 0) { zoomProperty.set(zoomProperty.get() * 1.1); } else if (event.getDeltaY() < 0) { zoomProperty.set(zoomProperty.get() / 1.1); } } }); stage.setScene(new Scene(new Group(sp))); stage.sizeToScene(); stage.show(); } catch (IOException ex) { showErrorDialog(ex); } }