List of usage examples for javafx.scene.input MouseEvent getY
public final double getY()
From source file:de.hs.mannheim.modUro.controller.diagram.fx.interaction.TooltipHandlerFX.java
/** * Handles a mouse moved event by updating the tooltip. * /* ww w . j a v a 2 s . com*/ * @param canvas the chart canvas (<code>null</code> not permitted). * @param e the mouse event. */ @Override public void handleMouseMoved(ChartCanvas canvas, MouseEvent e) { if (!canvas.isTooltipEnabled()) { return; } String text = getTooltipText(canvas, e.getX(), e.getY()); canvas.setTooltip(text, e.getScreenX(), e.getScreenY()); }
From source file:de.hs.mannheim.modUro.controller.diagram.fx.interaction.ZoomHandlerFX.java
/** * Handles a mouse pressed event by recording the initial mouse pointer * location./*from w w w. jav a2 s.c om*/ * * @param canvas the JavaFX canvas (<code>null</code> not permitted). * @param e the mouse event (<code>null</code> not permitted). */ @Override public void handleMousePressed(ChartCanvas canvas, MouseEvent e) { Point2D pt = new Point2D.Double(e.getX(), e.getY()); Rectangle2D dataArea = canvas.findDataArea(pt); if (dataArea != null) { this.startPoint = ShapeUtilities.getPointInRectangle(e.getX(), e.getY(), dataArea); } else { this.startPoint = null; canvas.clearLiveHandler(); } }
From source file:de.pixida.logtest.designer.automaton.Graph.java
private void mouseMovedOnPane(final MouseEvent event) { // Using double properties here to avoid spamming the heap with immutable objects like Point2D this.lastMousePositionOnPaneX = event.getX(); this.lastMousePositionOnPaneY = event.getY(); if (this.connectorSourceNode != null) { Validate.notNull(this.connector); if (this.currentConnectorTargetNode == null) { // Otherwise, connector was already aligned when object was hovered this.connector.align(this.connectorSourceNode, new Point2D(event.getX(), event.getY())); }//w w w . ja va 2s . c om } }
From source file:de.hs.mannheim.modUro.controller.diagram.fx.interaction.PanHandlerFX.java
/** * Handles a mouse dragged event by calculating the distance panned and * updating the axes accordingly.// ww w . j a v a 2 s. c om * * @param canvas the JavaFX canvas (<code>null</code> not permitted). * @param e the mouse event (<code>null</code> not permitted). */ public void handleMouseDragged(ChartCanvas canvas, MouseEvent e) { if (this.panLast == null) { //handle panning if we have a start point else unregister canvas.clearLiveHandler(); return; } JFreeChart chart = canvas.getChart(); double dx = e.getX() - this.panLast.getX(); double dy = e.getY() - this.panLast.getY(); if (dx == 0.0 && dy == 0.0) { return; } double wPercent = -dx / this.panW; double hPercent = dy / this.panH; boolean old = chart.getPlot().isNotify(); chart.getPlot().setNotify(false); Pannable p = (Pannable) chart.getPlot(); PlotRenderingInfo info = canvas.getRenderingInfo().getPlotInfo(); if (p.getOrientation().isVertical()) { p.panDomainAxes(wPercent, info, this.panLast); p.panRangeAxes(hPercent, info, this.panLast); } else { p.panDomainAxes(hPercent, info, this.panLast); p.panRangeAxes(wPercent, info, this.panLast); } this.panLast = new Point2D.Double(e.getX(), e.getY()); chart.getPlot().setNotify(old); }
From source file:de.hs.mannheim.modUro.controller.diagram.fx.interaction.PanHandlerFX.java
/** * Handles a mouse pressed event by recording the initial mouse pointer * location./* ww w . ja v a 2s . c o m*/ * * @param canvas the JavaFX canvas (<code>null</code> not permitted). * @param e the mouse event (<code>null</code> not permitted). */ @Override public void handleMousePressed(ChartCanvas canvas, MouseEvent e) { Plot plot = canvas.getChart().getPlot(); if (!(plot instanceof Pannable)) { canvas.clearLiveHandler(); return; } Pannable pannable = (Pannable) plot; if (pannable.isDomainPannable() || pannable.isRangePannable()) { Point2D point = new Point2D.Double(e.getX(), e.getY()); Rectangle2D dataArea = canvas.findDataArea(point); if (dataArea != null && dataArea.contains(point)) { this.panW = dataArea.getWidth(); this.panH = dataArea.getHeight(); this.panLast = point; canvas.setCursor(javafx.scene.Cursor.MOVE); } } // the actual panning occurs later in the mouseDragged() method }
From source file:de.pixida.logtest.designer.automaton.Graph.java
public void onMousePressed(final BaseObject baseObject, final MouseEvent event) { if (this.showConfigFrameOfObject(baseObject)) { event.consume();//from w w w . j a va 2 s .c o m } if (baseObject instanceof BaseNode) { final BaseNode baseNode = (BaseNode) baseObject; this.dragPressedPoint = new Point2D(event.getX(), event.getY()); this.dragOriginalObjectPosition = baseNode.getPosition(); } }
From source file:de.pixida.logtest.designer.automaton.Graph.java
public void onMouseDragged(final BaseObject baseObject, final MouseEvent event) { if (baseObject instanceof BaseNode) { final BaseNode baseNode = (BaseNode) baseObject; Validate.notNull(this.dragPressedPoint); Validate.notNull(this.dragOriginalObjectPosition); final Point2D mouseMovement = new Point2D(event.getX(), event.getY()).subtract(this.dragPressedPoint); if (mouseMovement.getX() != 0d || mouseMovement.getY() != 0d) { Point2D newRectPos = this.dragOriginalObjectPosition.add(mouseMovement); newRectPos = new Point2D(Math.max(0d, newRectPos.getX()), Math.max(0d, newRectPos.getY())); baseNode.moveTo(newRectPos); this.handleMinorChange(); }//from ww w.j a v a 2 s .c o m } }
From source file:mesclasses.view.TimetableController.java
private void handleClicks(Pane pane) { pane.setOnMouseClicked((MouseEvent mouseEvent) -> { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { Cours newCours = new Cours(); newCours.setClasse(classes.get(0)); newCours.setDay(paneMap.inverse().get(pane)); newCours.setWeek(config.getProperty(Constants.CONF_WEEK_DEFAULT)); newCours.setStartHour((int) (mouseEvent.getY()) / 60 + 7); newCours.setEndHour(newCours.getStartHour() + 1); createNewCours(newCours); }/*from w w w .ja va2 s. c o m*/ } }); }
From source file:Main.java
public static java.awt.event.MouseEvent toAwt(final MouseEvent event) { final EventType type = event.getEventType(); if (null == type) { return null; }/*from w w w . j a va 2 s. c o m*/ final int id; if (MouseEvent.MOUSE_MOVED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_MOVED; } else if (MouseEvent.MOUSE_DRAGGED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_DRAGGED; } else if (MouseEvent.MOUSE_CLICKED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_CLICKED; } else if (MouseEvent.MOUSE_PRESSED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_PRESSED; } else if (MouseEvent.MOUSE_RELEASED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_RELEASED; } else if (MouseEvent.MOUSE_ENTERED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_ENTERED; } else if (MouseEvent.MOUSE_EXITED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_EXITED; } else { return null; } final int button; if (event.isPrimaryButtonDown()) { button = java.awt.event.MouseEvent.BUTTON1; } else if (event.isMiddleButtonDown()) { button = java.awt.event.MouseEvent.BUTTON2; } else if (event.isSecondaryButtonDown()) { button = java.awt.event.MouseEvent.BUTTON3; } else { button = java.awt.event.MouseEvent.NOBUTTON; } final long when = -1; final int modifiers = modifiers(event); final int x = (int) event.getX(); final int y = (int) event.getY(); final int xAbs = Integer.MAX_VALUE; final int yAbs = Integer.MAX_VALUE; final int count = event.getClickCount(); boolean popup = event.isPopupTrigger(); if (MouseEvent.MOUSE_CLICKED.equals(type) && event.isMetaDown()) { // mack books use meta flag for right-clicks popup = true; } return new java.awt.event.MouseEvent(empty, id, when, modifiers, x, y, xAbs, yAbs, count, popup, button); }
From source file:Main.java
private Node makeDraggable(final Node node) { final DragContext dragContext = new DragContext(); final Group wrapGroup = new Group(node); wrapGroup.addEventFilter(MouseEvent.ANY, new EventHandler<MouseEvent>() { public void handle(final MouseEvent mouseEvent) { if (dragModeActiveProperty.get()) { // disable mouse events for all children mouseEvent.consume();/*from w w w . j av a 2 s .c om*/ } } }); wrapGroup.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() { public void handle(final MouseEvent mouseEvent) { if (dragModeActiveProperty.get()) { // remember initial mouse cursor coordinates // and node position dragContext.mouseAnchorX = mouseEvent.getX(); dragContext.mouseAnchorY = mouseEvent.getY(); dragContext.initialTranslateX = node.getTranslateX(); dragContext.initialTranslateY = node.getTranslateY(); } } }); wrapGroup.addEventFilter(MouseEvent.MOUSE_DRAGGED, new EventHandler<MouseEvent>() { public void handle(final MouseEvent mouseEvent) { if (dragModeActiveProperty.get()) { // shift node from its initial position by delta // calculated from mouse cursor movement node.setTranslateX( dragContext.initialTranslateX + mouseEvent.getX() - dragContext.mouseAnchorX); node.setTranslateY( dragContext.initialTranslateY + mouseEvent.getY() - dragContext.mouseAnchorY); } } }); return wrapGroup; }