Game of Life 1.5

org.bitstorm.gameoflife
Class GameOfLifeControls

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byorg.bitstorm.gameoflife.GameOfLifeControls
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class GameOfLifeControls
extends java.awt.Panel

GUI-controls of the Game of Life. It contains controls like Shape, zoom and speed selector, next and start/stop-button. It is a seperate class, so it can be replaced by another implementation for e.g. mobile phones or PDA's. Communicates via the GameOfLifeControlsListener.

Author:
Edwin Martin
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String BIG
           
static java.lang.String FAST
           
private  java.awt.Label genLabel
           
private  java.lang.String genLabelText
           
static java.lang.String HYPER
           
private  java.util.Vector listeners
           
static java.lang.String MEDIUM
           
private  java.awt.Button nextButton
           
private  java.lang.String nextLabelText
           
private  java.awt.Choice shapesChoice
           
static int SIZE_BIG
           
static int SIZE_MEDIUM
           
static int SIZE_SMALL
           
static java.lang.String SLOW
           
static java.lang.String SMALL
           
private  java.lang.String startLabelText
           
private  java.awt.Button startstopButton
           
private  java.lang.String stopLabelText
           
private  java.awt.Choice zoomChoice
           
 
Fields inherited from class java.awt.Panel
 
Fields inherited from class java.awt.Container
 
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
GameOfLifeControls()
          Contructs the controls.
 
Method Summary
 void addGameOfLifeControlsListener(GameOfLifeControlsListener listener)
          Add listener for this control
 void nextButtonClicked()
          Called when the next-button is clicked.
 void removeGameOfLifeControlsListener(GameOfLifeControlsListener listener)
          Remove listener from this control
 void setGeneration(int generations)
          Set the number of generations in the control bar.
 void setZoom(java.lang.String n)
          Called when a new cell size from the zoom pull down is selected.
 void shapeSelected(java.lang.String shapeName)
          Called when a new shape from the shape pull down is selected.
 void speedChanged(int speed)
          Called when a new speed from the speed pull down is selected.
 void start()
          Start-button is activated.
 void startStopButtonClicked()
          Called when the start/stop-button is clicked.
 void stop()
          Stop-button is activated.
 void zoomChanged(int zoom)
          Called when a new zoom from the zoom pull down is selected.
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, 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, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

genLabel

private java.awt.Label genLabel

genLabelText

private final java.lang.String genLabelText
See Also:
Constant Field Values

nextLabelText

private final java.lang.String nextLabelText
See Also:
Constant Field Values

startLabelText

private final java.lang.String startLabelText
See Also:
Constant Field Values

stopLabelText

private final java.lang.String stopLabelText
See Also:
Constant Field Values

SLOW

public static final java.lang.String SLOW
See Also:
Constant Field Values

FAST

public static final java.lang.String FAST
See Also:
Constant Field Values

HYPER

public static final java.lang.String HYPER
See Also:
Constant Field Values

BIG

public static final java.lang.String BIG
See Also:
Constant Field Values

MEDIUM

public static final java.lang.String MEDIUM
See Also:
Constant Field Values

SMALL

public static final java.lang.String SMALL
See Also:
Constant Field Values

SIZE_BIG

public static final int SIZE_BIG
See Also:
Constant Field Values

SIZE_MEDIUM

public static final int SIZE_MEDIUM
See Also:
Constant Field Values

SIZE_SMALL

public static final int SIZE_SMALL
See Also:
Constant Field Values

startstopButton

private java.awt.Button startstopButton

nextButton

private java.awt.Button nextButton

listeners

private java.util.Vector listeners

shapesChoice

private java.awt.Choice shapesChoice

zoomChoice

private java.awt.Choice zoomChoice
Constructor Detail

GameOfLifeControls

public GameOfLifeControls()
Contructs the controls.

Method Detail

addGameOfLifeControlsListener

public void addGameOfLifeControlsListener(GameOfLifeControlsListener listener)
Add listener for this control

Parameters:
listener - Listener object

removeGameOfLifeControlsListener

public void removeGameOfLifeControlsListener(GameOfLifeControlsListener listener)
Remove listener from this control

Parameters:
listener - Listener object

setGeneration

public void setGeneration(int generations)
Set the number of generations in the control bar.

Parameters:
generations - number of generations

start

public void start()
Start-button is activated.


stop

public void stop()
Stop-button is activated.


startStopButtonClicked

public void startStopButtonClicked()
Called when the start/stop-button is clicked. Notify event-listeners.


nextButtonClicked

public void nextButtonClicked()
Called when the next-button is clicked. Notify event-listeners.


speedChanged

public void speedChanged(int speed)
Called when a new speed from the speed pull down is selected. Notify event-listeners.


zoomChanged

public void zoomChanged(int zoom)
Called when a new zoom from the zoom pull down is selected. Notify event-listeners.


shapeSelected

public void shapeSelected(java.lang.String shapeName)
Called when a new shape from the shape pull down is selected. Notify event-listeners.


setZoom

public void setZoom(java.lang.String n)
Called when a new cell size from the zoom pull down is selected. Notify event-listeners.


Game of Life 1.5

This API descibes the Game of Life program, written by Edwin Martin. The source code is available online too.

Copyright 1996-2004 Edwin Martin <edwin@bitstorm.org>.