コード例 #1
0
 /**
  * Instantiate a new ImageExportOptions from a preserved state.
  *
  * @param node An XML context in which state was saved
  * @return The new ImageExportOptions
  * @throws XMLException If the given node has invalid content.
  */
 public static ImageExportOptions read(XmlNode node) throws XMLException {
   node = node.getChild(ExportOptionsTag);
   final String typeName = node.getAttribute(TypeTag);
   final ImageType type = ImageType.getImageTypeByName(typeName);
   if (type == null) {
     throw new XMLException("Unrecognized image export type");
   }
   final ImageExportOptions options = type.newExportOptions();
   options.restore(node);
   if (node.hasAttribute(FileTag)) {
     options.m_exportFile = new File(node.getAttribute(FileTag));
   }
   return options;
 }
コード例 #2
0
  /**
   * Checks this <code>ImageExportOptions</code> to another object for equality.
   *
   * @param o The other object to compare to.
   * @return Returns <code>true</code> only if the other object is also an <code>ImageExportOptions
   *     </code> and they both are for the same {@link ImageType} and all of their options are
   *     equal.
   */
  public boolean equals(Object o) {
    if (o == null || !o.getClass().equals(getClass())) return false;
    final ImageExportOptions otherOpts = (ImageExportOptions) o;

    final File otherExportFile = otherOpts.getExportFile();
    if (otherExportFile == null) {
      if (getExportFile() != null) return false;
    } else if (!otherExportFile.equals(getExportFile())) return false;

    if (!otherOpts.getImageType().equals(getImageType())) return false;

    final Map<String, ImageExportOption> om = otherOpts.m_exportOptions;
    if (om.size() != m_exportOptions.size()) return false;
    for (Map.Entry<String, ImageExportOption> me : om.entrySet()) {
      final ImageExportOption opt = m_exportOptions.get(me.getKey());
      if (opt == null || !opt.equals(me.getValue())) return false;
    }
    return true;
  }