Hi Julien,

  You should be able to load the document, and subsequently calculate
a bbox without actually rendering the document.

Try some sequence like...

        InputStream templateStream =
MyClass.class.getResourceAsStream("mysvg.svg"); //
        String parser = XMLResourceDescriptor.getXMLParserClassName();
        SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
        SVGDocument doc = null;

        try {
            doc = f.createSVGDocument(null, templateStream);
        } catch (IOException ex) {
        } finally {
        }

        NodeList rects = doc.getElementsByTagName("rect");

       SVGRect bbox = null;

       for(int i = 0;i < rects.getLength();i++) {
            bbox = ((SVGLocatable)rects[i]).getBbox();
            //transforms, etc if needed
       }


On Fri, Oct 29, 2010 at 4:08 AM, Julien Beghin <[email protected]> wrote:
> Hi Batik World !
>
> We are working on a server-side SVG generator : The are getting an XML file,
> and we are converting its data to SVG.
> The main part of the process is done and is OK, but we are facing a problem
> of bounded box.
>
> Our problem is that we have to sort "rectangles" by size in order to put the
> bigger items first in the generated SVG (so in the background of displayed
> SVG) and the smallests at the end of the list( on the top of the SVG)?
> This sort is done so that we can select all our rectangles.
>
>
> So now the difficult part for us is to do this sort without rendering the
> SVG, and consequently without getting their Bounded Boxes ?
>
> Do any of you have already done something like this ?
>
> Can you give some advice or orientations on the way this is possible ?
>
>
>
> Thanks and Regards,
>
> Julien
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to