In fact, I think my problem is quite different but the idea is here.
 
As you know, the loadSVGDocument method takes an URL argument.
 
But I can't give it an URL because I have generated a SVGDocment in my program.
 
I just want to put this SVGDocument in my JSVGCanvas but I wasn't be able to.
 
I tried the setSVGDocument and so on... but without success.
 
That is why I suggest to redefine a subclass of JSCGCanvas and overwrite the paint mathod but I am not sure of the results.
 
I would to use a JSVGCanvas to make easier manipulations in the future.
 
Thanks for all.
 
-----Message d'origine-----
De : Jon Burgin <[EMAIL PROTECTED]>
À : 'Batik Users' <[EMAIL PROTECTED]>
Date : vendredi 12 avril 2002 16:10
Objet : RE: JSVGCanvas

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 database.
 
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) {
        stopProcessing();
 
        URL oldURI = null;
        if (svgDocument != null) {
            oldURI = ((SVGOMDocument)svgDocument).getURLObject();
        }
        URL newURI = null;
        try {
            newURI = new URL(oldURI, url);
        } catch (MalformedURLException e) {
            userAgent.displayError(e);
            return;
        }
        url = newURI.toString();
        fragmentIdentifier = newURI.getRef();
 
    //Next Line is OBSI Modification
        loader = new DBDocumentLoader(userAgent);
        nextDocumentLoader = new SVGDocumentLoader(url, loader);
        nextDocumentLoader.setPriority(Thread.MIN_PRIORITY);
 
        Iterator it = svgDocumentLoaderListeners.iterator();
        while (it.hasNext()) {
            nextDocumentLoader.addSVGDocumentLoaderListener
                ((SVGDocumentLoaderListener)it.next());
        }
 
        if (documentLoader == null &&
            gvtTreeBuilder == null &&
            gvtTreeRenderer == null) {
            startDocumentLoader();
        }
    }
 
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!
JON
-----Original Message-----
From: Yohann LIGOUT [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 12, 2002 9:13 AM
To: [EMAIL PROTECTED]
Subject: JSVGCanvas

I succeed in loading a  SVG file in a JSVGCanvas with the loadSVGDocument method.
 
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?
 
Thanks.

Reply via email to