public abstract class Line2D extends java.lang.Object implements Shape, java.lang.Cloneable
Modifier and Type | Class and Description |
---|---|
static class |
Line2D.Double
A line in 2D space using float coordinates
|
static class |
Line2D.Float
A line in 2D space using float coordinates
|
Modifier | Constructor and Description |
---|---|
protected |
Line2D()
This is an abstract class that cannot be instantiated: use Line2D.Float or Line2D.Double.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone() |
boolean |
contains(double x,
double y)
Test if the shape contains the point (x,y)
|
boolean |
contains(double x,
double y,
double w,
double h)
Test if the shape contains the rectangle with top left at (x,y), width w and height h.
|
boolean |
contains(Point2D p)
Test if the shape contains the Point2D
|
boolean |
contains(Rectangle2D r)
Test if the shape contains the Rectangle2D
|
RectangleInt32 |
getBounds()
Get the bounding Rectangle for the shape
|
abstract Point2D |
getP1()
Get the start point of the line as a Point2D
|
abstract Point2D |
getP2()
Get the end point of the line as a Point2D
|
abstract double |
getX1()
Get the x coordinate of the start of the line
|
abstract double |
getX2()
Get the x coordinate of the end of the line
|
abstract double |
getY1()
Get the y coordinate of the start of the line
|
abstract double |
getY2()
Get the y coordinate of the end of the line
|
boolean |
intersects(double x,
double y,
double w,
double h)
Test if the shape intersects the rectangle with top left at (x,y), width w and height h.
|
boolean |
intersects(Rectangle2D r)
Test if the shape intersects the Rectangle2D r
|
boolean |
intersectsLine(double x1,
double y1,
double x2,
double y2)
Test if this line intersects a given line
|
boolean |
intersectsLine(Line2D l)
Tests if this line intersects a given line
|
static boolean |
linesIntersect(double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
double x4,
double y4)
Test if one line intersects another line
|
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)
Returns an indicator of where the specified point
lies with respect to the line.
|
static int |
relativeCCW(double x1,
double y1,
double x2,
double y2,
double px,
double py)
Returns an indicator of where the specified point
lies with respect to the line
|
int |
relativeCCW(Point2D p)
Returns an indicator of where the specified point
lies with respect to the line
|
abstract void |
setLine(double x1,
double y1,
double x2,
double y2)
Sets the end points of the line using double coordinates.
|
void |
setLine(Line2D line)
Set the end points of a line to the same as a given line
|
void |
setLine(Point2D p1,
Point2D p2)
Sets the end points of the line from a given start and end point
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBounds2D
protected Line2D()
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 x coordinate of the start pointy1
- the y coordinate of the start pointx2
- the x coordinate of the end pointy2
- the y coordinate of the end pointpublic void setLine(Point2D p1, Point2D p2)
p1
- the start pointp2
- the end pointpublic void setLine(Line2D line)
line
- the given linepublic boolean contains(double x, double y)
Shape
public boolean contains(Point2D p)
Shape
public boolean contains(double x, double y, double w, double h)
Shape
public boolean contains(Rectangle2D r)
Shape
public boolean intersects(double x, double y, double w, double h)
Shape
intersects
in interface Shape
x
- the x-coordinate of the top left point of the rectangley
- the y-coordinate of the top left point of the rectanglew
- the width of the rectangleh
- the height of the rectanglepublic boolean intersectsLine(double x1, double y1, double x2, double y2)
x1
- the x coordinate of the start of the given liney1
- the y coordinate of the start of the given linex2
- the x coordinate of the end of the given liney2
- the y coordinate of the end of the given linepublic boolean intersectsLine(Line2D l)
l
- the given linepublic static boolean linesIntersect(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
x1
- the x coordinate of the start of the first liney1
- the y coordinate of the start of the first linex2
- the x coordinate of the end of the first liney2
- the y coordinate of the end of the first linex3
- the x coordinate of the start of the second liney3
- the y coordinate of the start of the second linex4
- the x coordinate of the end of the second liney4
- the y coordinate of the end of the second linepublic RectangleInt32 getBounds()
Shape
public java.lang.Object clone()
clone
in class java.lang.Object
public static int relativeCCW(double x1, double y1, double x2, double y2, double px, double py)
x1
- the x coordinate of the start of the liney1
- the y coordinate of the start of the linex2
- the x coordinate of the end of the liney2
- the y coordinate of the end of the linepx
- the x coordinate of the specified pointpy
- the y coordinate of the specified pointpublic int relativeCCW(Point2D p)
p
- the specified pointpublic int relativeCCW(double px, double py)
px
- the x coordinate of the specified pointpy
- the y coordinate of the specified pointpublic boolean intersects(Rectangle2D r)
Shape
intersects
in interface Shape
r
- the Recangle2Dpublic 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 pointpublic 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 pointpublic double ptSegDistSq(double px, double py)
px
- the x coordinate of the pointpy
- the y coordinate of the pointptSegDistSq(double, double, double, double, double, double)
public double ptSegDistSq(Point2D p)
p
- the pointjava.lang.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 pointptSegDist(double, double, double, double, double, double)
public double ptSegDist(Point2D p)
p
- the pointjava.lang.NullPointerException
- if p is nullptSegDist(double, double, double, double, double, double)