예제 #1
0
 /** Load a Drawing from a file */
 protected void loadDrawing(StorageFormat restoreFormat, String file) {
   try {
     Drawing restoredDrawing = restoreFormat.restore(file);
     if (restoredDrawing != null) {
       restoredDrawing.setTitle(file);
       newWindow(restoredDrawing);
     } else {
       showStatus("Unknown file type: could not open file '" + file + "'");
     }
   } catch (IOException e) {
     showStatus("Error: " + e);
   }
 }
 private Figure findConnectableFigure(int x, int y, Drawing drawing) {
   FigureEnumeration fe = drawing.figuresReverse();
   while (fe.hasNextFigure()) {
     Figure figure = fe.nextFigure();
     if (!figure.includes(getConnection()) && figure.canConnect() && figure.containsPoint(x, y)) {
       return figure;
     }
   }
   return null;
 }
 private Figure findConnectableFigure(int x, int y, Drawing drawing) {
   FigureEnumeration k = drawing.figuresReverse();
   while (k.hasMoreElements()) {
     Figure figure = k.nextFigure();
     if (!figure.includes(getConnection()) && figure.canConnect()) {
       if (figure.containsPoint(x, y)) {
         return figure;
       }
     }
   }
   return null;
 }
예제 #4
0
  protected void loadDrawing(String param) {
    if (param == fgUntitled) {
      fDrawing.release();
      initDrawing();
      return;
    }

    String filename = getParameter(param);
    if (filename != null) {
      readDrawing(filename);
    }
  }
예제 #5
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);
    }
  }
예제 #6
0
 private void readFromObjectInput(String filename) {
   try {
     URL url = new URL(getCodeBase(), filename);
     InputStream stream = url.openStream();
     ObjectInput input = new ObjectInputStream(stream);
     fDrawing.release();
     fDrawing = (Drawing) input.readObject();
     view().setDrawing(fDrawing);
   } catch (IOException e) {
     initDrawing();
     showStatus("Error: " + e);
   } catch (ClassNotFoundException e) {
     initDrawing();
     showStatus("Class not found: " + e);
   }
 }