On Wed, Feb 22, 2006 at 06:30:25PM -0800, Chris Nokleberg wrote:
> I need to be able to convert a Shape described by a WIND_NON_ZERO
> PathIterator into WIND_EVEN_ODD. Obviously some Java code that does this
> would be great, but a pointer to a nice algorithm would be appreciated
> too. So far I have found this:
> http://www.n-n-a.com/topic.php?p=1900-913-1
For the archives, I finally figured this out. There is a comment in
java/awt/geom/Area.java:
public int getWindingRule() {
// REMIND: Which is better, EVEN_ODD or NON_ZERO?
// The paths calculated could be classified either way.
//return WIND_EVEN_ODD;
return WIND_NON_ZERO;
}
So if you need to convert from non-zero to even-odd, the trick is to
create an Area, and then proxy the shape in order to override the
getWindingRule on any returned PathIterators. You can do this with
Dynamic Proxies or explicit FilterShape and FilterPathIterator classes.
It would be nice if there was a setWindingRule on Area so that you could
choose what the PathIterator will return, but I'm just happy it works.
Chris
===========================================================================
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".