|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectobjectdraw.Drawable
objectdraw.Drawable2D
objectdraw.Resizable2D
objectdraw.Rectangular
objectdraw.Rect
objectdraw.FramedRect
FramedRect is an implementation of a drawable framed rectangle object.
Constructor Summary | |
FramedRect(double x,
double y,
double width,
double height,
DrawingCanvas canvas)
Creates a new FramedRect object. |
|
FramedRect(Location origin,
double width,
double height,
DrawingCanvas canvas)
Creates a new FramedRect object. |
|
FramedRect(Location p0,
Location p1,
DrawingCanvas canvas)
Creates a new FramedRect object. |
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. |
double |
getHeight()
Get the height of a graphical object |
Location |
getLocation()
Get a graphical object's position |
double |
getWidth()
Get the width of a graphical object |
double |
getX()
Get the x coordinate of left edge of rectangle bounding the object |
double |
getY()
Get the y coordinate of top edge of rectangle bounding 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 |
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 |
boolean |
overlaps(Drawable2DInterface item)
Determines if another Drawable's bounding rectangle overlaps with this object's bounding rectangle. |
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 |
setHeight(double height)
Sets the height of the object's bounding rectangle |
void |
setSize(double width,
double height)
Sets the width and height of the rectangle bounding the object. |
void |
setWidth(double width)
Sets the width of the object's bounding rectangle |
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.Resizable2DInterface |
setHeight, setSize, setWidth |
Methods inherited from interface objectdraw.Drawable2DInterface |
getHeight, getLocation, getWidth, getX, getY, overlaps |
Methods inherited from interface objectdraw.DrawableInterface |
addToCanvas, contains, getCanvas, getColor, hide, isHidden, move, moveTo, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setColor, show |
Constructor Detail |
public FramedRect(Location origin, double width, double height, DrawingCanvas canvas)
origin
- the upper left corner of the bounding rectanglewidth
- the width of the bounding rectangleheight
- the height of the bounding rectanglecanvas
- the canvas in which the object is createdpublic FramedRect(double x, double y, double width, double height, DrawingCanvas canvas)
x
- coordinate of the upper left corner of the bounding rectangley
- coordinate of the upper left corner of the bounding rectanglewidth
- the width of the bounding rectangle.height
- the height of the bounding rectangle.canvas
- the canvas in which the object is created.public FramedRect(Location p0, Location p1, DrawingCanvas canvas)
p0
- endpoint of a diagonal of the rectanglep1
- other diagonal endpointcanvas
- the canvas in which the object is createdMethod Detail |
public java.lang.String toString()
public void setSize(double width, double height)
Resizable2DInterface
setSize
in interface Resizable2DInterface
public void setWidth(double width)
Resizable2DInterface
setWidth
in interface Resizable2DInterface
public void setHeight(double height)
Resizable2DInterface
setHeight
in interface Resizable2DInterface
public double getWidth()
Drawable2DInterface
getWidth
in interface Drawable2DInterface
public double getHeight()
Drawable2DInterface
getHeight
in interface Drawable2DInterface
public void moveTo(Location point)
DrawableInterface
public void move(double dx, double dy)
DrawableInterface
public double getX()
Drawable2DInterface
getX
in interface Drawable2DInterface
public double getY()
Drawable2DInterface
getY
in interface Drawable2DInterface
public Location getLocation()
Drawable2DInterface
getLocation
in interface Drawable2DInterface
public boolean contains(Location point)
DrawableInterface
contains
in interface DrawableInterface
public boolean overlaps(Drawable2DInterface item)
Drawable2DInterface
overlaps
in interface Drawable2DInterface
item
- the other object
true
if item intersects this object;
false
otherwise.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(double x, double y)
DrawableInterface
moveTo
in interface DrawableInterface
x
- horizontal coordinate of destination.y
- horizontal coordinate of destination.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 |