Class CellLife

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--CellLife

public class CellLife
extends java.applet.Applet
implements java.lang.Runnable

Our main applet class. Draw the creatures and manages their lives. Stores a list of creatures and a list of references to all the cells in the universe, to simplify collision detection. Keeps track of how much time has passed.

See Also:
Serialized Form

Field Summary
protected  tjhBuckets buckets
          space-partitioning structure to speed collision detection
protected  java.util.Vector creatures
          A list of the creatures currently alive.
protected  long generations
          The number of creatures that have been born since the simulation started
protected  tjh2dVector limit
          The world is a rectangle from (0,0) to (limit.x,limit,y)
protected static int MAX_CREATURES
          the maximum number of creatures in the world.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
CellLife()
          CellLife Class Constructor
 
Method Summary
 void destroy()
           
 java.lang.String getAppletInfo()
          The getAppletInfo() method returns a string describing the applet's author, copyright date, or miscellaneous information.
 void init()
          first-time initialization
 boolean mouseDown(java.awt.Event evt, int x, int y)
           
 boolean mouseDrag(java.awt.Event evt, int x, int y)
           
 boolean mouseUp(java.awt.Event evt, int x, int y)
           
 void paint(java.awt.Graphics g)
          CellLife Paint Handler
 void run()
           
 void start()
           
 void stop()
           
 
Methods inherited from class java.applet.Applet
getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setCursor, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseEnter, mouseExit, mouseMove, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_CREATURES

protected static final int MAX_CREATURES
the maximum number of creatures in the world. When the number of creatures alive drops below half this, a new one is created to bring the numbers back up.

creatures

protected java.util.Vector creatures
A list of the creatures currently alive. Stores tjhCreature references.

limit

protected tjh2dVector limit
The world is a rectangle from (0,0) to (limit.x,limit,y)

generations

protected long generations
The number of creatures that have been born since the simulation started

buckets

protected tjhBuckets buckets
space-partitioning structure to speed collision detection
Constructor Detail

CellLife

public CellLife()
CellLife Class Constructor
Method Detail

getAppletInfo

public java.lang.String getAppletInfo()
The getAppletInfo() method returns a string describing the applet's author, copyright date, or miscellaneous information.
Overrides:
getAppletInfo in class java.applet.Applet

init

public void init()
first-time initialization
Overrides:
init in class java.applet.Applet

destroy

public void destroy()
Overrides:
destroy in class java.applet.Applet

paint

public void paint(java.awt.Graphics g)
CellLife Paint Handler
Overrides:
paint in class java.awt.Container

start

public void start()
Overrides:
start in class java.applet.Applet

stop

public void stop()
Overrides:
stop in class java.applet.Applet

run

public void run()
Specified by:
run in interface java.lang.Runnable

mouseDown

public boolean mouseDown(java.awt.Event evt,
                         int x,
                         int y)
Overrides:
mouseDown in class java.awt.Component

mouseDrag

public boolean mouseDrag(java.awt.Event evt,
                         int x,
                         int y)
Overrides:
mouseDrag in class java.awt.Component

mouseUp

public boolean mouseUp(java.awt.Event evt,
                       int x,
                       int y)
Overrides:
mouseUp in class java.awt.Component