Generic Environment GUI Class Library

Class DefaultDisplay

All Implemented Interfaces:
Direct Known Subclasses:

public class DefaultDisplay
extends ScaledDisplay

AP® Computer Science Marine Biology Simulation:
A DefaultDisplay draws a centered question-mark. A DefaultDisplay object is used to display any locatable object that doesn't have a specialized display object. The association between a particular Locatable subclass and its display object is handled in the DisplayMap class.

The DefaultDisplay class is copyright© 2002 College Entrance Examination Board ( It has been modified as allowed by the GNU General Public License.

1 November 2002
See Also:
Environment, DisplayMap

Constructor Summary
Method Summary
 void draw(Locatable obj, java.awt.Component comp, java.awt.Graphics2D g2)
          Draws the given object.
protected  void paintCenteredText(java.awt.Graphics2D g2, java.lang.String s, float centerX, float centerY)
          Paints a horizontally and vertically-centered text string.
Methods inherited from class ScaledDisplay
adjust, draw
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public DefaultDisplay()
Method Detail


public void draw(Locatable obj,
                 java.awt.Component comp,
                 java.awt.Graphics2D g2)
Draws the given object. This implementation draws a question mark using the Java 2D Graphics API.
draw in class ScaledDisplay
obj - object we want to draw
comp - component on which to draw
g2 - drawing surface


protected void paintCenteredText(java.awt.Graphics2D g2,
                                 java.lang.String s,
                                 float centerX,
                                 float centerY)
Paints a horizontally and vertically-centered text string. This method is adapted from p. 134 of J. Knudsen's book, Java 2D Graphics, published by O'Reilly & Associates (1999).
g2 - drawing surface
s - string to draw (centered)
centerX - x-coordinate of center point
centerY - y-coordinate of center point

Generic Environment GUI Class Library

Copyright© 2003 Alyce Brady