xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark A Fortner <phidia...@yahoo.com>
Subject Problem with Batik Applet
Date Mon, 26 Jun 2006 22:27:03 GMT
I wrote a small applet to render an SVG file.  However, it can't seem to render the file. 
When the applet appears it's blank.

I've debugged through it and there doesn't seem to be any problem.

When I create an application using the same code, the SVG image appears without any problem.

I Googled "batik applet" and saw references to an internally developed applet in the org.apache.batik.apps
package, but it no longer seems to exist.

I've tried both the canvas.setURI approach and the canvas.setDocument approach to no avail.

Here's the relevant code that I'm using:

String svgurl = this.getParameter("svg");
        
        canvas.setDoubleBufferedRendering(true);
        canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
        
        canvas.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter() {
            public void documentLoadingStarted(SVGDocumentLoaderEvent e) {
                System.out.println("Document Loading...");
            }

            public void documentLoadingCompleted(SVGDocumentLoaderEvent e) {
                System.out.println("Document Loaded.");
            }
        });
        
        canvas.addSVGLoadEventDispatcherListener
        (new SVGLoadEventDispatcherAdapter() {
                public void svgLoadEventDispatchStarted
                    (SVGLoadEventDispatcherEvent e) {
                    // At this time the document is available...
                    document = canvas.getSVGDocument();
                    // ...and the window object too.
                    window = canvas.getUpdateManager().
                        getScriptingEnvironment().createWindow();
                    // Registers the listeners on the document
                    // just before the SVGLoad event is
                    // dispatched.
                    registerListeners();
                    // It is time to pack the frame.
                    //frame.pack();
                }
            });
        
        if (svgurl != null && !svgurl.equals("")) {
            String parser = XMLResourceDescriptor.getXMLParserClassName();
            SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
            SVGDocument doc;
            try {
                doc = f.createSVGDocument(svgurl);
                canvas.setDocument(doc);
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            
            
          }
        
        //canvas.setURI(svgurl);
        

If anyone has any ideas, please let me know.

Regards,

Mark Fortner

Mime
View raw message