Class KmgDoublePolygon


  • public class KmgDoublePolygon
    extends Object
    Stores the points ( xi, yi ) of a polygon.
    • Field Detail

      • elementCount

        public int elementCount
        Number of valid points in this polygon.
      • xData

        public double[] xData
        Internal storage.
      • yData

        public double[] yData
        Internal storage.
    • Constructor Detail

      • KmgDoublePolygon

        public KmgDoublePolygon()
        Creates an empty polygon.
      • KmgDoublePolygon

        public KmgDoublePolygon​(int initialCapacity)
        Creates an empty polygon (with given initial capacity).
      • KmgDoublePolygon

        public KmgDoublePolygon​(double[] xArray,
                                double[] yArray)
        Creates a polygon from two double arrays. Silently ignores surplus elements of the longer array if both arrays do not have equal length.
    • Method Detail

      • add

        public KmgDoublePolygon add​(double x,
                                    double y)
        Adds a point ( x, y ) to this polygon. The capacity of the internal storage is increased dynamically if needed.
      • size

        public int size()
        Returns the number of points of the polygon.
      • capacity

        public int capacity()
        Returns the current capacity.
      • clear

        public void clear()
        Removes all points.