|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectobjectdraw.Drawable
objectdraw.Line
public class Line
Line is an implementation of a drawable line segment object.
Field Summary | |
---|---|
protected Location |
end
The line's second endpoint. |
protected Location |
start
The line's first endpoint. |
Fields inherited from class objectdraw.Drawable |
---|
canvasContent, color, shown |
Constructor Summary | |
---|---|
Line(double startx,
double starty,
double endx,
double endy,
DrawingCanvas c)
Creates a new Line object going from (startx,starty) to (endx,endy). |
|
Line(Location start,
Location end,
DrawingCanvas canvas)
Creates a new Line object going from start to end. |
Method Summary | |
---|---|
boolean |
contains(Location point)
Determines if a particular position on the DrawingCanvas is contained within the object. |
(package private) void |
draw(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 object within the canvas in the x and y direction by the amounts specified as parameters. |
void |
moveTo(double x,
double y)
Moves the object within the canvas to the x and y coordinates provided. |
void |
setEnd(double x,
double y)
Sets the line's end point. |
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(double x,
double y)
Sets the line's start point. |
void |
setStart(Location point)
Sets the line's start point. |
String |
toString()
Generates a string representation of the object. |
Methods inherited from class objectdraw.Drawable |
---|
addToCanvas, clearCanvasContent, getCanvas, getColor, hide, isHidden, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setCanvasContent, setColor, setStateChanged, show |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface objectdraw.DrawableInterface |
---|
addToCanvas, getCanvas, getColor, hide, isHidden, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setColor, show |
Field Detail |
---|
protected Location end
protected Location start
Constructor Detail |
---|
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.public Line(Location start, Location end, DrawingCanvas canvas)
start
- the starting point of the line.end
- the destination point of the line.canvas
- the canvas in which the line is created.Method Detail |
---|
public boolean contains(Location point)
DrawableInterface
contains
in interface DrawableInterface
contains
in class Drawable
point
- the position on the canvas.
void draw(Graphics g)
draw
in class Drawable
g
- the graphics context into which the object is drawn.public Location getEnd()
Drawable1DInterface
getEnd
in interface Drawable1DInterface
public Location getStart()
Drawable1DInterface
getStart
in interface Drawable1DInterface
public void move(double dx, double dy)
DrawableInterface
move
in interface DrawableInterface
move
in class Drawable
dx
- the amount to move in the x-direction.dy
- the amount to move in the y-direction.public void moveTo(double x, double y)
DrawableInterface
moveTo
in interface DrawableInterface
moveTo
in class Drawable
x
- horizontal coordinate of destination.y
- horizontal coordinate of destination.public void setEnd(double x, double y)
Drawable1DInterface
setEnd
in interface Drawable1DInterface
x
- x coordinate of new end pointy
- y coordinate of new end pointpublic void setEnd(Location point)
Drawable1DInterface
setEnd
in interface Drawable1DInterface
point
- new endpointpublic void setEndPoints(double x1, double y1, double x2, double y2)
Drawable1DInterface
setEndPoints
in interface Drawable1DInterface
x1
- x coordinate of starty1
- y coordinate of startx2
- x coordinate of endy2
- y coordinate of endpublic void setEndPoints(Location start, Location end)
Drawable1DInterface
setEndPoints
in interface Drawable1DInterface
start
- first endpointend
- second endpointpublic void setStart(double x, double y)
Drawable1DInterface
setStart
in interface Drawable1DInterface
x
- x coordinate of new start pointy
- y coordinate of new start pointpublic void setStart(Location point)
Drawable1DInterface
setStart
in interface Drawable1DInterface
point
- new start pointpublic String toString()
toString
in class Object
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |