Пример #1
0
    /**
     * Loads the image at imageuri into the mapMapPanel
     *
     * @param imageuri URI to .jpg file
     * @return If loading was successful
     */
    private boolean loadNewImage(String imageuri) {
      if (mapSurfaceImage != null) {
        mapRenderLayer.removeAllRenderables();
      }

      try {
        mapBufferedImage = ImageIO.read(new URL(imageuri));
      } catch (IOException e) {
        return false;
      }

      double max =
          (mapBufferedImage.getHeight() > mapBufferedImage.getWidth())
              ? mapBufferedImage.getHeight()
              : mapBufferedImage.getWidth();
      mapImageGeoHeight = BASE_MAX_IMAGE_SIZE * mapBufferedImage.getWidth() / max;
      mapImageGeoWidth = BASE_MAX_IMAGE_SIZE * mapBufferedImage.getHeight() / max;

      mapSurfaceImage =
          new SurfaceImage(
              mapBufferedImage, Sector.fromDegrees(0, mapImageGeoWidth, 0, mapImageGeoHeight));
      Polyline boundary = new Polyline(mapSurfaceImage.getCorners(), 0);
      boundary.setFollowTerrain(true);
      boundary.setClosed(true);
      boundary.setPathType(Polyline.RHUMB_LINE);
      boundary.setColor(new Color(0, 255, 0));

      mapRenderLayer.addRenderable(mapSurfaceImage);
      mapRenderLayer.addRenderable(boundary);
      mapMapPanel.wwd.redraw();
      return true;
    }
Пример #2
0
 /**
  * 构造方法
  *
  * @param frame DartEarthAppFrame
  */
 public PolygonLayer(DartEarthAppFrame frame) {
   this.polygon = new SurfacePolygon();
   ShapeAttributes attrs = new BasicShapeAttributes();
   attrs.setInteriorMaterial(new Material(new Color(255, 255, 255)));
   this.polygon.setAttributes(attrs);
   this.frame = frame;
   this.positions = new ArrayList<Position>();
   this.setName("多边形" + (++count));
   this.frame.getWwd().getModel().getLayers().add(0, this);
   this.frame.getLayerPanelDialog().getLayerPanel().update();
   line = new Polyline();
   line.setLineWidth(3);
   line.setColor(new Color(205, 85, 10));
 }
Пример #3
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();
    }