// 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();
      }
    }
  }
Esempio n. 2
0
  public void selected(SelectEvent event) {
    if (event == null) {
      String msg = Logging.getMessage("nullValue.EventIsNull");
      Logging.logger().log(java.util.logging.Level.FINE, msg);
      throw new IllegalArgumentException(msg);
    }

    if (event.getTopObject() != null && !(event.getTopObject() instanceof RegionShape)) {
      this.setCursor(null);
      return;
    }

    if (event.getEventAction().equals(SelectEvent.LEFT_PRESS)) {
      this.setPreviousPosition(this.getWwd().getCurrentPosition());
    } else if (event.getEventAction().equals(SelectEvent.DRAG)) {
      DragSelectEvent dragEvent = (DragSelectEvent) event;
      Object topObject = dragEvent.getTopObject();
      if (topObject == null) return;

      RegionShape dragObject = (RegionShape) topObject;

      if (this.getOperation() == SIZING) {
        Sector newSector = this.resizeShape(dragObject, this.getSide());
        if (newSector != null) dragObject.setSector(newSector);
      } else {
        this.setSide(this.determineAdjustmentSide(dragObject, this.getEdgeFactor()));

        if (this.getSide() == NONE || this.getOperation() == MOVING) {
          this.setOperation(MOVING);
          this.dragWholeShape(dragEvent, dragObject);
        } else {
          Sector newSector = this.resizeShape(dragObject, this.getSide());
          if (newSector != null) dragObject.setSector(newSector);
          this.setOperation(SIZING);
        }
      }

      this.setPreviousPosition(this.getWwd().getCurrentPosition());
      this.notifySectorChanged();
    } else if (event.getEventAction().equals(SelectEvent.DRAG_END)) {
      this.setOperation(NONE);
      this.setPreviousPosition(null);
    } else if (event.getEventAction().equals(SelectEvent.ROLLOVER)) {
      if (!(this.getWwd() instanceof Component)) return;

      if (event.getTopObject() == null || event.getTopPickedObject().isTerrain()) {
        this.setCursor(null);
        return;
      }

      if (!(event.getTopObject() instanceof Movable)) return;

      this.setCursor(
          this.determineAdjustmentSide((Movable) event.getTopObject(), this.getEdgeFactor()));
    }
  }
  protected void doSelected(SelectEvent event) {
    if (this.movingTarget != null) return;

    if (!event.getEventAction().equals(SelectEvent.DRAG)
        && !event.getEventAction().equals(SelectEvent.DRAG_END)) return;

    if (event.getTopObject() == null
        || !(event.getTopObject() instanceof MeasureTool.ControlPoint)
        || ((MeasureTool.ControlPoint) event.getTopObject()).getParent() != measureTool) return;

    // Have drag events drag the selected object.
    this.dragSelected(event);
  }
Esempio n. 4
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();
        }
      }
    }
  protected void dragSelected(SelectEvent event) {
    MeasureTool.ControlPoint point = (MeasureTool.ControlPoint) event.getTopObject();

    LatLon lastPosition = point.getPosition();
    if (point.getValue(MeasureTool.CONTROL_TYPE_LOCATION_INDEX) != null)
      lastPosition =
          measureTool
              .getPositions()
              .get((Integer) point.getValue(MeasureTool.CONTROL_TYPE_LOCATION_INDEX));

    // Delegate dragging computations to a dragger.
    this.dragger.selected(event);

    measureTool.moveControlPoint(point);
    if (measureTool.isShowAnnotation()) measureTool.updateAnnotation(point.getPosition());
    measureTool.firePropertyChange(
        MeasureTool.EVENT_POSITION_REPLACE, lastPosition, point.getPosition());
    measureTool.getWwd().redraw();
  }