|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--objectdraw.Drawable | +--objectdraw.Line
Line is an implementation of a drawable line segment object.
Field Summary | |
static double |
CONTAINMENT_ECCENTRICITY
Eccentricity of the ellipse surrounding the line, used to test for containment. |
protected Location |
end
The line's second endpoint. |
protected Location |
start
The line's first endpoint. |
Fields inherited from class objectdraw.Drawable |
canvas, canvasContent, color, DEBUGGING, shown |
Constructor Summary | |
Line(double startx,
double starty,
double endx,
double endy,
DrawingCanvas c)
Creates a new Line object. |
|
Line(Location start,
Location end,
DrawingCanvas c)
Creates a new Line object. |
Method Summary | |
boolean |
contains(Location point)
Determines if the object contains the given point. |
void |
draw(java.awt.Graphics g)
Draws the object. |
Location |
getEnd()
Gets the line's end point. |
Location |
getStart()
Gets the line's start point. |
void |
move(double dx,
double dy)
Moves the line in the x and y directions the specified amounts. |
void |
moveTo(double x,
double y)
Moves the line to the specified coordinates. |
void |
moveTo(Location point)
Moves the line to the specified Location. |
void |
setEnd(Location point)
Sets the line's end point. |
void |
setEndPoints(double x1,
double y1,
double x2,
double y2)
Sets the line's end points. |
void |
setEndPoints(Location start,
Location end)
Sets the line's end points. |
void |
setStart(Location point)
Sets the line's start point. |
java.lang.String |
toString()
Generates a string representation of the object. |
Methods inherited from class objectdraw.Drawable |
addToCanvas, getColor, hide, isHidden, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setColor, setStateChanged, show |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final double CONTAINMENT_ECCENTRICITY
protected Location start
protected Location end
Constructor Detail |
public Line(Location start, Location end, DrawingCanvas c)
start
- the starting point of the line.end
- the destination point of the line.c
- the canvas in which the line is created.public Line(double startx, double starty, double endx, double endy, DrawingCanvas c)
startx
- x-coordinate of the first endpointstarty
- y-coordinate of the second endpointendx
- x-coordinate of the second endpointendy
- y-coordinate of the second endpointc
- the canvas in which the line is created.Method Detail |
public void draw(java.awt.Graphics g)
draw
in class Drawable
g
- the graphics context into which the object is drawn.public boolean contains(Location point)
contains
in class Drawable
point
- the pointtrue
if point is contained in the object;
false
otherwise.public Location getStart()
public Location getEnd()
public void setStart(Location point)
point
- new start pointpublic void setEnd(Location point)
point
- new endpointpublic void setEndPoints(Location start, Location end)
start
- first endpointend
- second endpointpublic void setEndPoints(double x1, double y1, double x2, double y2)
start
- first endpointend
- second endpointpublic java.lang.String toString()
toString
in class java.lang.Object
public void moveTo(Location point)
moveTo
in class Drawable
dest
- the destination for moving the object.public void moveTo(double x, double y)
moveTo
in class Drawable
x
- horizontal coordinate of destination.y
- horizontal coordinate of destination.public void move(double dx, double dy)
move
in class Drawable
dx
- the amount to move in the x-direction.dy
- the amount to move in the y-direction.
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |