コード例 #1
0
  /**
   * 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);
    }
  }
コード例 #2
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());
 }
コード例 #3
0
 public static Color readColor(StorableInput dr) throws IOException {
   return new Color(dr.readInt(), dr.readInt(), dr.readInt());
 }
コード例 #4
0
 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();
 }