public class ScaledImageDisplay extends ScaledDisplay
ScaledImageDisplay uses an image read from a file to
represent an object in a location in a grid. Images can be rotated
or tinted using appropriate decorators. ScaledImageDisplay
provides a tint method that can be used by a
tint decorator.| Modifier | Constructor and Description |
|---|---|
protected |
ScaledImageDisplay()
Internal constructor that does not initialize the icon
instance variable; subclasses must be sure to set the icon
using the
setIcon method (e.g., at the beginning
of a redefined draw method). |
|
ScaledImageDisplay(java.lang.String imageFilename)
Constructs an object that knows how to display a
GridObject object as an image.
|
| Modifier and Type | Method and Description |
|---|---|
void |
draw(GridObject obj,
java.awt.Component comp,
java.awt.Graphics2D g2)
Draws a unit-length object using an image.
|
protected javax.swing.ImageIcon |
getIcon()
Returns the image to use for display purposes.
|
boolean |
imageLoadedOK()
Returns
true if the image loaded OK; false
otherwise. |
protected void |
setIcon(javax.swing.ImageIcon icon)
Defines the image to use for display purposes.
|
addDecorator, adjust, draw, removeDecoratorprotected ScaledImageDisplay()
setIcon method (e.g., at the beginning
of a redefined draw method).public ScaledImageDisplay(java.lang.String imageFilename)
imageFilename
parameter may name a file in the jar file, may be the absolute
name of a file in the current file system, or may be the name
of a file in the current directory.imageFilename - name of file containing imagepublic boolean imageLoadedOK()
true if the image loaded OK; false
otherwise.protected void setIcon(javax.swing.ImageIcon icon)
protected javax.swing.ImageIcon getIcon()
public void draw(GridObject obj, java.awt.Component comp, java.awt.Graphics2D g2)
draw in class ScaledDisplayobj - object we want to drawcomp - the component we're drawing ong2 - drawing surface