|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.geom.Line2D
public abstract class Line2D
An abstract class representing a line in two dimensional space
Nested Class Summary | |
---|---|
static class |
Line2D.Double
A line in 2D space using float coordinates |
static class |
Line2D.Float
A line in 2D space using float coordinates |
Constructor Summary | |
---|---|
protected |
Line2D()
This is an abstract class that cannot be instantiated: use Line2D.Float or Line2D.Double. |
Method Summary | |
---|---|
Object |
clone()
Create a copy of this object, using a shallow copy. |
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 |
Rectangle |
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 |
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 |
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 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
contains
in interface Shape
x
- the x co-ordinate of the pointy
- the y co-ordinate of the point
public boolean contains(Point2D p)
Shape
contains
in interface Shape
p
- the Point2D
public boolean contains(double x, double y, double w, double h)
Shape
contains
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 rectangle
public boolean contains(Rectangle2D r)
Shape
contains
in interface Shape
r
- the Rectangle2D
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 rectangle
public 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 line
public boolean intersectsLine(Line2D l)
l
- the given line
public 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 line
public Rectangle getBounds()
Shape
getBounds
in interface Shape
public Object clone()
Object
clone
in class 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 point
public int relativeCCW(Point2D p)
p
- the specified point
public int relativeCCW(double px, double py)
px
- the x coordinate of the specified pointpy
- the y coordinate of the specified point
public boolean intersects(Rectangle2D r)
Shape
intersects
in interface Shape
r
- the Recangle2D
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |