This is probably due to the fact that the Area class does not optimize the case of 2 rectangular areas which abut each other top and bottom into a single rectangular area, but it does optimize the horizontal case.

The isRectangular() method performs a trivial check for a single outline with 4 sides, not a more exhaustive comparison to the area that the various pieces cover. In the case of a shape that wasn't optimized by the calculations it may not notice that the result is square. Also, its definition of rectangular is specific to an axis aligned rectangle so your 45 degree rotated square polygon would not evaluate as rectangular as per the intent of its implementation, though the spec doesn't quite call this out (unless your definition of rectangle assumes axis alignment which may be true of the Rectangle class, but not of the common English term "rectangular"). We should probably clarify that in the method comments.

The equals() method does perform the more exhaustive comparison/tests that notice that the area is equal when you compare it to its bounds rectangle. Obviously this fails for the 45 degree rotated square polygon that you test so the answers in that case are consistent with the above clarification of the definition of isRectangular()...

                        ...jim

[EMAIL PROTECTED] wrote:
Hi,

Under certain conditions I find the following:

[code]
Area a, b;
(a.equals(b) && b.equals(a)) != (a.isRectangular && b.isRectangular())
[/code]
Is this a bug? Or am I missing something?

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