|
|||||||
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.VisibleImage
public class VisibleImage
A VisibleImage represents an Image that can be drawn on the canvas.
Field Summary | |
---|---|
protected DrawingCanvas |
canvas
The convas on which the Image is displayed |
protected Image |
image
The object's image data. |
Fields inherited from class objectdraw.Drawable |
---|
color, shown |
Constructor Summary | |
---|---|
VisibleImage(Image image,
double x,
double y,
double width,
double height,
DrawingCanvas canvas)
Creates a new VisibleImage object. |
|
VisibleImage(Image image,
double x,
double y,
DrawingCanvas canvas)
Creates a new VisibleImage object. |
|
VisibleImage(Image image,
Location origin,
double width,
double height,
DrawingCanvas canvas)
Creates a new VisibleImage object. |
|
VisibleImage(Image image,
Location origin,
DrawingCanvas canvas)
Creates a new VisibleImage object. |
Method Summary | |
---|---|
void |
addToCanvas(DrawingCanvas canvas)
Places an existing object on a specified DrawingCanvas. |
(package private) void |
draw(Graphics g)
Draws the object. |
(package private) Bounds |
getBounds()
Retrieves the bounding rectangle of the object. |
double |
getHeight()
Get the height of a graphical object |
Image |
getImage()
Access the (unscaled) Image currently displayed by this VisibleImage |
double |
getWidth()
Get the width of a graphical object |
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(Location location)
Moves the object within the canvas to the specified Location |
(package private) void |
setBounds(Bounds b)
|
void |
setHeight(double height)
Sets the height of the object's bounding rectangle |
void |
setImage(Image newImage)
Change the Image displayed by this VisibleImage |
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 |
Methods inherited from class objectdraw.Drawable2D |
---|
contains, getLocation, getX, getY, overlaps |
Methods inherited from class objectdraw.Drawable |
---|
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, toString, wait, wait, wait |
Methods inherited from interface objectdraw.Drawable2DInterface |
---|
getLocation, getX, getY, overlaps |
Methods inherited from interface objectdraw.DrawableInterface |
---|
contains, getCanvas, getColor, hide, isHidden, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setColor, show |
Field Detail |
---|
protected DrawingCanvas canvas
protected Image image
Constructor Detail |
---|
public VisibleImage(Image image, double x, double y, double width, double height, DrawingCanvas canvas)
image
- the image to displayx
- 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 rectangleheight
- the height of the bounding rectanglecanvas
- the canvas in which the image is createdpublic VisibleImage(Image image, double x, double y, DrawingCanvas canvas)
image
- the image to displayx
- coordinate of the upper left corner of the bounding rectangley
- coordinate of the upper left corner of the bounding rectanglecanvas
- the canvas in which the image is createdpublic VisibleImage(Image image, Location origin, double width, double height, DrawingCanvas canvas)
image
- the image to displayorigin
- 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 image is createdpublic VisibleImage(Image image, Location origin, DrawingCanvas canvas)
image
- the image to displayorigin
- the upper left corner of the bounding rectanglecanvas
- the canvas in which the image is createdMethod Detail |
---|
public void addToCanvas(DrawingCanvas canvas)
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
addToCanvas
in class Drawable
canvas
- the canvas on which the object should be drawnvoid draw(Graphics g)
draw
in class Drawable2D
g
- the graphics context into which the object is drawnBounds getBounds()
getBounds
in class Drawable2D
public double getHeight()
Drawable2DInterface
getHeight
in interface Drawable2DInterface
getHeight
in class Drawable2D
public Image getImage()
public double getWidth()
Drawable2DInterface
getWidth
in interface Drawable2DInterface
getWidth
in class Drawable2D
public void move(double dx, double dy)
DrawableInterface
move
in interface DrawableInterface
move
in class Resizable2D
dx
- the amount to move in the x-direction.dy
- the amount to move in the y-direction.public void moveTo(Location location)
DrawableInterface
moveTo
in interface DrawableInterface
moveTo
in class Resizable2D
location
- the destination for moving the object.void setBounds(Bounds b)
setBounds
in class Resizable2D
public void setHeight(double height)
Resizable2DInterface
setHeight
in interface Resizable2DInterface
setHeight
in class Resizable2D
height
- the new height of the bounding rectanglepublic void setImage(Image newImage)
newImage
- the Image to be displayedpublic void setSize(double width, double height)
Resizable2DInterface
setSize
in interface Resizable2DInterface
setSize
in class Resizable2D
width
- the new width of the bounding rectangleheight
- the new height of the bounding rectanglepublic void setWidth(double width)
Resizable2DInterface
setWidth
in interface Resizable2DInterface
setWidth
in class Resizable2D
width
- the new width of the bounding rectangle
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |