Exemple #1
0
  /**
   * Save the status of the provided toolbar.
   *
   * @param toolbarName The toolbar name whose status wants to be saved.
   * @param visible Whether or not the toolbar is visible.
   */
  private void persistStatus(String toolbarName, boolean visible) {
    PluginServices ps = PluginServices.getPluginServices(this);
    XMLEntity xml = ps.getPersistentXML();
    XMLEntity child = null;
    for (int i = xml.getChildrenCount() - 1; i >= 0; i--) {
      if (xml.getChild(i).getName().equals("Toolbars")) child = xml.getChild(i).getChild(0);
    }
    if (child == null) {
      XMLEntity toolbars = new XMLEntity();
      toolbars.setName("Toolbars");
      child = new XMLEntity();
      toolbars.addChild(child);
      xml.addChild(toolbars);
    }

    if (visible) {
      child.putProperty(toolbarName, "visible");
    } else {
      child.putProperty(toolbarName, "hidden");
    }
    ps.setPersistentXML(xml);
  }
Exemple #2
0
  /**
   * Returns an entity that represents this collection of layers stored as a tree-node with children
   * that are also layers.
   *
   * <p>The root node has the same properties that <code>FlyrDefault#getXMLEntity()</code> returns,
   * and adds:
   *
   * <ul>
   *   <li><i>numLayers</i> : number of layers of this collection (direct children of this node)
   *   <li><i>LayerNames</i> : an array list with the name of the layers of this collection (direct
   *       children of this node) <code>FLayer.getXMLEntity()</code>
   * </ul>
   *
   * <p>All XML elements returned represent the information about this layer.
   *
   * @return an XML entity with information to this collection of layers
   * @throws XMLException if there is any error creating the XML from the layers.
   */
  public XMLEntity getXMLEntity() throws XMLException {
    XMLEntity xml = super.getXMLEntity();
    xml.putProperty("numLayers", layers.size());

    String[] s = new String[layers.size()];

    for (int i = 0; i < layers.size(); i++) {
      s[i] = ((FLayer) layers.get(i)).getName();
    }

    xml.putProperty("LayerNames", s);

    for (int i = 0; i < layers.size(); i++) {
      try {
        XMLEntity xmlLayer = ((FLayer) layers.get(i)).getXMLEntity();
        xmlLayer.putProperty("tagName", "layer");
        xml.addChild(xmlLayer);
      } catch (XMLException e) {
        e.printStackTrace();
      }
    }

    return xml;
  }
  public XMLEntity getXMLEntity() {
    XMLEntity xml = new XMLEntity();
    xml.putProperty("className", getClassName());
    xml.putProperty("isShapeVisible", isShapeVisible());
    // color (necessite)
    if (getFillColor() != null)
      xml.putProperty("color", StringUtilities.color2String(getFillColor()));
    xml.putProperty("desc", getDescription());
    xml.putProperty("referenceSystem", getReferenceSystem());
    xml.putProperty("unit", getUnit());
    xml.addChild(markerSymbol.getXMLEntity());
    xml.addChild(markerFillProperties.getXMLEntity());

    if (getOutline() != null) {
      XMLEntity outlineXML = getOutline().getXMLEntity();
      outlineXML.putProperty("id", "outline symbol");
      xml.addChild(outlineXML);
    }
    xml.putProperty("hasOutline", hasOutline());
    return xml;
  }
Exemple #4
0
  /**
   * Returns an XML entity with information of this object. All information is stored as properties:
   * <br>
   *
   * <p><b>Properties:</b>
   *
   * <ul>
   *   <li><i>className</i>: name of this class.
   *   <li><i>num</i>: number of extents registered.
   *   <li><i>numrec</i>: maximum number of extents that can register.
   *   <li><i>extentiX</i>: X coordinate of the upper left corner of the rectangle that defines the
   *       area.
   *   <li><i>extentiY</i>: Y coordinate of the upper left corner of the rectangle that defines the
   *       area.
   *   <li><i>extentiW</i>: width of the rectangle that defines the area.
   *   <li><i>extentiH</i>: height of the rectangle that defines the area.
   * </ul>
   *
   * @return XML entity that represents this object
   * @see #createFromXML(XMLEntity)
   * @see #get()
   * @see #put(Rectangle2D)
   */
  public XMLEntity getXMLEntity() {
    XMLEntity xml = new XMLEntity();
    xml.putProperty("className", this.getClass().getName());
    xml.putProperty("num", num);
    xml.putProperty("numrec", NUMREC);

    for (int i = 0; i < NUMREC; i++) {
      if (extents[i] != null) {
        xml.putProperty("extent" + i + "X", extents[i].getX());
        xml.putProperty("extent" + i + "Y", extents[i].getY());
        xml.putProperty("extent" + i + "W", extents[i].getWidth());
        xml.putProperty("extent" + i + "H", extents[i].getHeight());
      }
    }

    return xml;
  }
Exemple #5
0
  public void storeValues() throws StoreException {
    File f;
    String path, propertyName;
    PluginServices ps = PluginServices.getPluginServices(this);
    XMLEntity xml = ps.getPersistentXML();

    // Projects folder
    propertyName = PROJECTS_FOLDER_PROPERTY_NAME;
    path = txtProjectsFolder.getText();

    if (path.equals("")) {
      if (xml.contains(propertyName)) {
        xml.remove(propertyName);
      }
      prefs.remove(propertyName);
    } else {
      f = new File(path);
      if (f.exists()) {
        if (xml.contains(propertyName)) {
          xml.remove(propertyName);
        }
        xml.putProperty(propertyName, f.getAbsolutePath());
        prefs.put(propertyName, f.getAbsolutePath());
      }
    }

    // Data folder
    propertyName = DATA_FOLDER_PROPERTY_NAME;
    path = txtDataFolder.getText();

    if (path.equals("")) {
      if (xml.contains(propertyName)) {
        xml.remove(propertyName);
      }
      prefs.remove(propertyName);
    } else {
      f = new File(path);
      if (f.exists()) {
        if (xml.contains(propertyName)) {
          xml.remove(propertyName);
        }
        xml.putProperty(propertyName, f.getAbsolutePath());
        prefs.put(propertyName, f.getAbsolutePath());
      }
    }

    // Templates folder
    propertyName = TEMPLATES_FOLDER_PROPERTY_NAME;
    path = txtTemplatesFolder.getText();

    if (path.equals("")) {
      if (xml.contains(propertyName)) {
        xml.remove(propertyName);
      }
      prefs.remove(propertyName);
    } else {
      f = new File(path);
      if (f.exists()) {
        if (xml.contains(propertyName)) {
          xml.remove(propertyName);
        }
        xml.putProperty(propertyName, f.getAbsolutePath());
        prefs.put(propertyName, f.getAbsolutePath());
      }
    }

    // Symbol library folder
    propertyName = SYMBOL_LIBRARY_FOLDER_PROPERTY_NAME;
    path = txtSymbolLibraryFolder.getText();

    if (path.equals("")) {
      if (xml.contains(propertyName)) {
        xml.remove(propertyName);
      }
      prefs.remove(propertyName);
    } else {
      f = new File(path);
      if (f.exists()) {
        if (xml.contains(propertyName)) {
          xml.remove(propertyName);
        }
        xml.putProperty(propertyName, f.getAbsolutePath());
        prefs.put(propertyName, f.getAbsolutePath());
      }
    }
  }
  public XMLEntity getXMLEntity() {
    XMLEntity xml = new XMLEntity();
    xml.putProperty("className", getClassName());
    xml.putProperty("labelingStrategy", "labelingStrategy");

    try {
      if (getHeightField() != null) {
        xml.putProperty("HeightField", getHeightField());
      }
    } catch (DataException e) {
      Logger.getAnonymousLogger()
          .log(Level.SEVERE, "Acessing TextHeight field.\n" + e.getMessage());
    }

    try {
      if (getColorField() != null) {
        xml.putProperty("ColorField", getColorField());
      }
    } catch (DataException e) {
      Logger.getAnonymousLogger()
          .log(Level.SEVERE, "Acessing ColorField field.\n" + e.getMessage());
    }

    try {
      if (getTextField() != null) {
        xml.putProperty("TextField", getTextField());
      }
    } catch (DataException e) {
      Logger.getAnonymousLogger().log(Level.SEVERE, "Acessing TextField field.\n" + e.getMessage());
    }

    try {
      if (getRotationField() != null) {
        xml.putProperty("RotationField", getRotationField());
      }
    } catch (DataException e) {
      Logger.getAnonymousLogger()
          .log(Level.SEVERE, "Acessing RotationField field.\n" + e.getMessage());
    }

    if (getFont() != null) {
      xml.putProperty("fontSize", getFont().getSize());
      xml.putProperty("fontName", getFont().getName());
      xml.putProperty("fontStyle", getFont().getStyle());
    }
    if (getColorFont() != null) {
      xml.putProperty("Color", StringUtilities.color2String(getColorFont()));
    }
    xml.putProperty("useFixedSize", useFixedSize);
    xml.putProperty("useFixedColor", useFixedColor);
    xml.putProperty("fixedColor", StringUtilities.color2String(fixedColor));
    xml.putProperty("fixedSize", fixedSize);
    xml.putProperty("Unit", unit);
    xml.putProperty("referenceSystem", referenceSystem);
    return xml;
  }