예제 #1
0
 private void addDocument(NodeBoxDocument doc) {
   doc.setVisible(true);
   doc.requestFocus();
   doc.focusNetworkView();
   doc.setActiveNetwork("/");
   documents.add(doc);
   currentDocument = doc;
 }
예제 #2
0
 public boolean quit() {
   // Because documents will disappear from the list once they are closed,
   // make a copy of the list.
   java.util.List<NodeBoxDocument> documents = new ArrayList<NodeBoxDocument>(getDocuments());
   for (NodeBoxDocument d : documents) {
     if (!d.close()) return false;
   }
   System.exit(0);
   return true;
 }
예제 #3
0
 public void takeScreenshotOfDocument(String documentFileName) {
   File documentFile = new File(documentFileName);
   File documentDirectory = documentFile.getParentFile();
   String imageName = FileUtils.getBaseName(documentFile.getName()) + ".png";
   File screenshotFile = new File(documentDirectory, imageName);
   NodeBoxDocument doc = NodeBoxDocument.load(documentFile);
   addDocument(doc);
   doc.setVisible(true);
   doc.takeScreenshot(screenshotFile);
   doc.close();
 }
예제 #4
0
  public FullScreenFrame(final NodeBoxDocument document) {
    this.document = document;
    setLayout(new BorderLayout(0, 0));

    viewer = new Viewer();
    document.addZoomListener(viewer);
    add(viewer, BorderLayout.CENTER);

    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();

    if (gd.isFullScreenSupported()) {
      setUndecorated(true);
      gd.setFullScreenWindow(this);
    } else {
      System.err.println("Full screen not supported");
      setSize(100, 100); // just something to let you see the window
      setVisible(true);
    }
  }
예제 #5
0
  public boolean openDocument(File file) {
    // Check if the document is already open.
    String path;
    try {
      path = file.getCanonicalPath();
      for (NodeBoxDocument doc : Application.getInstance().getDocuments()) {
        try {
          if (doc.getDocumentFile() == null) continue;
          if (doc.getDocumentFile().getCanonicalPath().equals(path)) {
            // The document is already open. Bring it to the front.
            doc.toFront();
            doc.requestFocus();
            NodeBoxMenuBar.addRecentFile(file);
            return true;
          }
        } catch (IOException e) {
          logger.log(
              Level.WARNING,
              "The document " + doc.getDocumentFile() + " refers to path with errors",
              e);
        }
      }
    } catch (IOException e) {
      logger.log(Level.WARNING, "The document " + file + " refers to path with errors", e);
    }

    try {
      NodeBoxDocument doc = NodeBoxDocument.load(file);
      addDocument(doc);
      NodeBoxMenuBar.addRecentFile(file);
      return true;
    } catch (RuntimeException e) {
      logger.log(Level.SEVERE, "Error while loading " + file, e);
      ExceptionDialog d = new ExceptionDialog(null, e);
      d.setVisible(true);
      return false;
    }
  }
예제 #6
0
 public void rewindAnimation() {
   document.doRewind();
 }
예제 #7
0
 public void toggleAnimation() {
   document.toggleAnimation();
 }
예제 #8
0
 public void close() {
   document.closeFullScreenWindow();
 }