KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > apps > svgbrowser > JSVGViewerFrame


1 /*
2
3    Copyright 2001-2004 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.apps.svgbrowser;
19
20 import java.awt.BorderLayout JavaDoc;
21 import java.awt.Color JavaDoc;
22 import java.awt.Cursor JavaDoc;
23 import java.awt.Dimension JavaDoc;
24 import java.awt.Event JavaDoc;
25 import java.awt.EventQueue JavaDoc;
26 import java.awt.Font JavaDoc;
27 import java.awt.Graphics2D JavaDoc;
28 import java.awt.Rectangle JavaDoc;
29 import java.awt.Toolkit JavaDoc;
30 import java.awt.event.ActionEvent JavaDoc;
31 import java.awt.event.ComponentAdapter JavaDoc;
32 import java.awt.event.ComponentEvent JavaDoc;
33 import java.awt.event.KeyEvent JavaDoc;
34 import java.awt.event.MouseAdapter JavaDoc;
35 import java.awt.event.MouseEvent JavaDoc;
36 import java.awt.event.MouseMotionAdapter JavaDoc;
37 import java.awt.event.WindowAdapter JavaDoc;
38 import java.awt.event.WindowEvent JavaDoc;
39 import java.awt.geom.AffineTransform JavaDoc;
40 import java.awt.geom.NoninvertibleTransformException JavaDoc;
41 import java.awt.geom.Point2D JavaDoc;
42 import java.awt.image.BufferedImage JavaDoc;
43 import java.awt.print.PrinterException JavaDoc;
44 import java.io.BufferedOutputStream JavaDoc;
45 import java.io.File JavaDoc;
46 import java.io.FileOutputStream JavaDoc;
47 import java.io.IOException JavaDoc;
48 import java.io.InputStream JavaDoc;
49 import java.io.OutputStream JavaDoc;
50 import java.io.OutputStreamWriter JavaDoc;
51 import java.io.Reader JavaDoc;
52 import java.io.Writer JavaDoc;
53 import java.lang.reflect.Constructor JavaDoc;
54 import java.lang.reflect.Method JavaDoc;
55 import java.net.MalformedURLException JavaDoc;
56 import java.util.HashMap JavaDoc;
57 import java.util.Iterator JavaDoc;
58 import java.util.LinkedList JavaDoc;
59 import java.util.List JavaDoc;
60 import java.util.Locale JavaDoc;
61 import java.util.Map JavaDoc;
62 import java.util.MissingResourceException JavaDoc;
63 import java.util.ResourceBundle JavaDoc;
64 import java.util.Vector JavaDoc;
65
66 import javax.swing.AbstractAction JavaDoc;
67 import javax.swing.Action JavaDoc;
68 import javax.swing.BorderFactory JavaDoc;
69 import javax.swing.ButtonGroup JavaDoc;
70 import javax.swing.JCheckBox JavaDoc;
71 import javax.swing.JComponent JavaDoc;
72 import javax.swing.JDialog JavaDoc;
73 import javax.swing.JFileChooser JavaDoc;
74 import javax.swing.JFrame JavaDoc;
75 import javax.swing.JMenu JavaDoc;
76 import javax.swing.JMenuBar JavaDoc;
77 import javax.swing.JOptionPane JavaDoc;
78 import javax.swing.JPanel JavaDoc;
79 import javax.swing.JRadioButtonMenuItem JavaDoc;
80 import javax.swing.JScrollPane JavaDoc;
81 import javax.swing.JTextArea JavaDoc;
82 import javax.swing.JToolBar JavaDoc;
83 import javax.swing.JWindow JavaDoc;
84 import javax.swing.KeyStroke JavaDoc;
85 import javax.swing.filechooser.FileFilter JavaDoc;
86 import javax.swing.text.Document JavaDoc;
87 import javax.swing.text.PlainDocument JavaDoc;
88
89 import org.apache.batik.bridge.DefaultExternalResourceSecurity;
90 import org.apache.batik.bridge.DefaultScriptSecurity;
91 import org.apache.batik.bridge.EmbededExternalResourceSecurity;
92 import org.apache.batik.bridge.EmbededScriptSecurity;
93 import org.apache.batik.bridge.ExternalResourceSecurity;
94 import org.apache.batik.bridge.NoLoadExternalResourceSecurity;
95 import org.apache.batik.bridge.NoLoadScriptSecurity;
96 import org.apache.batik.bridge.RelaxedExternalResourceSecurity;
97 import org.apache.batik.bridge.RelaxedScriptSecurity;
98 import org.apache.batik.bridge.ScriptSecurity;
99 import org.apache.batik.bridge.UpdateManager;
100 import org.apache.batik.bridge.UpdateManagerEvent;
101 import org.apache.batik.bridge.UpdateManagerListener;
102 import org.apache.batik.dom.StyleSheetProcessingInstruction;
103 import org.apache.batik.dom.svg.SVGOMDocument;
104 import org.apache.batik.dom.util.HashTable;
105 import org.apache.batik.dom.util.DOMUtilities;
106 import org.apache.batik.ext.swing.JAffineTransformChooser;
107 import org.apache.batik.swing.JSVGCanvas;
108 import org.apache.batik.swing.gvt.GVTTreeRendererEvent;
109 import org.apache.batik.swing.gvt.GVTTreeRendererListener;
110 import org.apache.batik.swing.svg.GVTTreeBuilderEvent;
111 import org.apache.batik.swing.svg.GVTTreeBuilderListener;
112 import org.apache.batik.swing.svg.LinkActivationEvent;
113 import org.apache.batik.swing.svg.LinkActivationListener;
114 import org.apache.batik.swing.svg.SVGDocumentLoaderEvent;
115 import org.apache.batik.swing.svg.SVGDocumentLoaderListener;
116 import org.apache.batik.swing.svg.SVGFileFilter;
117 import org.apache.batik.swing.svg.SVGLoadEventDispatcherEvent;
118 import org.apache.batik.swing.svg.SVGLoadEventDispatcherListener;
119 import org.apache.batik.swing.svg.SVGUserAgent;
120 import org.apache.batik.transcoder.TranscoderInput;
121 import org.apache.batik.transcoder.TranscoderOutput;
122 import org.apache.batik.transcoder.image.ImageTranscoder;
123 import org.apache.batik.transcoder.image.JPEGTranscoder;
124 import org.apache.batik.transcoder.image.PNGTranscoder;
125 import org.apache.batik.transcoder.image.TIFFTranscoder;
126 import org.apache.batik.transcoder.print.PrintTranscoder;
127 import org.apache.batik.transcoder.svg2svg.SVGTranscoder;
128 import org.apache.batik.util.ParsedURL;
129 import org.apache.batik.util.Service;
130 import org.apache.batik.util.SVGConstants;
131 import org.apache.batik.util.XMLConstants;
132 import org.apache.batik.util.gui.DOMViewer;
133 import org.apache.batik.util.gui.JErrorPane;
134 import org.apache.batik.util.gui.LocationBar;
135 import org.apache.batik.util.gui.MemoryMonitor;
136 import org.apache.batik.util.gui.URIChooser;
137 import org.apache.batik.util.gui.resource.ActionMap;
138 import org.apache.batik.util.gui.resource.JComponentModifier;
139 import org.apache.batik.util.gui.resource.MenuFactory;
140 import org.apache.batik.util.gui.resource.MissingListenerException;
141 import org.apache.batik.util.gui.resource.ResourceManager;
142 import org.apache.batik.util.gui.resource.ToolBarFactory;
143 import org.apache.batik.xml.XMLUtilities;
144 import org.mozilla.javascript.Context;
145 import org.mozilla.javascript.ContextListener;
146 import org.w3c.dom.Element JavaDoc;
147 import org.w3c.dom.Node JavaDoc;
148 import org.w3c.dom.css.ViewCSS;
149 import org.w3c.dom.svg.SVGDocument;
150
151 /**
152  * This class represents a SVG viewer swing frame.
153  *
154  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
155  * @version $Id: JSVGViewerFrame.java,v 1.109 2005/03/29 10:48:01 deweese Exp $
156  */

157 public class JSVGViewerFrame
158     extends JFrame JavaDoc
159     implements ActionMap,
160                SVGDocumentLoaderListener,
161                GVTTreeBuilderListener,
162                SVGLoadEventDispatcherListener,
163                GVTTreeRendererListener,
164                LinkActivationListener,
165                UpdateManagerListener {
166
167     static private String JavaDoc EOL;
168     static {
169         String JavaDoc temp;
170         try { temp = System.getProperty ("line.separator", "\n"); }
171         catch (SecurityException JavaDoc e) { temp = "\n"; }
172         EOL = temp;
173     }
174
175     /**
176      * Kind of ugly, but we need to know if we are running before
177      * or after 1.4...
178      */

179     protected static boolean priorJDK1_4 = true;
180
181     /**
182      * If the following class can be found (it appeared in JDK 1.4),
183      * then we know we are post JDK 1.4.
184      */

185     protected static final String JavaDoc JDK_1_4_PRESENCE_TEST_CLASS
186         = "java.util.logging.LoggingPermission";
187
188     static {
189         Class JavaDoc cl = null;
190         try {
191             cl = Class.forName(JDK_1_4_PRESENCE_TEST_CLASS);
192         } catch (ClassNotFoundException JavaDoc e){
193         }
194
195         if (cl != null) {
196             priorJDK1_4 = false;
197         }
198     }
199
200     static JFrame JavaDoc debuggerFrame = null;
201     static Class JavaDoc debuggerClass = null;
202     static Method JavaDoc clearAllBreakpoints = null;
203     static Method JavaDoc scriptGo = null;
204     static Method JavaDoc setExitAction = null;
205     static {
206         try {
207             debuggerClass = JSVGViewerFrame.class.getClassLoader().loadClass
208                 ("org.mozilla.javascript.tools.debugger.Main");
209             clearAllBreakpoints = debuggerClass.getMethod
210                 ("clearAllBreakpoints", null);
211             scriptGo = debuggerClass.getMethod
212                 ("go", null);
213             setExitAction = debuggerClass.getMethod
214                 ("setExitAction", new Class JavaDoc[] {Runnable JavaDoc.class});
215         } catch (ThreadDeath JavaDoc td) {
216             debuggerClass = null;
217             clearAllBreakpoints = null;
218             scriptGo = null;
219             setExitAction = null;
220             throw td;
221         } catch (Throwable JavaDoc t) {
222             debuggerClass = null;
223             clearAllBreakpoints = null;
224             scriptGo = null;
225             setExitAction = null;
226         }
227     }
228
229     public static void showDebugger() {
230         if (debuggerClass == null) return;
231         if (debuggerFrame == null) {
232             try {
233                 Constructor JavaDoc c = debuggerClass.getConstructor
234                     (new Class JavaDoc [] { String JavaDoc.class });
235                 debuggerFrame = (JFrame JavaDoc)c.newInstance
236                     (new Object JavaDoc[] { "Rhino JavaScript Debugger" });
237                 // Customize the menubar a bit, disable menu
238
// items that can't be used and change 'Exit' to 'Close'.
239
JMenuBar JavaDoc menuBar = debuggerFrame.getJMenuBar();
240                 JMenu JavaDoc menu = menuBar.getMenu(0);
241                 menu.getItem(0).setEnabled(false); // Open...
242
menu.getItem(1).setEnabled(false); // Run...
243
menu.getItem(3).setText
244                     (Resources.getString("Close.text")); // Exit -> "Close"
245
menu.getItem(3).setAccelerator
246                     (KeyStroke.getKeyStroke(KeyEvent.VK_W, Event.CTRL_MASK));
247
248                 debuggerFrame.setSize(600, 460);
249                 debuggerFrame.pack();
250                 WindowAdapter JavaDoc wa = new WindowAdapter JavaDoc() {
251                         public void windowClosing(WindowEvent JavaDoc e) {
252                             hideDebugger();
253                         }};
254                 setExitAction.invoke(debuggerFrame,
255                                      new Object JavaDoc [] { new Runnable JavaDoc() {
256                                              public void run() {
257                                                  hideDebugger();
258                                              }}});
259                 debuggerFrame.addWindowListener(wa);
260             } catch (Exception JavaDoc ex) {
261                 ex.printStackTrace();
262                 return;
263             }
264         }
265         if (debuggerFrame != null) {
266             debuggerFrame.setVisible(true);
267             Context.addContextListener((ContextListener)debuggerFrame);
268         }
269     }
270
271     public static void hideDebugger() {
272         if (debuggerFrame == null)
273             return;
274         Context.removeContextListener((ContextListener)debuggerFrame);
275         debuggerFrame.setVisible(false);
276         try {
277             clearAllBreakpoints.invoke(debuggerFrame, null);
278             scriptGo.invoke(debuggerFrame, null);
279         } catch (Exception JavaDoc ex) {
280             ex.printStackTrace();
281         }
282     }
283
284     /**
285      * The gui resources file name
286      */

287     public final static String JavaDoc RESOURCES =
288         "org.apache.batik.apps.svgbrowser.resources.GUI";
289
290     // The actions names.
291
public final static String JavaDoc ABOUT_ACTION = "AboutAction";
292     public final static String JavaDoc OPEN_ACTION = "OpenAction";
293     public final static String JavaDoc OPEN_LOCATION_ACTION = "OpenLocationAction";
294     public final static String JavaDoc NEW_WINDOW_ACTION = "NewWindowAction";
295     public final static String JavaDoc RELOAD_ACTION = "ReloadAction";
296     public final static String JavaDoc SAVE_AS_ACTION = "SaveAsAction";
297     public final static String JavaDoc BACK_ACTION = "BackAction";
298     public final static String JavaDoc FORWARD_ACTION = "ForwardAction";
299     public final static String JavaDoc FULL_SCREEN_ACTION = "FullScreenAction";
300     public final static String JavaDoc PRINT_ACTION = "PrintAction";
301     public final static String JavaDoc EXPORT_AS_JPG_ACTION = "ExportAsJPGAction";
302     public final static String JavaDoc EXPORT_AS_PNG_ACTION = "ExportAsPNGAction";
303     public final static String JavaDoc EXPORT_AS_TIFF_ACTION = "ExportAsTIFFAction";
304     public final static String JavaDoc PREFERENCES_ACTION = "PreferencesAction";
305     public final static String JavaDoc CLOSE_ACTION = "CloseAction";
306     public final static String JavaDoc VIEW_SOURCE_ACTION = "ViewSourceAction";
307     public final static String JavaDoc EXIT_ACTION = "ExitAction";
308     public final static String JavaDoc RESET_TRANSFORM_ACTION = "ResetTransformAction";
309     public final static String JavaDoc ZOOM_IN_ACTION = "ZoomInAction";
310     public final static String JavaDoc ZOOM_OUT_ACTION = "ZoomOutAction";
311     public final static String JavaDoc PREVIOUS_TRANSFORM_ACTION = "PreviousTransformAction";
312     public final static String JavaDoc NEXT_TRANSFORM_ACTION = "NextTransformAction";
313     public final static String JavaDoc USE_STYLESHEET_ACTION = "UseStylesheetAction";
314     public final static String JavaDoc PLAY_ACTION = "PlayAction";
315     public final static String JavaDoc PAUSE_ACTION = "PauseAction";
316     public final static String JavaDoc STOP_ACTION = "StopAction";
317     public final static String JavaDoc MONITOR_ACTION = "MonitorAction";
318     public final static String JavaDoc DOM_VIEWER_ACTION = "DOMViewerAction";
319     public final static String JavaDoc SET_TRANSFORM_ACTION = "SetTransformAction";
320     public final static String JavaDoc FIND_DIALOG_ACTION = "FindDialogAction";
321     public final static String JavaDoc THUMBNAIL_DIALOG_ACTION = "ThumbnailDialogAction";
322     public final static String JavaDoc FLUSH_ACTION = "FlushAction";
323     public final static String JavaDoc TOGGLE_DEBUGGER_ACTION = "ToggleDebuggerAction";
324
325     /**
326      * The cursor indicating that an operation is pending.
327      */

328     public final static Cursor JavaDoc WAIT_CURSOR =
329         new Cursor JavaDoc(Cursor.WAIT_CURSOR);
330
331     /**
332      * The default cursor.
333      */

334     public final static Cursor JavaDoc DEFAULT_CURSOR =
335         new Cursor JavaDoc(Cursor.DEFAULT_CURSOR);
336
337     /**
338      * Name for the os-name property
339      */

340     public final static String JavaDoc PROPERTY_OS_NAME
341         = Resources.getString("JSVGViewerFrame.property.os.name");
342
343     /**
344      * Name for the os.name default
345      */

346     public final static String JavaDoc PROPERTY_OS_NAME_DEFAULT
347         = Resources.getString("JSVGViewerFrame.property.os.name.default");
348
349     /**
350      * Name for the os.name property prefix we are looking
351      * for in OpenAction to work around JFileChooser bug
352      */

353     public final static String JavaDoc PROPERTY_OS_WINDOWS_PREFIX
354         = Resources.getString("JSVGViewerFrame.property.os.windows.prefix");
355
356     /**
357      * The input handlers
358      */

359     protected static Vector JavaDoc handlers;
360
361     /**
362      * The default input handler
363      */

364     protected static SquiggleInputHandler defaultHandler = new SVGInputHandler();
365
366     /**
367      * The resource bundle
368      */

369     protected static ResourceBundle JavaDoc bundle;
370
371     /**
372      * The resource manager
373      */

374     protected static ResourceManager resources;
375     static {
376         bundle = ResourceBundle.getBundle(RESOURCES, Locale.getDefault());
377         resources = new ResourceManager(bundle);
378     }
379
380     /**
381      * The current application.
382      */

383     protected Application application;
384
385     /**
386      * The JSVGCanvas.
387      */

388     protected JSVGCanvas svgCanvas;
389
390     /**
391      * The panel where the svgCanvas is displayed
392      */

393     protected JPanel JavaDoc svgCanvasPanel;
394
395     /**
396      * A window used for full screen display
397      */

398     protected JWindow JavaDoc window;
399
400     /**
401      * The memory monitor frame.
402      */

403     protected static JFrame JavaDoc memoryMonitorFrame;
404
405     /**
406      * The current path.
407      */

408     protected File JavaDoc currentPath = new File JavaDoc("");
409
410     /**
411      * The current export path.
412      */

413     protected File JavaDoc currentSavePath = new File JavaDoc("");
414
415     /**
416      * The back action
417      */

418     protected BackAction backAction = new BackAction();
419
420     /**
421      * The forward action
422      */

423     protected ForwardAction forwardAction = new ForwardAction();
424
425     /**
426      * The play action
427      */

428     protected PlayAction playAction = new PlayAction();
429
430     /**
431      * The pause action
432      */

433     protected PauseAction pauseAction = new PauseAction();
434
435     /**
436      * The stop action
437      */

438     protected StopAction stopAction = new StopAction();
439
440     /**
441      * The previous transform action
442      */

443     protected PreviousTransformAction previousTransformAction =
444         new PreviousTransformAction();
445
446     /**
447      * The next transform action
448      */

449     protected NextTransformAction nextTransformAction =
450         new NextTransformAction();
451
452     /**
453      * The use (author) stylesheet action
454      */

455     protected UseStylesheetAction useStylesheetAction =
456         new UseStylesheetAction();
457
458     /**
459      * The debug flag.
460      */

461     protected boolean debug;
462
463     /**
464      * The auto adjust flag.
465      */

466     protected boolean autoAdjust = true;
467
468     /**
469      * Whether the update manager was stopped.
470      */

471     protected boolean managerStopped;
472
473     /**
474      * The SVG user agent.
475      */

476     protected SVGUserAgent userAgent = new UserAgent();
477
478     /**
479      * The current document.
480      */

481     protected SVGDocument svgDocument;
482
483     /**
484      * The URI chooser.
485      */

486     protected URIChooser uriChooser;
487
488     /**
489      * The DOM viewer.
490      */

491     protected DOMViewer domViewer;
492
493     /**
494      * The Find dialog.
495      */

496     protected FindDialog findDialog;
497
498     /**
499      * The Find dialog.
500      */

501     protected ThumbnailDialog thumbnailDialog;
502
503     /**
504      * The transform dialog
505      */

506     protected JAffineTransformChooser.Dialog transformDialog;
507
508     /**
509      * The location bar.
510      */

511     protected LocationBar locationBar;
512
513     /**
514      * The status bar.
515      */

516     protected StatusBar statusBar;
517
518     /**
519      * The initial frame title.
520      */

521     protected String JavaDoc title;
522
523     /**
524      * The local history.
525      */

526     protected LocalHistory localHistory;
527
528     /**
529      * The transform history.
530      */

531     protected TransformHistory transformHistory = new TransformHistory();
532
533     /**
534      * The alternate style-sheet title.
535      */

536     protected String JavaDoc alternateStyleSheet;
537
538     /**
539      * Creates a new SVG viewer frame.
540      */

541     public JSVGViewerFrame(Application app) {
542         application = app;
543
544         addWindowListener(new WindowAdapter JavaDoc() {
545             public void windowClosing(WindowEvent JavaDoc e) {
546                 application.closeJSVGViewerFrame(JSVGViewerFrame.this);
547             }
548         });
549
550         //
551
// Set the frame's maximum size so that content
552
// bigger than the screen does not cause the creation
553
// of unnecessary large images.
554
//
555
svgCanvas = new JSVGCanvas(userAgent, true, true){
556                 Dimension JavaDoc screenSize;
557                 
558                 {
559                     screenSize = Toolkit.getDefaultToolkit().getScreenSize();
560                     setMaximumSize(screenSize);
561                 }
562                 
563                 public Dimension JavaDoc getPreferredSize(){
564                     Dimension JavaDoc s = super.getPreferredSize();
565                     if (s.width > screenSize.width) s.width =screenSize.width;
566                     if (s.height > screenSize.height) s.height = screenSize.height;
567                     return s;
568                 }
569
570                 
571                 /**
572                  * This method is called when the component knows the desired
573                  * size of the window (based on width/height of outermost SVG
574                  * element). We override it to immediately pack this frame.
575                  */

576                 public void setMySize(Dimension JavaDoc d) {
577                     setPreferredSize(d);
578                     invalidate();
579                     if (JSVGViewerFrame.this.autoAdjust) {
580                         JSVGViewerFrame.this.pack();
581                     }
582                 }
583
584                 public void setDisableInteractions(boolean b) {
585                     super.setDisableInteractions(b);
586
587                     // Disable/Enable all our different ways to adjust the
588
// rendering transform (menus, toolbar, thumbnail, keyboard).
589

590                     ((Action JavaDoc)listeners.get(SET_TRANSFORM_ACTION)) .setEnabled(!b);
591
592                     if (thumbnailDialog != null)
593                         thumbnailDialog.setInteractionEnabled(!b);
594                 }
595             };
596         
597         javax.swing.ActionMap JavaDoc map = svgCanvas.getActionMap();
598         map.put(FULL_SCREEN_ACTION, new FullScreenAction());
599         javax.swing.InputMap JavaDoc imap = svgCanvas.getInputMap(JComponent.WHEN_FOCUSED);
600         KeyStroke JavaDoc key = KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0);
601         imap.put(key, FULL_SCREEN_ACTION);
602
603         svgCanvas.setDoubleBufferedRendering(true);
604
605         listeners.put(ABOUT_ACTION, new AboutAction());
606         listeners.put(OPEN_ACTION, new OpenAction());
607         listeners.put(OPEN_LOCATION_ACTION, new OpenLocationAction());
608         listeners.put(NEW_WINDOW_ACTION, new NewWindowAction());
609         listeners.put(RELOAD_ACTION, new ReloadAction());
610         listeners.put(SAVE_AS_ACTION, new SaveAsAction());
611         listeners.put(BACK_ACTION, backAction);
612         listeners.put(FORWARD_ACTION, forwardAction);
613         listeners.put(PRINT_ACTION, new PrintAction());
614         listeners.put(EXPORT_AS_JPG_ACTION, new ExportAsJPGAction());
615         listeners.put(EXPORT_AS_PNG_ACTION, new ExportAsPNGAction());
616         listeners.put(EXPORT_AS_TIFF_ACTION, new ExportAsTIFFAction());
617         listeners.put(PREFERENCES_ACTION, new PreferencesAction());
618         listeners.put(CLOSE_ACTION, new CloseAction());
619         listeners.put(EXIT_ACTION, application.createExitAction(this));
620         listeners.put(VIEW_SOURCE_ACTION, new ViewSourceAction());
621
622         javax.swing.ActionMap JavaDoc cMap = svgCanvas.getActionMap();
623         listeners.put(RESET_TRANSFORM_ACTION,
624                       cMap.get(JSVGCanvas.RESET_TRANSFORM_ACTION));
625         listeners.put(ZOOM_IN_ACTION,
626                       cMap.get(JSVGCanvas.ZOOM_IN_ACTION));
627         listeners.put(ZOOM_OUT_ACTION,
628                       cMap.get(JSVGCanvas.ZOOM_OUT_ACTION));
629
630         listeners.put(PREVIOUS_TRANSFORM_ACTION, previousTransformAction);
631         key = KeyStroke.getKeyStroke(KeyEvent.VK_K, KeyEvent.CTRL_MASK);
632         imap.put(key, previousTransformAction);
633
634         listeners.put(NEXT_TRANSFORM_ACTION, nextTransformAction);
635         key = KeyStroke.getKeyStroke(KeyEvent.VK_L, KeyEvent.CTRL_MASK);
636         imap.put(key, nextTransformAction);
637
638         listeners.put(USE_STYLESHEET_ACTION, useStylesheetAction);
639         listeners.put(PLAY_ACTION, playAction);
640         listeners.put(PAUSE_ACTION, pauseAction);
641         listeners.put(STOP_ACTION, stopAction);
642         listeners.put(MONITOR_ACTION, new MonitorAction());
643         listeners.put(DOM_VIEWER_ACTION, new DOMViewerAction());
644         listeners.put(SET_TRANSFORM_ACTION, new SetTransformAction());
645         listeners.put(FIND_DIALOG_ACTION, new FindDialogAction());
646         listeners.put(THUMBNAIL_DIALOG_ACTION, new ThumbnailDialogAction());
647         listeners.put(FLUSH_ACTION, new FlushAction());
648         listeners.put(TOGGLE_DEBUGGER_ACTION, new ToggleDebuggerAction());
649
650         JPanel JavaDoc p = null;
651         try {
652             // Create the menu
653
MenuFactory mf = new MenuFactory(bundle, this);
654             JMenuBar JavaDoc mb = mf.createJMenuBar("MenuBar");
655             setJMenuBar(mb);
656
657             localHistory = new LocalHistory(mb, this);
658
659             String JavaDoc uri[] = application.getVisitedURIs();
660             for (int i=0; i<uri.length; i++) {
661                 if (uri[i] != null && !"".equals(uri[i])) {
662                     localHistory.update(uri[i]);
663                 }
664             }
665             p = new JPanel JavaDoc(new BorderLayout JavaDoc());
666
667             // Create the toolbar
668
ToolBarFactory tbf = new ToolBarFactory(bundle, this);
669             JToolBar JavaDoc tb = tbf.createJToolBar("ToolBar");
670             tb.setFloatable(false);
671             getContentPane().add(p, BorderLayout.NORTH);
672             p.add(tb, BorderLayout.NORTH);
673             p.add(new javax.swing.JSeparator JavaDoc(), BorderLayout.CENTER);
674             p.add(locationBar = new LocationBar(), BorderLayout.SOUTH);
675
676         } catch (MissingResourceException JavaDoc e) {
677             System.out.println(e.getMessage());
678             System.exit(0);
679         }
680
681         svgCanvasPanel = new JPanel JavaDoc(new BorderLayout JavaDoc());
682         svgCanvasPanel.setBorder(BorderFactory.createEtchedBorder());
683
684         svgCanvasPanel.add(svgCanvas, BorderLayout.CENTER);
685         p = new JPanel JavaDoc(new BorderLayout JavaDoc());
686         p.add(svgCanvasPanel, BorderLayout.CENTER);
687         p.add(statusBar = new StatusBar(), BorderLayout.SOUTH);
688
689         getContentPane().add(p, BorderLayout.CENTER);
690
691         svgCanvas.addSVGDocumentLoaderListener(this);
692         svgCanvas.addGVTTreeBuilderListener(this);
693         svgCanvas.addSVGLoadEventDispatcherListener(this);
694         svgCanvas.addGVTTreeRendererListener(this);
695         svgCanvas.addLinkActivationListener(this);
696         svgCanvas.addUpdateManagerListener(this);
697
698         svgCanvas.addMouseMotionListener(new MouseMotionAdapter JavaDoc() {
699      &nbs