类javafx.scene.input.PickResult源码实例Demo

下面列出了怎么用javafx.scene.input.PickResult的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: marathonv5   文件: RFXButtonBaseTest.java
@Test
public void click() {
    Button button = (Button) getPrimaryStage().getScene().getRoot().lookup(".button");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
            Point2D sceneXY = button.localToScene(new Point2D(3, 3));
            PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
            Point2D screenXY = button.localToScreen(new Point2D(3, 3));
            MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
                    MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
            rfxButtonBase.mouseButton1Pressed(me);
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording select = recordings.get(0);
    AssertJUnit.assertEquals("click", select.getCall());
    AssertJUnit.assertEquals("", select.getParameters()[0]);
}
 
源代码2 项目: marathonv5   文件: RFXHyperlinkButtonTest.java
@Test
public void click() {
    Hyperlink button = (Hyperlink) getPrimaryStage().getScene().getRoot().lookup(".hyperlink");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
            Point2D sceneXY = button.localToScene(new Point2D(3, 3));
            PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
            Point2D screenXY = button.localToScreen(new Point2D(3, 3));
            MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
                    MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
            rfxButtonBase.mouseButton1Pressed(me);
        }
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording select = recordings.get(0);
    AssertJUnit.assertEquals("click", select.getCall());
    AssertJUnit.assertEquals("", select.getParameters()[0]);
}
 
源代码3 项目: marathonv5   文件: RFXButtonBaseTest.java
@Test
public void getText() {
    Button button = (Button) getPrimaryStage().getScene().getRoot().lookup(".button");
    LoggingRecorder lr = new LoggingRecorder();
    List<String> text = new ArrayList<>();
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr);
            Point2D sceneXY = button.localToScene(new Point2D(3, 3));
            PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY());
            Point2D screenXY = button.localToScreen(new Point2D(3, 3));
            MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(),
                    MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult);
            rfxButtonBase.mouseButton1Pressed(me);
            text.add(rfxButtonBase.getAttribute("text"));
        }
    });
    new Wait("Waiting for button text.") {
        @Override
        public boolean until() {
            return text.size() > 0;
        }
    };
    AssertJUnit.assertEquals("Color", text.get(0));
}
 
源代码4 项目: gef   文件: FXNonApplicationThreadRule.java
/**
 * Fires a newly created {@link MouseEvent} of type
 * {@link MouseEvent#MOUSE_DRAGGED} to the target {@link Node} of the last mouse
 * interaction.
 *
 * @param sceneX
 *            The final x-coordinate (in scene) for the drag.
 * @param sceneY
 *            The final y-coordinate (in scene) for the drag.
 * @param mods
 *            The {@link Modifiers} for the {@link MouseEvent}.
 */
public void mouseDrag(final double sceneX, final double sceneY, final Modifiers mods) {
	waitForIdle();
	// save mouse interaction data
	lastMouseInteraction.sceneX = sceneX;
	lastMouseInteraction.sceneY = sceneY;
	run(() -> {
		Point2D local = lastMouseInteraction.target.sceneToLocal(sceneX, sceneY);
		Point2D screen = lastMouseInteraction.target.localToScreen(local.getX(), local.getY());
		fireEvent(lastMouseInteraction.target,
				new MouseEvent(lastMouseInteraction.target, lastMouseInteraction.target, MouseEvent.MOUSE_DRAGGED,
						local.getX(), local.getY(), screen.getX(), screen.getY(), MouseButton.PRIMARY, 0,
						mods.shift, mods.control, mods.alt, mods.meta, true, false, false, false, false, false,
						new PickResult(lastMouseInteraction.target, sceneX, sceneY)));
	});
	waitForIdle();
}
 
源代码5 项目: gef   文件: FXNonApplicationThreadRule.java
/**
 * Fires a newly created {@link MouseEvent} of type
 * {@link MouseEvent#MOUSE_MOVED} to the given target {@link Node}.
 *
 * @param sceneX
 *            The final x-coordinate (in scene) for the drag.
 * @param sceneY
 *            The final y-coordinate (in scene) for the drag.
 * @param mods
 *            The {@link Modifiers} for the {@link MouseEvent}.
 */
public void mouseMove(final Node target, final double sceneX, final double sceneY, final Modifiers mods) {
	waitForIdle();
	// save mouse interaction data
	lastMouseInteraction = new MouseInteraction();
	lastMouseInteraction.target = target;
	lastMouseInteraction.sceneX = sceneX;
	lastMouseInteraction.sceneY = sceneY;
	run(() -> {
		Point2D local = target.sceneToLocal(sceneX, sceneY);
		Point2D screen = target.localToScreen(local.getX(), local.getY());
		fireEvent(target,
				new MouseEvent(target, target, MouseEvent.MOUSE_MOVED, local.getX(), local.getY(), screen.getX(),
						screen.getY(), MouseButton.NONE, 0, mods.shift, mods.control, mods.alt, mods.meta, false,
						false, false, false, false, false, new PickResult(target, sceneX, sceneY)));
	});
	waitForIdle();
}
 
源代码6 项目: gef   文件: FXNonApplicationThreadRule.java
/**
 * Fires a newly created {@link MouseEvent} of type
 * {@link MouseEvent#MOUSE_PRESSED} to the target {@link Node} of the last mouse
 * interaction.
 *
 * @param mods
 *            The {@link Modifiers} for the {@link MouseEvent}.
 */
public void mousePress(final Modifiers mods) {
	waitForIdle();
	run(() -> {
		Point2D local = lastMouseInteraction.target.sceneToLocal(lastMouseInteraction.sceneX,
				lastMouseInteraction.sceneY);
		Point2D screen = lastMouseInteraction.target.localToScreen(local.getX(), local.getY());
		fireEvent(lastMouseInteraction.target,
				new MouseEvent(lastMouseInteraction.target, lastMouseInteraction.target, MouseEvent.MOUSE_PRESSED,
						local.getX(), local.getY(), screen.getX(), screen.getY(), MouseButton.PRIMARY, 1,
						mods.shift, mods.control, mods.alt, mods.meta, true, false, false, false, false, false,
						new PickResult(lastMouseInteraction.target, lastMouseInteraction.sceneX,
								lastMouseInteraction.sceneY)));
	});
	waitForIdle();
}
 
源代码7 项目: gef   文件: FXNonApplicationThreadRule.java
/**
 * Fires a newly created {@link MouseEvent} of type
 * {@link MouseEvent#MOUSE_RELEASED} to the target {@link Node} of the last
 * mouse interaction.
 *
 * @param mods
 *            The {@link Modifiers} for the {@link MouseEvent}.
 */
public void mouseRelease(final Modifiers mods) {
	waitForIdle();
	run(() -> {
		Point2D local = lastMouseInteraction.target.sceneToLocal(lastMouseInteraction.sceneX,
				lastMouseInteraction.sceneY);
		Point2D screen = lastMouseInteraction.target.localToScreen(local.getX(), local.getY());
		fireEvent(lastMouseInteraction.target,
				new MouseEvent(lastMouseInteraction.target, lastMouseInteraction.target, MouseEvent.MOUSE_RELEASED,
						local.getX(), local.getY(), screen.getX(), screen.getY(), MouseButton.PRIMARY, 1,
						mods.shift, mods.control, mods.alt, mods.meta, false, false, false, false, false, false,
						new PickResult(lastMouseInteraction.target, lastMouseInteraction.sceneX,
								lastMouseInteraction.sceneY)));
	});
	waitForIdle();
}
 
源代码8 项目: DockFX   文件: DockEvent.java
/**
 * Constructs new DockEvent event..
 * 
 * @param source the source of the event. Can be null.
 * @param target the target of the event. Can be null.
 * @param eventType The type of the event.
 * @param x The x with respect to the source. Should be in scene coordinates if source == null or
 *        source is not a Node.
 * @param y The y with respect to the source. Should be in scene coordinates if source == null or
 *        source is not a Node.
 * @param screenX The x coordinate relative to screen.
 * @param screenY The y coordinate relative to screen.
 * @param pickResult pick result. Can be null, in this case a 2D pick result without any further
 *        values is constructed based on the scene coordinates
 * @param contents The contents being dragged during this event.
 */
public DockEvent(Object source, EventTarget target, EventType<? extends DockEvent> eventType,
    double x, double y, double screenX, double screenY, PickResult pickResult, Node contents) {
  super(source, target, eventType);
  this.x = x;
  this.y = y;
  this.screenX = screenX;
  this.screenY = screenY;
  this.sceneX = x;
  this.sceneY = y;
  this.pickResult = pickResult != null ? pickResult : new PickResult(target, x, y);
  final Point3D p = InputEventUtils.recomputeCoordinates(this.pickResult, null);
  this.x = p.getX();
  this.y = p.getY();
  this.z = p.getZ();
  this.contents = contents;
}
 
源代码9 项目: marathonv5   文件: FXEventQueueDevice.java
@Override
public void click(Node node, Node target, PickResult pickResult, Buttons button, int clickCount, double xoffset,
        double yoffset) {
    MouseButton b = button.getMouseButton();
    dispatchMouseEvent(node, target, pickResult, button == Buttons.RIGHT, clickCount, b, xoffset, yoffset);
    deviceState.setNode(node);
}
 
源代码10 项目: marathonv5   文件: FXEventQueueDevice.java
private void dispatchMouseEvent(Node node, Node target, PickResult pickResult, boolean popupTrigger, int clickCount,
        MouseButton buttons, double x, double y) {
    ensureVisible(node);
    Point2D screenXY = node.localToScreen(new Point2D(x, y));
    if (node != deviceState.getNode()) {
        if (deviceState.getNode() != null) {
            dispatchEvent(createMouseEvent(MouseEvent.MOUSE_EXITED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
                    buttons, clickCount, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed,
                    deviceState.metaPressed, false, false, false, false, popupTrigger, false, node));
        }
        dispatchEvent(createMouseEvent(MouseEvent.MOUSE_ENTERED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
                buttons, clickCount, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed,
                deviceState.metaPressed, false, false, false, false, popupTrigger, false, node));
    }
    for (int n = 1; n <= clickCount; n++) {
        dispatchEvent(createMouseEvent(MouseEvent.MOUSE_PRESSED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
                buttons, n, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed,
                buttons == MouseButton.PRIMARY, buttons == MouseButton.MIDDLE, buttons == MouseButton.SECONDARY, false,
                popupTrigger, false, node));
        dispatchEvent(createMouseEvent(MouseEvent.MOUSE_RELEASED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
                buttons, n, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed,
                buttons == MouseButton.PRIMARY, buttons == MouseButton.MIDDLE, buttons == MouseButton.SECONDARY, false,
                popupTrigger, false, node));
        dispatchEvent(createMouseEvent(MouseEvent.MOUSE_CLICKED, target, pickResult, x, y, screenXY.getX(), screenXY.getY(),
                buttons, n, deviceState.shiftPressed, deviceState.ctrlPressed, deviceState.altPressed, deviceState.metaPressed,
                buttons == MouseButton.PRIMARY, buttons == MouseButton.MIDDLE, buttons == MouseButton.SECONDARY, false,
                popupTrigger, false, node));
    }
}
 
源代码11 项目: marathonv5   文件: JavaFXElement.java
@Override
public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
    verifyCanInteractWithElement();

    EventQueueWait.requestFocus(node);
    IDevice mouse = driver.getDevices();
    mouse.click(node, target, pickResult, Buttons.getButtonFor(button), clickCount, xoffset, yoffset);
}
 
源代码12 项目: marathonv5   文件: JavaFXTableCellElement.java
@Override
public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
    Node cell = getPseudoComponent();
    target = getTextObj((TableCell<?, ?>) cell);
    Point2D targetXY = target.localToParent(xoffset, yoffset);
    targetXY = node.localToScene(targetXY);
    super.click(button, target, new PickResult(target, targetXY.getX(), targetXY.getY()), clickCount, xoffset, yoffset);
}
 
源代码13 项目: marathonv5   文件: JavaFXTreeViewNodeElement.java
@Override
public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
    Node cell = getPseudoComponent();
    target = getTextObj((TreeCell<?>) cell);
    Point2D targetXY = node.localToScene(xoffset, yoffset);
    super.click(button, target, new PickResult(target, targetXY.getX(), targetXY.getY()), clickCount, xoffset, yoffset);
}
 
源代码14 项目: marathonv5   文件: JavaFXListViewItemElement.java
@Override
public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
    Node cell = getPseudoComponent();
    target = getTextObj((ListCell<?>) cell);
    Point2D targetXY = node.localToScene(xoffset, yoffset);
    super.click(button, target, new PickResult(target, targetXY.getX(), targetXY.getY()), clickCount, xoffset, yoffset);
}
 
@Override
public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
    Node cell = getPseudoComponent();
    target = getTextObj((TreeTableCell<?, ?>) cell);
    Point2D targetXY = target.localToParent(xoffset, yoffset);
    targetXY = node.localToScene(targetXY);
    super.click(button, target, new PickResult(target, targetXY.getX(), targetXY.getY()), clickCount, xoffset, yoffset);
}
 
源代码16 项目: marathonv5   文件: JavaFXBrowserViewItem.java
@Override
public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
    parent.click(selector, frameId);
}
 
源代码17 项目: marathonv5   文件: JavaFXChoiceBoxOptionElement.java
@Override
public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
    Platform.runLater(() -> ((ChoiceBox<?>) getComponent()).getSelectionModel().select(option));
}
 
源代码18 项目: marathonv5   文件: JavaFXWebViewItem.java
@Override
public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
    parent.click(selector);
}
 
源代码19 项目: marathonv5   文件: JavaFXComboBoxOptionElement.java
@Override
public void click(int button, Node target, PickResult pickResult, int clickCount, double xoffset, double yoffset) {
    Platform.runLater(() -> ((ComboBox<?>) getComponent()).getSelectionModel().select(option));
}
 
源代码20 项目: DockFX   文件: DockEvent.java
/**
 * Returns information about the pick.
 * 
 * @return new PickResult object that contains information about the pick
 */
public final PickResult getPickResult() {
  return pickResult;
}
 
源代码21 项目: DockFX   文件: DockEvent.java
/**
 * Constructs new DockEvent event..
 * 
 * @param eventType The type of the event.
 * @param x The x with respect to the source. Should be in scene coordinates if source == null or
 *        source is not a Node.
 * @param y The y with respect to the source. Should be in scene coordinates if source == null or
 *        source is not a Node.
 * @param screenX The x coordinate relative to screen.
 * @param screenY The y coordinate relative to screen.
 * @param pickResult pick result. Can be null, in this case a 2D pick result without any further
 *        values is constructed based on the scene coordinates
 */
public DockEvent(EventType<? extends DockEvent> eventType, double x, double y, double screenX,
    double screenY, PickResult pickResult) {
  this(null, null, eventType, x, y, screenX, screenY, pickResult);
}
 
源代码22 项目: DockFX   文件: DockEvent.java
/**
 * Constructs new DockEvent event..
 * 
 * @param source the source of the event. Can be null.
 * @param target the target of the event. Can be null.
 * @param eventType The type of the event.
 * @param x The x with respect to the source. Should be in scene coordinates if source == null or
 *        source is not a Node.
 * @param y The y with respect to the source. Should be in scene coordinates if source == null or
 *        source is not a Node.
 * @param screenX The x coordinate relative to screen.
 * @param screenY The y coordinate relative to screen.
 * @param pickResult pick result. Can be null, in this case a 2D pick result without any further
 *        values is constructed based on the scene coordinates
 */
public DockEvent(Object source, EventTarget target, EventType<? extends DockEvent> eventType,
    double x, double y, double screenX, double screenY, PickResult pickResult) {
  this(source, target, eventType, x, y, screenX, screenY, pickResult, null);
}
 
源代码23 项目: marathonv5   文件: IDevice.java
void click(Node component, Node target, PickResult pickResult, Buttons button, int clickCount, double xoffset, double yoffset); 
源代码24 项目: marathonv5   文件: IJavaFXElement.java
public abstract void click(int button, Node target, PickResult pickResult, int clickCount, double x, double y); 
 类所在包
 同包方法