| java.lang.Object java.awt.geom.Line2D
Line2D | abstract public class Line2D implements Shape,Cloneable(Code) | | This 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.
This class is only the abstract superclass for all objects that
store a 2D line segment.
The actual storage representation of the coordinates is left to
the subclass.
version: 1.37, 05/05/07 author: Jim Graham since: 1.2 |
Constructor Summary | |
protected | Line2D() This is an abstract class that cannot be instantiated directly. |
Method Summary | |
public Object | clone() Creates a new object of the same class as this object. | public boolean | contains(double x, double y) Tests if a specified coordinate is inside the boundary of this
Line2D . | public boolean | contains(Point2D p) Tests if a given Point2D is inside the boundary of
this Line2D . | public boolean | contains(double x, double y, double w, double h) Tests if the interior of this Line2D entirely contains
the specified set of rectangular coordinates. | public boolean | contains(Rectangle2D r) Tests if the interior of this Line2D entirely contains
the specified Rectangle2D . | public Rectangle | getBounds() | abstract public Point2D | getP1() Returns the start Point2D of this Line2D . | abstract public Point2D | getP2() Returns the end Point2D of this Line2D . | public PathIterator | getPathIterator(AffineTransform at) Returns an iteration object that defines the boundary of this
Line2D . | public PathIterator | getPathIterator(AffineTransform at, double flatness) Returns an iteration object that defines the boundary of this
flattened Line2D .
The iterator for this class is not multi-threaded safe,
which means that this Line2D class does not
guarantee that modifications to the geometry of this
Line2D object do not affect any iterations of that
geometry that are already in process. | abstract public double | getX1() Returns the X coordinate of the start point in double precision. | abstract public double | getX2() Returns the X coordinate of the end point in double precision. | abstract public double | getY1() Returns the Y coordinate of the start point in double precision. | abstract public double | getY2() Returns the Y coordinate of the end point in double precision. | public boolean | intersects(double x, double y, double w, double h) | public boolean | intersects(Rectangle2D r) | public boolean | intersectsLine(double x1, double y1, double x2, double y2) Tests if the line segment from
(x1,y1) to
(x2,y2) intersects this line segment. | public boolean | intersectsLine(Line2D l) Tests if the specified line segment intersects this line segment. | public static boolean | linesIntersect(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) Tests if the line segment from
(x1,y1) to
(x2,y2) intersects the line segment from
(x3,y3)
to
(x4,y4) .
Parameters: x1 - the X coordinate of the start point of the firstspecified line segment Parameters: y1 - the Y coordinate of the start point of the firstspecified line segment Parameters: x2 - the X coordinate of the end point of the firstspecified line segment Parameters: y2 - the Y coordinate of the end point of the firstspecified line segment Parameters: x3 - the X coordinate of the start point of the secondspecified line segment Parameters: y3 - the Y coordinate of the start point of the secondspecified line segment Parameters: x4 - the X coordinate of the end point of the secondspecified line segment Parameters: y4 - the Y coordinate of the end point of the secondspecified line segment true if the first specified line segment and the second specified line segment intersect each other; false otherwise. | public static double | ptLineDist(double x1, double y1, double x2, double y2, double px, double 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. | public double | ptLineDist(double px, double 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 Line2D . | public double | ptLineDist(Point2D pt) Returns the distance from a Point2D 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 Line2D . | public static double | ptLineDistSq(double x1, double y1, double x2, double y2, double px, double 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. | public double | ptLineDistSq(double px, double 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 Line2D . | public double | ptLineDistSq(Point2D pt) Returns the square of the distance from a specified
Point2D 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 Line2D . | public static double | ptSegDist(double x1, double y1, double x2, double y2, double px, double 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. | public double | ptSegDist(double px, double 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. | public double | ptSegDist(Point2D pt) Returns the distance from a Point2D 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. | public static double | ptSegDistSq(double x1, double y1, double x2, double y2, double px, double 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. | public double | ptSegDistSq(double px, double 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. | public double | ptSegDistSq(Point2D pt) Returns the square of the distance from a Point2D 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. | public static int | relativeCCW(double x1, double y1, double x2, double y2, double px, double py) Returns an indicator of where the specified point
(px,py) lies with respect to the line segment from
(x1,y1) to
(x2,y2) .
The return value can be either 1, -1, or 0 and indicates
in which direction the specified line must pivot around its
first end point,
(x1,y1) , in order to point at the
specified point
(px,py) .
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. | public int | relativeCCW(double px, double py) Returns an indicator of where the specified point
(px,py) lies with respect to this line segment. | public int | relativeCCW(Point2D p) Returns an indicator of where the specified Point2D
lies with respect to this line segment. | abstract public void | setLine(double x1, double y1, double x2, double y2) Sets the location of the end points of this Line2D to
the specified double coordinates. | public void | setLine(Point2D p1, Point2D p2) Sets the location of the end points of this Line2D to
the specified Point2D coordinates. | public void | setLine(Line2D l) Sets the location of the end points of this Line2D to
the same as those end points of the specified Line2D . |
Line2D | protected Line2D()(Code) | | This is an abstract class that cannot be instantiated directly.
Type-specific implementation subclasses are available for
instantiation and provide a number of formats for storing
the information necessary to satisfy the various accessory
methods below.
See Also: java.awt.geom.Line2D.Float See Also: java.awt.geom.Line2D.Double since: 1.2 |
contains | public boolean contains(double x, double y)(Code) | | Tests if a specified coordinate is inside the boundary of this
Line2D . This method is required to implement the
Shape interface, but in the case of Line2D
objects it always returns false since a line contains
no area.
Parameters: x - the X coordinate of the specified point to be tested Parameters: y - the Y coordinate of the specified point to be tested false because a Line2D containsno area. since: 1.2 |
contains | public boolean contains(Point2D p)(Code) | | Tests if a given Point2D is inside the boundary of
this Line2D .
This method is required to implement the
Shape interface,
but in the case of Line2D objects it always returns
false since a line contains no area.
Parameters: p - the specified Point2D to be tested false because a Line2D containsno area. since: 1.2 |
contains | public boolean contains(double x, double y, double w, double h)(Code) | | Tests if the interior of this Line2D entirely contains
the specified set of rectangular coordinates.
This method is required to implement the Shape interface,
but in the case of Line2D objects it always returns
false since a line contains no area.
Parameters: x - the X coordinate of the upper-left corner of thespecified rectangular area Parameters: y - the Y coordinate of the upper-left corner of thespecified rectangular area Parameters: w - the width of the specified rectangular area Parameters: h - the height of the specified rectangular area false because a Line2D containsno area. since: 1.2 |
contains | public boolean contains(Rectangle2D r)(Code) | | Tests if the interior of this Line2D entirely contains
the specified Rectangle2D .
This method is required to implement the Shape interface,
but in the case of Line2D objects it always returns
false since a line contains no area.
Parameters: r - the specified Rectangle2D to be tested false because a Line2D containsno area. since: 1.2 |
getP1 | abstract public Point2D getP1()(Code) | | Returns the start Point2D of this Line2D .
the start Point2D of this Line2D . since: 1.2 |
getP2 | abstract public Point2D getP2()(Code) | | Returns the end Point2D of this Line2D .
the end Point2D of this Line2D . since: 1.2 |
getPathIterator | public PathIterator getPathIterator(AffineTransform at)(Code) | | Returns an iteration object that defines the boundary of this
Line2D .
The iterator for this class is not multi-threaded safe,
which means that this Line2D class does not
guarantee that modifications to the geometry of this
Line2D object do not affect any iterations of that
geometry that are already in process.
Parameters: at - the specified AffineTransform a PathIterator that defines the boundary of thisLine2D . since: 1.2 |
getPathIterator | public PathIterator getPathIterator(AffineTransform at, double flatness)(Code) | | Returns an iteration object that defines the boundary of this
flattened Line2D .
The iterator for this class is not multi-threaded safe,
which means that this Line2D class does not
guarantee that modifications to the geometry of this
Line2D object do not affect any iterations of that
geometry that are already in process.
Parameters: at - the specified AffineTransform Parameters: flatness - the maximum amount that the control points for a given curve can vary from colinear before a subdividedcurve is replaced by a straight line connecting theend points. Since a Line2D object is always flat, this parameter is ignored. a PathIterator that defines the boundary of theflattened Line2D since: 1.2 |
getX1 | abstract public double getX1()(Code) | | Returns the X coordinate of the start point in double precision.
the X coordinate of the start point of this Line2D object. since: 1.2 |
getX2 | abstract public double getX2()(Code) | | Returns the X coordinate of the end point in double precision.
the X coordinate of the end point of this Line2D object. since: 1.2 |
getY1 | abstract public double getY1()(Code) | | Returns the Y coordinate of the start point in double precision.
the Y coordinate of the start point of this Line2D object. since: 1.2 |
getY2 | abstract public double getY2()(Code) | | Returns the Y coordinate of the end point in double precision.
the Y coordinate of the end point of this Line2D object. since: 1.2 |
intersects | public boolean intersects(double x, double y, double w, double h)(Code) | | since: 1.2 |
intersectsLine | public boolean intersectsLine(double x1, double y1, double x2, double y2)(Code) | | Tests if the line segment from
(x1,y1) to
(x2,y2) intersects this line segment.
Parameters: x1 - the X coordinate of the start point of thespecified line segment Parameters: y1 - the Y coordinate of the start point of thespecified line segment Parameters: x2 - the X coordinate of the end point of thespecified line segment Parameters: y2 - the Y coordinate of the end point of thespecified line segment if this line segment and the specified line segmentintersect each other; false otherwise. since: 1.2 |
intersectsLine | public boolean intersectsLine(Line2D l)(Code) | | Tests if the specified line segment intersects this line segment.
Parameters: l - the specified Line2D true if this line segment and the specified linesegment intersect each other; false otherwise. since: 1.2 |
linesIntersect | public static boolean linesIntersect(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)(Code) | | Tests if the line segment from
(x1,y1) to
(x2,y2) intersects the line segment from
(x3,y3)
to
(x4,y4) .
Parameters: x1 - the X coordinate of the start point of the firstspecified line segment Parameters: y1 - the Y coordinate of the start point of the firstspecified line segment Parameters: x2 - the X coordinate of the end point of the firstspecified line segment Parameters: y2 - the Y coordinate of the end point of the firstspecified line segment Parameters: x3 - the X coordinate of the start point of the secondspecified line segment Parameters: y3 - the Y coordinate of the start point of the secondspecified line segment Parameters: x4 - the X coordinate of the end point of the secondspecified line segment Parameters: y4 - the Y coordinate of the end point of the secondspecified line segment true if the first specified line segment and the second specified line segment intersect each other; false otherwise. since: 1.2 |
ptLineDist | public static double ptLineDist(double x1, double y1, double x2, double y2, double px, double py)(Code) | | 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.
Parameters: x1 - the X coordinate of the start point of the specified line Parameters: y1 - the Y coordinate of the start point of the specified line Parameters: x2 - the X coordinate of the end point of the specified line Parameters: y2 - the Y coordinate of the end point of the specified line Parameters: px - the X coordinate of the specified point beingmeasured against the specified line Parameters: py - the Y coordinate of the specified point beingmeasured against the specified line a double value that is the distance from the specifiedpoint to the specified line. See Also: Line2D.ptSegDist(double,double,double,double,double,double) since: 1.2 |
ptLineDist | public double ptLineDist(double px, double py)(Code) | | 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 Line2D . If the specified point
intersects the line, this method returns 0.0.
Parameters: px - the X coordinate of the specified point beingmeasured against this line Parameters: py - the Y coordinate of the specified point beingmeasured against this line a double value that is the distance from a specified pointto the current line. See Also: Line2D.ptSegDist(double,double) since: 1.2 |
ptLineDist | public double ptLineDist(Point2D pt)(Code) | | Returns the distance from a Point2D 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 Line2D . If the specified point
intersects the line, this method returns 0.0.
Parameters: pt - the specified Point2D being measured a double value that is the distance from a specified Point2D to the current line. See Also: Line2D.ptSegDist(Point2D) since: 1.2 |
ptLineDistSq | public static double ptLineDistSq(double x1, double y1, double x2, double y2, double px, double py)(Code) | | 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.
Parameters: x1 - the X coordinate of the start point of the specified line Parameters: y1 - the Y coordinate of the start point of the specified line Parameters: x2 - the X coordinate of the end point of the specified line Parameters: y2 - the Y coordinate of the end point of the specified line Parameters: px - the X coordinate of the specified point beingmeasured against the specified line Parameters: py - the Y coordinate of the specified point beingmeasured against the specified line a double value that is the square of the distance from thespecified point to the specified line. See Also: Line2D.ptSegDistSq(double,double,double,double,double,double) since: 1.2 |
ptLineDistSq | public double ptLineDistSq(double px, double py)(Code) | | 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 Line2D . If the specified point
intersects the line, this method returns 0.0.
Parameters: px - the X coordinate of the specified point beingmeasured against this line Parameters: py - the Y coordinate of the specified point beingmeasured against this line a double value that is the square of the distance from a specified point to the current line. See Also: Line2D.ptSegDistSq(double,double) since: 1.2 |
ptLineDistSq | public double ptLineDistSq(Point2D pt)(Code) | | Returns the square of the distance from a specified
Point2D 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 Line2D . If the specified point
intersects the line, this method returns 0.0.
Parameters: pt - the specified Point2D being measuredagainst this line a double value that is the square of the distance from aspecified Point2D to the currentline. See Also: Line2D.ptSegDistSq(Point2D) since: 1.2 |
ptSegDist | public static double ptSegDist(double x1, double y1, double x2, double y2, double px, double py)(Code) | | 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.
Parameters: x1 - the X coordinate of the start point of thespecified line segment Parameters: y1 - the Y coordinate of the start point of thespecified line segment Parameters: x2 - the X coordinate of the end point of thespecified line segment Parameters: y2 - the Y coordinate of the end point of thespecified line segment Parameters: px - the X coordinate of the specified point beingmeasured against the specified line segment Parameters: py - the Y coordinate of the specified point beingmeasured against the specified line segment a double value that is the distance from the specified pointto the specified line segment. See Also: Line2D.ptLineDist(double,double,double,double,double,double) since: 1.2 |
ptSegDist | public double ptSegDist(double px, double py)(Code) | | 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.
Parameters: px - the X coordinate of the specified point beingmeasured against this line segment Parameters: py - the Y coordinate of the specified point beingmeasured against this line segment a double value that is the distance from the specified point to the current line segment. See Also: Line2D.ptLineDist(double,double) since: 1.2 |
ptSegDist | public double ptSegDist(Point2D pt)(Code) | | Returns the distance from a Point2D 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.
Parameters: pt - the specified Point2D being measuredagainst this line segment a double value that is the distance from the specifiedPoint2D to the current linesegment. See Also: Line2D.ptLineDist(Point2D) since: 1.2 |
ptSegDistSq | public static double ptSegDistSq(double x1, double y1, double x2, double y2, double px, double py)(Code) | | 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.
Parameters: x1 - the X coordinate of the start point of thespecified line segment Parameters: y1 - the Y coordinate of the start point of thespecified line segment Parameters: x2 - the X coordinate of the end point of thespecified line segment Parameters: y2 - the Y coordinate of the end point of thespecified line segment Parameters: px - the X coordinate of the specified point beingmeasured against the specified line segment Parameters: py - the Y coordinate of the specified point beingmeasured against the specified line segment a double value that is the square of the distance from thespecified point to the specified line segment. See Also: Line2D.ptLineDistSq(double,double,double,double,double,double) since: 1.2 |
ptSegDistSq | public double ptSegDistSq(double px, double py)(Code) | | 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.
Parameters: px - the X coordinate of the specified point beingmeasured against this line segment Parameters: py - the Y coordinate of the specified point beingmeasured against this line segment a double value that is the square of the distance from thespecified point to the current line segment. See Also: Line2D.ptLineDistSq(double,double) since: 1.2 |
ptSegDistSq | public double ptSegDistSq(Point2D pt)(Code) | | Returns the square of the distance from a Point2D 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.
Parameters: pt - the specified Point2D being measured againstthis line segment. a double value that is the square of the distance from thespecified Point2D to the current line segment. See Also: Line2D.ptLineDistSq(Point2D) since: 1.2 |
relativeCCW | public static int relativeCCW(double x1, double y1, double x2, double y2, double px, double py)(Code) | | Returns an indicator of where the specified point
(px,py) lies with respect to the line segment from
(x1,y1) to
(x2,y2) .
The return value can be either 1, -1, or 0 and indicates
in which direction the specified line must pivot around its
first end point,
(x1,y1) , in order to point at the
specified point
(px,py) .
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
(x1,y1) " or 1 if the point lies
"beyond
(x2,y2) ".
Parameters: x1 - the X coordinate of the start point of thespecified line segment Parameters: y1 - the Y coordinate of the start point of thespecified line segment Parameters: x2 - the X coordinate of the end point of thespecified line segment Parameters: y2 - the Y coordinate of the end point of thespecified line segment Parameters: px - the X coordinate of the specified point to becompared with the specified line segment Parameters: py - the Y coordinate of the specified point to becompared with the specified line segment an integer that indicates the position of the third specifiedcoordinates with respect to the line segment formedby the first two specified coordinates. since: 1.2 |
relativeCCW | public int relativeCCW(double px, double py)(Code) | | Returns an indicator of where the specified point
(px,py) lies with respect to this line segment.
See the method comments of
Line2D.relativeCCW(double,double,double,double,double,double) to interpret the return value.
Parameters: px - the X coordinate of the specified pointto be compared with this Line2D Parameters: py - the Y coordinate of the specified pointto be compared with this Line2D an integer that indicates the position of the specifiedcoordinates with respect to this Line2D See Also: Line2D.relativeCCW(double,double,double,double,double,double) since: 1.2 |
relativeCCW | public int relativeCCW(Point2D p)(Code) | | Returns an indicator of where the specified Point2D
lies with respect to this line segment.
See the method comments of
Line2D.relativeCCW(double,double,double,double,double,double) to interpret the return value.
Parameters: p - the specified Point2D to be compared with this Line2D an integer that indicates the position of the specifiedPoint2D with respect to this Line2D See Also: Line2D.relativeCCW(double,double,double,double,double,double) since: 1.2 |
setLine | abstract public void setLine(double x1, double y1, double x2, double y2)(Code) | | Sets the location of the end points of this Line2D to
the specified double coordinates.
Parameters: x1 - the X coordinate of the start point Parameters: y1 - the Y coordinate of the start point Parameters: x2 - the X coordinate of the end point Parameters: y2 - the Y coordinate of the end point since: 1.2 |
setLine | public void setLine(Point2D p1, Point2D p2)(Code) | | Sets the location of the end points of this Line2D to
the specified Point2D coordinates.
Parameters: p1 - the start Point2D of the line segment Parameters: p2 - the end Point2D of the line segment since: 1.2 |
setLine | public void setLine(Line2D l)(Code) | | Sets the location of the end points of this Line2D to
the same as those end points of the specified Line2D .
Parameters: l - the specified Line2D since: 1.2 |
|
|