Ejemplo n.º 1
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();
    }
  }
  // Handle dragging of control points
  public void selected(SelectEvent event) {
    // Ignore select events if the tools is armed, or in a move/rotate action. In either case we
    // don't
    // want to change the currently selected or hightlighted control point.
    if (measureTool == null || (this.isArmed() && this.isUseRubberBand()) || this.isMoving())
      return;

    if (dragger == null) dragger = new BasicDragger(measureTool.getWwd());

    // Have rollover events highlight the rolled-over object.
    if (event.getEventAction().equals(SelectEvent.ROLLOVER) && !dragger.isDragging()) {
      this.highlight(event.getTopObject());
      this.measureTool.getWwd().redraw();
    }

    this.doSelected(event);

    // We missed any roll-over events while dragging, so highlight any under the cursor now,
    // or de-highlight the dragged control point if it's no longer under the cursor.
    if (event.getEventAction().equals(SelectEvent.DRAG_END)) {
      PickedObjectList pol = this.measureTool.getWwd().getObjectsAtCurrentPosition();
      if (pol != null) {
        this.highlight(pol.getTopObject());
        this.measureTool.getWwd().redraw();
      }
    }
  }
Ejemplo n.º 3
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();
        }
      }
    }
  }
Ejemplo n.º 4
0
    protected void handleSelect() {
      // If the picked object is null or something other than an airspace, then ignore the mouse
      // click. If we
      // deselect the current entry at this point, the user cannot easily navigate without loosing
      // the selection.

      PickedObjectList pickedObjects = this.getApp().getWwd().getObjectsAtCurrentPosition();

      Object topObject = pickedObjects.getTopObject();
      if (!(topObject instanceof Airspace)) return;

      AirspaceEntry pickedEntry = this.getEntryFor((Airspace) topObject);
      if (pickedEntry == null) return;

      if (this.getSelectedEntry() != pickedEntry) {
        this.selectEntry(pickedEntry, true);
      }
    }
Ejemplo n.º 5
0
    public void selected(SelectEvent event) {
      // Have rollover events highlight the rolled-over object.
      if (event.getEventAction().equals(SelectEvent.ROLLOVER) && !this.dragger.isDragging()) {
        this.highlight(event.getTopObject());
        this.wwd.redraw();
      }

      // Drag the selected object.
      if (event.getEventAction().equals(SelectEvent.DRAG)
          || event.getEventAction().equals(SelectEvent.DRAG_END)) {
        this.dragger.selected(event);

        if (this.dragger.isDragging()) this.wwd.redraw();
      }

      // We missed any roll-over events while dragging, so highlight any under the cursor now.
      if (event.getEventAction().equals(SelectEvent.DRAG_END)) {
        PickedObjectList pol = this.wwd.getObjectsAtCurrentPosition();
        if (pol != null) {
          this.highlight(pol.getTopObject());
          this.wwd.redraw();
        }
      }
    }