コード例 #1
0
 /**
  * Restore a Drawing from a file with a given name.
  *
  * @param fileName of the file in which the Drawing has been saved
  * @return restored Drawing
  */
 public Drawing restore(String fileName) throws IOException {
   if (!hasCorrectFileExtension(fileName)) {
     return null;
   } else {
     FileInputStream stream = new FileInputStream(fileName);
     StorableInput input = new StorableInput(stream);
     return (Drawing) input.readStorable();
   }
 }
コード例 #2
0
 public void read(StorableInput dr) throws IOException {
   super.read(dr);
   Connector start = (Connector) dr.readStorable();
   if (start != null) {
     connectStart(start);
   }
   Connector end = (Connector) dr.readStorable();
   if (end != null) {
     connectEnd(end);
   }
   if ((start != null) && (end != null)) {
     updateConnection();
   }
 }
コード例 #3
0
  private void readFromStorableInput(String filename) {
    try {
      URL url = new URL(getCodeBase(), filename);
      InputStream stream = url.openStream();
      StorableInput input = new StorableInput(stream);
      fDrawing.release();

      fDrawing = (Drawing) input.readStorable();
      view().setDrawing(fDrawing);
    } catch (IOException e) {
      initDrawing();
      showStatus("Error:" + e);
    }
  }
コード例 #4
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());
 }
コード例 #5
0
 public void read(StorableInput dr) throws IOException {
   super.read(dr);
   fRelativeX = dr.readDouble();
   fRelativeY = dr.readDouble();
 }
コード例 #6
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);
    }
  }
コード例 #7
0
 public static Color readColor(StorableInput dr) throws IOException {
   return new Color(dr.readInt(), dr.readInt(), dr.readInt());
 }
コード例 #8
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();
 }
コード例 #9
0
 /** Reads the arrow tip from a StorableInput. */
 public void read(StorableInput dr) throws IOException {
   super.read(dr);
   fLocator = (Locator) dr.readStorable();
 }
コード例 #10
0
ファイル: ArrowTip.java プロジェクト: mmohan01/MultiRefactor
 /** Reads the arrow tip from a StorableInput. */
 public void read(StorableInput dr) throws IOException {
   setAngle(dr.readDouble());
   setOuterRadius(dr.readDouble());
   setInnerRadius(dr.readDouble());
   super.read(dr);
 }