// 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();
   }
 }
Пример #2
0
  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();
  }
  // 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();
    }
  }
Пример #4
0
  public void mouseDragged(MouseEvent mouseEvent) {
    if (MouseEvent.BUTTON1_DOWN_MASK != mouseEvent.getModifiersEx()) return;

    if (this.getShape().isResizeable()) mouseEvent.consume(); // prevent view operations
  }