appletbots
Class Applet

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by javax.swing.JApplet
                      extended by appletbots.Applet
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer
Direct Known Subclasses:
BallsApplet, DirectedBallsApplet, FriendlyApplet, GatherersApplet, SpreadOutApplet, SwarmApplet, TagApplet

public abstract class Applet
extends javax.swing.JApplet

This is an abstract applet class to run appletbots worlds. Subclasses need only to implement the initializeWorld() method. Optionally, they can override the getSettingsPanel() method to all define a settings panel.

Author:
Erik Rasmussen
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JApplet
javax.swing.JApplet.AccessibleJApplet
 
Nested classes/interfaces inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected static long MILLISECONDS_BETWEEN_TIME_FIELD_UPDATES
          The number of milliseconds to wait between time field updates.
protected  ObjectViewer objectViewer
          The object viewer panel
protected  javax.swing.JPanel settingsPanel
          The settings panel
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
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
Applet()
          Constructs the applet
 
Method Summary
 void destroy()
          Stops any threads still running
 int getDelay()
          Returns the number of milliseconds between time cycles
protected  javax.swing.JPanel getSettingsPanel()
          Returns a blank settings panel.
 void init()
          Initializes the applet
protected abstract  World initializeWorld()
          Returns an initialized world with the desired agents and object added.
 void resetClicked(java.awt.event.ActionEvent event)
          The method invoked when the reset button is clicked.
 void speedChanged(javax.swing.event.ChangeEvent event)
          The method invoked when the speed slider is clicked.
 void startClicked(java.awt.event.ActionEvent event)
          The method invoked when the start button is clicked.
 void stopClicked(java.awt.event.ActionEvent event)
          The method invoked when the stop button is clicked.
 void updateTimeField()
          Updates the time field if the time field has not been updated in at least MILLISECONDS_BETWEEN_TIME_FIELD_UPDATES milliseconds.
 void worldClicked(java.awt.event.MouseEvent event)
          The method invoked when the user clicks on the world.
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.applet.Applet
getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
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, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, 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, firePropertyChange, firePropertyChange, firePropertyChange, 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, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, 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

MILLISECONDS_BETWEEN_TIME_FIELD_UPDATES

protected static final long MILLISECONDS_BETWEEN_TIME_FIELD_UPDATES
The number of milliseconds to wait between time field updates. If the time cycles are flying by too quickly, the applet cannot paint the time field quickly enough, so it waits until a minimum number of milliseconds have passed since the last update before updating the time field.

See Also:
Constant Field Values

settingsPanel

protected javax.swing.JPanel settingsPanel
The settings panel


objectViewer

protected ObjectViewer objectViewer
The object viewer panel

Constructor Detail

Applet

public Applet()
Constructs the applet

Method Detail

init

public void init()
Initializes the applet

Overrides:
init in class java.applet.Applet

destroy

public void destroy()
Stops any threads still running

Overrides:
destroy in class java.applet.Applet

startClicked

public void startClicked(java.awt.event.ActionEvent event)
The method invoked when the start button is clicked. Starts the world thread.

Parameters:
event - The action event

stopClicked

public void stopClicked(java.awt.event.ActionEvent event)
The method invoked when the stop button is clicked. Stops the world thread.

Parameters:
event - The action event

resetClicked

public void resetClicked(java.awt.event.ActionEvent event)
The method invoked when the reset button is clicked. Resets the world thread.

Parameters:
event - The action event

speedChanged

public void speedChanged(javax.swing.event.ChangeEvent event)
The method invoked when the speed slider is clicked. Calls world.setDelay(long).

Parameters:
event - The change event

getDelay

public int getDelay()
Returns the number of milliseconds between time cycles

Returns:
The number of milliseconds between time cycles

updateTimeField

public void updateTimeField()
Updates the time field if the time field has not been updated in at least MILLISECONDS_BETWEEN_TIME_FIELD_UPDATES milliseconds.


worldClicked

public void worldClicked(java.awt.event.MouseEvent event)
The method invoked when the user clicks on the world. It calls world.selectObjectAt(x,y).

Parameters:
event - The mouse event

getSettingsPanel

protected javax.swing.JPanel getSettingsPanel()
Returns a blank settings panel. This method may be overridden by subclasses to provide a user interface for changing world initialization settings.

Returns:
A blank settings panel

initializeWorld

protected abstract World initializeWorld()
Returns an initialized world with the desired agents and object added.

Returns:
An initialized world with the desired agents and object added.