hillion 02/01/11 02:49:32 Modified: sources/org/apache/batik/apps/svgbrowser JSVGViewerFrame.java sources/org/apache/batik/swing/svg JSVGComponent.java Log: The UpdateManagerListeners added to a JSVGComponent are now called from the AWT thread. Revision Changes Path 1.69 +23 -39 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.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- JSVGViewerFrame.java 21 Dec 2001 14:40:31 -0000 1.68 +++ JSVGViewerFrame.java 11 Jan 2002 10:49:31 -0000 1.69 @@ -159,7 +159,7 @@ * This class represents a SVG viewer swing frame. * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: JSVGViewerFrame.java,v 1.68 2001/12/21 14:40:31 hillion Exp $ + * @version $Id: JSVGViewerFrame.java,v 1.69 2002/01/11 10:49:31 hillion Exp $ */ public class JSVGViewerFrame extends JFrame @@ -1759,62 +1759,46 @@ * Called when the manager was started. */ public void managerStarted(UpdateManagerEvent e) { - EventQueue.invokeLater(new Runnable() { - public void run() { - if (debug) { - System.out.println("Manager Started"); - } - playAction.update(false); - pauseAction.update(true); - stopAction.update(true); - } - }); + if (debug) { + System.out.println("Manager Started"); + } + playAction.update(false); + pauseAction.update(true); + stopAction.update(true); } /** * Called when the manager was suspended. */ public void managerSuspended(UpdateManagerEvent e) { - EventQueue.invokeLater(new Runnable() { - public void run() { - if (debug) { - System.out.println("Manager Suspended"); - } - playAction.update(true); - pauseAction.update(false); - } - }); + if (debug) { + System.out.println("Manager Suspended"); + } + playAction.update(true); + pauseAction.update(false); } /** * Called when the manager was resumed. */ public void managerResumed(UpdateManagerEvent e) { - EventQueue.invokeLater(new Runnable() { - public void run() { - if (debug) { - System.out.println("Manager Resumed"); - } - playAction.update(false); - pauseAction.update(true); - } - }); + if (debug) { + System.out.println("Manager Resumed"); + } + playAction.update(false); + pauseAction.update(true); } /** * Called when the manager was stopped. */ public void managerStopped(UpdateManagerEvent e) { - EventQueue.invokeLater(new Runnable() { - public void run() { - if (debug) { - System.out.println("Manager Stopped"); - } - playAction.update(false); - pauseAction.update(false); - stopAction.update(false); - } - }); + if (debug) { + System.out.println("Manager Stopped"); + } + playAction.update(false); + pauseAction.update(false); + stopAction.update(false); } /** 1.35 +99 -3 xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java Index: JSVGComponent.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/svg/JSVGComponent.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- JSVGComponent.java 11 Jan 2002 08:57:25 -0000 1.34 +++ JSVGComponent.java 11 Jan 2002 10:49:32 -0000 1.35 @@ -157,7 +157,7 @@ * building/rendering a document (invalid XML file, missing attributes...).</p> * * @author <a href="mailto:[EMAIL PROTECTED]">Stephane Hillion</a> - * @version $Id: JSVGComponent.java,v 1.34 2002/01/11 08:57:25 hillion Exp $ + * @version $Id: JSVGComponent.java,v 1.35 2002/01/11 10:49:32 hillion Exp $ */ public class JSVGComponent extends JGVTComponent { @@ -265,7 +265,7 @@ addSVGDocumentLoaderListener((SVGListener)listener); addGVTTreeBuilderListener((SVGListener)listener); - addUpdateManagerListener((SVGListener)listener); + updateManagerListeners.add(listener); } /** @@ -562,7 +562,7 @@ * Adds a UpdateManagerListener to this component. */ public void addUpdateManagerListener(UpdateManagerListener l) { - updateManagerListeners.add(l); + updateManagerListeners.add(new UpdateManagerListenerWrapper(l)); } /** @@ -570,6 +570,102 @@ */ public void removeUpdateManagerListener(UpdateManagerListener l) { updateManagerListeners.remove(l); + } + + /** + * To call the update methods from the event thread. + */ + protected static class UpdateManagerListenerWrapper + implements UpdateManagerListener { + + /** + * The wrapped listener. + */ + protected UpdateManagerListener listener; + + /** + * Creates a new wrapper. + */ + public UpdateManagerListenerWrapper(UpdateManagerListener l) { + listener = l; + } + + /** + * Called when the manager was started. + */ + public void managerStarted(final UpdateManagerEvent e) { + EventQueue.invokeLater(new Runnable() { + public void run() { + listener.managerStarted(e); + } + }); + } + + /** + * Called when the manager was suspended. + */ + public void managerSuspended(final UpdateManagerEvent e) { + EventQueue.invokeLater(new Runnable() { + public void run() { + listener.managerSuspended(e); + } + }); + } + + /** + * Called when the manager was resumed. + */ + public void managerResumed(final UpdateManagerEvent e) { + EventQueue.invokeLater(new Runnable() { + public void run() { + listener.managerResumed(e); + } + }); + } + + /** + * Called when the manager was stopped. + */ + public void managerStopped(final UpdateManagerEvent e) { + EventQueue.invokeLater(new Runnable() { + public void run() { + listener.managerStopped(e); + } + }); + } + + /** + * Called when an update started. + */ + public void updateStarted(final UpdateManagerEvent e) { + EventQueue.invokeLater(new Runnable() { + public void run() { + listener.updateStarted(e); + } + }); + } + + /** + * Called when an update was completed. + */ + public void updateCompleted(final UpdateManagerEvent e) { + EventQueue.invokeLater(new Runnable() { + public void run() { + listener.updateCompleted(e); + } + }); + } + + /** + * Called when an update failed. + */ + public void updateFailed(final UpdateManagerEvent e) { + EventQueue.invokeLater(new Runnable() { + public void run() { + listener.updateFailed(e); + } + }); + } } /**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]