You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Danh Hoai <ho...@indent.org> on 2002/05/28 15:24:34 UTC

problem of using method setURI of JSVGCanvas

Hi all,

I am trying to use the method setURI from JSVGCanvas, but I can not get it
to work.  Please look at source code below and point out what I am doing
wrong.
It seems to be a thread problem.  For instance, if I move the
add(m_JSVGCanvas) and showFrame outside the
addSVGLoadEventDispatcherListener, the svg file is rendered.
However, the SVGDocument is null when I try to access it from
JSVGCanvas.getSVGDocument.

Thank you for your help.

Danh Hoai

 public EndApplication(){
            super("SVG Testing");
 try
 {

            m_JSVGCanvas = new JSVGCanvas();
            String fileName = "F:\\svg_collab\\html\\svg\\test.svg";
            getSVGFile(fileName); /* get svg file */

            m_JSVGCanvas.addSVGLoadEventDispatcherListener
            (new SVGLoadEventDispatcherAdapter() {
                    public void svgLoadEventDispatchStarted
                        (SVGLoadEventDispatcherEvent e) {
                        // At this time the document is available...
                        //getApplicationFrame() returns a JFrame

getApplicationFrame().frame.getContentPane().add(m_JSVGCanvas);
                        getApplicationFrame().showFrame(); //get current
JFrame and then use method show()
                    }

            }

            );

}
}

        public SVGDocument getSVGFile(String fileName)
        {
            SVGOMDocument svgDoc = null;


            m_JSVGCanvas.setDocumentState(new
JSVGComponent().ALWAYS_DYNAMIC);
            File file = new File(fileName);

            try
            {
                m_JSVGCanvas.setURI(file.toURL().toString());

            }
            catch (IOException ex)
            {
                 System.out.println("error: ");
                 ex.printStackTrace();
            }
        }



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


RE: problem of using method setURI of JSVGCanvas

Posted by Thierry Kormann <tk...@ilog.fr>.
> I am trying to use the method setURI from JSVGCanvas, but I can not get it
> to work.  Please look at source code below and point out what I am doing
> wrong.
> It seems to be a thread problem.  For instance, if I move the
> add(m_JSVGCanvas) and showFrame outside the
> addSVGLoadEventDispatcherListener, the svg file is rendered.
> However, the SVGDocument is null when I try to access it from
> JSVGCanvas.getSVGDocument.

Please have a look at how the example in our tutorial works:

http://xml.apache.org/batik/svgcanvas.html

Hope that will help,
Thierry.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org