Пример #1
0
  /** Set all the DTED properties from a properties object. */
  public void setProperties(String prefix, java.util.Properties properties) {

    super.setProperties(prefix, properties);
    prefix = PropUtils.getScopedPropertyPrefix(this);

    paths = PropUtils.initPathsFromProperties(properties, prefix + DTEDPathsProperty, paths);
    setOpaqueness(
        PropUtils.intFromProperties(properties, prefix + OpaquenessProperty, getOpaqueness()));

    setNumColors(
        PropUtils.intFromProperties(properties, prefix + NumColorsProperty, getNumColors()));

    setDtedLevel(
        PropUtils.intFromProperties(properties, prefix + DTEDLevelProperty, getDtedLevel()));

    setViewType(
        PropUtils.intFromProperties(properties, prefix + DTEDViewTypeProperty, getViewType()));

    setSlopeAdjust(
        PropUtils.intFromProperties(
            properties, prefix + DTEDSlopeAdjustProperty, getSlopeAdjust()));

    setBandHeight(
        PropUtils.intFromProperties(properties, prefix + DTEDBandHeightProperty, getBandHeight()));

    // The Layer maxScale is talking the place of the DTEDLayer minScale
    // property.
    setMaxScale(
        PropUtils.floatFromProperties(properties, prefix + DTEDMinScaleProperty, getMaxScale()));

    setCacheSize(
        (int)
            PropUtils.intFromProperties(
                properties, prefix + DTEDFrameCacheSizeProperty, getCacheSize()));

    setKillCache(
        PropUtils.booleanFromProperties(
            properties, prefix + DTEDKillCacheProperty, getKillCache()));
  }
Пример #2
0
  /**
   * Go through the properties, loading the shapefile, information file and attributes files, and
   * resolve how everything should be drawn. Might take awhile if the files are large. Called from
   * getRectangle, which is called when the AreaShapeLayer is added to the map.
   *
   * @param prefix property file entry header name
   * @param props the properties to look through.
   */
  public void initialize(String prefix, Properties props) {

    if (props == null) {
      Debug.error(
          "AreaHandler: initialize received bad input:\n\tprefix: "
              + prefix
              + "\n\tproperties: "
              + (props == null ? "null" : "OK"));
      politicalAreas = null;
      return;
    }

    prefix = PropUtils.getScopedPropertyPrefix(prefix);

    politicalAreas = new Hashtable();

    // OK, Get the graphics. We are not expecting that all the
    // graphics in the file are not too much to handle. Also, we
    // test for the serialized graphics file first, and if it
    // isn't designated, then look for a shapefile and spatial
    // index file to create an OMGraphicsList.
    String cacheFile = props.getProperty(prefix + CacheFileProperty);

    // First find the resource, if not, then try as a file-URL...
    try {
      cacheURL = PropUtils.getResourceOrFileOrURL(this, cacheFile);

      if (cacheURL != null) {
        omgraphics = readCachedGraphics(cacheURL);
      } else {
        // We'll use the spatial index set from the
        // ShapeLayer.

        // Now, get the attribute file
        String dbfFile = props.getProperty(prefix + dbfFileProperty);
        URL dbfFileURL = null;
        if (dbfFile != null) {
          dbfFileURL = PropUtils.getResourceOrFileOrURL(this, dbfFile);
        }
        if (dbfFileURL != null) {
          InputStream is = dbfFileURL.openStream();
          dbfModel = new DbfTableModel(new DbfInputStream(is));
        }
        if (dbfModel == null) {
          String csvFile = props.getProperty(prefix + csvFileProperty);
          URL infofileURL = null;
          if (csvFile != null) {
            infofileURL = PropUtils.getResourceOrFileOrURL(this, csvFile);
          }

          // Read them in.
          if (infofileURL != null) {
            infoFile = new CSVShapeInfoFile(csvFile);
            infoFile.setHeadersExist(
                PropUtils.booleanFromProperties(props, prefix + csvHeaderProperty, true));
            infoFile.loadData(true);
          }
        }
      }
    } catch (java.net.MalformedURLException murle) {
      omgraphics = new OMGraphicList();
    } catch (java.io.IOException ioe) {
      omgraphics = new OMGraphicList();
    } catch (Exception exc) {
      omgraphics = new OMGraphicList();
    }

    // This is handled properly yet. The PoliticalArea should be
    // updated to handle URLs for area points, and have different
    // icons for different areas.
    // String defaultPointImageURLString =
    // props.getProperty(prefix + pointImageURLProperty);

    // Now, match the attributes to the graphics. Find the
    // indexes of the name and the search key. Also figure out
    // which areas have special coloring needs.
    keyIndex = PropUtils.intFromProperties(props, prefix + keyIndexProperty, keyIndex);
    nameIndex = PropUtils.intFromProperties(props, prefix + nameIndexProperty, nameIndex);
    String areas = props.getProperty(prefix + areasProperty);

    if (areas == null) areas = "";

    StringTokenizer tokenizer = new StringTokenizer(areas, " ");
    // All this uses the properties to set the individual colors
    // of any area
    String currentArea;

    while (tokenizer.hasMoreTokens()) {
      currentArea = tokenizer.nextToken();

      PoliticalArea newParams = new PoliticalArea(currentArea);

      if (Debug.debugging("areas")) {
        Debug.output("AreaHandler: setting SPECIALIZED attributes for \"" + newParams.id + "\"");
      }

      areasItems.addElement(currentArea);

      newParams.drawingAttributes =
          new DrawingAttributes(prefix + areasProperty + "." + currentArea, props);

      politicalAreas.put(newParams.id.toUpperCase().intern(), newParams);
    }

    if (Debug.debugging("areas")) {
      Debug.output("AreaHandler: finished initialization");
    }
  }