@OpenApiAll
public class Line
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
java.awt.Point |
A
The first point of the line.
|
java.awt.Point |
B
The second point of the line.
|
Constructor and Description |
---|
Line()
Constructs a new line whose first point is at (0,0) in the
coordinate space, and whose second point is at (0, 0) in the
coordinate space.
|
Line(int x1,
int y1,
int x2,
int y2)
Constructs a new line whose first point is specified as
(
x , y ) and whose second point
is specified as (x , y ). |
Line(Line l)
Constructs a new line, initialized to match the values of
the specificed line.
|
Line(java.awt.Point p1,
java.awt.Point p2)
Constructs a new line whose first point is specified as
p1 and whose second point is specified as
p2 . |
Modifier and Type | Method and Description |
---|---|
boolean |
belongs(java.awt.Point p)
Checks whether specified point belongs to this line.
|
boolean |
equals(java.lang.Object obj)
Checks whether two lines are equal.
|
java.awt.Rectangle |
getBounds()
Gets the bounding rectangle of this line.
|
java.awt.Point |
intersection(Line l)
Computes the intersection of this line with the
specified line.
|
java.awt.Point |
intersection(java.awt.Point p)
Computes the intersection of this line with the
line perpendicular to this line.
|
boolean |
intersects(Line l)
Determines whether this line and the specified line
intersect.
|
boolean |
isVertical() |
java.lang.String |
toString()
Returns a string representation of this line
and its values.
|
public java.awt.Point A
public java.awt.Point B
public Line()
public Line(Line l)
l
- a line from which to copy initial values.public Line(java.awt.Point p1, java.awt.Point p2)
p1
and whose second point is specified as
p2
.p1
- the first point.p2
- the second point.public Line(int x1, int y1, int x2, int y2)
x
, y
) and whose second point
is specified as (x
, y
).x1
- the first point x coordinate.y1
- the first point y coordinate.x2
- the second point x coordinate.y2
- the second point y coordinate.public boolean intersects(Line l)
l
- a line.true
if the specified line
and this line insersect;
false
otherwise.public java.awt.Point intersection(Line l)
l
- a line.public java.awt.Point intersection(java.awt.Point p)
p
- a point.public boolean belongs(java.awt.Point p)
The result is true if and only if the argument is not null and belongs to this line.
p
- a point.true
if specified point belongs to this line;
false
otherwise.public boolean equals(java.lang.Object obj)
The result is true if and only if the argument is not null and is a Line object that has the same first point and second point as this line.
equals
in class java.lang.Object
obj
- the object to compare with.true
if the objects are equal;
false
otherwise.@OpenApi public java.lang.String toString()
toString
in class java.lang.Object
public java.awt.Rectangle getBounds()
This method is included for completeness, to parallel the
getBounds
method of Component
.
Component.getBounds()
public boolean isVertical()