|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectobjectdraw.Drawable
objectdraw.Line
Line is an implementation of a drawable line segment object.
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 | |
void |
addToCanvas(DrawingCanvas c)
Places an existing object on a specified DrawingCanvas. |
boolean |
contains(Location point)
Determines if a particular position on the DrawingCanvas is contained within the object. |
DrawingCanvas |
getCanvas()
Determine which (if any) DrawingCanvas this object is positioned on |
java.awt.Color |
getColor()
Retrieves the color of the object. |
Location |
getEnd()
Gets the line's end point. |
Location |
getStart()
Gets the line's start point. |
void |
hide()
Temporarily hides an object on a DrawingCanvas from view. |
boolean |
isHidden()
Determine whether an object is currently visible on its canvas |
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 |
moveTo(Location point)
Moves the object within the canvas to the specified Location |
void |
removeFromCanvas()
Permanently removes the object from the canvas it is currently on. |
void |
sendBackward()
Sends the object backward. |
void |
sendForward()
Sends the object forward. |
void |
sendToBack()
Sends the object to the back. |
void |
sendToFront()
Sends the object to the front. |
void |
setColor(java.awt.Color c)
Sets the color of the object. |
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. |
void |
show()
Shows the object if it has been hidden. |
java.lang.String |
toString()
Generates a string representation of the object. |
Methods inherited from class java.lang.Object |
equals, 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 |
Constructor Detail |
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.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 boolean contains(Location point)
DrawableInterface
contains
in interface DrawableInterface
public Location getStart()
Drawable1DInterface
getStart
in interface Drawable1DInterface
public Location getEnd()
Drawable1DInterface
getEnd
in interface Drawable1DInterface
public void setStart(Location point)
Drawable1DInterface
setStart
in interface Drawable1DInterface
point
- new start pointpublic 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 setEnd(Location point)
Drawable1DInterface
setEnd
in interface Drawable1DInterface
point
- new endpointpublic 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 setEndPoints(Location start, Location end)
Drawable1DInterface
setEndPoints
in interface Drawable1DInterface
start
- first endpointend
- second 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 java.lang.String toString()
public void moveTo(double x, double y)
DrawableInterface
moveTo
in interface DrawableInterface
public void move(double dx, double dy)
DrawableInterface
move
in interface DrawableInterface
public void addToCanvas(DrawingCanvas c)
DrawableInterface
removeFromCanvas()
followed
by addToCanvas. This method can also be invoked to place a Drawable object on a
DrawingCanvas after the object is loaded from a file or other stream.
addToCanvas
in interface DrawableInterface
c
- the canvas on which the object should be drawnpublic void removeFromCanvas()
DrawableInterface
hide()
instead.
removeFromCanvas
in interface DrawableInterface
public DrawingCanvas getCanvas()
DrawableInterface
getCanvas
in interface DrawableInterface
public void hide()
DrawableInterface
show()
method.
If the goal is to remove an object from the display permanently, the
removeFromCanvas()
method should be used instead.
hide
in interface DrawableInterface
public void show()
DrawableInterface
show
in interface DrawableInterface
public boolean isHidden()
DrawableInterface
isHidden
in interface DrawableInterface
public void moveTo(Location point)
DrawableInterface
moveTo
in interface DrawableInterface
point
- the destination for moving the object.public void setColor(java.awt.Color c)
DrawableInterface
setColor
in interface DrawableInterface
c
- the color.public java.awt.Color getColor()
DrawableInterface
getColor
in interface DrawableInterface
public void sendForward()
DrawableInterface
sendForward
in interface DrawableInterface
public void sendBackward()
DrawableInterface
sendBackward
in interface DrawableInterface
public void sendToFront()
DrawableInterface
sendToFront
in interface DrawableInterface
public void sendToBack()
DrawableInterface
sendToBack
in interface DrawableInterface
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |