xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Burgin <jbur...@onboard-software.com>
Subject RE: JSVGCanvas
Date Fri, 12 Apr 2002 14:21:04 GMT
I have had a similar problem, in that I have to retrieve the svg data from a
local database (that is non-networked). So anyhow,
I created my own class DBDocumentLoader that extends
..batik.bridge.DocumentLoader. That retrieves the information from a
Then I extended JSVGCanvas and overloaded the loadSVGDocuement(..) function
Like below.
My change is the "//Next Line is OBSI Modification" otherwise it is like the
original code in the latest official release.

     * Loads a SVG document from the database, according to the URL
     * <em>Note: Because the loading is multi-threaded, the current
     * SVG document is not guaranteed to be updated after this method
     * returns. The only way to be notified a document has been loaded
     * is to listen to the <tt>SVGDocumentLoaderEvent</tt>s.</em>
    public void loadSVGDocument(String url) {
        URL oldURI = null;
        if (svgDocument != null) {
            oldURI = ((SVGOMDocument)svgDocument).getURLObject();
        URL newURI = null;
        try {
            newURI = new URL(oldURI, url);
        } catch (MalformedURLException e) {
        url = newURI.toString();
        fragmentIdentifier = newURI.getRef();
    //Next Line is OBSI Modification
        loader = new DBDocumentLoader(userAgent);
        nextDocumentLoader = new SVGDocumentLoader(url, loader);
        Iterator it = svgDocumentLoaderListeners.iterator();
        while (it.hasNext()) {

        if (documentLoader == null &&
            gvtTreeBuilder == null &&
            gvtTreeRenderer == null) {

BTW: Batik guys: Should the batik code read something like: if (loader ==
null) loader = new DocumentLoader(userAgent)
If it were written this way, I could just set the loader and not have to
overwrite this function. What do ya'll think?
Also note that guaranteed was spelled incorrectly.   :)
PS: I may be making this too complicated, but it worked.  If anyone knows
how to do it better, please let me know!

-----Original Message-----
From: Yohann LIGOUT [mailto:yohann.ligout@unilog.fr]
Sent: Friday, April 12, 2002 9:13 AM
To: batik-users@xml.apache.org
Subject: JSVGCanvas

I succeed in loading a  SVG file in a JSVGCanvas with the loadSVGDocument
But, how can I load a SVGDocument in a JSVGCanvas without a file but a
variable of this type?
Do I have to define a new class which inherits from JSVGCanvas and redefine
the paint method?

View raw message