Class RectangleReader



  • public class RectangleReader
    extends Object
    This can identify if a shape is a Rectangle, Rectangle2D or other.

    If a shape is a rectangle, then certain operations can be optimized.

    Also there is a bug when clipping shapes using Quartz on Mac: a GeneralPath encapsulating exactly the same area as a Rectangle2D may not clip correctly. If this abstract shape is instead converted to a Rectangle2D: the bug goes away!

    • Constructor Detail

      • RectangleReader

        public RectangleReader()
    • Method Detail

      • isRectangle

        public static boolean isRectangle(Shape s)
        Returns true if a shape is a rectangle.
      • isRectangle

        public static boolean isRectangle(Shape s,
                                          AffineTransform tx)
        Returns true if a shape is a rectangle when the transform is applied.
      • convert

        public static final Rectangle2D convert(Shape shape)
        This studies a shape and determines if it is a Rectangle, a Rectangle2D, or neither.
        Parameters:
        shape - the shape to study
        Returns:
        a Rectangle, Rectangle2D, or null.
      • convert

        public static final Rectangle2D convert(Shape shape,
                                                AffineTransform transform)
        This studies a shape and determines if it is a Rectangle, a Rectangle2D, or neither.
        Parameters:
        shape - the shape to study
        transform - the optional transform to apply to the shape.
        Returns:
        a Rectangle, Rectangle2D, or null.