Hi Logolas,
Legolas Woodland <[EMAIL PROTECTED]> wrote on 02/17/2006 06:40:30 AM:
> My problem :
> Indeed i want to retrieve a sequence of straight lines from each shape .
more
> explanation :
> Imagine that i have a java.awt.Shape object , this object contain one of
SVG
> document elements (for example a text element)
> Now , i want to convert this text element to a Path , and convert the
path
> to a sequence of straight lines. maybe there are some ways to convert
the
> element to straight lines directly....
If you build the GVT tree for the Document the you can ask any
batik.gvt.GraphicsNode for it's 'outline' which is a AWT Shape. Stroke
makes this a bit more complex of course (this can be accessed through
the ShapePainters on the GraphicsNode).
The Wiki has example code to build the GVT tree:
http://wiki.apache.org/xmlgraphics-batik/BootSvgAndCssDom
> so far another member kindly answered this question , but i could not
find out
> how i should use his/her tip
> the other member said :
>> Anyway if you have the 'd' data you can use the
>> batik.parser.AWTPathProducer with the batik.parser.PathParser
>> to create an AWT GeneralPath which you can either query for
>> the real 'curve' segments (quadradic and cubic beziers, lines, etc)
>> or you can call flatten on that path and get a sequence of straight
>> lines that approximate the original path...
> I tried both of this classes but i can not find how i should use them.
> indeed i did not find a method that get a shape and return a sequence
of lines.
java.awt.Shape has two methods called 'getPathIterator'. One has a
'flatness' paramter, this one will only return move-to, line-to, and close
path commands (the line will deviate from the the true curve by no more
than the flatness parameter). The version without the flatness argument
will return the path potentially with cubic and quadradic path commands
as well.
You might want to use Google a little to explore problems before
posting (google is much quicker to respond that I am ;)
http://www.google.com/search?q=flatten+AWT+Shape
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]