Beispiel #1
0
  /** Capture an image for all ViewManagers */
  public void captureAll() {
    List vms = getViewManagers();

    String filename = FileManager.getWriteFile(FileManager.FILTER_IMAGE, FileManager.SUFFIX_JPG);
    if (filename == null) {
      return;
    }
    String root = IOUtil.stripExtension(filename);
    String ext = IOUtil.getFileExtension(filename);

    StringBuffer sb = new StringBuffer("<html>");
    sb.append("Since there were multiple images they were written out as:<ul>");
    for (int i = 0; i < vms.size(); i++) {
      ViewManager vm = (ViewManager) vms.get(i);
      String name = vm.getName();
      if ((name == null) || (name.trim().length() == 0)) {
        name = "" + (i + 1);
      }
      if (vms.size() != 1) {
        filename = root + name + ext;
      }

      sb.append("<li> " + filename);
      vm.writeImage(filename);
    }
    sb.append("</ul></html>");
    if (vms.size() > 1) {
      GuiUtils.showDialog("Captured Images", GuiUtils.inset(new JLabel(sb.toString()), 5));
    }
  }
  /**
   * Writes the location of the views of the known {@link Note}s.
   *
   * @param element the xml-element to write into, the attributes of <code>element</code> will not
   *     be changed
   */
  public void writeXML(XElement element) throws IOException {
    PropertyTransformer transformer = new PropertyTransformer();

    for (Map.Entry<Note, Tuple<DockStation, DockableProperty>> location : locations.entrySet()) {
      XElement xnote = element.addElement("note");
      xnote.addString("id", location.getKey().getId());
      xnote.addString("station", manager.getName(location.getValue().getA()));
      transformer.writeXML(location.getValue().getB(), xnote);
    }
  }
  /**
   * Writes the location of the views of the known {@link Note}s.
   *
   * @param out the stream to write into
   * @throws IOException if this method can't write into <code>out</code>
   */
  public void write(DataOutputStream out) throws IOException {
    PropertyTransformer transformer = new PropertyTransformer();

    out.writeInt(locations.size());
    for (Map.Entry<Note, Tuple<DockStation, DockableProperty>> location : locations.entrySet()) {
      out.writeUTF(location.getKey().getId());
      out.writeUTF(manager.getName(location.getValue().getA()));
      transformer.write(location.getValue().getB(), out);
    }
  }