Class Polygon

  • All Implemented Interfaces:
    Shape

    public class Polygon
    extends java.lang.Object
    implements Shape
    Describes a two-dimensional convex polygon with float precision coordinates. The polygon is described by an array of points, e.g. [x0, y0, x1, y1, ...].
    • Constructor Detail

      • Polygon

        public Polygon​(float[] points)
    • Method Detail

      • setPoints

        public void setPoints​(float[] points)
      • getPoints

        public float[] getPoints()
      • getNumPoints

        public int getNumPoints()
      • getPointX

        public float getPointX​(int n)
      • getPointY

        public float getPointY​(int n)
      • move

        public void move​(float dx,
                         float dy)
      • contains

        public boolean contains​(Point p)
        Specified by:
        contains in interface Shape
      • intersects

        public boolean intersects​(Polygon p)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • createCircle

        public static Polygon createCircle​(float x,
                                           float y,
                                           float radius,
                                           int numPoints)