xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Hebner <hebn...@gmail.com>
Subject Re: Get stroke-width from GVT nodes
Date Sun, 09 May 2010 16:08:42 GMT
On Sun, May 9, 2010 at 1:19 AM, Cameron McCormack <cam@mcc.id.au> wrote:

> Hi Nick.
> Nick Hebner:
> > I am a noob batik user and I am probably missing something simple. What I
> am
> > trying to do is to calculate the total composite path length of all paths
> > having a stroke-width 0.01 or less within a given document. So far, I
> have
> > been successful in loading the document, building a GVT tree, iterating
> > through it to create a composite path, and using the PathLength class to
> > calculate the length. What I cannot figure out is how to check the
> > stroke-width of a given path in the GVT tree. How can I accomplish this?
> From the ShapeNode, you can get its ShapePainter.  If it is a
> StrokeShapePainter, then you can get its java.awt.Stroke (which should
> be a java.awt.BasicStroke; on which you can call getLineWidth()).
> Otherwise, if it is CompositeShapePainter, then it could have a
> StrokePainter in it.  Otherwise, the shape isn’t stroked.

Awesome, thanks! This is exactly what I needed.

> Or, if you wanted to work on the SVG DOM instead, you could traverse the
> document tree and call window.getComputedStyle() on each <path>/whatever
> element to determine the value of its ‘stroke-width’ property.

I initially went with GVT just because I was following the GVT builder
tutorial. Later, I found the PathLength class that operated on Shape
objects. Is there a PathLength analogue for DOM or is GVT better in this

> --
> Cameron McCormack ≝ http://mcc.id.au/
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

View raw message