info.gridworld.gui
Class ImageDisplay

java.lang.Object
  extended by info.gridworld.gui.AbstractDisplay
      extended by info.gridworld.gui.ImageDisplay
All Implemented Interfaces:
Display

public class ImageDisplay
extends AbstractDisplay

An ImageDisplay displays an object as a tinted image from an image file whose name matches the class name.
This code is not tested on the AP CS A and AB exams. It contains GUI implementation details that are not intended to be understood by AP CS students.


Constructor Summary
ImageDisplay(java.lang.Class cl)
          Constructs an object that knows how to display an image.
 
Method Summary
 void draw(java.lang.Object obj, java.awt.Component comp, java.awt.Graphics2D g2)
          Draws a unit-length object facing North.
 
Methods inherited from class info.gridworld.gui.AbstractDisplay
draw, getProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageDisplay

public ImageDisplay(java.lang.Class cl)
             throws java.io.IOException
Constructs an object that knows how to display an image. Looks for the named file first in the jar file, then in the current directory.

Parameters:
cl - name of class from which to construct a search string.
Throws:
java.io.IOException
Method Detail

draw

public void draw(java.lang.Object obj,
                 java.awt.Component comp,
                 java.awt.Graphics2D g2)
Draws a unit-length object facing North. This implementation draws an object by tinting, scaling, and rotating the image in the image file.

Specified by:
draw in class AbstractDisplay
Parameters:
obj - object we want to draw
comp - the component we're drawing on
g2 - drawing surface