Пример #1
0
  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;
  }
Пример #2
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);
  }
Пример #3
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;
  }