Пример #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);
   }
 }
Пример #2
0
  protected void loadDrawing(String param) {
    if (param == fgUntitled) {
      fDrawing.release();
      initDrawing();
      return;
    }

    String filename = getParameter(param);
    if (filename != null) {
      readDrawing(filename);
    }
  }
Пример #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
 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);
   }
 }