public class ImageFigure extends AbstractFigure
Modifier and Type | Field and Description |
---|---|
protected java.awt.Rectangle |
fDisplayBox |
protected java.awt.Image |
fImage |
listenerList
Constructor and Description |
---|
ImageFigure()
Create a null image figure where the image and position is given later by
the set method
|
ImageFigure(java.awt.Image img,
java.awt.Point p)
Create an image figure from a given image
|
ImageFigure(java.lang.String imagename,
java.awt.Point p) |
Modifier and Type | Method and Description |
---|---|
protected void |
basicMoveBy(int x,
int y)
This is the hook method to be overridden when a figure moves.
|
java.awt.Rectangle |
displayBox()
Return the display box of this figure.
|
void |
draw(java.awt.Graphics g)
Draws the figure.
|
void |
set(java.awt.Image img,
java.awt.Point p)
Change the image and position of this image figure
|
void |
set(java.lang.String imagename,
java.awt.Point p)
Change the image (based on the string used in the image manager) and
position of this image figure.
|
addFigureChangeListener, changed, invalidate, moveBy, removeFigureChangeListener, willChange
protected java.awt.Image fImage
protected java.awt.Rectangle fDisplayBox
public ImageFigure()
public ImageFigure(java.awt.Image img, java.awt.Point p)
img
- the image to setp
- the position of the figure to setpublic ImageFigure(java.lang.String imagename, java.awt.Point p)
public void set(java.awt.Image img, java.awt.Point p)
img
- the image to setp
- the position of the figure to setpublic void set(java.lang.String imagename, java.awt.Point p)
imagename
- the name of image to setp
- the position of the figure to setpublic void draw(java.awt.Graphics g)
Figure
g
- the Graphics to draw intopublic java.awt.Rectangle displayBox()
Figure
protected void basicMoveBy(int x, int y)
AbstractFigure
basicMoveBy
in class AbstractFigure
x
- the delta to move in x directiony
- the delta to move in y directionFrom the book: Flexible, Reliable Software, © CRC Press 2010. Author: Henrik B. Christensen, Aarhus University, Denmark