/**
   * Resolves a reference to a local element identified by address and identifier, where {@code
   * linkBase} identifies a document, including the current document, and {@code linkRef} is the id
   * of the desired element.
   *
   * <p>If {@code linkBase} refers to a local COLLADA file and {@code linkRef} is non-null, the
   * return value is the element identified by {@code linkRef}. If {@code linkRef} is null, the
   * return value is a parsed {@link ColladaRoot} for the COLLADA file identified by {@code
   * linkBase}. Otherwise, {@code linkBase} is returned.
   *
   * @param linkBase the address of the document containing the requested element.
   * @param linkRef the element's identifier.
   * @return the requested element, or null if the element is not found.
   * @throws IllegalArgumentException if the address is null.
   */
  protected Object resolveLocalReference(String linkBase, String linkRef) {
    if (linkBase == null) {
      String message = Logging.getMessage("nullValue.DocumentSourceIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    try {
      File file = new File(linkBase);

      if (!file.exists()) return null;

      // Determine whether the file is a COLLADA document. If not, just return the file path.
      if (!WWIO.isContentType(file, ColladaConstants.COLLADA_MIME_TYPE))
        return file.toURI().toString();

      // Attempt to open and parse the COLLADA file.
      ColladaRoot refRoot = ColladaRoot.createAndParse(file);
      // An exception is thrown if parsing fails, so no need to check for null.

      // Add the parsed file to the session cache so it doesn't have to be parsed again.
      WorldWind.getSessionCache().put(linkBase, refRoot);

      // Now check the newly opened COLLADA file for the referenced item, if a reference was
      // specified.
      if (linkRef != null) return refRoot.getItemByID(linkRef);
      else return refRoot;
    } catch (Exception e) {
      String message =
          Logging.getMessage("generic.UnableToResolveReference", linkBase + "/" + linkRef);
      Logging.logger().warning(message);
      return null;
    }
  }
  /** {@inheritDoc} */
  public void dispose() {
    if (this.disposed) // Do not dispose the WebView multiple times
    return;

    try {
      // Remove the notification adapter
      if (webViewWindowPtr != 0 && observerPtr != 0)
        WindowsWebViewJNI.removeWindowUpdateObserver(webViewWindowPtr, observerPtr);
      // Free the native WebView object associated with this Java WebView object.
      if (webViewWindowPtr != 0) {
        WindowsWebViewJNI.releaseWebView(webViewWindowPtr);
        // Decrement the instance counter. Only do this if the webViewWindow pointer was non-zero,
        // indicating
        // that native resources were actually allocated.
        instances.decrementAndGet();
      }
      if (observerPtr != 0) WindowsWebViewJNI.releaseComObject(observerPtr);

      this.webViewWindowPtr = 0;
      this.observerPtr = 0;

      // Terminate the message loop thread if this is the last active instance.
      this.stopMessageLoopIfNoInstances();

      this.disposed = true;
    } catch (Exception e) {
      Logging.logger()
          .log(
              Level.SEVERE,
              Logging.getMessage("generic.ExceptionAttemptingToDisposeRenderable"),
              e);
    }
  }
Ejemplo n.º 3
0
  protected void initializeTexture(DrawContext dc) {
    Texture iconTexture = dc.getTextureCache().getTexture(this.getIconFilePath());
    if (iconTexture != null) return;

    try {
      InputStream iconStream = this.getClass().getResourceAsStream("/" + this.getIconFilePath());
      if (iconStream == null) {
        File iconFile = new File(this.iconFilePath);
        if (iconFile.exists()) {
          iconStream = new FileInputStream(iconFile);
        }
      }

      iconTexture = TextureIO.newTexture(iconStream, false, null);
      iconTexture.bind();
      this.iconWidth = iconTexture.getWidth();
      this.iconHeight = iconTexture.getHeight();
      dc.getTextureCache().put(this.getIconFilePath(), iconTexture);
    } catch (IOException e) {
      String msg = Logging.getMessage("layers.IOExceptionDuringInitialization");
      Logging.logger().severe(msg);
      throw new WWRuntimeException(msg, e);
    }

    GL gl = dc.getGL();
    gl.glTexParameteri(
        GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); // _MIPMAP_LINEAR);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
    // Enable texture anisotropy, improves "tilted" world map quality.
    int[] maxAnisotropy = new int[1];
    gl.glGetIntegerv(GL.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy, 0);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy[0]);
  }
Ejemplo n.º 4
0
  /**
   * @param placeNameServiceSet the set of PlaceNameService objects that PlaceNameLayer will render.
   * @throws IllegalArgumentException if {@link
   *     gov.nasa.worldwind.layers.placename.PlaceNameServiceSet} is null
   */
  public PlaceNameLayer(PlaceNameServiceSet placeNameServiceSet) {
    if (placeNameServiceSet == null) {
      String message = Logging.getMessage("nullValue.PlaceNameServiceSetIsNull");
      Logging.logger().fine(message);
      throw new IllegalArgumentException(message);
    }

    //
    this.placeNameServiceSet = placeNameServiceSet.deepCopy();
    for (int i = 0; i < this.placeNameServiceSet.getServiceCount(); i++) {
      // todo do this for long as well and pick min
      int calc1 =
          (int)
              (PlaceNameService.TILING_SECTOR.getDeltaLatDegrees()
                  / this.placeNameServiceSet
                      .getService(i)
                      .getTileDelta()
                      .getLatitude()
                      .getDegrees());
      int numLevels = (int) Math.log(calc1);
      navTiles.add(
          new NavigationTile(
              this.placeNameServiceSet.getService(i),
              PlaceNameService.TILING_SECTOR,
              numLevels,
              "top"));
    }

    if (!WorldWind.getMemoryCacheSet().containsCache(Tile.class.getName())) {
      long size = Configuration.getLongValue(AVKey.PLACENAME_LAYER_CACHE_SIZE, 2000000L);
      MemoryCache cache = new BasicMemoryCache((long) (0.85 * size), size);
      cache.setName("Placename Tiles");
      WorldWind.getMemoryCacheSet().addCache(Tile.class.getName(), cache);
    }
  }
Ejemplo n.º 5
0
  public void makeOrderedRenderable(DrawContext dc, AirspaceRenderer renderer) {
    if (dc == null) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (renderer == null) {
      String message = Logging.getMessage("nullValue.RendererIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    for (Layer layer : this.layers) {
      if (!layer.isVisible()) continue;

      if (!layer.isAirspaceVisible(dc)) continue;

      // The layer is responsible for applying its own attributes, so we override its attributes
      // with our own just
      // before rendering.
      layer.setAttributes(this.getAttributes());

      // Create an ordered renderable that draws each layer, but specifies this Cake as the picked
      // object.
      OrderedRenderable or =
          renderer.createOrderedRenderable(dc, layer, layer.computeEyeDistance(dc), this);
      dc.addOrderedRenderable(or);
    }
  }
Ejemplo n.º 6
0
  public boolean isAirspaceVisible(DrawContext dc) {
    if (dc == null) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    // If the parent Cake is not visible, then return false immediately without testing the child
    // layers.
    if (!super.isAirspaceVisible(dc)) return false;

    boolean visible = false;

    // The parent Cake is visible. Since the parent Cake's extent potentially contains volumes where
    // no child
    // geometry exists, test that at least one of the child layers are visible.
    for (Layer l : this.layers) {
      if (l.isAirspaceVisible(dc)) {
        visible = true;
        break;
      }
    }

    return visible;
  }
Ejemplo n.º 7
0
  protected boolean loadTile(Tile tile, java.net.URL url) {
    if (WWIO.isFileOutOfDate(url, this.placeNameServiceSet.getExpiryTime())) {
      // The file has expired. Delete it then request download of newer.
      this.getDataFileStore().removeFile(url);
      String message = Logging.getMessage("generic.DataFileExpired", url);
      Logging.logger().fine(message);
      return false;
    }

    PlaceNameChunk tileData;
    synchronized (this.fileLock) {
      tileData = readTileData(tile, url);
    }

    if (tileData == null) {
      // Assume that something's wrong with the file and delete it.
      this.getDataFileStore().removeFile(url);
      tile.getPlaceNameService()
          .markResourceAbsent(tile.getPlaceNameService().getTileNumber(tile.row, tile.column));
      String message = Logging.getMessage("generic.DeletedCorruptDataFile", url);
      Logging.logger().fine(message);
      return false;
    }

    tile.setDataChunk(tileData);
    WorldWind.getMemoryCache(Tile.class.getName()).add(tile.getFileCachePath(), tile);
    return true;
  }
Ejemplo n.º 8
0
 public void setBackgroundColor(Color color) {
   if (color == null) {
     String msg = Logging.getMessage("nullValue.ColorIsNull");
     Logging.logger().severe(msg);
     throw new IllegalArgumentException(msg);
   }
   this.backColor = color;
 }
Ejemplo n.º 9
0
 /**
  * Sets the relative viewport location to display the world map icon. Can be one of
  * AVKey.NORTHEAST, AVKey.NORTHWEST (the default), AVKey.SOUTHEAST, or SOUTHWEST. These indicate
  * the corner of the viewport to place the icon.
  *
  * @param position the desired world map position
  */
 public void setPosition(String position) {
   if (position == null) {
     String message = Logging.getMessage("nullValue.PositionIsNull");
     Logging.logger().severe(message);
     throw new IllegalArgumentException(message);
   }
   this.position = position;
 }
Ejemplo n.º 10
0
 /**
  * Sets the world map icon's image location. The layer first searches for this location in the
  * current Java classpath. If not found then the specified path is assumed to refer to the local
  * file system. found there then the
  *
  * @param iconFilePath the path to the icon's image file
  */
 public void setIconFilePath(String iconFilePath) {
   if (iconFilePath == null || iconFilePath.length() == 0) {
     String message = Logging.getMessage("nullValue.FilePathIsNull");
     Logging.logger().severe(message);
     throw new IllegalArgumentException(message);
   }
   this.iconFilePath = iconFilePath;
 }
 /**
  * This method is called by the constructor if an exception is thrown creating the WebView. It
  * gives the WebView a change to cleanup static state that may have been set during the failed
  * WebView construction.
  */
 protected void handleWebViewCreationError() {
   try {
     this.stopMessageLoopIfNoInstances();
   } catch (Throwable t) {
     String message = Logging.getMessage("WebView.ExceptionStoppingWebViewThread", t);
     Logging.logger().severe(message);
   }
 }
Ejemplo n.º 12
0
 static Angle computeRowLatitude(int row, Angle delta) {
   if (delta == null) {
     String msg = Logging.getMessage("nullValue.AngleIsNull");
     Logging.logger().severe(msg);
     throw new IllegalArgumentException(msg);
   }
   return Angle.fromDegrees(-90d + delta.getDegrees() * row);
 }
Ejemplo n.º 13
0
 /**
  * Set the scalebar legend Fon
  *
  * @param font the scalebar legend Font
  */
 public void setFont(Font font) {
   if (font == null) {
     String msg = Logging.getMessage("nullValue.FontIsNull");
     Logging.logger().severe(msg);
     throw new IllegalArgumentException(msg);
   }
   this.defaultFont = font;
 }
Ejemplo n.º 14
0
 static Angle computeColumnLongitude(int column, Angle delta) {
   if (delta == null) {
     String msg = Logging.getMessage("nullValue.AngleIsNull");
     Logging.logger().severe(msg);
     throw new IllegalArgumentException(msg);
   }
   return Angle.fromDegrees(-180 + delta.getDegrees() * column);
 }
Ejemplo n.º 15
0
 static int computeColumn(Angle delta, Angle longitude) {
   if (delta == null || longitude == null) {
     String msg = Logging.getMessage("nullValue.AngleIsNull");
     Logging.logger().severe(msg);
     throw new IllegalArgumentException(msg);
   }
   return (int) ((longitude.getDegrees() + 180d) / delta.getDegrees());
 }
Ejemplo n.º 16
0
 /**
  * Set the scalebar graphic Dimenion (in pixels)
  *
  * @param size the scalebar graphic Dimension
  */
 public void setSize(Dimension size) {
   if (size == null) {
     String message = Logging.getMessage("nullValue.DimensionIsNull");
     Logging.logger().severe(message);
     throw new IllegalArgumentException(message);
   }
   this.size = size;
 }
Ejemplo n.º 17
0
  /**
   * Specifies the material used to draw the label.
   *
   * @param material New material.
   */
  public void setMaterial(Material material) {
    if (material == null) {
      String message = Logging.getMessage("nullValue.MaterialIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.material = material;
  }
Ejemplo n.º 18
0
  /**
   * Specifies the line spacing applied to multi-line labels.
   *
   * @param lineSpacing New line spacing.
   */
  public void setLineSpacing(int lineSpacing) {
    if (lineSpacing < 0) {
      String message = Logging.getMessage("generic.ArgumentOutOfRange");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.lineSpacing = lineSpacing;
  }
Ejemplo n.º 19
0
  /**
   * Specifies the amount of space (in pixels) between the label's content and the edges of the
   * label's frame.
   *
   * @param insets the desired padding between the label's content and its frame, in pixels.
   * @throws IllegalArgumentException if <code>insets</code> is <code>null</code>.
   * @see #getInsets()
   */
  public void setInsets(Insets insets) {
    if (insets == null) {
      String message = Logging.getMessage("nullValue.InsetsIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.insets = insets;
  }
Ejemplo n.º 20
0
  /**
   * Specifies the text alignment. Can be one of {@link AVKey#LEFT} (default), {@link AVKey#CENTER},
   * or {@link AVKey#RIGHT}.
   *
   * @param textAlign New text alignment.
   */
  public void setTextAlign(String textAlign) {
    if (textAlign == null) {
      String message = Logging.getMessage("nullValue.StringIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.textAlign = textAlign;
  }
Ejemplo n.º 21
0
  /**
   * Specifies an effect used to decorate the text. Can be one of {@link AVKey#TEXT_EFFECT_SHADOW}
   * (default), or {@link AVKey#TEXT_EFFECT_NONE}.
   *
   * @param effect the effect to use for text rendering
   */
  public void setEffect(String effect) {
    if (effect == null) {
      String message = Logging.getMessage("nullValue.StringIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.effect = effect;
  }
 /** Closes the event stream associated with this context's XML event reader. */
 protected void closeEventStream() {
   try {
     this.eventStream.close();
     this.eventStream = null;
   } catch (IOException e) {
     String message = Logging.getMessage("generic.ExceptionClosingXmlEventReader");
     Logging.logger().warning(message);
   }
 }
Ejemplo n.º 23
0
  /**
   * Specifies the opacity of the label's interior as a floating-point value in the range 0.0 to
   * 1.0. A value of 1.0 specifies a completely opaque interior, and 0.0 specifies a completely
   * transparent interior. Values in between specify a partially transparent interior.
   *
   * @param interiorOpacity the opacity of label's interior as a floating-point value from 0.0 to
   *     1.0.
   * @throws IllegalArgumentException if <code>opacity</code> is less than 0.0 or greater than 1.0.
   */
  public void setInteriorOpacity(double interiorOpacity) {
    if (opacity < 0 || opacity > 1) {
      String message = Logging.getMessage("generic.OpacityOutOfRange", opacity);
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.interiorOpacity = interiorOpacity;
  }
Ejemplo n.º 24
0
  /**
   * Specifies the offset from the geographic position at which to draw the label. The default
   * offset aligns the label horizontal with the text alignment position, and centers the label
   * vertically. For example, if the text alignment is <code>AVKey.LEFT</code>., then the left edge
   * of the text will be aligned with the geographic position, and the label will be centered
   * vertically.
   *
   * <p>When the text is rotated a horizontal offset moves the text along the orientation line, and
   * a vertical offset moves the text perpendicular to the orientation line.
   *
   * @param offset The offset at which to draw the label.
   */
  public void setOffset(Offset offset) {
    if (offset == null) {
      String message = Logging.getMessage("nullValue.OffsetIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.offset = offset;
  }
Ejemplo n.º 25
0
 /**
  * @param that the task to compare
  * @return -1 if <code>this</code> less than <code>that</code>, 1 if greater than, 0 if equal
  * @throws IllegalArgumentException if <code>that</code> is null
  */
 public int compareTo(RequestTask that) {
   if (that == null) {
     String msg = Logging.getMessage("nullValue.RequestTaskIsNull");
     Logging.logger().severe(msg);
     throw new IllegalArgumentException(msg);
   }
   return this.tile.getPriority() == that.tile.getPriority()
       ? 0
       : this.tile.getPriority() < that.tile.getPriority() ? -1 : 1;
 }
  /**
   * Adds a named Renderable to the layer. The Renderable can subsequently participate in a name
   * search of the layer.
   *
   * @param item the Renderable to add.
   * @param name a name for the Renderable. May be null, in which case the item has no name.
   * @throws IllegalArgumentException if the item is null or does not implement {@link
   *     gov.nasa.worldwind.render.GeographicExtent}.
   * @see #add(gov.nasa.worldwind.render.Renderable)
   */
  public void add(Renderable item, String name) {
    if (!(item instanceof GeographicExtent)) {
      String message = Logging.getMessage("GeographicTree.NotGeometricExtent");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    // extent tree checks args
    this.extentTree.add(item, ((GeographicExtent) item).getSector().asDegreesArray(), name);
  }
Ejemplo n.º 27
0
  /**
   * Get the label bounding {@link java.awt.Rectangle} using OGL coordinates - bottom-left corner x
   * and y relative to the {@link gov.nasa.worldwind.WorldWindow} bottom-left corner. If the label
   * is rotated then the returned rectangle is the bounding rectangle of the rotated label.
   *
   * @param dc the current DrawContext.
   * @return the label bounding {@link java.awt.Rectangle} using OGL viewport coordinates.
   * @throws IllegalArgumentException if <code>dc</code> is null.
   */
  public Rectangle getBounds(DrawContext dc) {
    if (dc == null) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.computeGeometryIfNeeded(dc);
    return this.screenExtent;
  }
  /**
   * Create a new <code>ColladaRoot</code> for a {@link ColladaDoc} instance. A ColladaDoc
   * represents COLLADA files from either files or input streams.
   *
   * @param docSource the ColladaDoc instance representing the COLLADA document.
   * @throws IllegalArgumentException if the document source is null.
   * @throws IOException if an error occurs while reading the COLLADA document.
   */
  public ColladaRoot(ColladaDoc docSource) throws IOException {
    super(ColladaConstants.COLLADA_NAMESPACE);

    if (docSource == null) {
      String message = Logging.getMessage("nullValue.DocumentSourceIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.colladaDoc = docSource;
    this.initialize();
  }
Ejemplo n.º 29
0
  /**
   * Create an instance.
   *
   * @param tc the current {@link KMLTraversalContext}.
   * @param placemark the <i>Placemark</i> element containing the <i>LineString</i>.
   * @param geom the {@link gov.nasa.worldwind.ogc.kml.KMLPolygon} geometry.
   * @throws NullPointerException if the geometry is null.
   * @throws IllegalArgumentException if the parent placemark or the traversal context is null.
   */
  public KMLSurfacePolygonImpl(
      KMLTraversalContext tc, KMLPlacemark placemark, KMLAbstractGeometry geom) {
    if (tc == null) {
      String msg = Logging.getMessage("nullValue.TraversalContextIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    if (placemark == null) {
      String msg = Logging.getMessage("nullValue.ParentIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    this.parent = placemark;

    KMLPolygon polygon = (KMLPolygon) geom;

    // KMLPolygon's use linear interpolation between corners by definition. Configure the World Wind
    // SurfacePolygon
    // to use the appropriate path type for linear interpolation in geographic coordinates.
    this.setPathType(AVKey.LINEAR);

    // Note: SurfacePolygon implies altitude mode "clampToGround", therefore KMLSurfacePolygonImpl
    // ignores the
    // KMLPolygon's altitude mode property.

    KMLLinearRing outerBoundary = polygon.getOuterBoundary();
    if (outerBoundary != null) {
      Position.PositionList coords = outerBoundary.getCoordinates();
      if (coords != null && coords.list != null)
        this.setOuterBoundary(outerBoundary.getCoordinates().list);
    }

    Iterable<? extends KMLLinearRing> innerBoundaries = polygon.getInnerBoundaries();
    if (innerBoundaries != null) {
      for (KMLLinearRing ring : innerBoundaries) {
        Position.PositionList coords = ring.getCoordinates();
        if (coords != null && coords.list != null)
          this.addInnerBoundary(ring.getCoordinates().list);
      }
    }

    if (placemark.getName() != null) this.setValue(AVKey.DISPLAY_NAME, placemark.getName());

    if (placemark.getDescription() != null)
      this.setValue(AVKey.DESCRIPTION, placemark.getDescription());

    if (placemark.getSnippetText() != null)
      this.setValue(AVKey.SHORT_DESCRIPTION, placemark.getSnippetText());

    this.setValue(AVKey.CONTEXT, this.parent);
  }
Ejemplo n.º 30
0
  /**
   * Specifies the font used to draw the label.
   *
   * @param font New font.
   */
  public void setFont(Font font) {
    if (font == null) {
      String message = Logging.getMessage("nullValue.FontIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (font != this.font) {
      this.font = font;
      this.bounds = null; // Need to recompute
    }
  }