xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julien Beghin <minimoi1...@hotmail.com>
Subject RE: Getting BBox on non-graphic application
Date Sun, 31 Oct 2010 10:08:53 GMT

Hi Jonathan, Hi Thomas,
 
I'll try this on Tuesday ! As soon as I'll be able too modify my source code !
 
Thanks for the help !
 


To: batik-users@xmlgraphics.apache.org
CC: batik-users@xmlgraphics.apache.org
Subject: Re: Getting BBox on non-graphic application
From: thomas.deweese@kodak.com
Date: Sat, 30 Oct 2010 08:37:06 -0400

Hi Jonathan,  Julien, 

jonathan wood <jonathanshawwood@gmail.com> wrote on 10/29/2010 06:06:32 PM:

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

        Yes, this is close to what is needed but you need to "boot" 
the SVG and CSS DOM for the calls to getBBox to work. See the Wiki page: 

        http://wiki.apache.org/xmlgraphics-batik/BootSvgAndCssDom 

        I would do this after the createSVGDocument call. 

> 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 
> <minimoi1234@hotmail.com> wrote:
> > Hi Batik World !
> >
> > We are working on a server-side SVG generator : The are getting anXML 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: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 

 		 	   		  
Mime
View raw message