public void mousePressed(MouseEvent e) { this.mousePoint = e.getPoint(); Object topObject = null; PickedObjectList pickedObjects = this.wwd.getObjectsAtCurrentPosition(); if (pickedObjects != null) topObject = pickedObjects.getTopObject(); if (topObject instanceof ControlPointMarker) { this.activeControlPoint = (ControlPointMarker) topObject; this.activeAction = this.activeControlPoint.getType(); setShowAnnotation(true); updateAnnotation(this.activeControlPoint.getPosition()); // update controlPointIndex; int i = 0; for (Marker controlPoint : this.controlPoints) { if (controlPoint.equals(topObject)) break; i++; } this.activeControlPointIndex = i; e.consume(); } else if (topObject == this.getPolygon()) { this.activeAction = MOVE_POLYGON_ACTION; // set the shape to be the "active control point" this.activeControlPointIndex = -1; setShowAnnotation(true); updateAnnotation(this.polygon.getReferencePosition()); e.consume(); } }
// 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(); } }
public void mouseEvt(MouseEvent evt) { if (evt.isPopupTrigger()) { propDialog.setVisible(true); propDialog.toFront(); evt.consume(); } }
@Override protected void processMouseEvent(MouseEvent e) { if (UIUtil.isActionClick(e, MouseEvent.MOUSE_PRESSED) && isOnNextStepButton(e)) { e.consume(); } super.processMouseEvent(e); }
public void mouseClicked(MouseEvent e) { int x; int y; e.consume(); if (mouseEventsEnabled) { x = Math.round(e.getX() / scale); y = Math.round(e.getY() / scale); // allow for the canvas margin y -= margin; // System.out.println("Mouse Click: (" + x + ", " + y + ")"); if (e.getClickCount() < 2) { if (nativeSelectItem(x, y)) { parentFTAFrame.updateFrame(); } } else { if (nativeSelectItem(x, y)) { parentFTAFrame.updateFrame(); } editSelected(); parentFTAFrame.updateFrame(); } if (focusEventsEnabled) { // tell the main Canvas to point to this coordinate parentFTAFrame.setCanvasFocus(x, y); } } }
public void mousePressed(MouseEvent e) { mouseX = e.getX(); mouseY = e.getY(); // consume this event so that it will not be processed // in the default manner e.consume(); }
public void mouseReleased(MouseEvent mouseEvent) { if (this.isArmed() && this.isUseRubberBand() && mouseEvent.getButton() == MouseEvent.BUTTON1) { if (this.isUseRubberBand() && measureTool.getPositions().size() == 1) measureTool.removeControlPoint(); this.setActive(false); rubberBandTarget = null; // Disarm after second control point of a line or regular shape autoDisarm(); mouseEvent.consume(); measureTool.firePropertyChange(MeasureTool.EVENT_RUBBERBAND_STOP, null, null); } else if (this.isMoving() && mouseEvent.getButton() == MouseEvent.BUTTON1) { this.setMoving(false); this.movingTarget = null; mouseEvent.consume(); } }
@Override public void mouseDragged(MouseEvent e) { if (!myDragging) return; MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, MyDivider.this); final ToolWindowAnchor anchor = myInfo.getAnchor(); final Point point = event.getPoint(); final Container windowPane = InternalDecorator.this.getParent(); myLastPoint = SwingUtilities.convertPoint(MyDivider.this, point, windowPane); myLastPoint.x = Math.min(Math.max(myLastPoint.x, 0), windowPane.getWidth()); myLastPoint.y = Math.min(Math.max(myLastPoint.y, 0), windowPane.getHeight()); final Rectangle bounds = InternalDecorator.this.getBounds(); if (anchor == ToolWindowAnchor.TOP) { InternalDecorator.this.setBounds(0, 0, bounds.width, myLastPoint.y); } else if (anchor == ToolWindowAnchor.LEFT) { InternalDecorator.this.setBounds(0, 0, myLastPoint.x, bounds.height); } else if (anchor == ToolWindowAnchor.BOTTOM) { InternalDecorator.this.setBounds( 0, myLastPoint.y, bounds.width, windowPane.getHeight() - myLastPoint.y); } else if (anchor == ToolWindowAnchor.RIGHT) { InternalDecorator.this.setBounds( myLastPoint.x, 0, windowPane.getWidth() - myLastPoint.x, bounds.height); } InternalDecorator.this.validate(); e.consume(); }
public void mouseDragged(MouseEvent e) { // called during motion with buttons down ball.LaunchBall(); e.consume(); 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 mouseClicked(MouseEvent e) { if (this.isArmed()) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { Object topObject = null; PickedObjectList pickedObjects = this.wwd.getObjectsAtCurrentPosition(); if (pickedObjects != null) topObject = pickedObjects.getTopObject(); if (topObject instanceof ControlPointMarker) { this.removeVertex((ControlPointMarker) topObject); e.consume(); } else { this.addVertex(e.getPoint()); e.consume(); } } } }
public void mouseReleased(MouseEvent e) { this.activeControlPoint = null; this.activeAction = null; setShowAnnotation(false); updateAnnotation(null); e.consume(); }
/** {@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 void mouseMoved(MouseEvent e) { // called during motion when no buttons are down // if (e.getY == if ((e.getX() < appletsize_x - pad.width() / 2) && (e.getX() > (pad.width() / 2))) { pad.changeX(e.getX() - (pad.width() / 2)); ball.moveWithPaddle(pad.xPos + (pad.width() / 2) - (ball.radius())); } e.consume(); repaint(); }
@Override public void mouseReleased(MouseEvent e) { if (_up != null) { int[] pos = setUpNearest(e); if (_up.getType() == BoardObject.type.SETTLEMENT) gameLogic.writeBuildSettlement(pos[0], pos[1]); else if (_up.getType() == BoardObject.type.CITY) gameLogic.writeBuildCity(pos[0], pos[1]); else if ((_up.getType() == BoardObject.type.ROAD) && (((Road) _up).oneDown == true)) { gameLogic.writeBuildRoad(((Road) _up).mycoord[0], ((Road) _up).mycoord[1], pos[0], pos[1]); } if (_up.getType() == BoardObject.type.ROAD) { if (((Road) _up).oneDown == false) { _up.setX( hexleft + ((pos[0] - (pos[0] % 2)) / 2 * intervalSide[0] + (pos[0] - (pos[0] % 2)) / 2 * intervalSide[1] + (pos[0] % 2) * intervalSide[0]) + _display_offset[0]); _up.setY(hextop + pos[1] * intervalUp + _display_offset[1]); ((Road) _up).oneDown = true; ((Road) _up).mycoord = pos; _mousedown = null; e.consume(); } else { ((Road) _up) .setX2( hexleft + ((pos[0] - (pos[0] % 2)) / 2 * intervalSide[0] + (pos[0] - (pos[0] % 2)) / 2 * intervalSide[1] + (pos[0] % 2) * intervalSide[0])); ((Road) _up).setY2(hextop + pos[1] * intervalUp); ((Road) _up).oneDown = true; _up = null; _mousedown = null; } } else { _up.setX( hexleft + ((pos[0] - (pos[0] % 2)) / 2 * intervalSide[0] + (pos[0] - (pos[0] % 2)) / 2 * intervalSide[1] + (pos[0] % 2) * intervalSide[0]) - _up.getW() / 2); _up.setY(hextop + pos[1] * intervalUp - _up.getH() / 2); _up = null; _mousedown = null; } } repaint(); }
/** {@inheritDoc} */ @Override public void mouseMoved(final MouseEvent aEvent) { final MouseEvent event = convertEvent(aEvent); final Point point = event.getPoint(); final SignalDiagramModel model = getModel(); if (model.isCursorMode()) { final Cursor hoveredCursor = findCursor(point); if (hoveredCursor != null) { setMouseCursor(aEvent, CURSOR_MOVE_CURSOR); aEvent.consume(); } else { setMouseCursor(aEvent, null); aEvent.consume(); } } setToolTipText(ViewUtils.getToolTipText(getModel(), point)); }
public void mouseDragged(MouseEvent e) { int new_mx = e.getX(); int new_my = e.getY(); azimuth -= new_mx - mx; elevation += new_my - my; mx = new_mx; my = new_my; repaint(); e.consume(); }
public void mouseReleased(MouseEvent mouseEvent) { if (MouseEvent.BUTTON1 != mouseEvent.getButton()) return; if (this.getShape().isResizeable()) this.setCursor(null); this.getShape().setResizeable(false); mouseEvent.consume(); // prevent view operations this.firePropertyChange(SECTOR_PROPERTY, this.previousSector, 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(); }
/** * Determines whether or not the given mouse event is actually a popup trigger. * * @param aPoint the <em>corrected</em> mouse position, where the popup is to be shown, cannot be * <code>null</code>; * @param aEvent the mouse event that could be a popup trigger, cannot be <code>null</code>. */ private boolean handlePopupTrigger(final Point aPoint, final MouseEvent aEvent) { final boolean popupTrigger = isCursorPopupTrigger(aEvent); if (popupTrigger) { JPopupMenu contextMenu = createCursorPopup(aPoint, aEvent.getLocationOnScreen()); if (contextMenu != null) { contextMenu.show(aEvent.getComponent(), aEvent.getX(), aEvent.getY()); // Mark the event as consumed... aEvent.consume(); } } return popupTrigger; }
public void mouseDragged(MouseEvent e) { int x = e.getX(); int y = e.getY(); tmpMatrix.unit(); tmpMatrix.xrot(360.0 * (mouseY - y) / getSize().height); tmpMatrix.yrot(360.0 * (x - mouseX) / getSize().width); viewMatrix.mult(tmpMatrix); repaint(); mouseX = x; mouseY = y; e.consume(); }
// Handle single click for removing control points public void mouseClicked(MouseEvent mouseEvent) { if (measureTool == null) return; if (this.isArmed() && mouseEvent.getButton() == MouseEvent.BUTTON1) { if (mouseEvent.isControlDown()) measureTool.removeControlPoint(); else if (!this.isUseRubberBand()) { measureTool.addControlPoint(); // Disarm after second control point of a line or regular shape autoDisarm(); } mouseEvent.consume(); } }
public void mouseDragged(MouseEvent e) { Point lastMousePoint = this.mousePoint; this.mousePoint = e.getPoint(); if (lastMousePoint == null) lastMousePoint = this.mousePoint; // update annotation if (isShowAnnotation()) { if (this.activeControlPointIndex < 0) updateAnnotation(this.polygon.getReferencePosition()); else if (this.controlPoints != null) updateAnnotation(this.controlPoints.get(this.activeControlPointIndex).getPosition()); } if (MOVE_VERTEX_ACTION.equals(this.activeAction)) { this.moveControlPoint(this.activeControlPoint, lastMousePoint, this.mousePoint); e.consume(); } else if (CHANGE_HEIGHT_ACTION.equals(this.activeAction)) { this.setPolygonHeight(lastMousePoint, this.mousePoint); e.consume(); } else if (MOVE_POLYGON_ACTION.equals(this.activeAction)) { this.movePolygon(lastMousePoint, this.mousePoint); e.consume(); } }
// 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 mouseClicked(final MouseEvent aEvent) { // Ensure the focus is moved to the main signal diagram component... getSignalDiagram().requestFocusInWindow(); if (getModel().isCursorMode() && (aEvent.getClickCount() == 2)) { final MouseEvent event = convertEvent(aEvent); final Cursor hoveredCursor = findCursor(event.getPoint()); if (hoveredCursor != null) { editCursorProperties(hoveredCursor); // Consume the event to stop further processing... aEvent.consume(); } } }
public void mousePressed(MouseEvent e) { // Selects to create a handler for resizing if (!graph.isCellSelected(cell)) { graphContainer.selectCellForEvent(cell, e); } // Initiates a resize event in the handler mxCellHandler handler = graphContainer.getSubHandler().getHandler(cell); if (handler != null) { // Starts the resize at index 7 (bottom right) handler.start( SwingUtilities.convertMouseEvent( (Component) e.getSource(), e, graphContainer.getGraphControl()), index); e.consume(); } }
public void mouseMoved(MouseEvent e) { mx = e.getX(); my = e.getY(); showStatus("Mouse at (" + mx + "," + my + ")"); // update background dbg.drawImage(background, 0, 0, this); // draw the choosen building my = my - (int) (building.getHeight(null)) / 2; mx = mx - (int) (building.getWidth(null)) / 2; dbg.drawImage(building, mx, my, this); repaint(); e.consume(); }
public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); e.consume(); requestFocus(); if (mx < x && x < mx + getSize().width / 10 - 1 && my < y && y < my + getSize().height / 10 - 1) { // determine if hit if (onaroll > 0) { // not first hit switch (onaroll % 4) { // play a sound case 0: play(getCodeBase(), "sounds/tiptoe.thru.the.tulips.au"); break; case 1: play(getCodeBase(), "sounds/danger.au"); break; case 2: play(getCodeBase(), "sounds/adapt-or-die.au"); break; case 3: play(getCodeBase(), "sounds/cannot.be.completed.au"); break; } onaroll++; if (onaroll > 5) { getAppletContext() .showStatus("You're on your way to THE HALL OF FAME:" + onaroll + "Hits!"); } else { getAppletContext().showStatus("YOU'RE ON A ROLL:" + onaroll + "Hits!"); } } else { // first hit getAppletContext().showStatus("HIT IT AGAIN! AGAIN!"); play(getCodeBase(), "sounds/that.hurts.au"); onaroll = 1; } } else { // miss getAppletContext().showStatus("You hit nothing at (" + x + ", " + y + "), exactly"); play(getCodeBase(), "sounds/thin.bell.au"); onaroll = 0; } repaint(); }
/** Handles a mouse click. */ @Override public boolean handleMouseClick(Point2D.Double p, MouseEvent evt, DrawingView view) { if (evt.getClickCount() == 2 && view.getHandleDetailLevel() % 2 == 0) { willChange(); final int index = splitSegment(p, 5f / view.getScaleFactor()); if (index != -1) { final BezierPath.Node newNode = getNode(index); fireUndoableEditHappened( new AbstractUndoableEdit() { private static final long serialVersionUID = 1L; @Override public String getPresentationName() { ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels"); return labels.getString("edit.bezierPath.splitSegment.text"); } @Override public void redo() throws CannotRedoException { super.redo(); willChange(); addNode(index, newNode); changed(); } @Override public void undo() throws CannotUndoException { super.undo(); willChange(); removeNode(index); changed(); } }); changed(); evt.consume(); return true; } } return false; }
/** * Re-dispatches glass pane mouse events only in case they occur on the security panel. * * @param glassPane the glass pane * @param e the mouse event in question */ private void redispatchMouseEvent(Component glassPane, MouseEvent e) { Point glassPanePoint = e.getPoint(); Point securityPanelPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, securityPanel); Component component; Point componentPoint; if (securityPanelPoint.y > 0) { component = securityPanel; componentPoint = securityPanelPoint; } else { Container contentPane = callRenderer.getCallContainer().getCallWindow().getFrame().getContentPane(); Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, contentPane); component = SwingUtilities.getDeepestComponentAt(contentPane, containerPoint.x, containerPoint.y); componentPoint = SwingUtilities.convertPoint(contentPane, glassPanePoint, component); } if (component != null) component.dispatchEvent( new MouseEvent( component, e.getID(), e.getWhen(), e.getModifiers(), componentPoint.x, componentPoint.y, e.getClickCount(), e.isPopupTrigger())); e.consume(); }