public int countImagesInSector(Sector sector, int levelNumber) {
    if (sector == null) {
      String msg = Logging.getMessage("nullValue.SectorIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    Level targetLevel = this.levels.getLastLevel();
    if (levelNumber >= 0) {
      for (int i = levelNumber; i < this.getLevels().getLastLevel().getLevelNumber(); i++) {
        if (this.levels.isLevelEmpty(i)) continue;

        targetLevel = this.levels.getLevel(i);
        break;
      }
    }

    // Collect all the tiles intersecting the input sector.
    LatLon delta = targetLevel.getTileDelta();
    Angle latOrigin = this.levels.getTileOrigin().getLatitude();
    Angle lonOrigin = this.levels.getTileOrigin().getLongitude();
    final int nwRow = Tile.computeRow(delta.getLatitude(), sector.getMaxLatitude(), latOrigin);
    final int nwCol = Tile.computeColumn(delta.getLongitude(), sector.getMinLongitude(), lonOrigin);
    final int seRow = Tile.computeRow(delta.getLatitude(), sector.getMinLatitude(), latOrigin);
    final int seCol = Tile.computeColumn(delta.getLongitude(), sector.getMaxLongitude(), lonOrigin);

    int numRows = nwRow - seRow + 1;
    int numCols = seCol - nwCol + 1;

    return numRows * numCols;
  }
  /**
   * @param fileName the name to give the newly created file
   * @return a handle to the newly created file if it could be created and added to the file store,
   *     otherwise null
   * @throws IllegalArgumentException if <code>fileName</code> is null
   */
  public java.io.File newFile(String fileName) {
    if (fileName == null) {
      String message = Logging.getMessage("nullValue.FilePathIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (this.writeLocation != null) {
      String fullPath = makeAbsolutePath(this.writeLocation.getFile(), fileName);
      java.io.File file = new java.io.File(fullPath);
      boolean canCreateFile = false;

      // This block of code must be synchronized for proper operation. A thread may check that
      // file.getParentFile() does not exist, and become immediately suspended. A second thread may
      // then create
      // the parent and ancestor directories. When the first thread wakes up,
      // file.getParentFile().mkdirs()
      // fails, resulting in an erroneous log message: The log reports that the file cannot be
      // created.
      synchronized (this.fileLock) {
        if (file.getParentFile().exists()) canCreateFile = true;
        else if (file.getParentFile().mkdirs()) canCreateFile = true;
      }

      if (canCreateFile) return file;
      else {
        String msg = Logging.getMessage("generic.CannotCreateFile", fullPath);
        Logging.logger().severe(msg);
      }
    }

    return null;
  }
  /**
   * @param url the "file:" URL of the file to remove from the file store. Only files in the
   *     writable World Wind disk cache or temp file directory are removed by this method.
   * @throws IllegalArgumentException if <code>url</code> is null
   */
  @SuppressWarnings({"ResultOfMethodCallIgnored"})
  public void removeFile(java.net.URL url) {
    if (url == null) {
      String msg = Logging.getMessage("nullValue.URLIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    try {
      java.io.File file = new java.io.File(url.toURI());

      // This block of code must be synchronized for proper operation. A thread may check that the
      // file exists,
      // and become immediately suspended. A second thread may then delete that file. When the first
      // thread
      // wakes up, file.delete() fails.
      synchronized (this.fileLock) {
        if (file.exists()) {
          // Don't remove files outside the cache or temp directory.
          String parent = file.getParent();
          if (!(parent.startsWith(this.getWriteLocation().getPath())
              || parent.startsWith(Configuration.getSystemTempDirectory()))) return;

          file.delete();
        }
      }
    } catch (java.net.URISyntaxException e) {
      Logging.logger()
          .log(
              Level.SEVERE,
              Logging.getMessage("FileStore.ExceptionRemovingFile", url.toString()),
              e);
    }
  }
Exemplo n.º 4
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]);
  }
  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;
  }
Exemplo n.º 6
0
  @Override
  protected Layer doCreateFromCapabilities(OGCCapabilities caps, AVList params) {
    String serviceName = caps.getServiceInformation().getServiceName();
    if (serviceName == null
        || !(serviceName.equalsIgnoreCase(OGCConstants.WMS_SERVICE_NAME)
            || serviceName.equalsIgnoreCase("WMS"))) {
      String message =
          Logging.getMessage("WMS.NotWMSService", serviceName != null ? serviceName : "null");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (params == null) params = new AVListImpl();

    if (params.getStringValue(AVKey.LAYER_NAMES) == null) {
      // Use the first named layer since no other guidance given
      List<WMSLayerCapabilities> namedLayers = ((WMSCapabilities) caps).getNamedLayers();

      if (namedLayers == null || namedLayers.size() == 0 || namedLayers.get(0) == null) {
        String message = Logging.getMessage("WMS.NoLayersFound");
        Logging.logger().severe(message);
        throw new IllegalStateException(message);
      }

      params.setValue(AVKey.LAYER_NAMES, namedLayers.get(0).getName());
    }

    return new WMSTiledImageLayer((WMSCapabilities) caps, params);
  }
  /**
   * Appends elevation model parameters as elements to a specified context. If a parameter key
   * exists, that parameter is appended to the context. Supported key and element paths are:
   *
   * <table> <th><td>Key</td><td>Name</td><td>Type</td></th>
   * <tr><td>{@link AVKey#DISPLAY_NAME}</td><td>DisplayName</td><td>String</td></tr> <tr><td>{@link
   * AVKey#NETWORK_RETRIEVAL_ENABLED}</td><td>NetworkRetrievalEnabled</td><td>Boolean</td></tr> <tr><td>{@link
   * AVKey#MISSING_DATA_SIGNAL}</td><td>MissingData/@signal</td><td>Double</td></tr> <tr><td>{@link
   * AVKey#MISSING_DATA_REPLACEMENT}</td><td>MissingData/@replacement</td><td>Double</td></tr> <tr><td>{@link
   * AVKey#DETAIL_HINT}</td><td>DataDetailHint</td><td>Double</td></tr> </table>
   *
   * @param params the key-value pairs which define the elevation model parameters.
   * @param context the XML document root on which to append parameter elements.
   * @return a reference to context.
   * @throws IllegalArgumentException if either the parameters or the context are null.
   */
  public static Element createElevationModelElements(AVList params, Element context) {
    if (params == null) {
      String message = Logging.getMessage("nullValue.ParametersIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

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

    WWXML.checkAndAppendTextElement(params, AVKey.DISPLAY_NAME, context, "DisplayName");
    WWXML.checkAndAppendBooleanElement(
        params, AVKey.NETWORK_RETRIEVAL_ENABLED, context, "NetworkRetrievalEnabled");

    if (params.getValue(AVKey.MISSING_DATA_SIGNAL) != null
        || params.getValue(AVKey.MISSING_DATA_REPLACEMENT) != null) {
      Element el = WWXML.getElement(context, "MissingData", null);
      if (el == null) el = WWXML.appendElementPath(context, "MissingData");

      Double d = AVListImpl.getDoubleValue(params, AVKey.MISSING_DATA_SIGNAL);
      if (d != null) el.setAttribute("signal", Double.toString(d));

      d = AVListImpl.getDoubleValue(params, AVKey.MISSING_DATA_REPLACEMENT);
      if (d != null) el.setAttribute("replacement", Double.toString(d));
    }

    WWXML.checkAndAppendDoubleElement(params, AVKey.DETAIL_HINT, context, "DataDetailHint");

    return context;
  }
  /**
   * @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);
    }
  }
  protected static String determineSingleUserLocation() {
    String home = getUserHomeDir();
    if (home == null) {
      Logging.logger().warning("generic.UsersHomeDirectoryNotKnown");
      return null;
    }

    String path = null;

    if (gov.nasa.worldwind.Configuration.isMacOS()) {
      path = "/Library/Caches";
    } else if (gov.nasa.worldwind.Configuration.isWindowsOS()) {
      // This produces an incorrect path with duplicate parts,
      // like "C:\Users\PatC:\Users\Pat\Application Data".
      // path = System.getenv("USERPROFILE");
      // if (path == null)
      // {
      //    Logging.logger().fine("generic.UsersWindowsProfileNotKnown");
      //    return null;
      // }
      // path += "\\Application Data";

      path = "\\Application Data";
    } else if (gov.nasa.worldwind.Configuration.isLinuxOS()
        || gov.nasa.worldwind.Configuration.isUnixOS()
        || gov.nasa.worldwind.Configuration.isSolarisOS()) {
      path = "/var/cache/";
    } else {
      Logging.logger().fine("generic.UnknownOperatingSystem");
    }

    if (path == null) return null;

    return home + path;
  }
Exemplo n.º 10
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());
 }
Exemplo 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;
 }
Exemplo n.º 12
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);
 }
Exemplo n.º 13
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;
 }
Exemplo n.º 14
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;
 }
Exemplo n.º 15
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);
 }
  public String[] listTopFileNames(String pathName, FileStoreFilter filter) {
    if (filter == null) {
      String msg = Logging.getMessage("nullValue.FilterIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    // Recurse, but stop searching a branch after a match is found.
    return this.doListFileNames(pathName, filter, true, true);
  }
  public boolean isInstallLocation(String path) {
    if (path == null || path.length() == 0) {
      String message = Logging.getMessage("nullValue.FileStorePathIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    StoreLocation location = this.storeLocationFor(path);
    return location != null && location.isInstall();
  }
Exemplo n.º 18
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;
 }
  public String[] listFileNames(String pathName, FileStoreFilter filter) {
    if (filter == null) {
      String msg = Logging.getMessage("nullValue.FilterIsNull");
      Logging.logger().severe(msg);
      throw new IllegalArgumentException(msg);
    }

    // Do not recurse.
    return this.doListFileNames(pathName, filter, false, false);
  }
  /**
   * 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);
  }
  /**
   * Returns true if a specified DOM document should be accepted as an ElevationModel configuration
   * document, and false otherwise.
   *
   * @param domElement the DOM document in question.
   * @return true if the document is an ElevationModel configuration document; false otherwise.
   * @throws IllegalArgumentException if document is null.
   */
  public static boolean isElevationModelDocument(Element domElement) {
    if (domElement == null) {
      String message = Logging.getMessage("nullValue.DocumentIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    XPath xpath = WWXML.makeXPath();
    Element[] elements = WWXML.getElements(domElement, "//ElevationModel", xpath);

    return elements != null && elements.length > 0;
  }
 protected void doRender(DrawContext dc, Iterable<? extends Renderable> renderables) {
   for (Renderable renderable : renderables) {
     try {
       // If the caller has specified their own Iterable,
       // then we cannot make any guarantees about its contents.
       if (renderable != null) renderable.render(dc);
     } catch (Exception e) {
       String msg = Logging.getMessage("generic.ExceptionWhileRenderingRenderable");
       Logging.logger().log(java.util.logging.Level.SEVERE, msg, e);
       // continue to next renderable
     }
   }
 }
  protected void disposeRenderables() {
    for (Renderable renderable : this.getAllRenderables()) {
      try {
        if (renderable instanceof Disposable) ((Disposable) renderable).dispose();
      } catch (Exception e) {
        String msg = Logging.getMessage("generic.ExceptionAttemptingToDisposeRenderable");
        Logging.logger().severe(msg);
        // continue to next renderable
      }
    }

    this.extentTree.clear();
  }
Exemplo n.º 24
0
 protected double parseDouble(StringBuilder sb) {
   double value = 0;
   try {
     value = Double.parseDouble(sb.toString());
   } catch (NumberFormatException e) {
     Logging.logger()
         .log(
             Level.FINE,
             Logging.getMessage("layers.PlaceNameLayer.ExceptionAttemptingToReadFile", ""),
             e);
   }
   return value;
 }
  /**
   * Parses basic elevation model parameters from a specified DOM document. This also parses
   * LevelSet parameters by invoking {@link
   * gov.nasa.worldwind.util.DataConfigurationUtils#getLevelSetParams(org.w3c.dom.Element,
   * gov.nasa.worldwind.avlist.AVList)}. This writes output as key-value pairs to params. If a
   * parameter from the XML document already exists in params, that parameter is ignored. Supported
   * key and parameter names are:
   *
   * <table>
   * <th><td>Key</td><td>Name</td><td>Type</td></th> <tr><td>{@link AVKey#SERVICE_NAME}</td><td>Service/@serviceName</td><td>String</td></tr>
   * <tr><td>{@link AVKey#PIXEL_TYPE}</td><td>DataType</td><td>String</td></tr> <tr><td>{@link
   * AVKey#BYTE_ORDER}</td><td>DataType/@byteOrder</td><td>String</td></tr> <tr><td>{@link
   * AVKey#ELEVATION_EXTREMES_FILE}</td><td>ExtremeElevations/FileName</td><td>String</td></tr> <tr><td>{@link
   * AVKey#ELEVATION_MAX}</td><td>ExtremeElevations/@max</td><td>Double</td></tr> <tr><td>{@link
   * AVKey#ELEVATION_MIN}</td><td>ExtremeElevations/@min</td><td>Double</td></tr> </table>
   *
   * @param domElement the XML document root to parse for basic elevation model parameters.
   * @param params the output key-value pairs which recieve the basic elevation model parameters. A
   *     null reference is permitted.
   * @return a reference to params, or a new AVList if params is null.
   * @throws IllegalArgumentException if the document is null.
   */
  public static AVList getBasicElevationModelParams(Element domElement, AVList params) {
    if (domElement == null) {
      String message = Logging.getMessage("nullValue.DocumentIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (params == null) params = new AVListImpl();

    XPath xpath = WWXML.makeXPath();

    // LevelSet properties.
    DataConfigurationUtils.getLevelSetParams(domElement, params);

    // Service properties.
    WWXML.checkAndSetStringParam(
        domElement, params, AVKey.SERVICE_NAME, "Service/@serviceName", xpath);
    WWXML.checkAndSetBooleanParam(
        domElement,
        params,
        AVKey.RETRIEVE_PROPERTIES_FROM_SERVICE,
        "RetrievePropertiesFromService",
        xpath);

    // Image format properties.
    if (params.getValue(AVKey.PIXEL_TYPE) == null) {
      String s = WWXML.getText(domElement, "DataType/@type", xpath);
      if (s != null && s.length() > 0) {
        s = WWXML.parseDataType(s);
        if (s != null && s.length() > 0) params.setValue(AVKey.PIXEL_TYPE, s);
      }
    }

    if (params.getValue(AVKey.BYTE_ORDER) == null) {
      String s = WWXML.getText(domElement, "DataType/@byteOrder", xpath);
      if (s != null && s.length() > 0) {
        s = WWXML.parseByteOrder(s);
        if (s != null && s.length() > 0) params.setValue(AVKey.BYTE_ORDER, s);
      }
    }

    // Elevation data properties.
    WWXML.checkAndSetStringParam(
        domElement, params, AVKey.ELEVATION_EXTREMES_FILE, "ExtremeElevations/FileName", xpath);
    WWXML.checkAndSetDoubleParam(
        domElement, params, AVKey.ELEVATION_MAX, "ExtremeElevations/@max", xpath);
    WWXML.checkAndSetDoubleParam(
        domElement, params, AVKey.ELEVATION_MIN, "ExtremeElevations/@min", xpath);

    return params;
  }
  /**
   * Parses WMS elevation model parameters from a specified DOM document. This also parses common
   * WMS layer parameters by invoking {@link
   * DataConfigurationUtils#getWMSLayerParams(org.w3c.dom.Element,
   * gov.nasa.worldwind.avlist.AVList)}. This writes output as key-value pairs to params. If a
   * parameter from the XML document already exists in params, that parameter is ignored. Supported
   * key and parameter names are:
   *
   * <table>
   * <th><td>Key</td><td>Name</td><td>Type</td></th> <tr><td>{@link AVKey#PIXEL_TYPE}</td><td>PixelType</td><td>String</td></tr>
   * </table>
   *
   * @param domElement the XML document root to parse for tiled image layer parameters.
   * @param params the output key-value pairs which recieve the tiled image layer parameters. A null
   *     reference is permitted.
   * @return a reference to params, or a new AVList if params is null.
   * @throws IllegalArgumentException if the document is null.
   */
  public static AVList getWMSElevationModelParams(Element domElement, AVList params) {
    if (domElement == null) {
      String message = Logging.getMessage("nullValue.DocumentIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (params == null) params = new AVListImpl();

    // Common WMS layer properties.
    DataConfigurationUtils.getWMSLayerParams(domElement, params);

    return params;
  }
 protected void doPreRender(DrawContext dc, Iterable<? extends Renderable> renderables) {
   for (Renderable renderable : renderables) {
     try {
       // If the caller has specified their own Iterable,
       // then we cannot make any guarantees about its contents.
       if (renderable != null && renderable instanceof PreRenderable)
         ((PreRenderable) renderable).preRender(dc);
     } catch (Exception e) {
       String msg = Logging.getMessage("generic.ExceptionWhilePrerenderingRenderable");
       Logging.logger().severe(msg);
       // continue to next renderable
     }
   }
 }
Exemplo n.º 28
0
  public void drawOnTo(DataRaster canvas) {
    if (canvas == null) {
      String message = Logging.getMessage("nullValue.DestinationIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }
    if (!(canvas instanceof BufferedImageRaster)) {
      String message = Logging.getMessage("DataRaster.IncompatibleRaster", canvas);
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.doDrawOnTo((BufferedImageRaster) canvas);
  }
    public void run() {
      if (Thread.currentThread().isInterrupted())
        return; // the task was cancelled because it's a duplicate or for some other reason

      try {
        this.placemark.retrieveModel(this.address);
      } catch (IOException e) {
        String message = Logging.getMessage("generic.ExceptionWhileReading", e.getMessage());
        Logging.logger().warning(message);
      } catch (XMLStreamException e) {
        String message =
            Logging.getMessage("generic.ExceptionAttemptingToParseXml", e.getMessage());
        Logging.logger().warning(message);
      }
    }
Exemplo n.º 30
0
  /**
   * Create a collection of layer lists and their included layers described by an array of XML
   * layer-list description elements.
   *
   * <p>Any exceptions occurring during creation of the layer lists or their included layers are
   * logged and not re-thrown. The layers associated with the exceptions are not included in the
   * returned layer list.
   *
   * @param elements the XML elements describing the layer lists to create.
   * @param params any parameters to apply when creating the included layers.
   * @return an array containing the specified layer lists.
   */
  protected LayerList[] createLayerLists(Element[] elements, AVList params) {
    ArrayList<LayerList> layerLists = new ArrayList<LayerList>();

    for (Element element : elements) {
      try {
        String href = WWXML.getText(element, "@href");
        if (href != null && href.length() > 0) {
          Object o = this.createFromConfigSource(href, params);
          if (o == null) continue;

          if (o instanceof Layer) {
            LayerList ll = new LayerList();
            ll.add((Layer) o);
            o = ll;
          }

          if (o instanceof LayerList) {
            LayerList list = (LayerList) o;
            if (list != null && list.size() > 0) layerLists.add(list);
          } else if (o instanceof LayerList[]) {
            LayerList[] lists = (LayerList[]) o;
            if (lists != null && lists.length > 0) layerLists.addAll(Arrays.asList(lists));
          } else {
            String msg =
                Logging.getMessage("LayerFactory.UnexpectedTypeForLayer", o.getClass().getName());
            Logging.logger().log(java.util.logging.Level.WARNING, msg);
          }

          continue;
        }

        String title = WWXML.getText(element, "@title");
        Element[] children = WWXML.getElements(element, "./Layer", null);
        if (children != null && children.length > 0) {
          LayerList list = this.createLayerList(children, params);
          if (list != null && list.size() > 0) {
            layerLists.add(list);
            if (title != null && title.length() > 0) list.setValue(AVKey.DISPLAY_NAME, title);
          }
        }
      } catch (Exception e) {
        Logging.logger().log(java.util.logging.Level.WARNING, e.getMessage(), e);
        // keep going to create other layers
      }
    }

    return layerLists.toArray(new LayerList[layerLists.size()]);
  }