You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Legolas Woodland <le...@gmail.com> on 2006/02/14 20:13:47 UTC

how i can convert a path into Its composer points by using batik ?

Hi
Thank you for reading my post.
how i can convert a path (SVG path element) into its corresponding points ?
I mean points that i can use to draw the path on a raster canvas.

Thanks

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


Re: how i can convert a path into Its composer points by using batik ?

Posted by Tonny Kohar <to...@kiyut.com>.
Hi,

On Fri, 2006-02-17 at 13:46 +0330, Legolas Woodland wrote:
> Can you please explain more , 
> I have an java.awt.shape object   , now i want to have a sequence of
> straight lines that create that shape , can you give me more details
> on , how i can achieve this ?
> I should say that , indeed i have SVGDocument and i build the above
> shape by using the document node.
> so if it is require i have the SVGdocument too.

If you already have java Shape object it will be simpler, just use
PathIterator

PathIterator pi = shape.getPathIterator(null)
float[] coords = new float[6];
        while (!pi.isDone()) {
            int segment = pi.currentSegment(coords);
            if (segment == PathIterator.SEG_MOVETO) {
                
            } else if (segment == PathIterator.SEG_CLOSE) {
                
            } else if (segment == PathIterator.SEG_LINETO) {
                
            } else if (segment == PathIterator.SEG_QUADTO) {
                
            } else if (segment == PathIterator.SEG_CUBICTO) {
                
            }
            pi.next();
        }

Please note, the above code is straight typing, probably have syntax
error, etc. Please check the Java API PathIterator doc for correct
syntax and other option like flatten

Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com


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


Re: how i can convert a path into Its composer points by using batik ?

Posted by Legolas Woodland <le...@gmail.com>.
thomas.deweese@kodak.com wrote:
> Hi Legolas,
>
> Legolas Woodland <le...@gmail.com> wrote on 02/14/2006 02:13:47 PM:
>
>   
>> how i can convert a path (SVG path element) into its corresponding 
>>     
> points ?
>   
>> I mean points that i can use to draw the path on a raster canvas.
>>     
>
>    Well Batik will draw the path on a raster canvas for you... It's sort
> of it's purpose in life ;)
>
>    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...
>   
Hi
Can you please explain more ,
I have an java.awt.shape object   , now i want to have a sequence of 
straight lines that create that shape , can you give me more details on 
, how i can achieve this ?
I should say that , indeed i have SVGDocument and i build the above 
shape by using the document node.
so if it is require i have the SVGdocument too.

I tried both

AWTPathProducer , PathParser

but i did not find a method that get a shape and return a sequence of lines.

Thanks

Re: how i can convert a path into Its composer points by using batik ?

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

Legolas Woodland <le...@gmail.com> wrote on 02/14/2006 02:13:47 PM:

> how i can convert a path (SVG path element) into its corresponding 
points ?
> I mean points that i can use to draw the path on a raster canvas.

   Well Batik will draw the path on a raster canvas for you... It's sort
of it's purpose in life ;)

   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...


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