Esempio n. 1
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);
    }
  }
  /**
   * 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;
    }
  }
  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;
  }
  /**
   * 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);
  }
  /**
   * Create a new WebView.
   *
   * @param frameSize The size of the WebView rectangle.
   * @throws UnsupportedOperationException if this class is instantiated on a non-Windows operating
   *     system.
   * @throws WWRuntimeException if creating the native web browser window fails for any reason. For
   *     example, because the process has run out of User Object handles (see documentation <a
   *     href="#limits">above</a>).
   */
  public WindowsWebView(Dimension frameSize) {
    if (frameSize == null) {
      String message = Logging.getMessage("nullValue.SizeIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (!Configuration.isWindowsOS()) {
      String message =
          Logging.getMessage(
              "NativeLib.UnsupportedOperatingSystem",
              "Windows WebView",
              System.getProperty("os.name"));
      Logging.logger().severe(message);
      throw new UnsupportedOperationException(message);
    }

    this.frameSize = frameSize;

    try {
      // Increment the instance counter
      instances.incrementAndGet();

      // Make sure that the message loop thread is running
      this.ensureMessageLoopRunning();

      // Create the web view
      this.webViewWindowPtr = WindowsWebViewJNI.newWebViewWindow(webViewMessageLoop);
      if (this.webViewWindowPtr == 0) {
        String message = Logging.getMessage("WebView.NativeExceptionInitializingWebView");
        Logging.logger().severe(message);
        throw new WWRuntimeException(message);
      }

      WindowsWebViewJNI.setFrameSize(
          this.webViewWindowPtr, this.frameSize.width, this.frameSize.height);

      this.observerPtr = WindowsWebViewJNI.newNotificationAdapter(this);

      WindowsWebViewJNI.addWindowUpdateObserver(this.webViewWindowPtr, observerPtr);
    } catch (RuntimeException e) {
      // If the WebView was not created successfully do not increment the instance counter.
      instances.decrementAndGet();
      this.handleWebViewCreationError();
      throw e;
    } catch (Error e) {
      // If the WebView was not created successfully do not increment the instance counter.
      instances.decrementAndGet();
      this.handleWebViewCreationError();
      throw e;
    }
  }
  /**
   * Resolves a reference to a local or remote file or element. If the link refers to an element in
   * the current document, this method returns that element. If the link refers to a remote
   * document, this method will initiate asynchronous retrieval of the document, and return a URL of
   * the downloaded document in the file cache, if it is available locally. If the link identifies a
   * COLLADA document, the document will be returned as a parsed ColladaRoot.
   *
   * @param link the address of the document or element to resolve. This may be a full URL, a URL
   *     fragment that identifies an element in the current document ("#myElement"), or a URL and a
   *     fragment identifier ("http://server.com/model.dae#myElement").
   * @return the requested element, or null if the element is not found.
   * @throws IllegalArgumentException if the address is null.
   */
  public Object resolveReference(String link) {
    if (link == null) {
      String message = Logging.getMessage("nullValue.DocumentSourceIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    try {
      String[] linkParts = link.split("#");
      String linkBase = linkParts[0];
      String linkRef = linkParts.length > 1 ? linkParts[1] : null;

      // See if it's a reference to an internal element.
      if (WWUtil.isEmpty(linkBase) && !WWUtil.isEmpty(linkRef)) return this.getItemByID(linkRef);

      // Interpret the path relative to the current document.
      String path = this.getSupportFilePath(linkBase);
      if (path == null) path = linkBase;

      // See if it's an already found and parsed COLLADA file.
      Object o = WorldWind.getSessionCache().get(path);
      if (o != null && o instanceof ColladaRoot)
        return linkRef != null ? ((ColladaRoot) o).getItemByID(linkRef) : o;

      URL url = WWIO.makeURL(path);
      if (url == null) {
        // See if the reference can be resolved to a local file.
        o = this.resolveLocalReference(path, linkRef);
      }

      // If we didn't find a local file, treat it as a remote reference.
      if (o == null) o = this.resolveRemoteReference(path, linkRef);

      if (o != null) return o;

      // If the reference was not resolved as a remote reference, look for a local element
      // identified by the
      // reference string. This handles the case of malformed internal references that omit the #
      // sign at the
      // beginning of the reference.
      return this.getItemByID(link);
    } catch (Exception e) {
      String message = Logging.getMessage("generic.UnableToResolveReference", link);
      Logging.logger().warning(message);
    }

    return null;
  }
  /**
   * @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);
    }
  }
Esempio n. 8
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]);
  }
  /** {@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);
    }
  }
Esempio n. 10
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;
  }
Esempio n. 11
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;
 }
 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);
 }
 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());
 }
 /**
  * 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);
   }
 }
Esempio n. 15
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;
 }
Esempio n. 16
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;
 }
Esempio n. 17
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;
 }
 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);
 }
Esempio n. 19
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;
 }
  /**
   * Resolves a reference to a remote element identified by address and identifier, where {@code
   * linkBase} identifies a remote document, and {@code linkRef} is the id of the desired element.
   * This method retrieves resources asynchronously using the {@link
   * gov.nasa.worldwind.cache.FileStore}.
   *
   * <p>The return value is null if the file is not yet available in the FileStore. If {@code
   * linkBase} refers to a COLLADA file and {@code linkRef} is non-null, the return value is the
   * element identified by {@code linkRef}. If {@code linkBase} refers to a COLLADA file and {@code
   * linkRef} is null, the return value is a parsed {@link ColladaRoot} for the COLLADA file
   * identified by {@code linkBase}. Otherwise the return value is a {@link URL} to the file in the
   * file cache.
   *
   * @param linkBase the address of the document containing the requested element.
   * @param linkRef the element's identifier.
   * @return URL to the requested file, parsed ColladaRoot, or COLLADA element. Returns null if the
   *     document is not yet available in the FileStore.
   * @throws IllegalArgumentException if the {@code linkBase} is null.
   */
  public Object resolveRemoteReference(String linkBase, String linkRef) {
    if (linkBase == null) {
      String message = Logging.getMessage("nullValue.DocumentSourceIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    try {
      // See if it's in the cache. If not, requestFile will start another thread to retrieve it and
      // return null.
      URL url = WorldWind.getDataFileStore().requestFile(linkBase);
      if (url == null) return null;

      // It's in the cache. If it's a COLLADA file try to parse it so we can search for the
      // specified reference.
      // If it's not COLLADA, just return the url for the cached file.
      String contentType = WorldWind.getDataFileStore().getContentType(linkBase);
      if (contentType == null) {
        String suffix = WWIO.getSuffix(linkBase.split(";")[0]); // strip of trailing garbage
        if (!WWUtil.isEmpty(suffix)) contentType = WWIO.makeMimeTypeForSuffix(suffix);
      }

      if (!this.canParseContentType(contentType)) return url;

      // If the file is a COLLADA document, attempt to open it. We can't open it as a File with
      // createAndParse
      // because the ColladaRoot that will be created needs to have the remote address in order to
      // resolve any
      // relative references within it.
      ColladaRoot refRoot = this.parseCachedColladaFile(url, linkBase);

      // 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;
    }
  }
Esempio n. 21
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;
  }
Esempio n. 22
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;
  }
Esempio n. 23
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;
  }
Esempio n. 24
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;
  }
Esempio n. 25
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;
  }
Esempio n. 26
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;
  }
Esempio n. 27
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;
  }
  /**
   * Called just before the constructor returns. If overriding this method be sure to invoke <code>
   * super.initialize()</code>.
   *
   * @throws java.io.IOException if an I/O error occurs attempting to open the document source.
   */
  protected void initialize() throws IOException {
    this.eventStream = new BufferedInputStream(this.getColladaDoc().getInputStream());
    this.eventReader = this.createReader(this.eventStream);
    if (this.eventReader == null)
      throw new WWRuntimeException(
          Logging.getMessage("XML.UnableToOpenDocument", this.getColladaDoc()));

    this.parserContext = this.createParserContext(this.eventReader);
  }
 /** 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);
   }
 }
  /**
   * 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);
  }