Hello,

I would like to block and wait until the rendering of the SVG DOM is
completed. What is wrong with the following code? It blocks even if no
Swing thread is involved.

Thanks in advance for your help.

public class DeadLock {

        private static final String svgNS = 
SVGDOMImplementation.SVG_NAMESPACE_URI;

        /**
         * @param args
         */
        public static void main(String[] args) {
                final Object mutext = new Object();

                DOMImplementation impl = 
SVGDOMImplementation.getDOMImplementation();
                Document doc = impl.createDocument(svgNS, "svg", null);

                JSVGCanvas canvas = new JSVGCanvas();
                canvas.addGVTTreeRendererListener(new GVTTreeRendererAdapter() {
                        @Override
                        public void gvtRenderingCompleted(GVTTreeRendererEvent 
e) {
                                System.out.println("completed");
                                synchronized (mutext) {
                                        mutext.notifyAll();
                                }

                        }
                });

                synchronized (mutext) {
                        System.out.println("Loading document");
                        canvas.setDocument(doc);
                        System.out.println("Waiting for document to be 
loaded...");
                        try {
                                mutext.wait();
                                System.out.println("rendering finished");
                        } catch (InterruptedException ie) {
                                ie.printStackTrace();
                        }
                }
        }

}

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-h...@xmlgraphics.apache.org

Reply via email to