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

The following examples show how to use javafx.scene.input.MouseEvent#getSceneY() . 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: ADCCanvasView.java    From arma-dialog-creator with MIT License 7 votes vote down vote up
@Override
public void handle(MouseEvent event) {
	//use this so that when the mouse moves over the canvas and something in canvas controls has focus, the key presses
	//and mouse events are sent to the canvas rather than the focuses control
	canvasView.focusToCanvas(event.getTarget() == canvasView.uiCanvasEditor.getCanvas());

	double sceneX = event.getSceneX();
	double sceneY = event.getSceneY();
	for (Node node : canvasView.notificationPane.getContentPane().getChildren()) {
		Point2D point2D = node.sceneToLocal(sceneX, sceneY);
		if (node.contains(point2D)) {
			canvasView.notificationPane.getContentPane().setMouseTransparent(false);
			return;
		}
	}
	canvasView.notificationPane.getContentPane().setMouseTransparent(true);

}
 
Example 2
Source File: BendOnSegmentDragHandler.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void drag(MouseEvent e, Dimension delta) {
	if (isInvalid) {
		return;
	}

	Point newEndPointInScene = new Point(e.getSceneX(), e.getSceneY());
	if (snapToSupport != null) {
		if (!isPrecise(e)) {
			newEndPointInScene.translate(snapToSupport.snap(delta));
		} else {
			snapToSupport.clearSnappingFeedback();
		}
	}

	// perform changes
	bendPolicy.move(initialMouseInScene, newEndPointInScene);
	updateHandles();
}
 
Example 3
Source File: MouseDragSnippet.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
protected void onMousePress(MouseEvent event) {
	pressed = (Node) event.getTarget();
	System.out.println("press " + pressed);
	startMousePosition = new Point2D(event.getSceneX(), event.getSceneY());
	startLayoutPosition = new Point2D(pressed.getLayoutX(),
			pressed.getLayoutY());

	// add effect
	pressed.setEffect(new Bloom(0));
	IAnchor ifxAnchor = anchors.get(pressed);
	if (ifxAnchor != null) {
		Set<AnchorKey> keys = ifxAnchor.positionsUnmodifiableProperty()
				.keySet();
		for (AnchorKey key : keys) {
			key.getAnchored().setEffect(null);
		}
	}
}
 
Example 4
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 5
Source File: Fx3DStageController.java    From mzmine2 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 6
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 7
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 8
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 dragSouth(MouseEvent event, Wrapper<Point2D> mouseLocation, Region region, double handleRadius) {
	final double deltaY = event.getSceneY() - mouseLocation.value.getY();
	final double newMaxY = region.getLayoutY() + region.getHeight() + deltaY;
	if(newMaxY >= region.getLayoutY() && newMaxY <= region.getParent().getBoundsInLocal().getHeight() - handleRadius) {
		region.setPrefHeight(region.getPrefHeight() + deltaY);
	}
}
 
Example 9
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 dragNorth(MouseEvent event, Wrapper<Point2D> mouseLocation, Region region, double handleRadius) {
	final double deltaY = event.getSceneY() - mouseLocation.value.getY();
	final double newY = region.getLayoutY() + deltaY;
	if(newY != 0 && newY >= handleRadius && newY <= region.getLayoutY() + region.getHeight() - handleRadius) {
		region.setLayoutY(newY);
		region.setPrefHeight(region.getPrefHeight() - deltaY);
	}
}
 
Example 10
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 11
Source File: ChartPlugin.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
/**
 * Converts mouse location within the scene to the location relative to the plot area.
 *
 * @param event mouse event
 * @return location within the plot area
 */
protected final Point2D getLocationInPlotArea(final MouseEvent event) {
    final Point2D mouseLocationInScene = new Point2D(event.getSceneX(), event.getSceneY());
    final Chart chart = getChart();
    if (!(chart instanceof XYChart)) {
        return null;
    }
    final XYChart xyChart = (XYChart) chart;
    final double xInAxis = ((Node) xyChart.getXAxis()).sceneToLocal(mouseLocationInScene).getX();
    final double yInAxis = ((Node) xyChart.getYAxis()).sceneToLocal(mouseLocationInScene).getY();
    return new Point2D(xInAxis, yInAxis);
}
 
Example 12
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 13
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 14
Source File: ResizeHelper.java    From ApkToolPlus 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) == true) {
        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_PRESSED.equals(mouseEventType) == true) {
        startX = stage.getWidth() - mouseEventX;
        startY = stage.getHeight() - mouseEventY;
    } else if (MouseEvent.MOUSE_DRAGGED.equals(mouseEventType) == true) {
        if (Cursor.DEFAULT.equals(cursorEvent) == false) {
            if (Cursor.W_RESIZE.equals(cursorEvent) == false && Cursor.E_RESIZE.equals(cursorEvent) == false) {
                double minHeight = stage.getMinHeight() > (border*2) ? stage.getMinHeight() : (border*2);
                if (Cursor.NW_RESIZE.equals(cursorEvent) == true || Cursor.N_RESIZE.equals(cursorEvent) == true || Cursor.NE_RESIZE.equals(cursorEvent) == true) {
                    if (stage.getHeight() > minHeight || mouseEventY < 0) {
                        stage.setHeight(stage.getY() - mouseEvent.getScreenY() + stage.getHeight());
                        stage.setY(mouseEvent.getScreenY());
                    }
                } else {
                    if (stage.getHeight() > minHeight || mouseEventY + startY - stage.getHeight() > 0) {
                        stage.setHeight(mouseEventY + startY);
                    }
                }
            }

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

    }
}
 
Example 15
Source File: ResizeHelper.java    From JavaFX-Chat with GNU General Public License v3.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) == false) {
            if (Cursor.W_RESIZE.equals(cursorEvent) == false && Cursor.E_RESIZE.equals(cursorEvent) == false) {
                double minHeight = stage.getMinHeight() > (border*2) ? stage.getMinHeight() : (border*2);
                if (Cursor.NW_RESIZE.equals(cursorEvent) == true || Cursor.N_RESIZE.equals(cursorEvent) == true || Cursor.NE_RESIZE.equals(cursorEvent) == true) {
                    if (stage.getHeight() > minHeight || mouseEventY < 0) {
                        stage.setHeight(stage.getY() - mouseEvent.getScreenY() + stage.getHeight());
                        stage.setY(mouseEvent.getScreenY());
                    }
                } else {
                    if (stage.getHeight() > minHeight || mouseEventY + startY - stage.getHeight() > 0) {
                        stage.setHeight(mouseEventY + startY);
                    }
                }
            }

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

    }
}
 
Example 16
Source File: RotateSelectedOnHandleDragHandler.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void startDrag(MouseEvent e) {
	// do nothing when the user does not press control
	invalidGesture = !isRotate(e);
	if (invalidGesture) {
		return;
	}

	// save pointer location for later angle calculation
	initialPointerLocationInScene = new Point(e.getSceneX(), e.getSceneY());
	targetParts = determineTargetParts();
	if (targetParts == null) {
		targetParts = Collections.emptyList();
	}
	Rectangle bounds = PartUtils.getUnionedVisualBoundsInScene(targetParts);
	if (bounds == null) {
		throw new IllegalStateException(
				"Cannot determine visual bounds (null).");
	}
	pivotInScene = bounds.getCenter();

	// initialize for all target parts
	rotationIndices.clear();
	for (IContentPart<? extends Node> part : getTargetParts()) {
		// transform pivot point to local coordinates
		TransformPolicy transformPolicy = getTransformPolicy(part);
		if (transformPolicy != null) {
			storeAndDisableRefreshVisuals(part);
			init(transformPolicy);
			// transform pivot to parent coordinates
			Point pivotInLocal = FX2Geometry
					.toPoint(getHost().getVisual().getParent()
							.sceneToLocal(pivotInScene.x, pivotInScene.y));
			// create transformations
			int translateIndex = transformPolicy.createPostTransform();
			int rotateIndex = transformPolicy.createPostTransform();
			int translateBackIndex = transformPolicy.createPostTransform();
			// set translation transforms
			transformPolicy.setPostTranslate(translateIndex,
					-pivotInLocal.x, -pivotInLocal.y);
			transformPolicy.setPostTranslate(translateBackIndex,
					pivotInLocal.x, pivotInLocal.y);
			// save rotation index for later adjustment
			rotationIndices.put(part, rotateIndex);
		}
	}
}
 
Example 17
Source File: ResizeTranslateFirstAnchorageOnHandleDragHandler.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void drag(MouseEvent e, Dimension delta) {
	// guard against uninitialized access
	if (invalidGesture) {
		return;
	}

	// compute end point
	Node visual = getTargetPart().getVisual();
	Point newEndScene = new Point(e.getSceneX(), e.getSceneY());

	// compute delta in scene
	Point deltaInScene = new Point(newEndScene.x - initialPointerLocation.x,
			newEndScene.y - initialPointerLocation.y);

	// apply delta to the moved vertex
	Point newVertex = initialVertex.getTranslated(deltaInScene);

	// snap the moved vertex (unless isPrecise(e))
	Point snappedVertex = newVertex;
	if (snapToSupport != null) {
		if (!isPrecise(e)) {
			snappedVertex.translate(snapToSupport
					.snap(new Dimension(deltaInScene.x, deltaInScene.y)));
		} else {
			snapToSupport.clearSnappingFeedback();
		}
	}

	// compute delta between initial and snapped vertex
	Point2D startLocal = visual.sceneToLocal(initialVertex.x,
			initialVertex.y);
	Point2D endLocal = visual.sceneToLocal(snappedVertex.x,
			snappedVertex.y);

	// compute delta in local coordinates
	double deltaX = endLocal.getX() - startLocal.getX();
	double deltaY = endLocal.getY() - startLocal.getY();

	// segment index determines logical position (0 = top left, 1 = top
	// right, 2 = bottom right, 3 = bottom left)
	int segment = getHost().getSegmentIndex();

	// determine resize in local coordinates
	double ldw, ldh;
	if (segment == 1 || segment == 2) {
		// right side
		ldw = deltaX;
	} else {
		// left side
		ldw = -deltaX;
	}
	if (segment == 2 || segment == 3) {
		// bottom side
		ldh = deltaY;
	} else {
		// top side
		ldh = -deltaY;
	}

	// XXX: Resize before querying the applicable delta, so that the minimum
	// size is respected.
	getResizePolicy().resize(ldw, ldh);
	Dimension applicableDelta = new Dimension(
			getResizePolicy().getDeltaWidth(),
			getResizePolicy().getDeltaHeight());

	// Only apply translation if possible, i.e. if the resize cannot be
	// applied in total, the translation can probably not be applied in
	// total as well.
	if (applicableDelta.width != ldw) {
		deltaX = applicableDelta.width;
		if (segment == 0 || segment == 3) {
			deltaX = -deltaX;
		}
	}
	if (applicableDelta.height != ldh) {
		deltaY = applicableDelta.height;
		if (segment == 0 || segment == 1) {
			deltaY = -deltaY;
		}
	}

	// compute (local) translation
	double ldx = segment == 0 || segment == 3 ? deltaX : 0;
	double ldy = segment == 0 || segment == 1 ? deltaY : 0;

	// apply translation
	getTransformPolicy().setPreTranslate(translationIndex, ldx, ldy);
}
 
Example 18
Source File: ResizeTranslateFirstAnchorageOnHandleDragHandler.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void startDrag(MouseEvent e) {
	setTargetPart(determineTargetPart());
	invalidGesture = !isResizeTranslate(e);
	if (invalidGesture) {
		return;
	}
	ITransformableContentPart<? extends Node> targetPart = getTargetPart();
	storeAndDisableRefreshVisuals(targetPart);
	initialPointerLocation = new Point(e.getSceneX(), e.getSceneY());
	init(getResizePolicy());
	init(getTransformPolicy());
	translationIndex = getTransformPolicy().createPreTransform();
	// determine initial bounds in scene
	Bounds layoutBounds = targetPart.getVisual().getLayoutBounds();
	Bounds initialBoundsInScene = targetPart.getVisual()
			.localToScene(layoutBounds);
	// save moved vertex
	int segment = getHost().getSegmentIndex();
	if (segment == 0) {
		initialVertex = new Point(initialBoundsInScene.getMinX(),
				initialBoundsInScene.getMinY());
	} else if (segment == 1) {
		initialVertex = new Point(initialBoundsInScene.getMaxX(),
				initialBoundsInScene.getMinY());
	} else if (segment == 2) {
		initialVertex = new Point(initialBoundsInScene.getMaxX(),
				initialBoundsInScene.getMaxY());
	} else if (segment == 3) {
		initialVertex = new Point(initialBoundsInScene.getMinX(),
				initialBoundsInScene.getMaxY());
	}

	snapToSupport = targetPart.getViewer().getAdapter(SnapToSupport.class);
	if (snapToSupport != null) {
		SnappingLocation hssl = new SnappingLocation(targetPart,
				Orientation.HORIZONTAL, initialVertex.x);
		SnappingLocation vssl = new SnappingLocation(targetPart,
				Orientation.VERTICAL, initialVertex.y);
		snapToSupport.startSnapping(targetPart, Arrays.asList(hssl, vssl));
	}
}
 
Example 19
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 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;
}