You could only add the first in each set of DUPLICATE CONSECUTIVE POINTS …

 

if ( segmentType == PathIterator.SEG_LINETO ) {

  if ( prev0 != (float)coords[0] || prev1 != (float)coords[1] ) {

    myGenPath.lineTo ( (float)coords[0] ,(float)coords[1] );

  }

  prev0 = (float)coords[0];

  prev1 = (float)coords[1];

}

 

Jon

 

-----Original Message-----
From: Discussion list for Java 2D API [mailto:[EMAIL PROTECTED]On Behalf Of Ted Hill
Sent: Wednesday, June 23, 2004 10:47 AM
To: [EMAIL PROTECTED]
Subject: [JAVA2D] Area.getPathIterator() question

 

Hello,

 

I have an Area that I want to break down into discrete paths, for example, if I have an Area that looks like a doughnut, I want to extract two discrete paths from it.

I do this by getting the PathIterator from the Area as follows:

 

        PathIterator pi = myArea.getPathIterator(new AffineTransform(), 1.0);

 

Then I look at the segment type, e.g. SEG_LINETO, on each iteration to determine whether I should add the current point to my current path or start a new path.

 

When I iterate over the path iterator, I find many DUPLICATE CONSECUTIVE POINTS.

 

So if I build up a  GeneralPath from the points given to me by the PathIterator as follows:

 

 

                if(segmentType == PathIterator.SEG_LINETO)

                {

                    myGenPath.lineTo((float)coords[0], (float)coords[1]);

                }

 

I wind up with a GeneralPath that looks fine when drawn on screen, however, examination shows that it can have many DUPLICATE CONSECUTIVE POINTS.

 

Is there some way to get a PathIterator from an Area that will not have duplicate consecutive points?

 

Thank you,

 

Ted Hill

 

 

 

 

=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to