List of usage examples for javafx.scene Node getScene
public final Scene getScene()
From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java
/** * Implementation of the mouse move. The mouse is moved into the graphics * component./* www . j av a2s. c o m*/ * * @param graphicsComponent * The component to move to * @param constraints * The more specific constraints. Use this, for example when you * want the click point to be relative to a part of the component * (e.g. tree node, table cell, etc) rather than the overall * component itself. May be <code>null</code>. * @param xPos * xPos in component * @param yPos * yPos in component * @param xAbsolute * true if x-position should be absolute * @param yAbsolute * true if y-position should be absolute * @param clickOptions * The click options * @throws StepExecutionException * If the click delay is interrupted or the event confirmation * receives a timeout. */ private void moveImpl(final Object graphicsComponent, final Rectangle constraints, final int xPos, final boolean xAbsolute, final int yPos, final boolean yAbsolute, final ClickOptions clickOptions) throws StepExecutionException { Rectangle bounds = getComponentBounds(graphicsComponent, clickOptions); if (constraints != null) { bounds.x += constraints.x; bounds.y += constraints.y; bounds.height = constraints.height; bounds.width = constraints.width; } Point p = PointUtil.calculateAwtPointToGo(xPos, xAbsolute, yPos, yAbsolute, bounds); // Move if necessary if (isMouseMoveRequired(p)) { if (log.isDebugEnabled()) { log.debug("Moving mouse to: " + p); //$NON-NLS-1$ } Point startpoint = m_mouseMotionTracker.getLastMousePointOnScreen(); if (startpoint == null) { // If there is no starting point the center of the root // component is used if (graphicsComponent instanceof Stage) { Stage s = (Stage) graphicsComponent; Node root = s.getScene().getRoot(); startpoint = (root != null) ? getLocation(root, null) : new Point(Rounding.round(s.getWidth() / 2), Rounding.round(s.getHeight() / 2)); } else { Node node = (Node) graphicsComponent; Node root = node.getScene().getRoot(); Node c = (root != null) ? root : node; startpoint = getLocation(c, null); } } IRobotEventConfirmer confirmer = null; InterceptorOptions options = new InterceptorOptions(new long[] { AWTEvent.MOUSE_MOTION_EVENT_MASK }); //For drag Events we have to register the confirmer earlier //because the drag event is thrown when the movement starts if (DragAndDropHelper.getInstance().isDragMode()) { confirmer = m_interceptor.intercept(options); } final Point[] mouseMove = MouseMovementStrategy.getMovementPath(startpoint, p, clickOptions.getStepMovement(), clickOptions.getFirstHorizontal()); for (int i = 0; i < mouseMove.length - 1; i++) { m_robot.mouseMove(mouseMove[i].x, mouseMove[i].y); m_robot.waitForIdle(); } if (!DragAndDropHelper.getInstance().isDragMode()) { confirmer = m_interceptor.intercept(options); } Point endPoint = mouseMove[mouseMove.length - 1]; m_robot.mouseMove(endPoint.x, endPoint.y); m_robot.waitForIdle(); if (confirmer != null) { confirmMove(confirmer, graphicsComponent); } } }
From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java
/** * * {@inheritDoc}//from w w w .j a v a2 s . c om */ public boolean isMouseInComponent(final Object graphicsComponent) { final Point currMousePos = getCurrentMousePosition(); return EventThreadQueuerJavaFXImpl.invokeAndWait("isMouseInComponent", //$NON-NLS-1$ new Callable<Boolean>() { @Override public Boolean call() throws Exception { if (graphicsComponent instanceof Node) { Node comp = (Node) graphicsComponent; comp.getScene().getRoot().layout(); if (currMousePos == null) { return false; } return NodeBounds.checkIfContains(new Point2D(currMousePos.x, currMousePos.y), comp); } Stage comp = (Stage) graphicsComponent; comp.getScene().getRoot().layout(); Bounds stageBounds = new BoundingBox(comp.getX(), comp.getY(), comp.getWidth(), comp.getHeight()); return stageBounds.contains(new Point2D(currMousePos.x, currMousePos.y)); } }); }