xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: Parsing SVG and grouping actions
Date Sat, 12 Apr 2008 11:32:07 GMT
Hi Keywan,

Keywan Najafi Tonekaboni <me@prometoys.net> wrote on 04/08/2008 12:19:23 

> I work on a whiteboard for Jabber/XMPP. I use Batik and JSVGCanvas for
> the GUI. I found in another whiteboard implementation [1] (which is not
> using Batik) the class SVGUtil[2].
> This class is a parser for SVG and connected with the other classes
> doing the SVG, as far as I understand.
> My question: Is there a ready parser from Batik available, which I could
> use instead? 

   Yes and probably (yes there is a parser from Batik, and probably 
you should use it instead).  It depends a lot on what you are trying
to do.  Since SVG is based on XML the parser is really any XML parser,
the more important part is that the XML parser use the Batik SVG Document
implementation to build the document (otherwise we will clone the
document when you ask Batik to do anything with it).

   Our parser is org.apache.batik.dom.svg.SAXSVGDocumentFactory.

> I draw something on the canvas with this code:
>          svgG2D.draw(shape);
>          Element root = doc.getDocumentElement();
>          svgG2D.getRoot(root);

   You can use:
        Element group = doc.createElementNS(SVG_NS, "g");

> Can I group it somehow to one parent element, which I could append to my
> jabber messages and send it.. I recognised, that the above code created
> stanzas like this in the SVG-file:

    This will make the stanza a child of the created group.
Be aware that you need to append that group to the root
of it to also show up in the rendering:

View raw message