|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.kzoo.grid.display.ScaledDisplay | +--edu.kzoo.grid.display.ScaledImageDisplay
Grid Display Package:
A 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.
Constructor Summary | |
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. |
Method Summary | |
void |
draw(GridObject obj,
java.awt.Component comp,
java.awt.Graphics2D g2)
Draws a unit-length object using an image. |
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. |
void |
tint(GridObject obj,
java.awt.Component comp,
java.awt.Graphics2D g2)
Adjusts the graphics system to use an object's color to tint an image. |
Methods inherited from class edu.kzoo.grid.display.ScaledDisplay |
addDecorator, adjust, draw, removeDecorator |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected ScaledImageDisplay()
setIcon
method (e.g., at the beginning
of a redefined draw method).
public ScaledImageDisplay(java.lang.String imageFilename)
imageFilename
- name of file containing imageMethod Detail |
public boolean imageLoadedOK()
true
if the image loaded OK; false
otherwise.
protected void setIcon(javax.swing.ImageIcon icon)
public void draw(GridObject obj, java.awt.Component comp, java.awt.Graphics2D g2)
adjust
method to make further
adjustments (for example, rotating and tinting
the image) as appropriate.
draw
in class ScaledDisplay
obj
- object we want to drawcomp
- the component we're drawing ong2
- drawing surfacepublic void tint(GridObject obj, java.awt.Component comp, java.awt.Graphics2D g2)
obj
has a color
method.)
obj
- object we want to drawcomp
- the component we're drawing ong2
- drawing surface
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |