// 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 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(); } }
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); }
// 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(); } }