model.fish.display
Class ImageFishDisplay
java.lang.Object
model.fish.display.ImageFishDisplay
- All Implemented Interfaces:
- IFishDisplay
public class ImageFishDisplay
- extends java.lang.Object
- implements IFishDisplay
Use an image file to display a fish.
- Author:
- Mathias Ricken
Nested Class Summary |
private static class |
ImageFishDisplay.TintFilter
An image filter class that tints colors based on the tint provided to the constructor (the color of a fish). |
Constructor Summary |
ImageFishDisplay(java.lang.String imageFilename,
double radians)
Make an object that knows how to display a fish as an image. |
Method Summary |
void |
draw(java.awt.Graphics2D g,
java.awt.Component comp,
java.awt.Color fishColor)
Draw the fish. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_icon
private javax.swing.ImageIcon _icon
_originalImage
private java.awt.Image _originalImage
_radians
private double _radians
_tintedVersions
private java.util.HashMap<java.awt.Color,java.awt.Image> _tintedVersions
ImageFishDisplay
public ImageFishDisplay(java.lang.String imageFilename,
double radians)
- Make an object that knows how to display a fish 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, a colored circle will be
substituted instead.
- Parameters:
imageFilename
- name of file containing imageradians
- radians the fish has to be rotated by to make it face north
draw
public void draw(java.awt.Graphics2D g,
java.awt.Component comp,
java.awt.Color fishColor)
- Draw the fish. The Graphics2D object has been set up so that the origin is in the center of the fish. A fish that
is 32x32 wide should thus drawFish from (-16,-16) to (16,16).
- Specified by:
draw
in interface IFishDisplay
- Parameters:
g
- graphics object to drawFish on.comp
- the component to drawFish onfishColor
- color of the fish