示例#1
0
  /**
   * Binds the information in the XML entity argument to create and return an <code>ExtentHistory
   * </code> object.
   *
   * @param xml an XML entity of a <code>ExtentHistory</code>
   * @return an <code>ExtentHistory</code> object with the information of the <code>xml</code>
   *     argument
   * @see #getXMLEntity()
   */
  public static ExtentHistory createFromXML(XMLEntity xml) {
    ExtentHistory eh = new ExtentHistory();
    eh.num = xml.getIntProperty("num");
    eh.NUMREC = xml.getIntProperty("numrec");

    for (int i = 0; i < eh.NUMREC; i++) {
      try {
        eh.extents[i] =
            new Rectangle2D.Double(
                xml.getDoubleProperty("extent" + i + "X"),
                xml.getDoubleProperty("extent" + i + "Y"),
                xml.getDoubleProperty("extent" + i + "W"),
                xml.getDoubleProperty("extent" + i + "H"));
      } catch (Exception e) {
        /// System.out.println("En las ExtentHistory =" + e); //TODO o se captura de alguna forma o
        // se mete un nuevo parametro en el xml para saber exactamente cuantos rectágulos se han
        // añadido.
      }
    }

    return eh;
  }
  public void setXMLEntity(XMLEntity xml) {
    if (xml.contains("TextField")) {
      setTextField(xml.getStringProperty("TextField"));
    }

    if (xml.contains("HeightField")) {
      setHeightField(xml.getStringProperty("HeightField"));
    }

    if (xml.contains("ColorField")) {
      setColorField(xml.getStringProperty("ColorField"));
    }

    if (xml.contains("RotationField")) {
      setRotationField(xml.getStringProperty("RotationField"));
    }

    if (xml.contains("Unit")) {
      setUnit(xml.getIntProperty("Unit"));
    }

    if (xml.contains("fontName")) {
      Font font =
          new Font(
              xml.getStringProperty("fontName"),
              xml.getIntProperty("fontStyle"),
              xml.getIntProperty("fontSize"));
      setFont(font);
    }
    if (xml.contains("useFixedSize")) {
      useFixedSize = xml.getBooleanProperty("useFixedSize");
      fixedSize = xml.getDoubleProperty("fixedSize");
    }
    if (xml.contains("useFixedColor")) {
      useFixedColor = xml.getBooleanProperty("useFixedColor");
      fixedColor = StringUtilities.string2Color(xml.getStringProperty("fixedColor"));
    }
    if (xml.contains("referenceSystem")) {
      referenceSystem = xml.getIntProperty("referenceSystem");
    }
  }