galton
Class BallDrop

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--edu.davidson.tools.SApplet
                                |
                                +--galton.BallDrop
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.lang.Runnable, edu.davidson.tools.SDataSource, java.io.Serializable

public class BallDrop
extends SApplet
implements java.lang.Runnable, edu.davidson.tools.SDataSource

BallDrop is an 'applet' that manages a set of Ball objects that are falling through a set of pins. This serves as an example of double buffered animation and the use of Java as an educational tool. What can you learn from this Applet? Probably that there are several correct ways to do the same thing, and that this isn't one of them.

See Also:
Serialized Form

Fields inherited from class edu.davidson.tools.SApplet
clock, dataConnections, dataListeners, dataSources, lock
 
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
BallDrop()
           
 
Method Summary
 void destroy()
           
 void forward()
          Start clock.
 double getMean()
           
 SApplet getOwner()
           
 double getStDev()
           
 double[][] getVariables()
           
 java.lang.String[] getVarStrings()
           
 void init()
          The code that initializes the applet.
 boolean mouseDown(java.awt.Event e, int x, int y)
          Stop the animation when the user clicks on the applet.
 void paint(java.awt.Graphics g)
          Paint the next frame in the animation
 void pause()
          Pause the clock.
 void reset()
          Reset the clock to time=0.
 void run()
          The thread has begun to run
 void setDefault()
          Reset the clock to time=0.
 void setOwner(SApplet owner)
           
 void setShowFunc(boolean value)
           
 void start()
          Begin the animation thread
 void stop()
          Stop the tread
 void update(java.awt.Graphics g)
          Just call paint() so that the background color isn't painted also
 
Methods inherited from class edu.davidson.tools.SApplet
addDataListener, addDataSource, cleanupDataConnections, clearAllData, clearData, deleteDataConnection, deleteDataConnections, getClockID, getClockTime, getDataConnectionFromDL, getDataConnectionFromDS, getDataFromDS, getDataListener, getDataListener, getDataSource, getDataSource, getID, getRunningID, getSourceData, getSourceVariables, isAutoRefresh, isClockRunning, makeDataConnection, removeDataListener, removeDataSource, reverse, setAutoRefresh, setClockContinous, setClockCycle, setClockOneShot, setClockTime, setConnectionBlock, setConnectionListener, setConnectionSmoothing, setConnectionSource, setConnectionStride, setDt, setExternalClock, setFPS, setRunningID, setRunningID, setTimeContinuous, setTimeCycle, setTimeOneShot, startClock, stepClock, stepTime, stepTimeBack, stepTimeForward, stopClock, updateDataConnection, updateDataConnections
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAppletInfo, 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, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, 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, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.davidson.tools.SDataSource
getID
 

Constructor Detail

BallDrop

public BallDrop()
Method Detail

destroy

public void destroy()
Overrides:
destroy in class SApplet

forward

public void forward()
Description copied from class: SApplet
Start clock.
Overrides:
forward in class SApplet

getMean

public double getMean()

getOwner

public SApplet getOwner()
Specified by:
getOwner in interface edu.davidson.tools.SDataSource

getStDev

public double getStDev()

getVariables

public double[][] getVariables()
Specified by:
getVariables in interface edu.davidson.tools.SDataSource

getVarStrings

public java.lang.String[] getVarStrings()
Specified by:
getVarStrings in interface edu.davidson.tools.SDataSource

init

public void init()
The code that initializes the applet. Loads in the images for the balls and pins using the MediaTracker. Also start out the balls with a little nudge to get them going.
Overrides:
init in class java.applet.Applet

mouseDown

public boolean mouseDown(java.awt.Event e,
                         int x,
                         int y)
Stop the animation when the user clicks on the applet.
Overrides:
mouseDown in class java.awt.Component

paint

public void paint(java.awt.Graphics g)
Paint the next frame in the animation
Overrides:
paint in class java.awt.Container

pause

public void pause()
Description copied from class: SApplet
Pause the clock.
Overrides:
pause in class SApplet

reset

public void reset()
Description copied from class: SApplet
Reset the clock to time=0.
Overrides:
reset in class SApplet

run

public void run()
The thread has begun to run
Specified by:
run in interface java.lang.Runnable

setDefault

public void setDefault()
Description copied from class: SApplet
Reset the clock to time=0.
Overrides:
setDefault in class SApplet

setOwner

public void setOwner(SApplet owner)
Specified by:
setOwner in interface edu.davidson.tools.SDataSource

setShowFunc

public void setShowFunc(boolean value)

start

public void start()
Begin the animation thread
Overrides:
start in class java.applet.Applet

stop

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

update

public void update(java.awt.Graphics g)
Just call paint() so that the background color isn't painted also
Overrides:
update in class java.awt.Container

Copyright Wolfgang Christian

Visit the Davidson CollegePhyslets Page