Class Polygon2D

  • All Implemented Interfaces:
    Shape2D

    public class Polygon2D
    extends java.lang.Object
    implements Shape2D
    Simple 2D shape polygon.
    • Constructor Summary

      Constructors 
      Constructor Description
      Polygon2D​(double startX, double startY)
      Ctor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(double x, double y)
      boolean isEmpty()
      Polygon2D lineTo​(double x, double y)
      Add another corner Point to the polygon.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • points_

        private final java.util.ArrayList<Point2D> points_
    • Constructor Detail

      • Polygon2D

        public Polygon2D​(double startX,
                         double startY)
        Ctor.
        Parameters:
        startX - the x value of the first point.
        startY - the Y value of the first point.
        See Also:
        lineTo(double, double)
    • Method Detail

      • lineTo

        public Polygon2D lineTo​(double x,
                                double y)
        Add another corner Point to the polygon.
        Parameters:
        x - the x value of the corner to be added
        y - the y value of the corner to be added
        Returns:
        this to support fluent style construction
      • contains

        public boolean contains​(double x,
                                double y)
        Specified by:
        contains in interface Shape2D
        Parameters:
        x - point x value
        y - point y value
        Returns:
        true if the specified point is inside; false otherwise.
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface Shape2D
        Returns:
        true if the Shape is empty.
      • toString

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