xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Davis-5 <t...@robertjdavis.co.uk>
Subject Solution: How to filter/clip SVG elements in a certain region in drawing and get resultant SVG-XML (Can you do better?)
Date Thu, 03 Apr 2008 10:36:05 GMT

I searched the forum about this subject but the results are always to do with
displaying a region of a drawing or using Swing - which I do not want.

My requirement is to take an SVG drawing and generate just the SVG of the
elements that exist within a certain region (as defined by a Shape, or a
Shape derived from a SVG element within the document).

I have a solution to this problem that works very well. But I wondered if I
was re-inventing the wheel. Perhaps batik has a too built in.  (the batik
documentation is great to get started but is incomplete - supplemented by
this forum which I guess is being pragmatic!) 

In summary, my solution uses a recursive algorithm on the DOM Tree Walker
and implementation of NodeFilter to inspect each element to see if it is
inside the region and indicate that it should be excluded it if is not. To
do this it uses the standard batik GVT - the CSS and DOM is booted. A list
is built of the elements outside the region.

The list returned is then iterated through and elements deleted using
standard DOM methods.


View this message in context: http://www.nabble.com/Solution%3A-How-to-filter-clip-SVG-elements-in-a-certain-region-in-drawing-and-get-resultant-SVG-XML-%28Can-you-do-better-%29-tp16467384p16467384.html
Sent from the Batik - Users mailing list archive at Nabble.com.

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

View raw message