示例#1
0
    public AppFrame() {
      super(true, true, true);

      RenderableLayer layer = new RenderableLayer();
      layer.setName("Video on terrain");
      insertBeforePlacenames(this.getWwd(), layer);
      this.layerPanel.update(
          this.getWwd()); // makes the ApplicationTemplate layer list show the new layer

      // Set up a SelectListener to drag the SurfaceImage.
      this.getWwd().addSelectListener(new SurfaceImageDragger(this.getWwd()));

      final SurfaceImage surfaceImage = new SurfaceImage(makeImage(), CORNERS);
      surfaceImage.setOpacity(IMAGE_OPACITY);
      layer.addRenderable(surfaceImage);

      javax.swing.Timer timer =
          new javax.swing.Timer(
              50,
              new ActionListener() {
                public void actionPerformed(ActionEvent actionEvent) {
                  Iterable<LatLon> corners = surfaceImage.getCorners();
                  surfaceImage.setImageSource(makeImage(), corners);
                  getWwd().redraw();
                }
              });
      timer.start();
    }
    /**
     * 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;
    }
  public void preRender(KMLTraversalContext tc, DrawContext dc) {
    if (this.mustResolveHref()) // resolve the href to either a local file or a remote URL
    {
      // The icon reference may be to a support file within a KMZ file, so check for that. If it's
      // not, then just
      // let the normal SurfaceImage code resolve the reference.
      String href = this.parent.getIcon().getHref();
      String localAddress = (String) this.parent.getRoot().resolveLocalReference(href, null);

      this.setImageSource((localAddress != null ? localAddress : href), this.getCorners());
    }

    super.preRender(dc);
  }
 /** {@inheritDoc} */
 public void render(KMLTraversalContext tc, DrawContext dc) {
   super.render(dc);
 }