コード例 #1
0
  public void select(Object o, Layer parentLayer, Position pickPosition) {
    if (this.selectedAnnotLayer == null) {
      selectedAnnotLayer = new SelectedAnnotationLayer();
      selectedAnnotLayer.setEnabled(true);
      selectedAnnotLayer.setName("Layers.SelectedFeatureAnnotationLayer");

      wwd.getModel().getLayers().add(selectedAnnotLayer);
    } // if

    synchronized (selectedAnnotLayer) {
      // unselect the currently selected object
      unselect();

      // select o
      if (null != o) {
        if (o instanceof Annotation) {
          Annotation ann = (Annotation) o;

          this.savedAnnotationBorderColor = ann.getAttributes().getBorderColor();
          ann.getAttributes().setBorderColor(SELECTED_ANNOTATION_BORDER_COLOR);
          storeSelection(o, parentLayer);
        } else if (o instanceof Selectable) {
          ((Selectable) o).select(this.wwd, this.selectedAnnotLayer, pickPosition);
          storeSelection(o, parentLayer);
        } else {
          Logging.logger().severe("Unsupported object type selected!");
        }
      }
    }
  }
コード例 #2
0
  private void highlight(Object o) {
    // Manage highlighting of features
    if (this.lastPickedObject == o) {
      return;
    } // same thing picked

    // Turn off highlight if on.
    if (this.lastPickedObject != null) {
      if (this.lastPickedObject instanceof Annotation) {
        Annotation ann = (Annotation) this.lastPickedObject;

        ann.getAttributes().setHighlighted(false);
        this.lastPickedObject = null;
      } else if (this.lastPickedObject instanceof SelectableIcon) {
        ((SelectableIcon) this.lastPickedObject).setHighlighted(false);
        this.lastPickedObject = null;
      } else {
        Logging.logger().severe("Unsupported object type highlighted!");
      }
    }

    // Turn on highlight if object selected.
    if (o != null) {
      if (o instanceof Annotation) {
        // highlight the annotation UNLESS it's the annotation of the selected icon
        if (!(this.selectedObject instanceof Selectable)

        /* || ((Selectable)this.selectedObject).getAnnotation() != o*/ ) {
          Annotation ann = (Annotation) o;

          ann.getAttributes().setHighlighted(true);
        }

        this.lastPickedObject = o;
      } else if (o instanceof SelectableIcon) {
        ((SelectableIcon) o).setHighlighted(true);
        this.lastPickedObject = o;
      }
    }
  }
コード例 #3
0
  protected void setupAnnotationAttributes(Annotation annotation) {
    java.awt.Color transparentBlack = new java.awt.Color(0, 0, 0, 0);

    AnnotationAttributes defaultAttribs = new AnnotationAttributes();
    defaultAttribs.setAdjustWidthToText(AVKey.SIZE_FIXED);
    defaultAttribs.setBackgroundColor(transparentBlack);
    defaultAttribs.setBorderColor(transparentBlack);
    defaultAttribs.setBorderWidth(0);
    defaultAttribs.setCornerRadius(0);
    defaultAttribs.setDrawOffset(new java.awt.Point(0, 0));
    defaultAttribs.setHighlightScale(1);
    defaultAttribs.setInsets(new java.awt.Insets(0, 0, 0, 0));
    defaultAttribs.setImageScale(1);
    defaultAttribs.setImageOffset(new java.awt.Point(0, 0));
    defaultAttribs.setImageOpacity(1);
    defaultAttribs.setImageRepeat(AVKey.REPEAT_NONE);
    defaultAttribs.setLeader(AVKey.SHAPE_NONE);
    defaultAttribs.setSize(new java.awt.Dimension(0, 0));

    annotation.setPickEnabled(false);
    annotation.getAttributes().setDefaults(defaultAttribs);
  }