コード例 #1
0
ファイル: ExtendedGraphFrame.java プロジェクト: ptII/ptII
  /** Cancel full screen mode. Note that this should be called in the swing event thread. */
  public void cancelFullScreen() {
    if (_screen == null) {
      // Already canceled.
      return;
    }

    _screen.dispose();
    _screen = null;

    // Only include the palettePane and panner if there is an actor library.
    // The ptinyViewer configuration uses this.
    if ((CompositeEntity) getConfiguration().getEntity("actor library") != null) {
      // Put the component back into the original window.
      _splitPane.setRightComponent(_getRightComponent());

      // Restore association with the graph panner.
      _graphPanner.setCanvas(getJGraph());
    } else {
      getContentPane().add(_getRightComponent());
    }
    pack();
    show();
    UndeferredGraphicalMessageHandler.setContext(_previousDefaultContext);
    toFront();
    _getRightComponent().requestFocus();
  }
コード例 #2
0
ファイル: ExtendedGraphFrame.java プロジェクト: ptII/ptII
  /** Go to full screen. */
  public void fullScreen() {
    if (_screen != null) {
      // Already in full screen mode.
      _screen.toFront();
      return;
    }

    // NOTE: Do not make the original graph frame the owner,
    // because we are going to hide it, and if it is the owner,
    // then the new frame will be hidden also.
    _screen = new JDialog();
    _screen.getContentPane().setLayout(new BorderLayout());

    // Set to full-screen size.
    Toolkit toolkit = _screen.getToolkit();
    int width = toolkit.getScreenSize().width;
    int height = toolkit.getScreenSize().height;
    _screen.setSize(width, height);

    _screen.setUndecorated(true);
    _screen.getContentPane().add(getJGraph(), BorderLayout.CENTER);

    // NOTE: Have to avoid the following, which forces the
    // dialog to resize the preferred size of _jgraph, which
    // nullifies the call to setSize() above.
    // _screen.pack();
    _screen.setVisible(true);

    // Make the new screen the default context for modal messages.
    _previousDefaultContext = UndeferredGraphicalMessageHandler.getContext();
    UndeferredGraphicalMessageHandler.setContext(_screen);

    // NOTE: As usual with swing, what the UI does is pretty
    // random, and doesn't correlate much with the documentation.
    // The following two lines do not work if _screen is a
    // JWindow instead of a JDialog.  There is no apparent
    // reason for this, but this is why we use JDialog.
    // Unfortunately, apparently the JDialog does not appear
    // in the Windows task bar.
    _screen.toFront();
    getJGraph().requestFocus();

    _screen.setResizable(false);

    // Bind escape key to remove full-screen mode.
    ActionMap actionMap = getJGraph().getActionMap();

    // Use the action as both a key and the action.
    actionMap.put(_fullScreenAction, _fullScreenAction);

    InputMap inputMap = getJGraph().getInputMap();
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), _fullScreenAction);

    // The ptinyViewer configuration will have a null _graphPanner.
    if (_graphPanner != null) {
      // Remove association with the graph panner.
      _graphPanner.setCanvas(null);
    }

    setVisible(false);
  }