/**
   * Reads the attributes from 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 read(StorableInput dr) throws IOException {
    String s = dr.readString();
    if (!s.toLowerCase().equals("attributes")) {
      throw new IOException("Attributes expected");
    }

    fMap = new Hashtable();
    int size = dr.readInt();
    for (int i = 0; i < size; i++) {
      String key = dr.readString();
      String valtype = dr.readString();
      Object val = null;
      if (valtype.equals("Color")) {
        val = new Color(dr.readInt(), dr.readInt(), dr.readInt());
      } else if (valtype.equals("Boolean")) {
        val = new Boolean(dr.readString());
      } else if (valtype.equals("String")) {
        val = dr.readString();
      } else if (valtype.equals("Int")) {
        val = new Integer(dr.readInt());
      } else if (valtype.equals("Storable")) {
        val = dr.readStorable();
      } else if (valtype.equals(Figure.POPUP_MENU)) {
        // read String but don't store it
        continue;
      } else if (valtype.equals("UNKNOWN")) {
        continue;
      }
      fMap.put(key, val);
    }
  }
 /**
  * Storable inoput support
  *
  * @param dr storable input
  * @exception IOException thrown by called methods
  */
 public void read(StorableInput dr) throws IOException {
   // read the default content producers, count first
   int prodCount = dr.readInt();
   String prodClass;
   ContentProducer producer;
   for (int cnt = 0; cnt < prodCount; cnt++) {
     prodClass = dr.readString();
     producer = (ContentProducer) dr.readStorable();
     try {
       registerContentProducer(Class.forName(prodClass), producer);
     } catch (ClassNotFoundException ex) {
       // the class does not exist in this application
       // cannot do much about it so ignore it, the entities of
       // this class will get their toString() value instead
     }
   }
 }
示例#3
0
 /** Reads the contained figures from StorableInput. */
 public void read(StorableInput dr) throws IOException {
   super.read(dr);
   int size = dr.readInt();
   fFigures = new Vector(size);
   for (int i = 0; i < size; i++) add((Figure) dr.readStorable());
 }
 public static Color readColor(StorableInput dr) throws IOException {
   return new Color(dr.readInt(), dr.readInt(), dr.readInt());
 }
 public void read(StorableInput dr) throws IOException {
   super.read(dr);
   fDisplayBox = new Rectangle(dr.readInt(), dr.readInt(), dr.readInt(), dr.readInt());
   fArcWidth = dr.readInt();
   fArcHeight = dr.readInt();
 }