As a separate issue, the very fact that you have to do the following shows that the current definition of BaseBounds.is2D() is not ideal:
+ /**
+ * Return true if contentBounds is purely a 2D bounds, ie. it is a
+ * RectBounds or its Z dimension is almost zero.
+ */
+ public boolean isContentBounds2D() {
+ return (contentBounds.is2D()
+ || (Affine3D.almostZero(contentBounds.getMaxZ())
+ && Affine3D.almostZero(contentBounds.getMinZ())));
+ }
+
I recall suggesting at the time BaseBounds was created that having the definition of is2D() be true if bounds instanceof RectBounds and false otherwise was probably not what we wanted. A better definition would be to take a cue from BaseTransform and have the is2D method be true if it represents a 2D bounds, regardless of whether the object happens to be a RectBounds or is a 2D bounds (i.e., minZ = maxZ = 0) in a BoxBounds object. It would allow you to just write:
public boolean isContentBounds2D() {
return contentBounds.is2D();
}
and move the check for Z into the BoxBounds class. It would mean that you would need to stop using is2D() in a couple places to mean "I can cast this to a RectBounds".
In any case, as I said, this is a separate issue that can be addressed in a separate JIRA issue (and we might decide not to do it for Presidio). -- Kevin
+ /**
+ * Return true if contentBounds is purely a 2D bounds, ie. it is a
+ * RectBounds or its Z dimension is almost zero.
+ */
+ public boolean isContentBounds2D() {
+ return (contentBounds.is2D()
+ || (Affine3D.almostZero(contentBounds.getMaxZ())
+ && Affine3D.almostZero(contentBounds.getMinZ())));
+ }
+
I recall suggesting at the time BaseBounds was created that having the definition of is2D() be true if bounds instanceof RectBounds and false otherwise was probably not what we wanted. A better definition would be to take a cue from BaseTransform and have the is2D method be true if it represents a 2D bounds, regardless of whether the object happens to be a RectBounds or is a 2D bounds (i.e., minZ = maxZ = 0) in a BoxBounds object. It would allow you to just write:
public boolean isContentBounds2D() {
return contentBounds.is2D();
}
and move the check for Z into the BoxBounds class. It would mean that you would need to stop using is2D() in a couple places to mean "I can cast this to a RectBounds".
In any case, as I said, this is a separate issue that can be addressed in a separate JIRA issue (and we might decide not to do it for Presidio). -- Kevin