|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Objectobjectdraw.Drawable
abstract class Drawable
Drawable is a general base class for objects being placed on a DrawingCanvas. Basic functionality includes the ability to show, hide, set the color of, and move Drawables.
| Field Summary | |
|---|---|
protected CanvasManager |
canvasContent
The contents of the canvas on which the object is displayed. |
protected Color |
color
The object's color. |
protected boolean |
shown
Whether the object is currently visible on its canvas |
| Constructor Summary | |
|---|---|
Drawable()
Creates a new Drawable object. |
|
| Method Summary | |
|---|---|
void |
addToCanvas(DrawingCanvas c)
Places an existing object on a specified DrawingCanvas. |
protected void |
clearCanvasContent()
Set canvasContent to null to indicate object has been removed from its canvas. |
abstract 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. |
DrawingCanvas |
getCanvas()
Determine which (if any) DrawingCanvas this object is positioned on |
Color |
getColor()
Retrieves the color of the object. |
void |
hide()
Temporarily hides an object on a DrawingCanvas from view. |
boolean |
isHidden()
Determine whether an object is currently visible on its canvas |
abstract 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. |
(package private) void |
setCanvasContent(CanvasManager cc)
Save a reference to the CanvasManager for the canvas in which this object is currently displayed. |
void |
setColor(Color c)
Sets the color of the object. |
protected void |
setStateChanged()
Sets the state of the object to be changed so that it gets repainted. |
void |
show()
Shows the object if it has been hidden. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected transient CanvasManager canvasContent
protected Color color
protected boolean shown
| Constructor Detail |
|---|
public Drawable()
| Method Detail |
|---|
public void addToCanvas(DrawingCanvas c)
DrawableInterfaceremoveFromCanvas() 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 DrawableInterfacec - the canvas on which the object should be drawnprotected void clearCanvasContent()
public abstract boolean contains(Location point)
DrawableInterface
contains in interface DrawableInterfacepoint - the position on the canvas.
void draw(Graphics g)
g - the graphics context into which the object is drawnpublic DrawingCanvas getCanvas()
DrawableInterface
getCanvas in interface DrawableInterfacepublic Color getColor()
DrawableInterface
getColor in interface DrawableInterfacepublic void hide()
DrawableInterfaceshow() method.
If the goal is to remove an object from the display permanently, the
removeFromCanvas() method should be used instead.
hide in interface DrawableInterfacepublic boolean isHidden()
DrawableInterface
isHidden in interface DrawableInterface
public abstract void move(double dx,
double dy)
DrawableInterface
move in interface DrawableInterfacedx - 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 DrawableInterfacex - horizontal coordinate of destination.y - horizontal coordinate of destination.public void moveTo(Location point)
DrawableInterface
moveTo in interface DrawableInterfacepoint - the destination for moving the object.public void removeFromCanvas()
DrawableInterfacehide() instead.
removeFromCanvas in interface DrawableInterfacepublic void sendBackward()
DrawableInterface
sendBackward in interface DrawableInterfacepublic void sendForward()
DrawableInterface
sendForward in interface DrawableInterfacepublic void sendToBack()
DrawableInterface
sendToBack in interface DrawableInterfacepublic void sendToFront()
DrawableInterface
sendToFront in interface DrawableInterfacevoid setCanvasContent(CanvasManager cc)
cc - the manager for this object's canvaspublic void setColor(Color c)
DrawableInterface
setColor in interface DrawableInterfacec - the color.protected void setStateChanged()
public void show()
DrawableInterface
show in interface DrawableInterface
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||