예제 #1
0
 @Override
 public void setSurfShapeColor(String id, Color col, double opacity) throws NoSuchShapeException {
   SurfaceShape shape = getSurfShape(id);
   BasicShapeAttributes newAttr = new BasicShapeAttributes(attr);
   newAttr.setOutlineMaterial(new Material(col));
   newAttr.setInteriorMaterial(new Material(col.brighter().brighter()));
   newAttr.setOutlineOpacity(opacity);
   newAttr.setInteriorOpacity(NORM_INSIDE_OPACITY * opacity);
   shape.setAttributes(newAttr);
 }
예제 #2
0
 /**
  * Implementation of WorldWind selection API.
  *
  * @param event selection event
  */
 @Override
 public void selected(SelectEvent event) {
   // short circuit exit if highlighting is not enabled
   if (!highlightingEnabled) {
     return;
   }
   if (event.getEventAction().equals(highlightEvent)) {
     final Object topObject = event.getTopObject();
     if (topObject instanceof SurfaceShape) {
       SurfaceShape shape = (SurfaceShape) topObject;
       final Object layer = shape.getValue(AVKey.LAYER);
       if (layer instanceof SurfShapesLayer) {
         SurfShapesLayer sl = (SurfShapesLayer) layer;
         if (sl.getName().equals(getName())) {
           internalHighlight(shape, false);
         }
         wwd.redraw();
       }
     }
   }
 }
예제 #3
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();
   }
 }
예제 #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;
   }
 }
예제 #5
0
    private void update() {
      for (JComponent c : onTerrainOnlyItems) {
        c.setEnabled(currentFollowTerrain);
      }

      for (JComponent c : offTerrainOnlyItems) {
        c.setEnabled(!currentFollowTerrain);
      }

      if (this.currentShape instanceof SurfaceShape) {
        SurfaceShape shape = (SurfaceShape) currentShape;
        ShapeAttributes attr = shape.getAttributes();

        if (attr == null) attr = new BasicShapeAttributes();

        if (!currentBorderStyle.equals("None")) {
          float alpha =
              currentBorderOpacity >= 10
                  ? 1f
                  : currentBorderOpacity <= 0 ? 0f : currentBorderOpacity / 10f;
          Color color = null;
          if (currentBorderColor.equals("Yellow")) color = new Color(1f, 1f, 0f);
          else if (currentBorderColor.equals("Red")) color = new Color(1f, 0f, 0f);
          else if (currentBorderColor.equals("Green")) color = new Color(0f, 1f, 0f);
          else if (currentBorderColor.equals("Blue")) color = new Color(0f, 0f, 1f);

          attr.setDrawOutline(true);
          attr.setOutlineMaterial(new Material(color));
          attr.setOutlineOpacity(alpha);
          attr.setOutlineWidth(currentBorderWidth);
        } else {
          attr.setDrawOutline(false);
        }

        if (!currentInteriorStyle.equals("None")) {
          float alpha =
              currentInteriorOpacity >= 10
                  ? 1f
                  : currentInteriorOpacity <= 0 ? 0f : currentInteriorOpacity / 10f;
          Color color = null;
          if (currentInteriorColor.equals("Yellow")) color = new Color(1f, 1f, 0f);
          else if (currentInteriorColor.equals("Red")) color = new Color(1f, 0f, 0f);
          else if (currentInteriorColor.equals("Green")) color = new Color(0f, 1f, 0f);
          else if (currentInteriorColor.equals("Blue")) color = new Color(0f, 0f, 1f);

          attr.setInteriorMaterial(new Material(color));
          attr.setInteriorOpacity(alpha);
          attr.setDrawInterior(true);
        } else {
          attr.setDrawInterior(false);
        }

        shape.setAttributes(attr);
      } else {
        float alpha =
            currentPathOpacity >= 10 ? 1f : currentPathOpacity <= 0 ? 0f : currentPathOpacity / 10f;
        Color color = null;
        if (currentPathColor.equals("Yellow")) color = new Color(1f, 1f, 0f, alpha);
        else if (currentPathColor.equals("Red")) color = new Color(1f, 0f, 0f, alpha);
        else if (currentPathColor.equals("Green")) color = new Color(0f, 1f, 0f, alpha);
        else if (currentPathColor.equals("Blue")) color = new Color(0f, 0f, 1f, alpha);

        if (currentShape instanceof Polyline) {
          Polyline pl = (Polyline) currentShape;
          pl.setColor(color);
          pl.setLineWidth(currentPathWidth);
          pl.setFollowTerrain(currentFollowTerrain);
          pl.setTerrainConformance(currentTerrainConformance);
          pl.setNumSubsegments(currentNumSubsegments);

          if (currentPathType.equalsIgnoreCase("linear")) pl.setPathType(Polyline.LINEAR);
          else if (currentPathType.equalsIgnoreCase("rhumb line"))
            pl.setPathType(Polyline.RHUMB_LINE);
          else pl.setPathType(Polyline.GREAT_CIRCLE);

          pl.setOffset(currentOffset);

          if (currentPathStyle.equals("Dash")) {
            pl.setStippleFactor(5);
            pl.setStipplePattern((short) 0xAAAA);
          } else {
            pl.setStippleFactor(0); // solid
          }
        }
      }
      this.layer.removeAllRenderables();
      if (this.currentShape != null) this.layer.addRenderable(this.currentShape);
      this.wwjPanel.getWwd().redraw();
    }
예제 #6
0
 @Override
 public void setSurfShapeVisible(String id, boolean flag) throws NoSuchShapeException {
   SurfaceShape shape = getSurfShape(id);
   shape.setVisible(flag);
 }
예제 #7
0
 @Override
 public void resetAllSurfShapeColors() {
   for (SurfaceShape shp : shapesById.values()) {
     shp.setAttributes(attr);
   }
 }
예제 #8
0
 @Override
 public void resetSurfShapeColor(String id) throws NoSuchShapeException {
   SurfaceShape shape = getSurfShape(id);
   shape.setAttributes(attr);
 }