/** * 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"); } } }
/** * Removes a vector of figures. * * @see #remove */ public void removeAll(Vector figures) { Enumeration k = figures.elements(); while (k.hasMoreElements()) remove((Figure) k.nextElement()); }
/** * Adds a vector of figures. * * @see #add */ public void addAll(Vector newFigures) { Enumeration k = newFigures.elements(); while (k.hasMoreElements()) add((Figure) k.nextElement()); }
public String getMap() { String areas = ""; Enumeration k = fFigures.elements(); while (k.hasMoreElements()) areas += ((Storable) k.nextElement()).getMap(); return areas; }
/** 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()); }
/** * Returns the next element of the enumeration. Calls to this method will enumerate successive * elements. * * @exception NoSuchElementException If no more elements exist. */ public Figure nextFigure() { return (Figure) fEnumeration.nextElement(); }
/** * Returns the next element of the enumeration. Calls to this method will enumerate successive * elements. * * @exception NoSuchElementException If no more elements exist. */ public Object nextElement() { return fEnumeration.nextElement(); }