xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas DeWeese <Thomas.DeWe...@Kodak.com>
Subject Re: Parsing out of a document scope
Date Sat, 02 Apr 2005 12:17:23 GMT
hi Pierrick,

Pierrick Brihaye wrote:
> Given the following Java string :
> String mypath = "<path d='M 100 100 L 300 100 L 200 300 z'/>";
> What would be the shortest and most elegant way to have an 
> org.apache.batik.dom.svg.SVGOMPathElement instance where I could take 
> benefit from, say, getTotalLength() ?

    The easiest thing to do would be to wrap it with a 'dummy' svg
element so you can can parse it as a regular document.  This would
be fairly efficient if you could 'gang' several such elements together.

    For the case of a shape you could bypass the whole DOM thing and just
parse the path data with o.a.b.parser.PathParser with AWTPathProducer
to turn it into a Java2D Shape.  Then use
o.a.b.ext.awt.geom.PathLength to get the sort of information
that you are interested in.

> Of course, any other shape may also be concerned.

   Some shapes can't be parsed outside of the scope of an
SVG element because they can use relative units (percentages).

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

View raw message