Line2D represents a line segment in (x,y)
coordinate space. This class, like all of the Java 2D API, uses a
default coordinate system called user space in which the y-axis
values increase downward and x-axis values increase to the right. For
more information on the user space coordinate system, see the
Coordinate Systems section of the Java 2D Programmer's Guide.
| Modifier and Type | Field and Description |
|---|---|
| public float | x1
The X coordinate of the start point of the line segment. |
| public float | x2
The X coordinate of the end point of the line segment. |
| public float | y1
The Y coordinate of the start point of the line segment. |
| public float | y2
The Y coordinate of the end point of the line segment. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Line2D(float
the X coordinate of the start point x1, float the Y coordinate of the start point y1, float the X coordinate of the end point x2, float the Y coordinate of the end point y2)Constructs and initializes a Line from the specified coordinates. |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | contains(float
the specified X coordinate to be tested x, float the specified Y coordinate to be tested y)Implements abstract com. Tests if the specified coordinates are inside the boundary of the
|
| public boolean | contains(float
the X coordinate of the upper-left corner
of the specified rectangular area x, float the Y coordinate of the upper-left corner
of the specified rectangular area y, float the width of the specified rectangular area w, float the height of the specified rectangular area h)Implements abstract com. Tests if the interior of the |
| public boolean | contains(Point2D
the specified p)Point2D to be testedOverrides com. Tests if a specified |
| public Line2D | copy()
Implements abstract com. Returns a new copy of this |
| public boolean | equals(Object
the reference object with which to compare. obj)Overrides java. Indicates whether some other object is "equal to" this one. |
| public RectBounds | getBounds()
Implements abstract com. Note that there is no guarantee that the returned
|
| public PathIterator | getPathIterator(BaseTransform
the specified tx)BaseTransformImplements abstract com. Returns an iteration object that defines the boundary of this
|
| public PathIterator | Returns: aPathIterator that defines the boundary of the
flattened Line2Dthe specified tx, float BaseTransformthe maximum amount that the control points for a
given curve can vary from colinear before a subdivided
curve is replaced by a straight line connecting the
end points. Since a flatness)Line2D object is
always flat, this parameter is ignored.Implements abstract com. Returns an iteration object that defines the boundary of this
flattened |
| public int | |
| public boolean | intersects(float
the X coordinate of the upper-left corner
of the specified rectangular area x, float the Y coordinate of the upper-left corner
of the specified rectangular area y, float the width of the specified rectangular area w, float the height of the specified rectangular area h)Implements abstract com. Tests if the interior of the |
| public boolean | Returns: false otherwise.the X coordinate of the start point of the
specified line segment x1, float the Y coordinate of the start point of the
specified line segment y1, float the X coordinate of the end point of the
specified line segment x2, float the Y coordinate of the end point of the
specified line segment y2)Tests if the line segment from |
| public boolean | Returns: true if this line segment and the specified line
segment intersect each other;
false otherwise.the specified l)Line2DTests if the specified line segment intersects this line segment. |
| public static boolean | Returns: true if the first specified line segment
and the second specified line segment intersect
each other; false otherwise.the X coordinate of the start point of the first
specified line segment x1, float the Y coordinate of the start point of the first
specified line segment y1, float the X coordinate of the end point of the first
specified line segment x2, float the Y coordinate of the end point of the first
specified line segment y2, float the X coordinate of the start point of the second
specified line segment x3, float the Y coordinate of the start point of the second
specified line segment y3, float the X coordinate of the end point of the second
specified line segment x4, float the Y coordinate of the end point of the second
specified line segment y4)Tests if the line segment from |
| public static float | Returns: a double value that is the distance from the specified point to the specified line.the X coordinate of the start point of the specified line x1, float the Y coordinate of the start point of the specified line y1, float the X coordinate of the end point of the specified line x2, float the Y coordinate of the end point of the specified line y2, float the X coordinate of the specified point being
measured against the specified line px, float the Y coordinate of the specified point being
measured against the specified line py)Returns the distance from a point to a line. |
| public float | Returns: a double value that is the distance from a specified point to the current line.the X coordinate of the specified point being
measured against this line px, float the Y coordinate of the specified point being
measured against this line py)Returns the distance from a point to this line. |
| public float | Returns: a double value that is the distance from a specifiedPoint2D to the current line.the specified pt)Point2D being measuredReturns the distance from a |
| public static float | Returns: a double value that is the square of the distance from the specified point to the specified line.the X coordinate of the start point of the specified line x1, float the Y coordinate of the start point of the specified line y1, float the X coordinate of the end point of the specified line x2, float the Y coordinate of the end point of the specified line y2, float the X coordinate of the specified point being
measured against the specified line px, float the Y coordinate of the specified point being
measured against the specified line py)Returns the square of the distance from a point to a line. |
| public float | Returns: a double value that is the square of the distance from a specified point to the current line.the X coordinate of the specified point being
measured against this line px, float the Y coordinate of the specified point being
measured against this line py)Returns the square of the distance from a point to this line. |
| public float | Returns: a double value that is the square of the distance from a specifiedPoint2D to the current
line.the specified pt)Point2D being measured
against this lineReturns the square of the distance from a specified
|
| public static float | Returns: a double value that is the distance from the specified point to the specified line segment.the X coordinate of the start point of the
specified line segment x1, float the Y coordinate of the start point of the
specified line segment y1, float the X coordinate of the end point of the
specified line segment x2, float the Y coordinate of the end point of the
specified line segment y2, float the X coordinate of the specified point being
measured against the specified line segment px, float the Y coordinate of the specified point being
measured against the specified line segment py)Returns the distance from a point to a line segment. |
| public double | Returns: a double value that is the distance from the specified point to the current line segment.the X coordinate of the specified point being
measured against this line segment px, float the Y coordinate of the specified point being
measured against this line segment py)Returns the distance from a point to this line segment. |
| public float | |
| public static float | Returns: a double value that is the square of the distance from the specified point to the specified line segment.the X coordinate of the start point of the
specified line segment x1, float the Y coordinate of the start point of the
specified line segment y1, float the X coordinate of the end point of the
specified line segment x2, float the Y coordinate of the end point of the
specified line segment y2, float the X coordinate of the specified point being
measured against the specified line segment px, float the Y coordinate of the specified point being
measured against the specified line segment py)Returns the square of the distance from a point to a line segment. |
| public float | Returns: a double value that is the square of the distance from the specified point to the current line segment.the X coordinate of the specified point being
measured against this line segment px, float the Y coordinate of the specified point being
measured against this line segment py)Returns the square of the distance from a point to this line segment. |
| public float | Returns: a double value that is the square of the distance from the specifiedPoint2D to the current
line segment.the specified pt)Point2D being measured against
this line segment.Returns the square of the distance from a |
| public static int | Returns: an integer that indicates the position of the third specified coordinates with respect to the line segment formed by the first two specified coordinates.the X coordinate of the start point of the
specified line segment x1, float the Y coordinate of the start point of the
specified line segment y1, float the X coordinate of the end point of the
specified line segment x2, float the Y coordinate of the end point of the
specified line segment y2, float the X coordinate of the specified point to be
compared with the specified line segment px, float the Y coordinate of the specified point to be
compared with the specified line segment py)Returns an indicator of where the specified point
|
| public int | Returns: an integer that indicates the position of the specified coordinates with respect to thisLine2Dthe X coordinate of the specified point
to be compared with this px, float Line2Dthe Y coordinate of the specified point
to be compared with this py)Line2DReturns an indicator of where the specified point
|
| public int | Returns: an integer that indicates the position of the specifiedPoint2D with respect to this Line2Dthe specified p)Point2D to be compared
with this Line2DReturns an indicator of where the specified |
| public void | setLine(float
the X coordinate of the start point x1, float the Y coordinate of the start point y1, float the X coordinate of the end point x2, float the Y coordinate of the end point y2)Sets the location of the end points of this |
| public void | |
| public void |
| x1 | back to summary |
|---|---|
| public float x1 The X coordinate of the start point of the line segment. | |
| x2 | back to summary |
|---|---|
| public float x2 The X coordinate of the end point of the line segment. | |
| y1 | back to summary |
|---|---|
| public float y1 The Y coordinate of the start point of the line segment. | |
| y2 | back to summary |
|---|---|
| public float y2 The Y coordinate of the end point of the line segment. | |
| Line2D | back to summary |
|---|---|
| public Line2D() Constructs and initializes a Line with coordinates (0, 0) -> (0, 0). | |
| Line2D | back to summary |
|---|---|
| public Line2D(float x1, float y1, float x2, float y2) Constructs and initializes a Line from the specified coordinates.
| |
| Line2D | back to summary |
|---|---|
| public Line2D(Point2D p1, Point2D p2) Constructs and initializes a | |
| contains | back to summary |
|---|---|
| public boolean contains(float x, float y) Implements abstract com. Doc from com. Tests if the specified coordinates are inside the boundary of the
| |
| contains | back to summary |
|---|---|
| public boolean contains(float x, float y, float w, float h) Implements abstract com. Doc from com. Tests if the interior of the
The
Shapes this method might
return false even though the Shape contains
the rectangular area.
The Area class performs
more accurate geometric computations than most
Shape objects and therefore can be used if a more precise
answer is required.
| |
| contains | back to summary |
|---|---|
| public boolean contains(Point2D p) Overrides com. Doc from com. Tests if a specified | |
| copy | back to summary |
|---|---|
| public Line2D copy() Implements abstract com. Doc from com. Returns a new copy of this | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getBounds | back to summary |
|---|---|
| public RectBounds getBounds() Implements abstract com. Doc from com. Note that there is no guarantee that the returned
| |
| getPathIterator | back to summary |
|---|---|
| public PathIterator getPathIterator(BaseTransform tx) Implements abstract com. Returns an iteration object that defines the boundary of this
| |
| getPathIterator | back to summary |
|---|---|
| public PathIterator getPathIterator(BaseTransform tx, float flatness) Implements abstract com. Returns an iteration object that defines the boundary of this
flattened
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| intersects | back to summary |
|---|---|
| public boolean intersects(float x, float y, float w, float h) Implements abstract com. Doc from com. Tests if the interior of the
The
Shapes this method might
return true even though the rectangular area does not
intersect the Shape.
The Area class performs
more accurate computations of geometric intersection than most
Shape objects and therefore can be used if a more precise
answer is required.
| |
| intersectsLine | back to summary |
|---|---|
| public boolean intersectsLine(float x1, float y1, float x2, float y2) Tests if the line segment from
| |
| intersectsLine | back to summary |
|---|---|
| public boolean intersectsLine(Line2D l) Tests if the specified line segment intersects this line segment.
| |
| linesIntersect | back to summary |
|---|---|
| public static boolean linesIntersect(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4) Tests if the line segment from
| |
| ptLineDist | back to summary |
|---|---|
| public static float ptLineDist(float x1, float y1, float x2, float y2, float px, float py) Returns the distance from a point to a line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by the specified coordinates. If the specified point intersects the line, this method returns 0.0.
| |
| ptLineDist | back to summary |
|---|---|
| public float ptLineDist(float px, float py) Returns the distance from a point to this line.
The distance measured is the distance between the specified
point and the closest point on the infinitely-extended line
defined by this
| |
| ptLineDist | back to summary |
|---|---|
| public float ptLineDist(Point2D pt) Returns the distance from a
| |
| ptLineDistSq | back to summary |
|---|---|
| public static float ptLineDistSq(float x1, float y1, float x2, float y2, float px, float py) Returns the square of the distance from a point to a line. The distance measured is the distance between the specified point and the closest point on the infinitely-extended line defined by the specified coordinates. If the specified point intersects the line, this method returns 0.0.
| |
| ptLineDistSq | back to summary |
|---|---|
| public float ptLineDistSq(float px, float py) Returns the square of the distance from a point to this line.
The distance measured is the distance between the specified
point and the closest point on the infinitely-extended line
defined by this
| |
| ptLineDistSq | back to summary |
|---|---|
| public float ptLineDistSq(Point2D pt) Returns the square of the distance from a specified
| |
| ptSegDist | back to summary |
|---|---|
| public static float ptSegDist(float x1, float y1, float x2, float y2, float px, float py) Returns the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.
| |
| ptSegDist | back to summary |
|---|---|
| public double ptSegDist(float px, float py) Returns the distance from a point to this line segment. The distance measured is the distance between the specified point and the closest point between the current line's end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.
| |
| ptSegDist | back to summary |
|---|---|
| public float ptSegDist(Point2D pt) Returns the distance from a
| |
| ptSegDistSq | back to summary |
|---|---|
| public static float ptSegDistSq(float x1, float y1, float x2, float y2, float px, float py) Returns the square of the distance from a point to a line segment. The distance measured is the distance between the specified point and the closest point between the specified end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.
| |
| ptSegDistSq | back to summary |
|---|---|
| public float ptSegDistSq(float px, float py) Returns the square of the distance from a point to this line segment. The distance measured is the distance between the specified point and the closest point between the current line's end points. If the specified point intersects the line segment in between the end points, this method returns 0.0.
| |
| ptSegDistSq | back to summary |
|---|---|
| public float ptSegDistSq(Point2D pt) Returns the square of the distance from a
| |
| relativeCCW | back to summary |
|---|---|
| public static int relativeCCW(float x1, float y1, float x2, float y2, float px, float py) Returns an indicator of where the specified point
A return value of 1 indicates that the line segment must turn in the direction that takes the positive X axis towards the negative Y axis. In the default coordinate system used by Java 2D, this direction is counterclockwise. A return value of -1 indicates that the line segment must turn in the direction that takes the positive X axis towards the positive Y axis. In the default coordinate system, this direction is clockwise. A return value of 0 indicates that the point lies exactly on the line segment. Note that an indicator value of 0 is rare and not useful for determining colinearity because of floating point rounding issues. If the point is colinear with the line segment, but
not between the end points, then the value will be -1 if the point
lies "beyond
| |
| relativeCCW | back to summary |
|---|---|
| public int relativeCCW(float px, float py) Returns an indicator of where the specified point
| |
| relativeCCW | back to summary |
|---|---|
| public int relativeCCW(Point2D p) Returns an indicator of where the specified
| |
| setLine | back to summary |
|---|---|
| public void setLine(float x1, float y1, float x2, float y2) Sets the location of the end points of this
| |
| setLine | back to summary |
|---|---|
| public void setLine(Point2D p1, Point2D p2) Sets the location of the end points of this | |
| setLine | back to summary |
|---|---|
| public void setLine(Line2D l) Sets the location of the end points of this
| |