Example #1
0
  /** Reads the view from the specified uri. */
  @Override
  public void read(URI f, URIChooser chooser) throws IOException {
    try {
      final Drawing drawing = createDrawing();
      InputFormat inputFormat = drawing.getInputFormats().get(0);
      inputFormat.read(f, drawing, true);
      SwingUtilities.invokeAndWait(
          new Runnable() {

            @Override
            public void run() {
              view.getDrawing().removeUndoableEditListener(undo);
              view.setDrawing(drawing);
              view.getDrawing().addUndoableEditListener(undo);
              undo.discardAllEdits();
            }
          });
    } catch (InterruptedException e) {
      InternalError error = new InternalError();
      e.initCause(e);
      throw error;
    } catch (InvocationTargetException e) {
      InternalError error = new InternalError();
      e.initCause(e);
      throw error;
    }
  }
Example #2
0
 public void redraw(BufferedImage redrawImage) throws InterruptedException {
   try {
     image = redrawImage;
     SwingUtilities.invokeAndWait(
         new Runnable() {
           @Override
           public void run() {
             invalidate();
             revalidate();
             repaint();
           }
         });
   } catch (InvocationTargetException ite) {
     InterruptedException ie = new InterruptedException("Error rendering test");
     ie.initCause(ite);
     throw ie;
   }
 }
Example #3
0
 private static InterruptedException asInterruptedException(Throwable throwable) {
   InterruptedException e = new InterruptedException();
   e.initCause(throwable);
   return e;
 }