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:58:17 GMT
Good!  This should work fine for you, with the document loader that I wrote
I am (currently) ignoring the URL. That could work for you, or you could use
the URL to pass some information for presenting your generated code, such as
translation or transformation.  Just make sure that the URL is well formed.

Also, have your DocumentLoader send an inputstream and not a Reader.  as

    Document document = documentFactory
            new FileInputStream("c:\\Frame_00001_0805.svg"));
If you send a Reader, you have to setup the content type somewhere, I don't
know how to do that.

-----Original Message-----
From: Yohann LIGOUT [mailto:yohann.ligout@unilog.fr]
Sent: Friday, April 12, 2002 9:57 AM
To: Batik Users
Subject: Re: JSVGCanvas

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
I just want to put this SVGDocument in my JSVGCanvas but I wasn't be able
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 < jburgin@onboard-software.com
<mailto:jburgin@onboard-software.com> >
À : 'Batik Users' < batik-users@xml.apache.org
<mailto:batik-users@xml.apache.org> >
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

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