Example usage for javafx.scene Node localToScene

List of usage examples for javafx.scene Node localToScene

Introduction

In this page you can find the example usage for javafx.scene Node localToScene.

Prototype

void localToScene(com.sun.javafx.geom.Vec3d pt) 

Source Link

Usage

From source file:com.eviware.loadui.ui.fx.util.NodeUtils.java

public static Rectangle2D localToScreen(Node node, Scene scene) {
    Bounds selectableBounds = node.localToScene(node.getBoundsInLocal());

    return new Rectangle2D(selectableBounds.getMinX() + scene.getX() + scene.getWindow().getX(),
            selectableBounds.getMinY() + scene.getY() + scene.getWindow().getY(),
            node.getBoundsInLocal().getWidth(), node.getBoundsInLocal().getHeight());
}

From source file:com.eviware.loadui.ui.fx.util.NodeUtils.java

public static Bounds absoluteBoundsOf(Node node) {
    double tX = node.getScene().getWindow().getX() + node.getScene().getX();
    double tY = node.getScene().getWindow().getY() + node.getScene().getY();
    Bounds boundsInScene = node.localToScene(node.getBoundsInLocal());
    return new BoundingBox(boundsInScene.getMinX() + tX, boundsInScene.getMinY() + tY, boundsInScene.getWidth(),
            boundsInScene.getHeight());/*from w w  w.  j  a v  a2s . c o m*/
}

From source file:Main.java

public static void addMarker(final XYChart<?, ?> chart, final StackPane chartWrap) {
    final Line valueMarker = new Line();
    final Node chartArea = chart.lookup(".chart-plot-background");

    chartArea.setOnMouseMoved(new EventHandler<MouseEvent>() {
        @Override/*from  w  w w  .  j a  v  a2 s .  com*/
        public void handle(MouseEvent event) {
            Point2D scenePoint = chart.localToScene(event.getSceneX(), event.getSceneY());
            Point2D position = chartWrap.sceneToLocal(scenePoint.getX(), scenePoint.getY());

            Bounds chartAreaBounds = chartArea.localToScene(chartArea.getBoundsInLocal());
            valueMarker.setStartY(0);
            valueMarker.setEndY(chartWrap.sceneToLocal(chartAreaBounds).getMaxY()
                    - chartWrap.sceneToLocal(chartAreaBounds).getMinY());

            valueMarker.setStartX(0);
            valueMarker.setEndX(0);
            valueMarker.setTranslateX(position.getX() - chartWrap.getWidth() / 2);

            double ydelta = chartArea.localToScene(0, 0).getY() - chartWrap.localToScene(0, 0).getY();
            valueMarker.setTranslateY(-ydelta * 2);
        }
    });

    chartWrap.getChildren().add(valueMarker);
}