Class AbstractPolygon

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Shape>
    Direct Known Subclasses:
    Polygon, Rectangle

    public abstract class AbstractPolygon
    extends Shape
    Abstract polygon definition.

    WARNING: this API is experimental and will likely change in the near future.

    See Also:
    Serialized Form
    • Constructor Detail

      • AbstractPolygon

        public AbstractPolygon()
    • Method Detail

      • getPoint

        public final Point getPoint​(int index)
        Get the Point at index.
      • getPointX

        public final double getPointX​(int index)
        Get the X Coordinate of the Point at index.
      • getPointY

        public final double getPointY​(int index)
        Get the X Coordinate of the Point at index.
      • fastGetX

        public abstract double fastGetX​(int index)
        Get the X coordinate of the Point at index.

        WARNING: this method assumes that index is positive and less than size().

      • fastGetY

        public abstract double fastGetY​(int index)
        Get the Y coordinate of the Point at index.

        WARNING: this method assumes that index is positive and less than size().

      • size

        public abstract int size()
        Return the number of vertices in this polygon.
      • intersects

        public boolean intersects​(Rectangle box,
                                  Shape other)
        Check if this shape intersects with other.
        Specified by:
        intersects in class Shape
        Parameters:
        box - The bounding box of this shape from Shape.getBoundingBox().
        other - The shape to check for intersection with
      • intersects

        protected final boolean intersects​(Rectangle box,
                                           AbstractPolygon poly)
        Check for intersection with poly.
        Parameters:
        box - This polygon's bounding box
        poly - Polygon to check intersection with.
      • lineIntersects

        public abstract boolean lineIntersects​(double x1,
                                               double y1,
                                               double x2,
                                               double y2)
        Check if the line (x1, y1), (x2, y2) intersects with this polygon.