You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Müller Clemens <pa...@gmail.com> on 2010/09/07 16:11:35 UTC

Map with overlapping Elements

Hello!

I am implementing a map with SVG which has some movable elements in it. Those elements change their position over time and are basically some (more or less complex) svg's inside the root svg. What I want to implement now is some kind of merging the elements, if two or more are overlapping.

My approach would be to check every time an element is moved or the zooming is changed, wether there are elements which' bounding box do overlap and if so, temporarily set their visibility to false and create a new element which represents the merged one (also by indicating the number of "merged" elements).

The problem is that I can't get the correct bounding box, depending on the current position of the elements. What I'm trying to get is the bounding box of each element in relation to the root SVG. Do you know how I can achieve my goal or do you know how to implement such a feature??

Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Map with overlapping Elements

Posted by th...@kodak.com.
Hi Muller,

"Müller Clemens" <pa...@gmail.com> wrote on 09/07/2010 10:11:35 AM:

> The problem is that I can't get the correct bounding box, depending 
> on the current position of the elements. What I'm trying to get is 
> the bounding box of each element in relation to the root SVG. Do you
> know how I can achieve my goal or do you know how to implement such 
> a feature??

        You can use getScreenCTM in Batik to get the affine transform from
any element to the screen coordinate system.  You could alternately use
getTransformToElement with the root SVG Element to get the affine 
transform
to the local coordinate system of the root SVG Element.

        Once you have the affine transform you can use it to transform the
corners of the bbox for an element to know it's bounds in the root SVG
element's coordinate system (or the screen coordinate system).

        Does that answer your question?