Module org.htmlunit

Class Line2D

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

public class Line2D extends Object implements Shape2D
Simple 2D line segment shape.
Author:
Ronald Brill
  • Field Summary

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

    EPSILON
  • Constructor Summary

    Constructors
    Constructor
    Description
    Line2D(double x1, double y1, double x2, double y2)
    Creates a new line segment between the two given coordinates.
    Line2D(Point2D start, Point2D end)
    Creates a new line segment between the two given points.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(double x, double y)
    Returns whether the specified point lies inside this shape.
    Returns the intersection point of this line with the given line, or null if the lines are parallel.
    boolean
    Returns whether this shape is empty.
     

    Methods inherited from class java.lang.Object

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

    • Line2D

      public Line2D(Point2D start, Point2D end)
      Creates a new line segment between the two given points.
      Parameters:
      start - the start point
      end - the end point
    • Line2D

      public Line2D(double x1, double y1, double x2, double y2)
      Creates a new line segment between the two given coordinates.
      Parameters:
      x1 - the x coordinate of the start point
      y1 - the y coordinate of the start point
      x2 - the x coordinate of the end point
      y2 - the y coordinate of the end point
  • Method Details

    • intersect

      public Point2D intersect(Line2D line)
      Returns the intersection point of this line with the given line, or null if the lines are parallel.
      Parameters:
      line - the line to intersect with
      Returns:
      the intersection point, or null if the lines are parallel
    • 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