You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by vh...@apache.org on 2002/07/22 10:28:29 UTC

cvs commit: xml-batik/sources/org/apache/batik/apps/svgbrowser JSVGViewerFrame.java

vhardy      2002/07/22 01:28:29

  Modified:    sources/org/apache/batik/apps/svgbrowser
                        JSVGViewerFrame.java
  Log:
  Added full screen toggle with F11 key in Squiggle
  
  Revision  Changes    Path
  1.84      +53 -5     xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java
  
  Index: JSVGViewerFrame.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java,v
  retrieving revision 1.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- JSVGViewerFrame.java	11 Jul 2002 16:42:45 -0000	1.83
  +++ JSVGViewerFrame.java	22 Jul 2002 08:28:29 -0000	1.84
  @@ -22,6 +22,7 @@
   import java.awt.event.ComponentAdapter;
   import java.awt.event.ComponentEvent;
   import java.awt.event.InputEvent;
  +import java.awt.event.KeyEvent;
   import java.awt.event.MouseAdapter;
   import java.awt.event.MouseEvent;
   import java.awt.event.MouseMotionAdapter;
  @@ -78,6 +79,8 @@
   import javax.swing.JScrollPane;
   import javax.swing.JTextArea;
   import javax.swing.JToolBar;
  +import javax.swing.JWindow;
  +import javax.swing.KeyStroke;
   
   import javax.swing.filechooser.FileFilter;
   
  @@ -225,6 +228,7 @@
       public final static String RELOAD_ACTION = "ReloadAction";
       public final static String BACK_ACTION = "BackAction";
       public final static String FORWARD_ACTION = "ForwardAction";
  +    public final static String FULL_SCREEN_ACTION = "FullScreenAction";
       public final static String PRINT_ACTION = "PrintAction";
       public final static String EXPORT_AS_JPG_ACTION = "ExportAsJPGAction";
       public final static String EXPORT_AS_PNG_ACTION = "ExportAsPNGAction";
  @@ -315,6 +319,16 @@
       protected JSVGCanvas svgCanvas;
   
       /**
  +     * The panel where the svgCanvas is displayed
  +     */
  +    protected JPanel svgCanvasPanel;
  +
  +    /**
  +     * A window used for full screen display
  +     */
  +    protected JWindow window;
  +
  +    /**
        * The memory monitor frame.
        */
       protected static JFrame memoryMonitorFrame;
  @@ -485,6 +499,12 @@
                   
               };
           
  +        javax.swing.ActionMap map = svgCanvas.getActionMap();
  +        map.put(FULL_SCREEN_ACTION, new FullScreenAction());
  +        javax.swing.InputMap imap = svgCanvas.getInputMap(JComponent.WHEN_FOCUSED);
  +        KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0);
  +        imap.put(key, FULL_SCREEN_ACTION);
  +
           svgCanvas.setDoubleBufferedRendering(true);
   
           listeners.put(ABOUT_ACTION, new AboutAction());
  @@ -555,12 +575,12 @@
               System.exit(0);
           }
   
  -        JPanel p2 = new JPanel(new BorderLayout());
  -        p2.setBorder(BorderFactory.createEtchedBorder());
  +        svgCanvasPanel = new JPanel(new BorderLayout());
  +        svgCanvasPanel.setBorder(BorderFactory.createEtchedBorder());
   
  -        p2.add(svgCanvas, BorderLayout.CENTER);
  +        svgCanvasPanel.add(svgCanvas, BorderLayout.CENTER);
           p = new JPanel(new BorderLayout());
  -        p.add(p2, BorderLayout.CENTER);
  +        p.add(svgCanvasPanel, BorderLayout.CENTER);
           p.add(statusBar = new StatusBar(), BorderLayout.SOUTH);
   
           getContentPane().add(p, BorderLayout.CENTER);
  @@ -1640,6 +1660,34 @@
           }
       }
   
  +    /**
  +     * To display the document full screen
  +     */
  +    public class FullScreenAction extends AbstractAction {
  +        public FullScreenAction() {}
  +
  +        public void actionPerformed(ActionEvent e) {
  +            if (window == null || !window.isVisible()) {
  +                if (window == null) {
  +                    window = new JWindow(JSVGViewerFrame.this);
  +                    Dimension size = Toolkit.getDefaultToolkit().getScreenSize();
  +                    window.setSize(size);
  +                }
  +                // Go to full screen in JWindow)
  +                svgCanvas.getParent().remove(svgCanvas);
  +                window.getContentPane().add(svgCanvas);
  +                window.setVisible(true);
  +                window.toFront();
  +                svgCanvas.requestFocus();
  +            } else {
  +                // Go back to JSVGViewerFrame display
  +                svgCanvas.getParent().remove(svgCanvas);
  +                svgCanvasPanel.add(svgCanvas, BorderLayout.CENTER);
  +                window.setVisible(false);
  +            } 
  +        }
  +    }
  +    
       /**
        * To display the DOM viewer of the document
        */
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org