Esempio n. 1
0
  public void setProperties(String prefix, Properties props) {
    super.setProperties(prefix, props);

    // Important for ToolPanel that controls what it is listening
    // for, instead of grabbing any Tool. The prefix will be used
    // as a discriminator.
    if (prefix != null) {
      setKey(prefix);
    }

    prefix = PropUtils.getScopedPropertyPrefix(prefix);
    setUseAsTool(
        PropUtils.booleanFromProperties(props, prefix + UseAsToolProperty, getUseAsTool()));
  }
Esempio n. 2
0
  /**
   * Read the DataInputStream, and create an OMPoint. Assumes that the LinkPoint header has been
   * read from the link.
   *
   * @param dis DataInputStream
   * @param propertiesBuffer a LinkProperties object used to cache previous settings that can be set
   *     on the OMPoint being read.
   * @return OMPoint
   * @throws IOException
   * @see com.bbn.openmap.omGraphics.OMPoint
   */
  public static OMPoint read(DataInputStream dis, LinkProperties propertiesBuffer)
      throws IOException {
    OMPoint point = null;
    int x1, y1, radius;
    float lt, ln;

    int renderType = dis.readByte();

    switch (renderType) {
      case RENDERTYPE_LATLON:
        lt = dis.readFloat();
        ln = dis.readFloat();
        radius = dis.readInt();

        point = new OMPoint(lt, ln, radius);
        break;
      case RENDERTYPE_XY:
        x1 = dis.readInt();
        y1 = dis.readInt();
        radius = dis.readInt();

        point = new OMPoint(x1, y1, radius);
        break;
      case RENDERTYPE_OFFSET:
        lt = dis.readFloat();
        ln = dis.readFloat();

        x1 = dis.readInt();
        y1 = dis.readInt();
        radius = dis.readInt();

        point = new OMPoint(lt, ln, x1, y1, radius);
        break;
      default:
    }

    if (point != null) {
      propertiesBuffer = LinkProperties.loadPropertiesIntoOMGraphic(dis, point, propertiesBuffer);

      if (propertiesBuffer != null) {
        point.setOval(
            PropUtils.booleanFromProperties(
                propertiesBuffer, LPC_POINT_OVAL, OMPoint.DEFAULT_ISOVAL));
      }
    }

    return point;
  }
Esempio n. 3
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()));
  }
Esempio n. 4
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");
    }
  }