public interface DrawableInterface
DrawableInterface
is the interface shared by all objects that can
be drawn on a canvas. It includes methods for moving objects, hiding and showing them,
changing their order, and manipulating their color and canvas.
Method Summary | |
---|---|
void |
addToCanvas(DrawingCanvas c)
Place this object on the specified canvas. |
boolean |
contains(Location point)
Return true if the given location is inside this object, false
otherwise. |
DrawingCanvas |
getCanvas()
Return the canvas that this object is on. |
Color |
getColor()
Return the color of this object |
void |
hide()
Make this object invisible. |
boolean |
isHidden()
Return true if this object has been rendered invisible with a call to its
hide() method, false if it is still being drawn. |
void |
move(double dx,
double dy)
Shift (translate) this object left or right by an amount dx , and up or
down by an amount dy . |
void |
moveTo(double x,
double y)
Move the reference point of this object to the given location. |
void |
moveTo(Location point)
Move the reference point of this object to the given location. |
void |
removeFromCanvas()
Remove this object from its canvas. |
void |
sendBackward()
Move this object one step backward in the draw order, causing it to be drawn underneath the objects that are in front of it. |
void |
sendForward()
Move this object one step forward in the draw order, causing it to be drawn on top of the objects that are behind it. |
void |
sendToBack()
Move this object to the very back of the draw order, causing it to be drawn underneath all the other objects. |
void |
sendToFront()
Move this object to the very front of the draw order, causing it to be drawn on top of all the other objects. |
void |
setColor(Color c)
Change the color of this object. |
void |
show()
Make an object visible again after it had been hidden. |
Method Detail |
---|
void addToCanvas(DrawingCanvas c)
null
the object is simply removed from its current canvas.
c
- DrawingCanvas
to place this object onboolean contains(Location point)
true
if the given location is inside this object, false
otherwise. Because Line
s and FramedArc
s have no "inside", a
point is considered to be contained in one of them as long as it is within a few pixels
of the line.
point
- Location
to test
DrawingCanvas getCanvas()
null
.
DrawingCanvas
that this object is on.Color getColor()
Color
of this objectvoid hide()
boolean isHidden()
true
if this object has been rendered invisible with a call to its
hide()
method, false
if it is still being drawn.
void move(double dx, double dy)
dx
, and up or
down by an amount dy
. A negative dx
indicates a shift to the
left; a negative dy
indicates a shift up
dx
- amount of x translationdy
- amount of y translationvoid moveTo(double x, double y)
x
- x coordinate to move toy
- y coordinate to move tovoid moveTo(Location point)
point
- Location
to move tovoid removeFromCanvas()
void sendBackward()
void sendForward()
void sendToBack()
void sendToFront()
void setColor(Color c)
c
- new Color
for this objectvoid show()