Module org.htmlunit

Class Polygon2D

java.lang.Object
org.htmlunit.util.geometry.Polygon2D
All Implemented Interfaces:
Shape2D

public class Polygon2D extends Object implements Shape2D
Simple 2D polygon shape.
Author:
Ronald Brill
  • Field Summary

    Fields inherited from interface org.htmlunit.util.geometry.Shape2D

    EPSILON
  • Constructor Summary

    Constructors
    Constructor
    Description
    Polygon2D(double startX, double startY)
    Creates a new polygon starting at the given point.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(double x, double y)
    Returns whether the specified point lies inside this shape.
    boolean
    Returns whether this shape is empty.
    lineTo(double x, double y)
    Adds another corner point to the polygon.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Polygon2D

      public Polygon2D(double startX, double startY)
      Creates a new polygon starting at the given point. Use lineTo(double, double) to add further corner points.
      Parameters:
      startX - the x coordinate of the first point
      startY - the y coordinate of the first point
  • Method Details

    • lineTo

      public Polygon2D lineTo(double x, double y)
      Adds another corner point to the polygon.
      Parameters:
      x - the x coordinate of the corner to add
      y - the y coordinate of the corner to add
      Returns:
      this instance to support fluent-style construction
    • contains

      public boolean contains(double x, double y)
      Returns whether the specified point lies inside this shape.
      Specified by:
      contains in interface Shape2D
      Parameters:
      x - the x coordinate of the point to test
      y - the y coordinate of the point to test
      Returns:
      true if the point is inside this shape; false otherwise
    • isEmpty

      public boolean isEmpty()
      Returns whether this shape is empty.
      Specified by:
      isEmpty in interface Shape2D
      Returns:
      true if this shape is empty; false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object