Class ImageFishDisplay

  extended by
All Implemented Interfaces:

public class ImageFishDisplay
extends java.lang.Object
implements IFishDisplay

Use an image file to display a fish.

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).
Field Summary
private  javax.swing.ImageIcon _icon
private  java.awt.Image _originalImage
private  double _radians
private  java.util.HashMap _tintedVersions
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

Field Detail


private javax.swing.ImageIcon _icon


private java.awt.Image _originalImage


private double _radians


private java.util.HashMap _tintedVersions
Constructor Detail


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.

imageFilename - name of file containing image
radians - radians the fish has to be rotated by to make it face north
Method Detail


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
g - graphics object to drawFish on.
comp - the component to drawFish on
fishColor - color of the fish