Example #1
0
 /**
  * Initializing constructor.
  *
  * @param name the name of this layer
  */
 public SurfShapesLayer(String name) {
   // properties of layer
   setName(name);
   setEnabled(true);
   // painting attributes for shapes
   attr.setOutlineMaterial(Material.ORANGE);
   attr.setOutlineWidth(1.5);
   Material intMat = new Material(Color.ORANGE.brighter().brighter());
   attr.setInteriorMaterial(intMat);
   attr.setInteriorOpacity(NORM_INSIDE_OPACITY);
   // painting attributes for hihglighted shapes
   attrHigh.setOutlineMaterial(Material.BLACK);
   attrHigh.setOutlineWidth(2);
   attrHigh.setInteriorMaterial(Material.WHITE);
   attrHigh.setInteriorOpacity(HIGHL_INSIDE_OPACITY);
   // popup annotation attributes
   AnnotationAttributes attrAnno = new AnnotationAttributes();
   attrAnno.setAdjustWidthToText(AVKey.SIZE_FIT_TEXT);
   attrAnno.setFrameShape(AVKey.SHAPE_RECTANGLE);
   attrAnno.setCornerRadius(3);
   attrAnno.setDrawOffset(new Point(0, 8));
   attrAnno.setLeaderGapWidth(8);
   attrAnno.setTextColor(Color.BLACK);
   attrAnno.setBackgroundColor(new Color(1f, 1f, 1f, .85f));
   attrAnno.setBorderColor(new Color(0xababab));
   attrAnno.setInsets(new Insets(3, 3, 3, 3));
   attrAnno.setVisible(false);
   popupAnnotation.setAttributes(attrAnno);
   popupAnnotation.setAlwaysOnTop(true);
   addRenderable(popupAnnotation);
 }
Example #2
0
 @Override
 public void setShowAnnotation(boolean showAnnotation) {
   this.showAnnotation = showAnnotation;
   if (!showAnnotation) {
     popupAnnotation.getAttributes().setVisible(false);
     wwd.redraw();
   }
 }
Example #3
0
 @Override
 public void removeAllShapes() {
   super.removeAllRenderables();
   shapesById.clear();
   // re-add the hidden notation
   popupAnnotation.getAttributes().setVisible(false);
   addRenderable(popupAnnotation);
 }
Example #4
0
 // manages change of attributes for highlighting, annotation bubble toggle, event firing
 private void internalHighlight(SurfaceShape shape, boolean noDeselect) {
   if (!highlightingEnabled) {
     return;
   }
   String shpId = (String) shape.getValue(AVKey.HOVER_TEXT);
   // if annotation visible and same shape
   if (shape.equals(prevPopupShape) && shape.isHighlighted()) {
     if (!noDeselect) {
       // hide annotation and de-highlight
       popupAnnotation.getAttributes().setVisible(false);
       shape.setHighlighted(false);
       // forget previous highlighted shape and fire deselection event
       prevPopupShape = null;
       firePropertyChange(new PropertyChangeEvent(this, PROPERTY_SELECTION, shpId, null));
     }
   } else {
     if (showAnnotation) {
       // find shape centroid
       final Sector boundingSector =
           Sector.boundingSector(shape.getLocations(wwd.getModel().getGlobe()));
       Position centroid = new Position(boundingSector.getCentroid(), 0d);
       // prepare and show annotation
       popupAnnotation.setText(shpId);
       popupAnnotation.setPosition(centroid);
       popupAnnotation.getAttributes().setVisible(true);
     }
     // highlight shape
     shape.setHighlighted(true);
     if (prevPopupShape != null) {
       // de-highlight previous shape and fire deselection event
       prevPopupShape.setHighlighted(false);
       firePropertyChange(
           new PropertyChangeEvent(
               this, PROPERTY_SELECTION, prevPopupShape.getValue(AVKey.HOVER_TEXT), shpId));
     } else {
       // fire event only
       firePropertyChange(new PropertyChangeEvent(this, PROPERTY_SELECTION, null, shpId));
     }
     // remember shape
     prevPopupShape = shape;
   }
 }
Example #5
0
 @Override
 public void setHighlightingEnabled(boolean highlightingEnabled) {
   this.highlightingEnabled = highlightingEnabled;
   // hide popup and clear highlighed object when disabling
   if (!highlightingEnabled) {
     popupAnnotation.getAttributes().setVisible(false);
     if (prevPopupShape != null) {
       prevPopupShape.setHighlighted(false);
     }
     wwd.redraw();
   }
 }