示例#1
0
    protected RegionShape(Sector sector) {
      super(sector);

      // Create the default border shape.
      this.setBorder(new SurfaceSector(sector));

      // The edges of the region shape should be constant lines of latitude and longitude.
      this.setPathType(AVKey.LINEAR);
      this.getBorder().setPathType(AVKey.LINEAR);

      // Setup default interior rendering attributes. Note that the interior rendering attributes
      // are
      // configured so only the SurfaceSector's interior is rendered.
      ShapeAttributes interiorAttrs = new BasicShapeAttributes();
      interiorAttrs.setDrawOutline(false);
      interiorAttrs.setInteriorMaterial(new Material(Color.WHITE));
      interiorAttrs.setInteriorOpacity(0.1);
      this.setAttributes(interiorAttrs);

      // Setup default border rendering attributes. Note that the border rendering attributes are
      // configured
      // so that only the SurfaceSector's outline is rendered.
      ShapeAttributes borderAttrs = new BasicShapeAttributes();
      borderAttrs.setDrawInterior(false);
      borderAttrs.setOutlineMaterial(new Material(Color.RED));
      borderAttrs.setOutlineOpacity(0.7);
      borderAttrs.setOutlineWidth(3);
      this.getBorder().setAttributes(borderAttrs);
    }
 protected ShapeAttributes createPolygonAttributes(Color color) {
   ShapeAttributes attrs = new BasicShapeAttributes();
   attrs.setInteriorMaterial(new Material(color));
   attrs.setOutlineMaterial(new Material(WWUtil.makeColorBrighter(color)));
   attrs.setInteriorOpacity(0.5);
   attrs.setOutlineWidth(3);
   return attrs;
 }
    protected void addPath(RenderableLayer layer, List<Position> positions, String displayName) {
      ShapeAttributes attrs = new BasicShapeAttributes();
      attrs.setOutlineWidth(5);

      Path path = new Path(positions);
      path.setPathType(AVKey.LINEAR);
      path.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      path.setAttributes(attrs);
      path.setValue(AVKey.DISPLAY_NAME, displayName);
      layer.addRenderable(path);

      // Show how to make the colors vary along the paths.
      path.setPositionColors(new ExamplePositionColors());
    }
    protected void addContourShapes(
        List<List<Position>> contourList, double value, RenderableLayer layer) {
      String text = this.textForValue(value);
      Color color = this.colorForValue(value, 1.0); // color for value at 100% brightness

      ShapeAttributes attrs = new BasicShapeAttributes();
      attrs.setOutlineMaterial(new Material(color));
      attrs.setOutlineWidth(2);

      for (List<Position> positions : contourList) {
        Path path = new Path(positions);
        path.setAttributes(attrs);
        path.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
        path.setFollowTerrain(true);
        path.setValue(AVKey.DISPLAY_NAME, text);
        layer.addRenderable(path);
      }
    }
示例#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
    public AppFrame() {
      super(true, true, false);

      // Add detail hint slider panel
      this.getLayerPanel().add(makeDetailHintControlPanel(), BorderLayout.SOUTH);

      RenderableLayer layer = new RenderableLayer();

      // Create and set an attribute bundle.
      ShapeAttributes attrs = new BasicShapeAttributes();
      attrs.setInteriorMaterial(Material.YELLOW);
      attrs.setInteriorOpacity(0.7);
      attrs.setEnableLighting(true);
      attrs.setOutlineMaterial(Material.RED);
      attrs.setOutlineWidth(2d);
      attrs.setDrawInterior(true);
      attrs.setDrawOutline(false);

      // Create and set an attribute bundle.
      ShapeAttributes attrs2 = new BasicShapeAttributes();
      attrs2.setInteriorMaterial(Material.PINK);
      attrs2.setInteriorOpacity(1);
      attrs2.setEnableLighting(true);
      attrs2.setOutlineMaterial(Material.WHITE);
      attrs2.setOutlineWidth(2d);
      attrs2.setDrawOutline(false);

      // ********* sample  Wedges  *******************

      // Wedge with equal axes, ABSOLUTE altitude mode
      Wedge wedge3 =
          new Wedge(Position.fromDegrees(40, -120, 80000), Angle.POS90, 50000, 50000, 50000);
      wedge3.setAltitudeMode(WorldWind.ABSOLUTE);
      wedge3.setAttributes(attrs);
      wedge3.setVisible(true);
      wedge3.setValue(AVKey.DISPLAY_NAME, "Wedge with equal axes, ABSOLUTE altitude mode");
      layer.addRenderable(wedge3);

      // Wedge with equal axes, RELATIVE_TO_GROUND
      Wedge wedge4 =
          new Wedge(Position.fromDegrees(37.5, -115, 50000), Angle.POS90, 50000, 50000, 50000);
      wedge4.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge4.setAttributes(attrs);
      wedge4.setVisible(true);
      wedge4.setValue(
          AVKey.DISPLAY_NAME, "Wedge with equal axes, RELATIVE_TO_GROUND altitude mode");
      layer.addRenderable(wedge4);

      // Wedge with equal axes, CLAMP_TO_GROUND
      Wedge wedge5 =
          new Wedge(Position.fromDegrees(35, -110, 50000), Angle.POS90, 50000, 50000, 50000);
      wedge5.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);
      wedge5.setAttributes(attrs);
      wedge5.setVisible(true);
      wedge5.setValue(AVKey.DISPLAY_NAME, "Wedge with equal axes, CLAMP_TO_GROUND altitude mode");
      layer.addRenderable(wedge5);

      // Wedge with a texture, using Wedge(position, angle, height, radius) constructor
      Wedge wedge9 =
          new Wedge(Position.fromDegrees(0, -90, 600000), Angle.fromDegrees(225), 1200000, 600000);
      wedge9.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge9.setImageSources("gov/nasa/worldwindx/examples/images/500px-Checkerboard_pattern.png");
      wedge9.setAttributes(attrs);
      wedge9.setVisible(true);
      wedge9.setValue(AVKey.DISPLAY_NAME, "Wedge with a texture");
      layer.addRenderable(wedge9);

      // Scaled Wedge with default orientation
      Wedge wedge = new Wedge(Position.ZERO, Angle.fromDegrees(125), 500000, 500000, 500000);
      wedge.setAltitudeMode(WorldWind.ABSOLUTE);
      wedge.setAttributes(attrs);
      wedge.setVisible(true);
      wedge.setValue(AVKey.DISPLAY_NAME, "Scaled Wedge with default orientation");
      layer.addRenderable(wedge);

      // Scaled Wedge with a pre-set orientation
      Wedge wedge2 =
          new Wedge(
              Position.fromDegrees(0, 30, 750000),
              Angle.POS90,
              500000,
              500000,
              500000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      wedge2.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge2.setAttributes(attrs2);
      wedge2.setVisible(true);
      wedge2.setValue(AVKey.DISPLAY_NAME, "Scaled Wedge with a pre-set orientation");
      layer.addRenderable(wedge2);

      // Scaled Wedge with a pre-set orientation
      Wedge wedge6 =
          new Wedge(
              Position.fromDegrees(30, 30, 750000),
              Angle.POS90,
              500000,
              500000,
              500000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      wedge6.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge6.setImageSources("gov/nasa/worldwindx/examples/images/500px-Checkerboard_pattern.png");
      wedge6.setAttributes(attrs2);
      wedge6.setVisible(true);
      wedge6.setValue(AVKey.DISPLAY_NAME, "Scaled Wedge with a pre-set orientation");
      layer.addRenderable(wedge6);

      // Scaled Wedge with a pre-set orientation
      Wedge wedge7 =
          new Wedge(
              Position.fromDegrees(60, 30, 750000),
              Angle.POS90,
              500000,
              500000,
              500000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      wedge7.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge7.setAttributes(attrs2);
      wedge7.setVisible(true);
      wedge7.setValue(AVKey.DISPLAY_NAME, "Scaled Wedge with a pre-set orientation");
      layer.addRenderable(wedge7);

      // Scaled, oriented Wedge in 3rd "quadrant" (-X, -Y, -Z)
      Wedge wedge8 =
          new Wedge(
              Position.fromDegrees(-45, -180, 750000),
              Angle.POS90,
              500000,
              1000000,
              500000,
              Angle.fromDegrees(90),
              Angle.fromDegrees(45),
              Angle.fromDegrees(30));
      wedge8.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
      wedge8.setAttributes(attrs2);
      wedge8.setVisible(true);
      wedge8.setValue(
          AVKey.DISPLAY_NAME, "Scaled, oriented Wedge with in the 3rd 'quadrant' (-X, -Y, -Z)");
      layer.addRenderable(wedge8);

      // Add the layer to the model.
      insertBeforeCompass(getWwd(), layer);

      // Update layer panel
      this.getLayerPanel().update(this.getWwd());
    }
示例#7
0
 public void setBorderWidth(double width) {
   ShapeAttributes attr = this.getBorder().getAttributes();
   attr.setOutlineWidth(width);
   this.getBorder().setAttributes(attr);
 }
 protected ShapeAttributes createPolylineAttributes(Color color) {
   ShapeAttributes attrs = new BasicShapeAttributes();
   attrs.setOutlineMaterial(new Material(color));
   attrs.setOutlineWidth(1.5);
   return attrs;
 }