All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.geom.Line2D
java.lang.Object
|
+----java.awt.geom.Line2D
- public abstract class Line2D
- extends Object
- implements Shape
A line segment in (x, y) coordinate space.
For the purposes of the Shape interface, a coordinate is considered
to be inside or contained by this line segment if the coordinate
lies exactly on the line segment.
This class is only the abstract superclass for all objects which
store a 2D line segment.
The actual storage representation of the coordinates is left to
the subclass.
Line2D.Float- A line segment specified with float coordinates.
Line2D()
-
colinear(double, double)
- Test if a given (x, y) coordinate is colinear with the line segment.
colinear(Point2D)
- Test if a given Point is colinear with the line segment.
contains(double, double)
- Test if a given coordinate is inside the boundary of the shape.
contains(double, double, double, double)
- Test if the interior of the Shape entirely contains the given
set of rectangular coordinates.
contains(Point2D)
- Test if a given Point is inside the boundary of the shape.
contains(Rectangle2D)
- Test if the interior of the Shape entirely contains the given
Rectangle.
getBounds()
- Return the bounding box of the shape.
getPathIterator(AffineTransform)
- Return an iteration object that defines the boundary of the
shape.
getPathIterator(AffineTransform, double)
- Return an iteration object that defines the boundary of the
flattened shape.
getX1()
- Returns the X coordinate of the start point in double precision.
getX2()
- Returns the X coordinate of the end point in double precision.
getY1()
- Returns the Y coordinate of the start point in double precision.
getY2()
- Returns the Y coordinate of the end point in double precision.
intersects(double, double, double, double)
- Test if the Shape intersects the interior of a given
set of rectangular coordinates.
intersects(Rectangle2D)
- Test if the Shape intersects the interior of a given
Rectangle.
intersectsLine(double, double, double, double)
- Tests if the line segment from (x1, y1) to (x2, y2) intersects
this line segment.
intersectsLine(Line2D)
- Tests if the given line segment intersects this line segment.
linesIntersect(double, double, double, double, double, double, double, double)
- Tests if the line segment from (x1, y1) to (x2, y2) intersects
the line segment from (x3, y3) to (x4, y4).
ptSegDist(double, double, double, double, double, double)
- Returns the distance from a point to a line segment.
ptSegDistSq(double, double, double, double, double, double)
- Returns the square of the distance from a point to a line segment.
relativeCCW(double, double)
- Return an indicator of where the specified point (x, y) lies
with respect to this line segment.
relativeCCW(double, double, double, double, double, double)
- Return an indicator of where the specified point (px, py) lies
with respect to the line segment from (x1, y1) to (x2, y2).
relativeCCW(Point2D)
- Return an indicator of where the specified point lies
with respect to this line segment.
setLine(double, double, double, double)
- Sets the location of the endpoints of this line to the specified
double coordinates.
setLine(Line2D)
- Sets the location of the endpoints of this line to the same
as those in the specified Line.
setLine(Point2D, Point2D)
- Sets the location of the endpoints of this line to the specified
Point coordinates.
Line2D
protected Line2D()
getX1
public abstract double getX1()
- Returns the X coordinate of the start point in double precision.
getY1
public abstract double getY1()
- Returns the Y coordinate of the start point in double precision.
getX2
public abstract double getX2()
- Returns the X coordinate of the end point in double precision.
getY2
public abstract double getY2()
- Returns the Y coordinate of the end point in double precision.
setLine
public abstract void setLine(double x1,
double y1,
double x2,
double y2)
- Sets the location of the endpoints of this line to the specified
double coordinates.
setLine
public void setLine(Point2D p1,
Point2D p2)
- Sets the location of the endpoints of this line to the specified
Point coordinates.
setLine
public void setLine(Line2D l)
- Sets the location of the endpoints of this line to the same
as those in the specified Line.
colinear
public boolean colinear(double x,
double y)
- Test if a given (x, y) coordinate is colinear with the line segment.
colinear
public boolean colinear(Point2D p)
- Test if a given Point is colinear with the line segment.
relativeCCW
public static int relativeCCW(double x1,
double y1,
double x2,
double y2,
double px,
double py)
- Return an indicator of where the specified point (px, py) lies
with respect to the line segment from (x1, y1) to (x2, y2).
The value will be 1 if the line segment must turn counterclockwise
to point at the specified point, -1 if it must turn clockwise,
or 0 if the point lies exactly on the line segment.
If the point is colinear with the line segment, but not between
the endpoints, then the value will be -1 if the point lies
"beyond (x1, y1)" or 1 if the point lies "beyond (x2, y2)".
relativeCCW
public int relativeCCW(double x,
double y)
- Return an indicator of where the specified point (x, y) lies
with respect to this line segment.
The value will be 1 if the line segment must turn counterclockwise
to point at the specified point, -1 if it must turn clockwise,
or 0 if the point lies exactly on the line segment.
If the point is colinear with the line segment, but not between
the endpoints, then the value will be -1 if the point lies
"beyond (x1, y1)" or 1 if the point lies "beyond (x2, y2)".
relativeCCW
public int relativeCCW(Point2D p)
- Return an indicator of where the specified point lies
with respect to this line segment.
The value will be 1 if the line segment must turn counterclockwise
to point at the specified point, -1 if it must turn clockwise,
or 0 if the point lies exactly on the line segment.
If the point is colinear with the line segment, but not between
the endpoints, then the value will be -1 if the point lies
"beyond (x1, y1)" or 1 if the point lies "beyond (x2, y2)".
linesIntersect
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).
intersectsLine
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.
intersectsLine
public boolean intersectsLine(Line2D l)
- Tests if the given line segment intersects this line segment.
ptSegDistSq
public static double ptSegDistSq(double x0,
double y0,
double x1,
double y1,
double px,
double py)
- Returns the square of the distance from a point to a line segment.
- Parameters:
- x0 - the x coordinate of the beginning of the line segment
- y0 - the y coordinate of the beginning of the line segment
- x1 - the x coordinate of the end of the line segment
- y1 - the y coordinate of the end of the line segment
- px - the x coordinate of the point being measured
- py - the y coordinate of the point being measured
ptSegDist
public static double ptSegDist(double x0,
double y0,
double x1,
double y1,
double px,
double py)
- Returns the distance from a point to a line segment.
- Parameters:
- x0 - the x coordinate of the beginning of the line segment
- y0 - the y coordinate of the beginning of the line segment
- x1 - the x coordinate of the end of the line segment
- y1 - the y coordinate of the end of the line segment
- px - the x coordinate of the point being measured
- py - the y coordinate of the point being measured
contains
public boolean contains(double x,
double y)
- Test if a given coordinate is inside the boundary of the shape.
contains
public boolean contains(Point2D p)
- Test if a given Point is inside the boundary of the shape.
intersects
public boolean intersects(double x,
double y,
double w,
double h)
- Test if the Shape intersects the interior of a given
set of rectangular coordinates.
intersects
public boolean intersects(Rectangle2D r)
- Test if the Shape intersects the interior of a given
Rectangle.
contains
public boolean contains(double x,
double y,
double w,
double h)
- Test if the interior of the Shape entirely contains the given
set of rectangular coordinates.
contains
public boolean contains(Rectangle2D r)
- Test if the interior of the Shape entirely contains the given
Rectangle.
getBounds
public Rectangle getBounds()
- Return the bounding box of the shape.
getPathIterator
public PathIterator getPathIterator(AffineTransform at)
- Return an iteration object that defines the boundary of the
shape.
getPathIterator
public PathIterator getPathIterator(AffineTransform at,
double flatness)
- Return an iteration object that defines the boundary of the
flattened shape.
All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature