@Override public void initAnimation(Node contentContainer, Node overlay) { overlay.setOpacity(0); contentContainer.setTranslateY(contentContainer.getLayoutY() + contentContainer.getLayoutBounds().getMaxY()); }
@Override public void initAnimation(Node contentContainer, Node overlay) { overlay.setOpacity(0); contentContainer.setTranslateY(-(contentContainer.getLayoutY() + contentContainer.getLayoutBounds().getMaxY())); }
public VerticalTransition(boolean topDirection, Node contentContainer, Node overlay) { super(contentContainer, new Timeline( new KeyFrame(Duration.ZERO, new KeyValue(contentContainer.translateYProperty(), (contentContainer.getLayoutY() + contentContainer.getLayoutBounds().getMaxY()) * (topDirection? -1 : 1), Interpolator.LINEAR), new KeyValue(overlay.opacityProperty(), 0, Interpolator.EASE_BOTH) ), new KeyFrame(Duration.millis(1000), new KeyValue(overlay.opacityProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(contentContainer.translateYProperty(), 0, Interpolator.EASE_OUT) ))); // reduce the number to increase the shifting , increase number to reduce shifting setCycleDuration(Duration.seconds(0.4)); setDelay(Duration.seconds(0)); } }
@Override public double layoutX(Node node) { return node.getLayoutY(); }
@Override public double layoutY(Node node) { return node.getLayoutY(); }
import javafx.scene.Node; import javafx.scene.paint.Paint; import javafx.scene.shape.Rectangle; public class City extends Rectangle { public City(final Node node) { super(node.getLayoutX(), node.getLayoutY(), 32, 32); this.setFill(Paint.valueOf("BLUE")); } }
//gets the display region of the chart Node chartPlotArea = chart.lookup(".chart-plot-background"); double chartZeroX = chartPlotArea.getLayoutX(); double chartZeroY = chartPlotArea.getLayoutY();
private void clickOnMe(ObservableList<Node> nodes){ for(Node n : nodes){ n.fireEvent(new MouseEvent(MouseEvent.MOUSE_CLICKED, n.getLayoutX(), n.getLayoutY(), n.getLayoutX(), n.getLayoutY(), MouseButton.PRIMARY, 1, true, true, true, true, true, true, true, true, true, true, null)); } }
@Override protected double computeValue() { return senderNode.getLayoutY() + senderNode.getTranslateY() + senderShape.getRadius(); } };
@Override public void initAnimation(Node contentContainer, Node overlay) { overlay.setOpacity(0); contentContainer.setTranslateY(contentContainer.getLayoutY() + contentContainer.getLayoutBounds().getMaxY()); }
@Override public void initAnimation(Node contentContainer, Node overlay) { overlay.setOpacity(0); contentContainer.setTranslateY(-(contentContainer.getLayoutY() + contentContainer.getLayoutBounds().getMaxY())); }
private static Rectangle2D getBounds(Node node) { Bounds lBounds = node.getLayoutBounds(); return new Rectangle2D( node.getLayoutX(), node.getLayoutY(), lBounds.getWidth(), lBounds.getHeight() ); }
@Override protected void layoutChildren() { getParent().requestLayout(); super.layoutChildren(); for (Node n : getManagedChildren()) { if (n instanceof Region) { Region p = (Region) n; double width = Math.max(p.getMinWidth(), p.getPrefWidth()); double height = Math.max(p.getMinHeight(), p.getPrefHeight()); n.resize(width, height); double nX = Math.min(0, n.getLayoutX()); double nY = Math.min(0, n.getLayoutY()); n.relocate(nX, nY); } } }
public AssertNode assertXYWH(double x, double y, double w, double h, double accuracy) { Assert.assertEquals(description + ", X", x, node.getLayoutX(), accuracy); Assert.assertEquals(description + ", Y", y, node.getLayoutY(), accuracy); Assert.assertEquals(description + ", W", w, width(node), accuracy); Assert.assertEquals(description + ", H", h, height(node), accuracy); return this; }
EventHandler<MouseEvent> onMouseReleasedEventHandler = new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { fixPosition((Node) t.getSource()); } }; resource.setOnMouseReleased(onMouseReleasedEventHandler); private void fixPosition( Node node) { double x = node.getTranslateX(); double y = node.getTranslateY(); node.relocate(node.getLayoutX() + x, node.getLayoutY() + y); node.setTranslateX(0); node.setTranslateY(0); }
public static Group convertTo3D(Node node, int depth) { Group root = new Group(); root.setTranslateX(node.getLayoutX()); root.setTranslateY(node.getLayoutY()); root.setTranslateZ(-20); System.out.println("Layer " + depth + " - Node Type: " + node.getClass()); Box box = new Box(node.getBoundsInParent().getWidth(), node.getBoundsInParent().getHeight(), 0.1); box.setTranslateX(node.getLayoutX()); box.setTranslateY(node.getLayoutY()); SnapshotParameters snapshotParameters = new SnapshotParameters(); snapshotParameters.setFill(Color.TRANSPARENT); box.setMaterial(new PhongMaterial(Color.WHITE, node.snapshot(snapshotParameters, new WritableImage((int) node.getBoundsInParent().getWidth(), (int) node.getBoundsInParent().getHeight())), null, null, null)); root.getChildren().add(box); if (node instanceof Parent) { for (Node child : ((Parent) node).getChildrenUnmodifiable()) { root.getChildren().add(convertTo3D(child, depth + 1)); } } return root; }
protected void initSenderAndReceiver() { receiverConnectorUI = new Circle(15); final VNode sender = getSender().getNode(); final FXFlowNodeSkin senderSkin = (FXFlowNodeSkin) getController(). getNodeSkinLookup().getById(skinFactory, sender.getId()); senderShape = senderSkin.getConnectorShape(getSender()); final Node senderNode = senderShape.getNode(); senderConnectorUI = senderShape; receiverConnectorUI.setLayoutX(senderNode.getLayoutX() +receiverConnectorUI.getRadius()); receiverConnectorUI.setLayoutY(senderNode.getLayoutY() +receiverConnectorUI.getRadius()); }
public void performDragBegin( Node n, MouseEvent event) { final double parentScaleX = n.getParent(). localToSceneTransformProperty().getValue().getMxx(); final double parentScaleY = n.getParent(). localToSceneTransformProperty().getValue().getMyy(); // record the current mouse X and Y position on Node mouseX = event.getSceneX(); mouseY = event.getSceneY(); if (centerNode) { Point2D p2d = n.getParent().sceneToLocal(mouseX, mouseY); nodeX = p2d.getX(); nodeY = p2d.getY(); } else { nodeX = n.getLayoutX() * parentScaleX; nodeY = n.getLayoutY() * parentScaleY; } n.toFront(); } }
protected void initMaterialNodeDrag() { final Delta dragDelta = new Delta(); materialNode.setOnMousePressed(mouseEvent -> { AnchorPane.setTopAnchor(materialNode, null); AnchorPane.setBottomAnchor(materialNode, null); AnchorPane.setRightAnchor(materialNode, null); // record a delta distance for the drag and drop operation. dragDelta.x = materialNode.getLayoutX() - mouseEvent.getSceneX(); dragDelta.y = materialNode.getLayoutY() - mouseEvent.getSceneY(); materialNode.setCursor(Cursor.MOVE); }); materialNode.setOnMouseReleased(mouseEvent -> materialNode.setCursor(Cursor.HAND)); materialNode.setOnMouseDragged(mouseEvent -> { materialNode.setLayoutX(mouseEvent.getSceneX() + dragDelta.x); materialNode.setLayoutY(mouseEvent.getSceneY() + dragDelta.y); }); materialNode.setOnMouseEntered(mouseEvent -> materialNode.setCursor(Cursor.HAND)); }
public VerticalTransition(boolean topDirection, Node contentContainer, Node overlay) { super(contentContainer, new Timeline( new KeyFrame(Duration.ZERO, new KeyValue(contentContainer.translateYProperty(), (contentContainer.getLayoutY() + contentContainer.getLayoutBounds().getMaxY()) * (topDirection? -1 : 1), Interpolator.LINEAR), new KeyValue(overlay.opacityProperty(), 0, Interpolator.EASE_BOTH) ), new KeyFrame(Duration.millis(1000), new KeyValue(overlay.opacityProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(contentContainer.translateYProperty(), 0, Interpolator.EASE_OUT) ))); // reduce the number to increase the shifting , increase number to reduce shifting setCycleDuration(Duration.seconds(0.4)); setDelay(Duration.seconds(0)); } }