Java Code Examples for javafx.scene.shape.Rectangle#contains()

The following examples show how to use javafx.scene.shape.Rectangle#contains() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaFxGazeUtils.java    From tet-java-client with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private static boolean checkViewCollision(Node n, Point2D gaze, Rectangle roi)
{
    javafx.geometry.Point2D screenCoord = n.localToScreen(0d, 0d);

    roi.setX(Math.round(screenCoord.getX()));
    roi.setY(Math.round(screenCoord.getY()));
    roi.setWidth(n.getBoundsInParent().getWidth());
    roi.setHeight(n.getBoundsInParent().getHeight());

    return roi.contains(
            (int)Math.round(gaze.x),
            (int)Math.round(gaze.y)
    );
}
 
Example 2
Source File: DockStation.java    From AnchorFX with GNU Lesser General Public License v3.0 4 votes vote down vote up
public boolean isInnerPosition(double x, double y) {

        Window window = getStationWindow();
        Rectangle bounds = new Rectangle(window.getX(), window.getY(), window.getWidth(), window.getHeight());
        return bounds.contains(x, y);
    }