deweese 2005/02/12 05:04:08 Modified: resources/org/apache/batik/apps/svgbrowser/resources GUI.properties sources/org/apache/batik/apps/svgbrowser JSVGViewerFrame.java sources/org/apache/batik/dom/util SAXDocumentFactory.java Added: test-references/samples/tests/spec/scripting visibilityOnClick.png Log: 1) Squiggle browser now has a 'Save As' menu item. 2) Fixed a bug with comment parsering in SAX. Revision Changes Path 1.63 +11 -3 xml-batik/resources/org/apache/batik/apps/svgbrowser/resources/GUI.properties Index: GUI.properties =================================================================== RCS file: /home/cvs/xml-batik/resources/org/apache/batik/apps/svgbrowser/resources/GUI.properties,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- GUI.properties 23 Oct 2004 17:11:03 -0000 1.62 +++ GUI.properties 12 Feb 2005 13:04:08 -0000 1.63 @@ -54,6 +54,7 @@ Message.updateManagerSuspended = Update manager suspended... Message.updateManagerResumed = Update manager resumed... Message.updateManagerStopped = Update manager stopped... +Message.saveAs = Saving as SVG... Message.exportAsJPG = Exporting as JPG... Message.exportAsPNG = Exporting as PNG... Message.exportAsTIFF = Exporting as TIFF... @@ -61,6 +62,7 @@ # # Dialog Titles # +SaveAs.title = Save as SVG ExportAsJPG.title = Export as JPG ExportAsPNG.title = Export as PNG ExportAsTIFF.title = Export as TIFF @@ -73,7 +75,7 @@ MenuBar = File Edit View Processing Go Tools Help # File menu ################ -File = Open OpenLocation NewWindow Reload - \ +File = Open OpenLocation NewWindow Reload SaveAs - \ Print ExportAs - Close Exit File.type = MENU File.text = File @@ -107,6 +109,13 @@ Reload.action = ReloadAction Reload.accelerator = Ctrl+R +SaveAs.type = ITEM +SaveAs.text = Save SVG As +SaveAs.icon = resources/blank.gif +SaveAs.mnemonic = S +SaveAs.action = SaveAsAction +SaveAs.accelerator = Ctrl+S + Close.type = ITEM Close.text = Close Close.icon = resources/blank.gif @@ -283,7 +292,6 @@ Stop.icon = resources/stop.gif Stop.mnemonic = S Stop.action = StopAction -Stop.accelerator = Ctrl+S # Go menu ################ 1.106 +82 -8 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.105 retrieving revision 1.106 diff -u -r1.105 -r1.106 --- JSVGViewerFrame.java 30 Oct 2004 16:54:53 -0000 1.105 +++ JSVGViewerFrame.java 12 Feb 2005 13:04:08 -0000 1.106 @@ -22,6 +22,7 @@ import java.awt.Cursor; import java.awt.Dimension; import java.awt.Event; +import java.awt.EventQueue; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Rectangle; @@ -46,7 +47,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.io.Reader; +import java.io.Writer; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.MalformedURLException; @@ -92,11 +95,13 @@ import org.apache.batik.bridge.RelaxedExternalResourceSecurity; import org.apache.batik.bridge.RelaxedScriptSecurity; import org.apache.batik.bridge.ScriptSecurity; +import org.apache.batik.bridge.UpdateManager; import org.apache.batik.bridge.UpdateManagerEvent; import org.apache.batik.bridge.UpdateManagerListener; import org.apache.batik.dom.StyleSheetProcessingInstruction; import org.apache.batik.dom.svg.SVGOMDocument; import org.apache.batik.dom.util.HashTable; +import org.apache.batik.dom.util.DOMUtilities; import org.apache.batik.ext.swing.JAffineTransformChooser; import org.apache.batik.swing.JSVGCanvas; import org.apache.batik.swing.gvt.GVTTreeRendererEvent; @@ -276,6 +281,7 @@ public final static String OPEN_LOCATION_ACTION = "OpenLocationAction"; public final static String NEW_WINDOW_ACTION = "NewWindowAction"; public final static String RELOAD_ACTION = "ReloadAction"; + public final static String SAVE_AS_ACTION = "SaveAsAction"; public final static String BACK_ACTION = "BackAction"; public final static String FORWARD_ACTION = "ForwardAction"; public final static String FULL_SCREEN_ACTION = "FullScreenAction"; @@ -392,7 +398,7 @@ /** * The current export path. */ - protected File currentExportPath = new File(""); + protected File currentSavePath = new File(""); /** * The back action @@ -589,6 +595,7 @@ listeners.put(OPEN_LOCATION_ACTION, new OpenLocationAction()); listeners.put(NEW_WINDOW_ACTION, new NewWindowAction()); listeners.put(RELOAD_ACTION, new ReloadAction()); + listeners.put(SAVE_AS_ACTION, new SaveAsAction()); listeners.put(BACK_ACTION, backAction); listeners.put(FORWARD_ACTION, forwardAction); listeners.put(PRINT_ACTION, new PrintAction()); @@ -1229,13 +1236,80 @@ } /** + * To save the current document as SVG. + */ + public class SaveAsAction extends AbstractAction { + public SaveAsAction() {} + + public void actionPerformed(ActionEvent e) { + JFileChooser fileChooser; + fileChooser = new JFileChooser(makeAbsolute(currentSavePath)); + fileChooser.setDialogTitle(resources.getString("SaveAs.title")); + fileChooser.setFileHidingEnabled(false); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + fileChooser.addChoosableFileFilter(new ImageFileFilter(".svg")); + + int choice = fileChooser.showSaveDialog(JSVGViewerFrame.this); + if (choice != JFileChooser.APPROVE_OPTION) + return; + + final File f = fileChooser.getSelectedFile(); + final SVGDocument svgDoc = svgCanvas.getSVGDocument(); + if (svgDoc == null) return; + + statusBar.setMessage(resources.getString("Message.saveAs")); + currentSavePath = f; + Writer w = null; + try { + OutputStream tos = null; + tos = new FileOutputStream(f); + tos = new BufferedOutputStream(tos); + w = new OutputStreamWriter(tos); + } catch (Exception ex) { + userAgent.displayError(ex); + return; + } + + final Writer writer = w; + final Runnable doneRun = new Runnable() { + public void run() { + String doneStr = resources.getString("Message.done"); + statusBar.setMessage(doneStr); + } + }; + Runnable r = new Runnable() { + public void run() { + try { + DOMUtilities.writeDocument(svgDoc, writer); + writer.close(); + if (EventQueue.isDispatchThread()) { + doneRun.run(); + } else { + EventQueue.invokeLater(doneRun); + } + } catch (Exception ex) { + userAgent.displayError(ex); + } + } + }; + + UpdateManager um = svgCanvas.getUpdateManager(); + if ((um != null) && (um.isRunning())) { + um.getUpdateRunnableQueue().invokeLater(r); + } else { + r.run(); + } + } + } + + /** * To save the current document as JPG. */ public class ExportAsJPGAction extends AbstractAction { public ExportAsJPGAction() {} public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = - new JFileChooser(makeAbsolute(currentExportPath)); + new JFileChooser(makeAbsolute(currentSavePath)); fileChooser.setDialogTitle(resources.getString("ExportAsJPG.title")); fileChooser.setFileHidingEnabled(false); fileChooser.setFileSelectionMode @@ -1273,7 +1347,7 @@ new Thread() { public void run() { try { - currentExportPath = f; + currentSavePath = f; OutputStream ostream = new BufferedOutputStream(new FileOutputStream(f)); trans.writeImage(img, new TranscoderOutput(ostream)); @@ -1296,7 +1370,7 @@ public ExportAsPNGAction() {} public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = - new JFileChooser(makeAbsolute(currentExportPath)); + new JFileChooser(makeAbsolute(currentSavePath)); fileChooser.setDialogTitle(resources.getString("ExportAsPNG.title")); fileChooser.setFileHidingEnabled(false); fileChooser.setFileSelectionMode @@ -1341,7 +1415,7 @@ new Thread() { public void run() { try { - currentExportPath = f; + currentSavePath = f; OutputStream ostream = new BufferedOutputStream(new FileOutputStream(f)); trans.writeImage(img, @@ -1364,7 +1438,7 @@ public ExportAsTIFFAction() {} public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = - new JFileChooser(makeAbsolute(currentExportPath)); + new JFileChooser(makeAbsolute(currentSavePath)); fileChooser.setDialogTitle(resources.getString("ExportAsTIFF.title")); fileChooser.setFileHidingEnabled(false); fileChooser.setFileSelectionMode @@ -1394,7 +1468,7 @@ new Thread() { public void run() { try { - currentExportPath = f; + currentSavePath = f; OutputStream ostream = new BufferedOutputStream (new FileOutputStream(f)); trans.writeImage 1.26 +2 -1 xml-batik/sources/org/apache/batik/dom/util/SAXDocumentFactory.java Index: SAXDocumentFactory.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/util/SAXDocumentFactory.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- SAXDocumentFactory.java 12 Feb 2005 01:48:23 -0000 1.25 +++ SAXDocumentFactory.java 12 Feb 2005 13:04:08 -0000 1.26 @@ -721,6 +721,7 @@ */ public void comment(char ch[], int start, int length) throws SAXException { if (inDTD) return; + appendStringData(); String str = new String(ch, start, length); if (currentNode == null) { 1.1 xml-batik/test-references/samples/tests/spec/scripting/visibilityOnClick.png <<Binary file>>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]