|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.geom.Line2D
public abstract class Line2D
Represents a directed line bewteen two points in (x,y) Cartesian space. Remember, on-screen graphics have increasing x from left-to-right, and increasing y from top-to-bottom. The storage is left to subclasses.
Nested Class Summary | |
---|---|
static class |
Line2D.Double
This class defines a point in double precision. |
static class |
Line2D.Float
This class defines a point in float precision. |
Constructor Summary | |
---|---|
protected |
Line2D()
The default constructor. |
Method Summary | |
---|---|
Object |
clone()
Create a new line of the same run-time type with the same contents as this one. |
boolean |
contains(double x,
double y)
Test if a point is contained inside the line. |
boolean |
contains(double x,
double y,
double w,
double h)
Tests if the line contains a rectangle. |
boolean |
contains(Point2D p)
Test if a point is contained inside the line. |
boolean |
contains(Rectangle2D r)
Tests if the line contains a rectangle. |
Rectangle |
getBounds()
Gets a bounding box (not necessarily minimal) for this line. |
abstract Point2D |
getP1()
Return the first point. |
abstract Point2D |
getP2()
Return the second point. |
PathIterator |
getPathIterator(AffineTransform at)
Return a path iterator, possibly applying a transform on the result. |
PathIterator |
getPathIterator(AffineTransform at,
double flatness)
Return a flat path iterator, possibly applying a transform on the result. |
abstract double |
getX1()
Return the x coordinate of the first point. |
abstract double |
getX2()
Return the x coordinate of the second point. |
abstract double |
getY1()
Return the y coordinate of the first point. |
abstract double |
getY2()
Return the y coordinate of the second point. |
boolean |
intersects(double x,
double y,
double w,
double h)
Tests if this line intersects the interior of the specified rectangle. |
boolean |
intersects(Rectangle2D r)
Tests if this line intersects the interior of the specified rectangle. |
boolean |
intersectsLine(double x1,
double y1,
double x2,
double y2)
Test if this line intersects the line given by (x1,y1)->(x2,y2). |
boolean |
intersectsLine(Line2D l)
Test if this line intersects the given line. |
static boolean |
linesIntersect(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double x4,
double y4)
Test if the line segment (x1,y1)->(x2,y2) intersects the line segment (x3,y3)->(x4,y4). |
double |
ptLineDist(double px,
double py)
Measures the shortest distance from the reference point to a point on the infinite line extended from this segment. |
static double |
ptLineDist(double x1,
double y1,
double x2,
double y2,
double px,
double py)
Measures the shortest distance from the reference point to a point on the infinite line extended from the segment. |
double |
ptLineDist(Point2D p)
Measures the shortest distance from the reference point to a point on the infinite line extended from this segment. |
double |
ptLineDistSq(double px,
double py)
Measures the square of the shortest distance from the reference point to a point on the infinite line extended from this segment. |
static double |
ptLineDistSq(double x1,
double y1,
double x2,
double y2,
double px,
double py)
Measures the square of the shortest distance from the reference point to a point on the infinite line extended from the segment. |
double |
ptLineDistSq(Point2D p)
Measures the square of the shortest distance from the reference point to a point on the infinite line extended from this segment. |
double |
ptSegDist(double px,
double py)
Measures the shortest distance from the reference point to a point on this line segment. |
static double |
ptSegDist(double x1,
double y1,
double x2,
double y2,
double px,
double py)
Measures the shortest distance from the reference point to a point on the line segment. |
double |
ptSegDist(Point2D p)
Measures the shortest distance from the reference point to a point on this line segment. |
double |
ptSegDistSq(double px,
double py)
Measures the square of the shortest distance from the reference point to a point on this line segment. |
static double |
ptSegDistSq(double x1,
double y1,
double x2,
double y2,
double px,
double py)
Measures the square of the shortest distance from the reference point to a point on the line segment. |
double |
ptSegDistSq(Point2D p)
Measures the square of the shortest distance from the reference point to a point on this line segment. |
int |
relativeCCW(double px,
double py)
Computes the relative rotation direction needed to pivot this line about the first point in order to have the second point colinear with point p. |
static int |
relativeCCW(double x1,
double y1,
double x2,
double y2,
double px,
double py)
Computes the relative rotation direction needed to pivot the line about the first point in order to have the second point colinear with point p. |
int |
relativeCCW(Point2D p)
Computes the relative rotation direction needed to pivot this line about the first point in order to have the second point colinear with point p. |
abstract void |
setLine(double x1,
double y1,
double x2,
double y2)
Set the coordinates of the line to the given coordinates. |
void |
setLine(Line2D l)
Set the coordinates to those of the given line. |
void |
setLine(Point2D p1,
Point2D p2)
Set the coordinates to the given points. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.awt.Shape |
---|
getBounds2D |
Constructor Detail |
---|
protected Line2D()
Method Detail |
---|
public abstract double getX1()
public abstract double getY1()
public abstract Point2D getP1()
public abstract double getX2()
public abstract double getY2()
public abstract Point2D getP2()
public abstract void setLine(double x1, double y1, double x2, double y2)
x1
- the first x coordinatey1
- the first y coordinatex2
- the second x coordinatey2
- the second y coordinatepublic void setLine(Point2D p1, Point2D p2)
p1
- the first pointp2
- the second point
NullPointerException
- if either point is nullpublic void setLine(Line2D l)
l
- the line to copy
NullPointerException
- if l is nullpublic static int relativeCCW(double x1, double y1, double x2, double y2, double px, double py)
x1
- the first x coordinatey1
- the first y coordinatex2
- the second x coordinatey2
- the second y coordinatepx
- the reference x coordinatepy
- the reference y coordinate
public int relativeCCW(double px, double py)
px
- the reference x coordinatepy
- the reference y coordinate
relativeCCW(double, double, double, double, double, double)
public int relativeCCW(Point2D p)
p
- the reference point
NullPointerException
- if p is nullrelativeCCW(double, double, double, double, double, double)
public static boolean linesIntersect(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
x1
- the first x coordinate of the first segmenty1
- the first y coordinate of the first segmentx2
- the second x coordinate of the first segmenty2
- the second y coordinate of the first segmentx3
- the first x coordinate of the second segmenty3
- the first y coordinate of the second segmentx4
- the second x coordinate of the second segmenty4
- the second y coordinate of the second segment
public boolean intersectsLine(double x1, double y1, double x2, double y2)
x1
- the first x coordinate of the other segmenty1
- the first y coordinate of the other segmentx2
- the second x coordinate of the other segmenty2
- the second y coordinate of the other segment
linesIntersect(double, double, double, double,
double, double, double, double)
public boolean intersectsLine(Line2D l)
l
- the other segment
NullPointerException
- if l is nulllinesIntersect(double, double, double, double,
double, double, double, double)
public static double ptSegDistSq(double x1, double y1, double x2, double y2, double px, double py)
x1
- the first x coordinate of the segmenty1
- the first y coordinate of the segmentx2
- the second x coordinate of the segmenty2
- the second y coordinate of the segmentpx
- the x coordinate of the pointpy
- the y coordinate of the point
ptSegDist(double, double, double, double, double, double)
,
ptLineDistSq(double, double, double, double, double, double)
public static double ptSegDist(double x1, double y1, double x2, double y2, double px, double py)
x1
- the first x coordinate of the segmenty1
- the first y coordinate of the segmentx2
- the second x coordinate of the segmenty2
- the second y coordinate of the segmentpx
- the x coordinate of the pointpy
- the y coordinate of the point
ptSegDistSq(double, double, double, double, double, double)
,
ptLineDist(double, double, double, double, double, double)
public double ptSegDistSq(double px, double py)
px
- the x coordinate of the pointpy
- the y coordinate of the point
ptSegDistSq(double, double, double, double, double, double)
public double ptSegDistSq(Point2D p)
p
- the point
NullPointerException
- if p is nullptSegDistSq(double, double, double, double, double, double)
public double ptSegDist(double px, double py)
px
- the x coordinate of the pointpy
- the y coordinate of the point
ptSegDist(double, double, double, double, double, double)
public double ptSegDist(Point2D p)
p
- the point
NullPointerException
- if p is nullptSegDist(double, double, double, double, double, double)
public static double ptLineDistSq(double x1, double y1, double x2, double y2, double px, double py)
x1
- the first x coordinate of the segmenty1
- the first y coordinate of the segmentx2
- the second x coordinate of the segmenty2
- the second y coordinate of the segmentpx
- the x coordinate of the pointpy
- the y coordinate of the point
ptLineDist(double, double, double, double, double, double)
,
ptSegDistSq(double, double, double, double, double, double)
public static double ptLineDist(double x1, double y1, double x2, double y2, double px, double py)
x1
- the first x coordinate of the segmenty1
- the first y coordinate of the segmentx2
- the second x coordinate of the segmenty2
- the second y coordinate of the segmentpx
- the x coordinate of the pointpy
- the y coordinate of the point
ptLineDistSq(double, double, double, double, double, double)
,
ptSegDist(double, double, double, double, double, double)
public double ptLineDistSq(double px, double py)
px
- the x coordinate of the pointpy
- the y coordinate of the point
ptLineDistSq(double, double, double, double, double, double)
public double ptLineDistSq(Point2D p)
p
- the point
NullPointerException
- if p is nullptLineDistSq(double, double, double, double, double, double)
public double ptLineDist(double px, double py)
px
- the x coordinate of the pointpy
- the y coordinate of the point
ptLineDist(double, double, double, double, double, double)
public double ptLineDist(Point2D p)
p
- the point
NullPointerException
- if p is nullptLineDist(double, double, double, double, double, double)
public boolean contains(double x, double y)
contains
in interface Shape
x
- the x coordinatey
- the y coordinate
public boolean contains(Point2D p)
contains
in interface Shape
p
- the point
public boolean intersects(double x, double y, double w, double h)
intersects
in interface Shape
x
- the x coordinate of the rectangley
- the y coordinate of the rectanglew
- the width of the rectangleh
- the height of the rectangle
Area
public boolean intersects(Rectangle2D r)
intersects
in interface Shape
r
- the rectangle
NullPointerException
- if r is nullShape.intersects(double, double, double, double)
public boolean contains(double x, double y, double w, double h)
contains
in interface Shape
x
- the x coordinate of the rectangley
- the y coordinate of the rectanglew
- the width of the rectangleh
- the height of the rectangle
Area
public boolean contains(Rectangle2D r)
contains
in interface Shape
r
- the rectangle
Shape.contains(double, double, double, double)
public Rectangle getBounds()
getBounds
in interface Shape
Shape.getBounds2D()
public PathIterator getPathIterator(AffineTransform at)
getPathIterator
in interface Shape
at
- the transform, or null
public PathIterator getPathIterator(AffineTransform at, double flatness)
getPathIterator
in interface Shape
at
- the transform, or nullflatness
- ignored, since lines are already flat
getPathIterator(AffineTransform)
public Object clone()
clone
in class Object
OutOfMemoryError
- If there is not enough memory available.Cloneable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |