/** {@inheritDoc} */ @Override public void mouseDragged(final MouseEvent aEvent) { final MouseEvent event = convertEvent(aEvent); final Point point = event.getPoint(); // Update the selected channel while dragging... this.controller.setSelectedChannel(point); if (getModel().isCursorMode() && (this.movingCursor >= 0)) { this.controller.moveCursor(this.movingCursor, getCursorDropPoint(point)); aEvent.consume(); } else { if ((this.lastClickPosition == null) && ((aEvent.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0)) { this.lastClickPosition = new Point(point); } final JScrollPane scrollPane = getAncestorOfClass(JScrollPane.class, (Component) aEvent.getSource()); if ((scrollPane != null) && (this.lastClickPosition != null)) { final JViewport viewPort = scrollPane.getViewport(); final Component signalView = this.controller.getSignalDiagram().getSignalView(); boolean horizontalOnly = (aEvent.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0; boolean verticalOnly = horizontalOnly && ((aEvent.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0); int dx = aEvent.getX() - this.lastClickPosition.x; int dy = aEvent.getY() - this.lastClickPosition.y; Point scrollPosition = viewPort.getViewPosition(); int newX = scrollPosition.x; if (!verticalOnly) { newX -= dx; } int newY = scrollPosition.y; if (verticalOnly || !horizontalOnly) { newY -= dy; } int diagramWidth = signalView.getWidth(); int viewportWidth = viewPort.getWidth(); int maxX = diagramWidth - viewportWidth - 1; scrollPosition.x = Math.max(0, Math.min(maxX, newX)); int diagramHeight = signalView.getHeight(); int viewportHeight = viewPort.getHeight(); int maxY = diagramHeight - viewportHeight; scrollPosition.y = Math.max(0, Math.min(maxY, newY)); viewPort.setViewPosition(scrollPosition); } // Use UNCONVERTED/ORIGINAL mouse event! handleZoomRegion(aEvent, this.lastClickPosition); } }
public static void checkClickedModifiersTest(int testModifier, MouseEvent event) { int[] curStandardModifiers = getStandardArray(testModifier); int[] curStandardExModifiers = getStandardExArray(testModifier); // int index = (button - 4)*3 + 2; int button = event.getButton(); int modifiers = event.getModifiers(); int modifiersEx = event.getModifiersEx(); int index = (button - 1) * 3 + 2; dumpValues( button, modifiers, curStandardModifiers[index], modifiersEx, curStandardExModifiers[index]); if (modifiers != curStandardModifiers[index]) { if (debug) { System.out.println("Test failed : Clicked. modifiers != modifiersStandard"); } else { throw new RuntimeException("Test failed : Clicked. modifiers != modifiersStandard"); } } if (modifiersEx != curStandardExModifiers[index]) { if (debug) { System.out.println("Test failed : Clicked. modifiersEx != curStandardExModifiers"); } else { throw new RuntimeException("Test failed : Clicked. modifiersEx != curStandardExModifiers"); } } HashMap<String, String> paramStringElements = tokenizeParamString(event.paramString()); checkButton(paramStringElements, button); checkModifiers(testModifier, paramStringElements, button); checkExtModifiersOnReleaseClick(testModifier, paramStringElements, button); }
// Handle mouse actions public void mousePressed(MouseEvent mouseEvent) { if (this.isArmed() && this.isUseRubberBand() && mouseEvent.getButton() == MouseEvent.BUTTON1) { if ((mouseEvent.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { if (!mouseEvent.isControlDown()) { this.setActive(true); measureTool.addControlPoint(); if (measureTool.getControlPoints().size() == 1) { measureTool.addControlPoint(); // Simulate a second click } // Set the rubber band target to the last control point or the relevant control for // regular shapes. if (measureTool.isRegularShape()) { String initControl = measureTool.getShapeInitialControl(measureTool.getWwd().getCurrentPosition()); rubberBandTarget = measureTool.getControlPoint(initControl); } else { rubberBandTarget = (MeasureTool.ControlPoint) measureTool.getControlPoints().get(measureTool.getControlPoints().size() - 1); } measureTool.firePropertyChange(MeasureTool.EVENT_RUBBERBAND_START, null, null); } } mouseEvent.consume(); } else if (!this.isArmed() && mouseEvent.getButton() == MouseEvent.BUTTON1 && mouseEvent.isAltDown()) { if (!this.measureTool.isRegularShape()) { this.setMoving(true); this.movingTarget = this.lastPickedObject; } mouseEvent.consume(); } }
@Override public void mousePressed(MouseEvent evt) { // handle.mousePressed(evt); anchor = new Point(evt.getX(), evt.getY()); multicaster.trackStart(anchor, evt.getModifiersEx(), getView()); clearHoverHandles(); }
public void mouseDragged(MouseEvent e) { int mods = e.getModifiersEx(); Point dragEnd = e.getPoint(); boolean shift = (mods & MouseEvent.SHIFT_DOWN_MASK) > 0; boolean ctrl = (mods & MouseEvent.CTRL_DOWN_MASK) > 0; boolean alt = shift & ctrl; ctrl = ctrl & (!alt); shift = shift & (!alt); boolean nomods = !(shift | ctrl | alt); if (dragBegin == null) dragBegin = dragEnd; nodrag = false; if ((mods & InputEvent.BUTTON3_DOWN_MASK) > 0 || true) { double dx = dragEnd.getX() - dragBegin.getX(); double dy = dragEnd.getY() - dragBegin.getY(); synchronized (JImage.this) { t.preConcatenate(AffineTransform.getTranslateInstance(dx, dy)); } dragBegin = dragEnd; repaint(); } }
@Override public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2) { multicaster.trackDoubleClick( new Point(evt.getX(), evt.getY()), evt.getModifiersEx(), getView()); } evt.consume(); }
public void mouseReleased(MouseEvent e) { int mods = e.getModifiersEx(); if (nodrag && e.getButton() == MouseEvent.BUTTON3) { popupMenu.show(JImage.this, (int) e.getPoint().getX(), (int) e.getPoint().getY()); } nodrag = true; dragBegin = null; }
public void mousePressed(MouseEvent mouseEvent) { if (MouseEvent.BUTTON1_DOWN_MASK != mouseEvent.getModifiersEx()) return; if (!this.isArmed()) return; this.getShape().setResizeable(true); this.getShape().setStartPosition(null); this.setArmed(false); mouseEvent.consume(); }
@Override public void mouseReleased(MouseEvent evt) { dragLocation = new Point(evt.getX(), evt.getY()); multicaster.trackEnd(anchor, dragLocation, evt.getModifiersEx(), getView()); // Note: we must not fire "Tool Done" in this method, because then we can not // listen to keyboard events for the handle. Rectangle r = new Rectangle(anchor.x, anchor.y, 0, 0); r.add(evt.getX(), evt.getY()); maybeFireBoundsInvalidated(r); dragLocation = null; }
// Handle mouse motion public void mouseDragged(MouseEvent mouseEvent) { if (measureTool == null) return; if (this.isActive() && this.isArmed() && (mouseEvent.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { // Don't update the control point here because the wwd current cursor position will not // have been updated to reflect the current mouse position. Wait to update in the // position listener, but consume the event so the view doesn't respond to it. mouseEvent.consume(); } else if (!this.isArmed() && this.isMoving() && (mouseEvent.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0 && mouseEvent.isAltDown()) { // Consume the ALT+Drag mouse event to ensure the View does not respond to it. Don't update // the control // point here because the wwd current cursor position will not have been updated to reflect // the current // mouse position. Wait to update in the position listener, but consume the event so the view // doesn't // respond to it. mouseEvent.consume(); } }
/** {@inheritDoc} */ @Override public void mouseReleased(final MouseEvent aEvent) { final MouseEvent event = convertEvent(aEvent); final Point point = event.getPoint(); if (!isCursorHover(event)) { setMouseCursor(event, null); } if (!handlePopupTrigger(point, aEvent)) { this.movingCursor = -1; } if ((aEvent.getModifiersEx() & InputEvent.BUTTON1_MASK) != 0) { // Use UNCONVERTED/ORIGINAL mouse event! handleZoomRegion(aEvent, this.lastClickPosition); this.lastClickPosition = null; } }
/** {@inheritDoc} */ @Override public void mousePressed(final MouseEvent aEvent) { final MouseEvent event = convertEvent(aEvent); final Point point = event.getPoint(); if (!handlePopupTrigger(point, aEvent)) { if (getModel().isCursorMode()) { Cursor hoveredCursor = findCursor(point); if (hoveredCursor != null) { this.movingCursor = hoveredCursor.getIndex(); setMouseCursor(aEvent, SignalView.CURSOR_MOVE_CURSOR); } else { this.movingCursor = -1; } } if ((aEvent.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0) { this.lastClickPosition = point; } } }
@Override public void mouseDragged(MouseEvent evt) { dragLocation = new Point(evt.getX(), evt.getY()); multicaster.trackStep(anchor, dragLocation, evt.getModifiersEx(), getView()); clearHoverHandles(); }
public void mouseDragged(MouseEvent mouseEvent) { if (MouseEvent.BUTTON1_DOWN_MASK != mouseEvent.getModifiersEx()) return; if (this.getShape().isResizeable()) mouseEvent.consume(); // prevent view operations }
@Override public void mousePressed(MouseEvent evt) { if (getView() != null && getView().isEnabled()) { super.mousePressed(evt); DrawingView view = getView(); Handle handle = view.findHandle(anchor); Tool newTracker = null; if (handle != null) { newTracker = getHandleTracker(handle); } else { Figure figure; Drawing drawing = view.getDrawing(); Point2D.Double p = view.viewToDrawing(anchor); if (isSelectBehindEnabled() && (evt.getModifiersEx() & (InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) != 0) { // Select a figure behind the current selection figure = view.findFigure(anchor); while (figure != null && !figure.isSelectable()) { figure = drawing.findFigureBehind(p, figure); } HashSet<Figure> ignoredFigures = new HashSet<Figure>(view.getSelectedFigures()); ignoredFigures.add(figure); Figure figureBehind = view.getDrawing().findFigureBehind(view.viewToDrawing(anchor), ignoredFigures); if (figureBehind != null) { figure = figureBehind; } } else { // Note: The search sequence used here, must be // consistent with the search sequence used by the // DefaultHandleTracker, the DefaultSelectAreaTracker and DelegationSelectionTool. // If possible, continue to work with the current selection figure = null; if (isSelectBehindEnabled()) { for (Figure f : view.getSelectedFigures()) { if (f.contains(p)) { figure = f; break; } } } // If the point is not contained in the current selection, // search for a figure in the drawing. if (figure == null) { figure = view.findFigure(anchor); while (figure != null && !figure.isSelectable()) { figure = drawing.findFigureBehind(p, figure); } } } if (figure != null && figure.isSelectable()) { newTracker = getDragTracker(figure); } else { if (!evt.isShiftDown()) { view.clearSelection(); view.setHandleDetailLevel(0); } newTracker = getSelectAreaTracker(); } } if (newTracker != null) { setTracker(newTracker); } tracker.mousePressed(evt); } }