Example usage for javafx.scene.control TreeView localToScreen

List of usage examples for javafx.scene.control TreeView localToScreen

Introduction

In this page you can find the example usage for javafx.scene.control TreeView localToScreen.

Prototype

public Point2D localToScreen(double localX, double localY) 

Source Link

Document

Transforms a point from the local coordinate space of this Node into the coordinate space of its javafx.stage.Screen .

Usage

From source file:org.eclipse.jubula.rc.javafx.tester.adapter.TreeOperationContext.java

@Override
public Rectangle getNodeBounds(final Object node) {
    Rectangle result = EventThreadQueuerJavaFXImpl.invokeAndWait("getNodeBounds", new Callable<Rectangle>() { //$NON-NLS-1$
        @Override/*from   www  .  j a v  a 2 s  . co m*/
        public Rectangle call() throws Exception {
            List<? extends TreeCell> tCells = ComponentHandler.getAssignableFrom(TreeCell.class);
            for (TreeCell<?> cell : tCells) {
                TreeItem<?> item = cell.getTreeItem();
                TreeView<?> tree = (TreeView<?>) getTree();
                if ((item != null && item.equals(node))) {
                    // Update the layout coordinates otherwise
                    // we would get old position values
                    tree.layout();

                    Point2D posTree = tree.localToScreen(0, 0);
                    Point2D posCell = cell.localToScreen(0, 0);
                    Bounds b = cell.getBoundsInParent();
                    Rectangle cBounds = new Rectangle(
                            Math.abs(Rounding.round((posCell.getX() - posTree.getX()))),
                            Math.abs(Rounding.round((posCell.getY() - posTree.getY()))),
                            Rounding.round(b.getWidth()), Rounding.round(b.getHeight()));
                    return cBounds;
                }
            }
            return null;
        }
    });
    return result;
}