List of usage examples for javafx.scene Node localToScreen
public Point2D localToScreen(double localX, double localY)
From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java
/** * Gets a location inside the component. If <code>offset</code> is * <code>null</code>, it returns the middle of the component otherwise it * adds the offset to the upper left corner. * * @param comp/*from w w w .ja v a2 s .com*/ * the component to get the location for * @param offset * the offset * @throws IllegalArgumentException * if <code>component</code> is null * @return the <b>global </b> coordinates of <code>component</code> */ private Point getLocation(Node comp, final Point offset) throws IllegalArgumentException { Validate.notNull(comp, "component must not be null"); //$NON-NLS-1$ Scene s = comp.getScene(); s.getRoot().layout(); Point2D pos = comp.localToScreen(0, 0); double x = pos.getX(); double y = pos.getY(); if (offset == null) { final Bounds boundsInParent = comp.getBoundsInParent(); x += boundsInParent.getWidth() / 2; y += boundsInParent.getHeight() / 2; } else { x += offset.x; y += offset.y; } return new Point(Rounding.round(x), Rounding.round(y)); }