mdh.hephaestus2.gamelib
Class SpriteScreen

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--mdh.hephaestus2.gamelib.DoublePanel
                          |
                          +--mdh.hephaestus2.gamelib.Screen
                                |
                                +--mdh.hephaestus2.gamelib.SpriteScreen
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Runnable, Serializable

public class SpriteScreen
extends Screen

SpriteScreen is a Screen which can hold SpriteGroups. Every tick(), every SpriteGroup that has been added to the SpriteScreen is updated and drawn.

Author:
Copyright © 2002 by Mark Hughes <kamikaze@kuoi.asui.uidaho.edu>
See Also:
Serialized Form

Field Summary
static int A_CENTER
          Alignment: Centered on the visible area
static int A_E
          Alignment: East
static int A_N
          Alignment: North
static int A_NE
          Alignment: Northeast
static int A_NW
          Alignment: Northwest
static int A_S
          Alignment: South
static int A_SE
          Alignment: Southeast
static int A_SW
          Alignment: Southwest
static int A_TILE
          Alignment: Tiled across the visible area
static int A_W
          Alignment: West
static int A_ZOOM
          Alignment: Zoomed to fill the visible area
static String[] ALIGN_NAME
          Text equivalents of the constants above.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SpriteScreen()
           
 
Method Summary
 void addGroup(SpriteGroup sg)
          Adds a sprite group which will be drawn when the screen is redrawn.
 void clear()
          Erases the entire display.
 void clearGroups()
           
 void draw(Graphics2D g)
          Override this to do your drawing on the offscreen buffer; you need do nothing else.
 int getAlign()
          Returns the current alignment.
 Dimension getMinimumSize()
           
 Dimension getPreferredSize()
           
 void removeGroup(SpriteGroup sg)
          Removes a sprite group.
 void setAlign(int a)
          Sets the alignment of the background image, which must be one of the A_* constants.
 void setBackground(Image img)
          Sets the background image.
 void tick()
          Updates each SpriteGroup.
 
Methods inherited from class mdh.hephaestus2.gamelib.Screen
getInstance, interrupt, run, setFPS, setPaused, start
 
Methods inherited from class mdh.hephaestus2.gamelib.DoublePanel
isDoubleBuffered, isFixedSize, isFocusable, isFocusTraversable, paint, redraw, repaintNow, setSize, update
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusOwner, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

A_N

public static final int A_N
Alignment: North

See Also:
Constant Field Values

A_NE

public static final int A_NE
Alignment: Northeast

See Also:
Constant Field Values

A_E

public static final int A_E
Alignment: East

See Also:
Constant Field Values

A_SE

public static final int A_SE
Alignment: Southeast

See Also:
Constant Field Values

A_S

public static final int A_S
Alignment: South

See Also:
Constant Field Values

A_SW

public static final int A_SW
Alignment: Southwest

See Also:
Constant Field Values

A_W

public static final int A_W
Alignment: West

See Also:
Constant Field Values

A_NW

public static final int A_NW
Alignment: Northwest

See Also:
Constant Field Values

A_CENTER

public static final int A_CENTER
Alignment: Centered on the visible area

See Also:
Constant Field Values

A_TILE

public static final int A_TILE
Alignment: Tiled across the visible area

See Also:
Constant Field Values

A_ZOOM

public static final int A_ZOOM
Alignment: Zoomed to fill the visible area

See Also:
Constant Field Values

ALIGN_NAME

public static final String[] ALIGN_NAME
Text equivalents of the constants above.

Constructor Detail

SpriteScreen

public SpriteScreen()
Method Detail

addGroup

public void addGroup(SpriteGroup sg)
Adds a sprite group which will be drawn when the screen is redrawn.


clear

public void clear()
Erases the entire display.


clearGroups

public void clearGroups()

draw

public void draw(Graphics2D g)
Description copied from class: DoublePanel
Override this to do your drawing on the offscreen buffer; you need do nothing else.

Overrides:
draw in class Screen

getAlign

public final int getAlign()
Returns the current alignment.


getMinimumSize

public Dimension getMinimumSize()
Overrides:
getMinimumSize in class DoublePanel

getPreferredSize

public Dimension getPreferredSize()
Overrides:
getPreferredSize in class DoublePanel

removeGroup

public void removeGroup(SpriteGroup sg)
Removes a sprite group.


setAlign

public final void setAlign(int a)
Sets the alignment of the background image, which must be one of the A_* constants.

Throws:
IllegalArgumentException - if 'a' is unknown.

setBackground

public final void setBackground(Image img)
Sets the background image.


tick

public void tick()
Updates each SpriteGroup.

Overrides:
tick in class Screen