Class ScaledDisplay
java.lang.Object
|
+--ScaledDisplay
- All Implemented Interfaces:
- LocatableDisplay
- Direct Known Subclasses:
- ColorBlockDisplay, DefaultDisplay, RotatedDisplay, ScaledImageDisplay
- public abstract class ScaledDisplay
- extends java.lang.Object
- implements LocatableDisplay
Environment-Based Applications:
This abstract class provides common implementation code for
drawing a Locatable object. The class will translate and
scale the graphics system as needed and then invoke its
abstract draw
method. Subclasses of this abstract class
define draw
to just display an object with a fixed size.
- Version:
- 1 October 2002
Method Summary |
void |
adjust(Locatable obj,
java.awt.Component comp,
java.awt.Graphics2D g2)
Adjusts the graphics system for drawing an object, as appropriate. |
abstract void |
draw(Locatable obj,
java.awt.Component comp,
java.awt.Graphics2D g2)
Draw the given Locatable object. |
void |
draw(Locatable obj,
java.awt.Component comp,
java.awt.Graphics2D g2,
java.awt.Rectangle rect)
Draw the given object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ScaledDisplay
public ScaledDisplay()
draw
public abstract void draw(Locatable obj,
java.awt.Component comp,
java.awt.Graphics2D g2)
- Draw the given Locatable object.
Subclasses should implement this method to draw the object in a
cell of size (1,1) centered around (0,0) on the drawing surface.
(All scaling has been done beforehand).
- Parameters:
obj
- object we want to drawcomp
- component on which to drawg2
- drawing surface
draw
public void draw(Locatable obj,
java.awt.Component comp,
java.awt.Graphics2D g2,
java.awt.Rectangle rect)
- Draw the given object.
Scales the coordinate appropriately then invokes the simple
draw method above that is only responsible for drawing a
unit-length object.
- Specified by:
draw
in interface LocatableDisplay
- Parameters:
obj
- object we want to drawcomp
- component on which to drawg2
- drawing surfacerect
- rectangle in which to draw
adjust
public void adjust(Locatable obj,
java.awt.Component comp,
java.awt.Graphics2D g2)
- Adjusts the graphics system for drawing an object, as appropriate.
This method actually makes no further adjustments, but subclasses
could override this method to rotate the object, for example.
Copyright© 2003 Alyce Brady