コード例 #1
0
 // 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 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();
    }
  }
コード例 #3
0
 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();
   }
 }
コード例 #4
0
  public void mouseReleased(MouseEvent e) {
    this.activeControlPoint = null;
    this.activeAction = null;

    setShowAnnotation(false);
    updateAnnotation(null);
    e.consume();
  }
コード例 #5
0
  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();
        }
      }
    }
  }
コード例 #6
0
  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);
  }
コード例 #7
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();
  }
コード例 #8
0
  // 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();
    }
  }
コード例 #9
0
  // 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();
    }
  }
コード例 #10
0
  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();
    }
  }
コード例 #11
0
  public void mouseDragged(MouseEvent mouseEvent) {
    if (MouseEvent.BUTTON1_DOWN_MASK != mouseEvent.getModifiersEx()) return;

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