Class ScaledImageDisplay
java.lang.Object
|
+--ScaledDisplay
|
+--ScaledImageDisplay
- All Implemented Interfaces:
- LocatableDisplay
- Direct Known Subclasses:
- RotatedImageDisplay, TintedImageDisplay
- public class ScaledImageDisplay
- extends ScaledDisplay
Environment-Based Applications:
A ScaledImageDisplay uses an image read from a file to
represent an object with a location in an environment. This display
class does not rotate or tint the image, but subclasses could redefine
the draw method to do so. The ScaledDisplay
superclass provides an adjustForDirection method, and
ScaledImageDisplay provides a tint method.
- Version:
- 1 October 2002
|
Constructor Summary |
ScaledImageDisplay(java.lang.String imageFilename)
Constructs an object that knows how to display a
Locatable object as an image. |
|
Method Summary |
void |
adjust(Locatable obj,
java.awt.Component comp,
java.awt.Graphics2D g2)
Adjusts the graphics system for drawing an object, as appropriate. |
void |
draw(Locatable obj,
java.awt.Component comp,
java.awt.Graphics2D g2)
Draws a unit-length object using an image. |
void |
tint(Locatable 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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ScaledImageDisplay
public ScaledImageDisplay(java.lang.String imageFilename)
- Constructs an object that knows how to display a
Locatable object as an image. Looks for the
named file first in the jar file, then in the
current directory. If the named file is not found
or the file is malformed, the display will fall
back to the DefaultDisplay class.
- Parameters:
imageFilename - name of file containing image
draw
public void draw(Locatable obj,
java.awt.Component comp,
java.awt.Graphics2D g2)
- Draws a unit-length object using an image.
This implementation draws the object by scaling
the image provided to the constructor. It calls
the
adjust method to make further
adjustments (for example, rotating and tinting
the image) as appropriate.
methods
- Overrides:
draw in class ScaledDisplay
- Parameters:
obj - object we want to drawcomp - the component we're drawing ong2 - drawing surface
adjust
public void adjust(Locatable obj,
java.awt.Component comp,
java.awt.Graphics2D g2)
- Adjusts the graphics system for drawing an object, as appropriate.
This method actually makes no further adjustments, but subclasses
could override this method to rotate or color the object, for example.
- Overrides:
adjust in class ScaledDisplay
tint
public void tint(Locatable obj,
java.awt.Component comp,
java.awt.Graphics2D g2)
- Adjusts the graphics system to use an object's color to tint an image.
(Precondition:
obj has a color method.)
- Parameters:
obj - object we want to drawcomp - the component we're drawing ong2 - drawing surface
Copyright© 2003 Alyce Brady