/**
   * Writes the attributes to a StorableInput. FigureAttributes store the following types directly:
   * Color, Boolean, String, Int. Other attribute types have to implement the Storable interface or
   * they have to be wrapped by an object that implements Storable.
   *
   * @see Storable
   * @see #write
   */
  public void write(StorableOutput dw) {
    dw.writeString("attributes");

    dw.writeInt(fMap.size()); // number of attributes
    Enumeration k = fMap.keys();
    while (k.hasMoreElements()) {
      String s = (String) k.nextElement();
      Object v = fMap.get(s);

      dw.writeString(s);

      if (v instanceof String) {
        dw.writeString("String");
        dw.writeString((String) v);
      } else if (v instanceof Color) {
        writeColor(dw, "Color", (Color) v);
      } else if (v instanceof Boolean) {
        dw.writeString("Boolean");
        if (((Boolean) v).booleanValue()) {
          dw.writeString("TRUE");
        } else {
          dw.writeString("FALSE");
        }
      } else if (v instanceof Integer) {
        dw.writeString("Int");
        dw.writeInt(((Integer) v).intValue());
      } else if (v instanceof Storable) {
        dw.writeString("Storable");
        dw.writeStorable((Storable) v);
      } else if (v instanceof javax.swing.JPopupMenu) {
        dw.writeString(Figure.POPUP_MENU);
      } else {
        System.err.println("Unknown attribute: " + v);
        dw.writeString("UNKNOWN");
      }
    }
  }
Esempio n. 2
0
 /** Writes the contained figures to the StorableOutput. */
 public void write(StorableOutput dw) {
   super.write(dw);
   dw.writeInt(fFigures.size());
   Enumeration k = fFigures.elements();
   while (k.hasMoreElements()) dw.writeStorable((Storable) k.nextElement());
 }
 /** Stores the arrow tip to a StorableOutput. */
 public void write(StorableOutput dw) {
   super.write(dw);
   dw.writeStorable(fLocator);
 }
Esempio n. 4
0
 public void write(StorableOutput dw) {
   super.write(dw);
   dw.writeStorable(getStartConnector());
   dw.writeStorable(getEndConnector());
 }