Class DefaultDisplay
java.lang.Object
|
+--ScaledDisplay
|
+--DefaultDisplay
- All Implemented Interfaces:
- LocatableDisplay
- Direct Known Subclasses:
- TextCellDisplay
- 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
(www.collegeboard.com).
It has been modified as allowed by the GNU General Public License.
- Version:
- 1 November 2002
- See Also:
Environment
,
DisplayMap
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DefaultDisplay
public DefaultDisplay()
draw
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.
- Overrides:
draw
in class ScaledDisplay
- Parameters:
obj
- object we want to drawcomp
- component on which to drawg2
- drawing surface
paintCenteredText
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).
- Parameters:
g2
- drawing surfaces
- string to draw (centered)centerX
- x-coordinate of center pointcenterY
- y-coordinate of center point
Copyright© 2003 Alyce Brady