Java Code Examples for javafx.scene.input.MouseEvent#getSceneX()

The following examples show how to use javafx.scene.input.MouseEvent#getSceneX() . 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: Fx3DStageController.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public void handleMouseDragged(MouseEvent me) {
  double rotateFactor = 0.12;
  mousePosX = me.getSceneX();
  mousePosY = me.getSceneY();
  if (me.isPrimaryButtonDown()) {
    rotateX.setAngle(rotateX.getAngle() + rotateFactor * (mousePosY - mouseOldY));
    rotateY.setAngle(rotateY.getAngle() - rotateFactor * (mousePosX - mouseOldX));
  }
  if (me.isSecondaryButtonDown()) {
    translateX.setX(translateX.getX() + (mousePosX - mouseOldX));
    translateY.setY(translateY.getY() + (mousePosY - mouseOldY));

  }
  mouseOldX = mousePosX;
  mouseOldY = mousePosY;
}
 
Example 2
Source File: JointCreator.java    From graph-editor with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Updates the position of the joint creator effect based on the cursor position.
 *
 * @param event the mouse event containing information about the cursor position
 * @param root the root node of the connection
 */
private void updateHoverEffectPosition(final MouseEvent event, final Group root) {

    final double sceneX = event.getSceneX();
    final double sceneY = event.getSceneY();

    final Point2D offset = offsetCalculator.getOffset(sceneX, sceneY);

    // Do not show the joint-creator effect if the cursor is on/near a detour (too messy).
    if (offset == null) {
        hoverEffect.setVisible(false);
        return;
    } else {
        hoverEffect.setVisible(true);
    }

    final Point2D sceneCoordinatesOfParent = root.getParent().localToScene(0, 0);

    final double scaleFactor = root.getLocalToSceneTransform().getMxx();

    final double x = (sceneX - sceneCoordinatesOfParent.getX() + offset.getX()) / scaleFactor;
    final double y = (sceneY - sceneCoordinatesOfParent.getY() + offset.getY()) / scaleFactor;

    hoverEffect.setX(GeometryUtils.moveOnPixel(x - HOVER_EFFECT_SIZE / 2));
    hoverEffect.setY(GeometryUtils.moveOnPixel(y - HOVER_EFFECT_SIZE / 2));
}
 
Example 3
Source File: EditDataSet.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
protected void performPointDrag(final MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY && !controlDown && isPointDragActive) {
        if (mouseOriginX < 0) {
            mouseOriginX = event.getSceneX();
        }
        if (mouseOriginY < 0) {
            mouseOriginY = event.getSceneY();
        }
        final double deltaX = event.getSceneX() - mouseOriginX;
        final double deltaY = event.getSceneY() - mouseOriginY;

        // get the latest mouse coordinate.
        mouseOriginX = event.getSceneX();
        mouseOriginY = event.getSceneY();

        applyDrag(deltaX, deltaY);
        event.consume();
    } else {
        isPointDragActive = false;
    }
}
 
Example 4
Source File: DataViewWindow.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
private void dragStart(final MouseEvent mevt) {
    if (!mouseFilter.test(mevt)) {
        return;
    }
    installCursor();
    xOffset = mevt.getSceneX();
    yOffset = mevt.getSceneY();
}
 
Example 5
Source File: GeometryUtils.java    From graph-editor with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Gets the position of the cursor relative to some node.
 *
 * @param event a {@link MouseEvent} storing the cursor position
 * @param node some {@link Node}
 *
 * @return the position of the cursor relative to the node origin
 */
public static Point2D getCursorPosition(final MouseEvent event, final Node node) {

    final double sceneX = event.getSceneX();
    final double sceneY = event.getSceneY();

    final double containerSceneX = node.localToScene(0, 0).getX();
    final double containerSceneY = node.localToScene(0, 0).getY();

    return new Point2D(sceneX - containerSceneX, sceneY - containerSceneY);
}
 
Example 6
Source File: JFXDecorator.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private void updateInitMouseValues(MouseEvent mouseEvent) {
    initStageX = primaryStage.getX();
    initStageY = primaryStage.getY();
    initWidth = primaryStage.getWidth();
    initHeight = primaryStage.getHeight();
    initX = mouseEvent.getScreenX();
    initY = mouseEvent.getScreenY();
    xOffset = mouseEvent.getSceneX();
    yOffset = mouseEvent.getSceneY();
}
 
Example 7
Source File: CellGestures.java    From fxgraph with Do What The F*ck You Want To Public License 5 votes vote down vote up
private static void dragWest(MouseEvent event, Wrapper<Point2D> mouseLocation, Region region, double handleRadius) {
	final double deltaX = event.getSceneX() - mouseLocation.value.getX();
	final double newX = region.getLayoutX() + deltaX;
	if(newX != 0 && newX <= region.getParent().getBoundsInLocal().getWidth() - handleRadius) {
		region.setLayoutX(newX);
		region.setPrefWidth(region.getPrefWidth() - deltaX);
	}
}
 
Example 8
Source File: ViewportGestures.java    From fxgraph with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Override
public void handle(MouseEvent event) {

	// right mouse button => panning
	if(!event.isSecondaryButtonDown()) {
		return;
	}

	sceneDragContext.mouseAnchorX = event.getSceneX();
	sceneDragContext.mouseAnchorY = event.getSceneY();

	sceneDragContext.translateAnchorX = canvas.getTranslateX();
	sceneDragContext.translateAnchorY = canvas.getTranslateY();

}
 
Example 9
Source File: DraggableNode.java    From exit_code_java with GNU General Public License v3.0 5 votes vote down vote up
private void tileWindowIfOnEdge(MouseEvent event) {
    if(!tile_windows_on_edge) return; //check if setting is set to true

    int cornerSpace = 70;
    double desktopWidth = Desktop.main_root.getWidth();
    double desktopHeight = Desktop.main_root.getHeight() - Desktop.desktop_taskbar.getHeight();

    if (mousex <= 0 && mousey < cornerSpace || mousey <= 0 && mousex < cornerSpace) {
        snapOnEdge(0, 0, desktopWidth / 2, desktopHeight / 2);
    } else if (mousex <= 0 && mousey >= desktopHeight - cornerSpace || mousey >= desktopHeight && mousex <= cornerSpace) {
        snapOnEdge(0, desktopHeight / 2, desktopWidth / 2, desktopHeight / 2);
    } else if (mousex >= desktopWidth - 1 && mousey < cornerSpace || mousey <= 0 && mousex > desktopWidth - cornerSpace) {
        snapOnEdge(desktopWidth / 2, 0, desktopWidth / 2, desktopHeight / 2);
    } else if (mousex >= desktopWidth - 1 && mousey >= desktopHeight - cornerSpace || mousey >= desktopHeight && mousex > desktopWidth - cornerSpace) {
        snapOnEdge(desktopWidth / 2, desktopHeight / 2, desktopWidth / 2, desktopHeight / 2);
    } else if (mousey <= 0) {
        maximize();
    } else if (mousex <= 0) {
        snapOnEdge(0, 0, desktopWidth / 2, desktopHeight);
    } else if (mousex >= desktopWidth - 1) {
        snapOnEdge(desktopWidth / 2, 0, desktopWidth / 2, desktopHeight);
    } else if (onEdge) {
        restoreSize();
        x = event.getSceneX() - nonMaxSizeWidth / 2;
        setLayoutX(x);
        onEdge = false;
    }
}
 
Example 10
Source File: WolfensteinCheats.java    From jace with GNU General Public License v2.0 5 votes vote down vote up
private void processMouseEvent(MouseEvent evt) {
    if (evt.isPrimaryButtonDown() || evt.isSecondaryButtonDown()) {
        Node source = (Node) evt.getSource();
        double mouseX = evt.getSceneX() / source.getBoundsInLocal().getWidth();
        double mouseY = evt.getSceneY() / source.getBoundsInLocal().getHeight();
        int x = Math.max(0, Math.min(7, (int) ((mouseX - 0.148) * 11)));
        int y = Math.max(0, Math.min(7, (int) ((mouseY - 0.101) * 11)));
        int location = x + (y << 3);
        if (evt.getButton() == MouseButton.PRIMARY) {
            killEnemyAt(location);
        } else {
            teleportTo(location);
        }
    }
}
 
Example 11
Source File: CreateCurveOnDragHandler.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
protected Point getLocation(MouseEvent e) {
	// XXX: Viewer may be null if the host is removed in the same pass in
	// which the event is forwarded.
	if (getHost().getViewer() == null) {
		return new Point(e.getSceneX(), e.getSceneY());
	}
	// FIXME: Prevent invocation of interaction policies when their host
	// does not have a link to the viewer.
	Point2D location = ((InfiniteCanvasViewer) getHost().getRoot().getViewer()).getCanvas().getContentGroup()
			.sceneToLocal(e.getSceneX(), e.getSceneY());
	return new Point(location.getX(), location.getY());
}
 
Example 12
Source File: CameraController.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
private Point2D getMouseDelta(MouseEvent event) {
    Point2D res = new Point2D(event.getSceneX() - previousX, event.getSceneY() - previousY);
    previousX = event.getSceneX();
    previousY = event.getSceneY();

    return res;
}
 
Example 13
Source File: MouseDragSnippet.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
protected void onMouseEvent(MouseEvent event) {
	if (pressed == null) {
		// no processing if no node is pressed
		return;
	}

	// node is pressed, process all mouse events
	EventType<? extends Event> type = event.getEventType();
	if (type.equals(MouseEvent.MOUSE_RELEASED)) {
		System.out.println("release " + pressed);
		pressed.setEffect(null);
		IAnchor ifxAnchor = anchors.get(pressed);
		if (ifxAnchor != null) {
			Set<AnchorKey> keys = ifxAnchor.positionsUnmodifiableProperty()
					.keySet();
			for (AnchorKey key : keys) {
				key.getAnchored().setEffect(new BoxBlur());
			}
		}
		pressed = null;
		nodesUnderMouse.clear();
	} else if (type.equals(MouseEvent.MOUSE_DRAGGED)) {
		double dx = event.getSceneX() - startMousePosition.getX();
		double dy = event.getSceneY() - startMousePosition.getY();
		pressed.setLayoutX(startLayoutPosition.getX() + dx);
		pressed.setLayoutY(startLayoutPosition.getY() + dy);
		boolean changed = updateNodesUnderMouse(event.getSceneX(),
				event.getSceneY());
		if (changed) {
			System.out.println(
					"targets: " + Arrays.asList(nodesUnderMouse.toArray()));
		}
	}
}
 
Example 14
Source File: Fx3DStageController.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public void handleMousePressed(MouseEvent me) {
  mouseOldX = me.getSceneX();
  mouseOldY = me.getSceneY();
}
 
Example 15
Source File: BendOnSegmentDragHandler.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void startDrag(MouseEvent e) {
	isInvalid = !isBend(e);
	if (isInvalid) {
		return;
	}

	// save initial mouse position in scene coordinates
	initialMouseInScene = new Point(e.getSceneX(), e.getSceneY());

	// disable refresh visuals for the host
	storeAndDisableRefreshVisuals(getHost());

	bendPolicy = determineBendPolicy();
	init(bendPolicy);
	updateHandles();

	prepareBend(bendPolicy);
	// move initially so that the initial positions for the selected
	// points are computed
	bendPolicy.move(initialMouseInScene, initialMouseInScene);

	// query selected position
	List<Point> initialPositions = bendPolicy.getSelectedInitialPositions();
	Point startPositionInConnectionLocal = initialPositions.get(0);
	Point startPositionInScene = FX2Geometry.toPoint(getHost().getVisual()
			.localToScene(startPositionInConnectionLocal.x,
					startPositionInConnectionLocal.y));

	snapToSupport = getHost() instanceof IContentPart
			? getHost().getViewer().getAdapter(SnapToSupport.class) : null;
	if (snapToSupport != null) {
		// Only report HSL or VSL depending on segment orientation
		SnappingLocation sl = bendPolicy.isSelectionHorizontal()
				? new SnappingLocation(
						(IContentPart<? extends Connection>) getHost(),
						Orientation.VERTICAL, startPositionInScene.y)
				: new SnappingLocation(
						(IContentPart<? extends Connection>) getHost(),
						Orientation.HORIZONTAL, startPositionInScene.x);
		snapToSupport.startSnapping(
				(IContentPart<? extends Connection>) getHost(),
				Arrays.asList(sl));
	}
}
 
Example 16
Source File: CameraController.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
private void handleMousePress(MouseEvent event) {
    previousX = event.getSceneX();
    previousY = event.getSceneY();
    event.consume();
}
 
Example 17
Source File: PosGraphController.java    From Motion_Profile_Generator with MIT License 4 votes vote down vote up
@FXML
private void addPointOnClick( MouseEvent event )
{
    if( settings.isAddPointOnClick() )
    {
        // Only add a point if mouse has not moved since clicking. This filters out the mouse event from dragging a point.
        if ( event.isStillSincePress() )
        {
            // get pixel location
            Point2D mouseSceneCoords = new Point2D( event.getSceneX(), event.getSceneY() );
            double xLocal = axisPosX.sceneToLocal( mouseSceneCoords ).getX();
            double yLocal = axisPosY.sceneToLocal( mouseSceneCoords ).getY();

            // get location in units (ft, m, in)
            double raw_x = axisPosX.getValueForDisplay( xLocal ).doubleValue();
            double raw_y = axisPosY.getValueForDisplay( yLocal ).doubleValue();

            // round location
            double rnd_x;
            double rnd_y;

            if( vars.getUnit() == Units.FEET )
            {
                rnd_x = Mathf.round( raw_x, 0.5 );
                rnd_y = Mathf.round( raw_y, 0.5 );
            }
            else if( vars.getUnit() == Units.METERS )
            {
                rnd_x = Mathf.round( raw_x, 0.25 );
                rnd_y = Mathf.round( raw_y, 0.25 );
            }
            else if( vars.getUnit() == Units.INCHES )
            {
                rnd_x = Mathf.round( raw_x, 6.0 );
                rnd_y = Mathf.round( raw_y, 6.0 );
            }
            else
            {
                rnd_x = Mathf.round( raw_x, 2 );
                rnd_y = Mathf.round( raw_y, 2 );
            }

            if( ( rnd_x >= axisPosX.getLowerBound() && rnd_x <= axisPosX.getUpperBound() )
             && ( rnd_y >= axisPosY.getLowerBound() && rnd_y <= axisPosY.getUpperBound() ) )
            {

                // Clicking to add point not working on Mac???
                if ( OSValidator.isMac() )
                {
                    Optional<Waypoint> result;
                    result = DialogFactory.createWaypointDialog( String.valueOf( rnd_x ), String.valueOf( rnd_y ) ).showAndWait();
                    result.ifPresent( ( Waypoint w ) -> backend.addPoint( w ) );
                }
                else
                {
                    backend.addPoint( rnd_x, rnd_y, 0.0 );
                }
            }
        }
        else
        {
            event.consume();
        }
    }
    else
    {
        event.consume();
    }

}
 
Example 18
Source File: ResizeHelper.java    From CustomStage with Apache License 2.0 4 votes vote down vote up
@Override
public void handle(MouseEvent mouseEvent) {
    EventType<? extends MouseEvent> mouseEventType = mouseEvent.getEventType();
    Scene scene = stage.getScene();

    double mouseEventX = mouseEvent.getSceneX(),
            mouseEventY = mouseEvent.getSceneY(),
            sceneWidth = scene.getWidth(),
            sceneHeight = scene.getHeight();

    if (MouseEvent.MOUSE_MOVED.equals(mouseEventType)) {
        if (mouseEventX < border && mouseEventY < border) {
            cursorEvent = Cursor.NW_RESIZE;
        } else if (mouseEventX < border && mouseEventY > sceneHeight - border) {
            cursorEvent = Cursor.SW_RESIZE;
        } else if (mouseEventX > sceneWidth - border && mouseEventY < border) {
            cursorEvent = Cursor.NE_RESIZE;
        } else if (mouseEventX > sceneWidth - border && mouseEventY > sceneHeight - border) {
            cursorEvent = Cursor.SE_RESIZE;
        } else if (mouseEventX < border) {
            cursorEvent = Cursor.W_RESIZE;
        } else if (mouseEventX > sceneWidth - border) {
            cursorEvent = Cursor.E_RESIZE;
        } else if (mouseEventY < border) {
            cursorEvent = Cursor.N_RESIZE;
        } else if (mouseEventY > sceneHeight - border) {
            cursorEvent = Cursor.S_RESIZE;
        } else {
            cursorEvent = Cursor.DEFAULT;
        }
        scene.setCursor(cursorEvent);
    } else if (MouseEvent.MOUSE_EXITED.equals(mouseEventType) || MouseEvent.MOUSE_EXITED_TARGET.equals(mouseEventType)) {
        scene.setCursor(Cursor.DEFAULT);
    } else if (MouseEvent.MOUSE_PRESSED.equals(mouseEventType)) {
        startX = stage.getWidth() - mouseEventX;
        startY = stage.getHeight() - mouseEventY;
    } else if (MouseEvent.MOUSE_DRAGGED.equals(mouseEventType)) {
        if (!Cursor.DEFAULT.equals(cursorEvent)) {
            if (!Cursor.W_RESIZE.equals(cursorEvent) && !Cursor.E_RESIZE.equals(cursorEvent)) {
                double minHeight = stage.getMinHeight() > (border * 2) ? stage.getMinHeight() : (border * 2);
                if (Cursor.NW_RESIZE.equals(cursorEvent) || Cursor.N_RESIZE.equals(cursorEvent)
                        || Cursor.NE_RESIZE.equals(cursorEvent)) {
                    if (stage.getHeight() > minHeight || mouseEventY < 0) {
                        setStageHeight(stage.getY() - mouseEvent.getScreenY() + stage.getHeight());
                        stage.setY(mouseEvent.getScreenY());
                    }
                } else {
                    if (stage.getHeight() > minHeight || mouseEventY + startY - stage.getHeight() > 0) {
                        setStageHeight(mouseEventY + startY);
                    }
                }
            }

            if (!Cursor.N_RESIZE.equals(cursorEvent) && !Cursor.S_RESIZE.equals(cursorEvent)) {
                double minWidth = stage.getMinWidth() > (border * 2) ? stage.getMinWidth() : (border * 2);
                if (Cursor.NW_RESIZE.equals(cursorEvent) || Cursor.W_RESIZE.equals(cursorEvent)
                        || Cursor.SW_RESIZE.equals(cursorEvent)) {
                    if (stage.getWidth() > minWidth || mouseEventX < 0) {
                        setStageWidth(stage.getX() - mouseEvent.getScreenX() + stage.getWidth());
                        stage.setX(mouseEvent.getScreenX());
                    }
                } else {
                    if (stage.getWidth() > minWidth || mouseEventX + startX - stage.getWidth() > 0) {
                        setStageWidth(mouseEventX + startX);
                    }
                }
            }
        }

    }
}
 
Example 19
Source File: ResizeHelper.java    From Path-of-Leveling with MIT License 4 votes vote down vote up
@Override
public void handle(MouseEvent mouseEvent) {
    EventType<? extends MouseEvent> mouseEventType = mouseEvent.getEventType();
    Scene scene = stage.getScene();

    double mouseEventX = mouseEvent.getSceneX();
    double mouseEventY = mouseEvent.getSceneY();
    double sceneWidth = scene.getWidth();
    double sceneHeight = scene.getHeight();

    if (MouseEvent.MOUSE_MOVED.equals(mouseEventType)) {
        if (mouseEventX < border && mouseEventY < border) {
            cursorEvent = Cursor.NW_RESIZE;
        } else if (mouseEventX < border && mouseEventY > sceneHeight - border) {
            cursorEvent = Cursor.SW_RESIZE;
        } else if (mouseEventX > sceneWidth - border && mouseEventY < border) {
            cursorEvent = Cursor.NE_RESIZE;
        } else if (mouseEventX > sceneWidth - border && mouseEventY > sceneHeight - border) {
            cursorEvent = Cursor.SE_RESIZE;
        } else if (mouseEventX < border) {
            cursorEvent = Cursor.W_RESIZE;
        } else if (mouseEventX > sceneWidth - border) {
            cursorEvent = Cursor.E_RESIZE;
        } else if (mouseEventY < border) {
            cursorEvent = Cursor.N_RESIZE;
        } else if (mouseEventY > sceneHeight - border) {
            cursorEvent = Cursor.S_RESIZE;
        } else {
            cursorEvent = Cursor.DEFAULT;
        }
        scene.setCursor(cursorEvent);
    } else if (MouseEvent.MOUSE_EXITED.equals(mouseEventType) || MouseEvent.MOUSE_EXITED_TARGET.equals(mouseEventType)) {
        scene.setCursor(Cursor.DEFAULT);
    } else if (MouseEvent.MOUSE_PRESSED.equals(mouseEventType)) {
        startX = stage.getWidth() - mouseEventX;
        startY = stage.getHeight() - mouseEventY;
    } else if (MouseEvent.MOUSE_DRAGGED.equals(mouseEventType)) {
        if (!Cursor.DEFAULT.equals(cursorEvent)) {
            if (!Cursor.W_RESIZE.equals(cursorEvent) && !Cursor.E_RESIZE.equals(cursorEvent)) {
                double minHeight = stage.getMinHeight() > (border * 2) ? stage.getMinHeight() : (border * 2);
                double maxHeight = stage.getMaxHeight();
                if (Cursor.NW_RESIZE.equals(cursorEvent) || Cursor.N_RESIZE.equals(cursorEvent) || Cursor.NE_RESIZE.equals(cursorEvent)) {
                    double newHeight = stage.getHeight() - (mouseEvent.getScreenY() - stage.getY());
                    if (newHeight >= minHeight && newHeight <= maxHeight) {
                        stage.setHeight(newHeight);
                        stage.setY(mouseEvent.getScreenY());
                    } else {
                        newHeight = Math.min(Math.max(newHeight, minHeight), maxHeight);
                        // y1 + h1 = y2 + h2
                        // y1 = y2 + h2 - h1
                        stage.setY(stage.getY() + stage.getHeight() - newHeight);
                        stage.setHeight(newHeight);
                    }
                } else {
                    stage.setHeight(Math.min(Math.max(mouseEventY + startY, minHeight), maxHeight));
                }
            }

            if (!Cursor.N_RESIZE.equals(cursorEvent) && !Cursor.S_RESIZE.equals(cursorEvent)) {
                double minWidth = stage.getMinWidth() > (border * 2) ? stage.getMinWidth() : (border * 2);
                double maxWidth = stage.getMaxWidth();
                if (Cursor.NW_RESIZE.equals(cursorEvent) || Cursor.W_RESIZE.equals(cursorEvent) || Cursor.SW_RESIZE.equals(cursorEvent)) {
                    double newWidth = stage.getWidth() - (mouseEvent.getScreenX() - stage.getX());
                    if (newWidth >= minWidth && newWidth <= maxWidth) {
                        stage.setWidth(newWidth);
                        stage.setX(mouseEvent.getScreenX());
                    } else {
                        newWidth = Math.min(Math.max(newWidth, minWidth), maxWidth);
                        // x1 + w1 = x2 + w2
                        // x1 = x2 + w2 - w1
                        stage.setX(stage.getX() + stage.getWidth() - newWidth);
                        stage.setWidth(newWidth);
                    }
                } else {
                    stage.setWidth(Math.min(Math.max(mouseEventX + startX, minWidth), maxWidth));
                }
            }
        }
    }

    if (MouseEvent.MOUSE_PRESSED.equals(mouseEventType)) {
        startScreenX = mouseEvent.getScreenX();
        startScreenY = mouseEvent.getScreenY();
    } else if (MouseEvent.MOUSE_DRAGGED.equals(mouseEventType)) {
        if (Cursor.DEFAULT.equals(cursorEvent) && !stage.isMaximized()) {
            stage.setX(stage.getX() + mouseEvent.getScreenX() - startScreenX);
            startScreenX = mouseEvent.getScreenX();
            stage.setY(stage.getY() + mouseEvent.getScreenY() - startScreenY);
            startScreenY = mouseEvent.getScreenY();
        }
    }
}
 
Example 20
Source File: RotateSelectedOnHandleDragHandler.java    From gef with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Computes the clock-wise rotation angle based on the initial mouse
 * position and the actual mouse position.
 *
 * @param e
 *            The latest {@link MouseEvent}.
 * @param part
 *            The {@link IVisualPart} that is rotated.
 * @return The clock-wise rotation angle.
 */
protected Angle computeRotationAngleCW(MouseEvent e,
		IVisualPart<? extends Node> part) {
	Vector vStart = new Vector(pivotInScene, initialPointerLocationInScene);
	Vector vEnd = new Vector(pivotInScene,
			new Point(e.getSceneX(), e.getSceneY()));
	Angle angle = vStart.getAngleCW(vEnd);
	return angle;
}