edu.davidson.tools
Class SApplet

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--edu.davidson.tools.SApplet
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
Accumulator, Analytic, Analytic2D, Angular, Animator, BallDrop, Bar, BField, BlackBody, DataGraph, DataTable, Density, Differentiator, Diffusion, DLA, Doppler, EField, EMWave, EnergyEigenvalue, Engine, Faraday, FFT, FFT2D, Histogram, Integral, Integrator, Ising, IVApplet, LoadApplet, LRCApplet, Minkowski, MolecularApplet, MolecularFlow, MolecularMembrane, MolecularPiston, Multiplexer, ODE, OpticsApplet, PipeApplet, Poisson, QTime, Radial, RandomWalk, RCApplet, ReflectionApplet, Ripple, ScriptListener, SliderApplet, Spectrum, SPlotter, Superposition, Sync, TwoEnsembles

public class SApplet
extends java.applet.Applet

SApplet is designed to provide inter-applet communication and common functionality for Physlets. Physlets usually subclass from SApplet in order to access the animation clock, to register data sources and data listeners, and enable JavaScript to create data connections.

See Also:
Serialized Form

Field Summary
 edu.davidson.tools.SClock clock
           
 java.util.Vector dataConnections
           
static java.util.Hashtable dataListeners
           
static java.util.Hashtable dataSources
           
 edu.davidson.tools.BusyFlag 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
SApplet()
           
 
Method Summary
static void addDataListener(java.lang.Object dl)
           
static void addDataSource(java.lang.Object ds)
          Add a data source to the list.
 void cleanupDataConnections()
          Remove dataConnections if either the source or the listener no longer exist.
 void clearAllData()
          Delete all the data that has been sent to the DataConnections.
 void clearData(int id)
          Delete all the data that has been sent to the DataConnections.
 void deleteDataConnection(int id)
          Break the data connection identified by the id.
 void deleteDataConnections()
          Break all data connections for this applet.
 void destroy()
           
 void forward()
          Start clock.
 int getClockID()
          Get the clock id for use as a data source.
 double getClockTime()
          Get the time from the animation clock.
 edu.davidson.tools.SDataConnection getDataConnectionFromDL(edu.davidson.tools.SDataListener dl)
          Find the first data connection in the list that has a specific data listener.
 edu.davidson.tools.SDataConnection getDataConnectionFromDS(edu.davidson.tools.SDataSource ds)
          Find the first data connection in the list that has a specific data source.
 java.lang.String getDataFromDS(int id)
          Return the data as a string.
static edu.davidson.tools.SDataListener getDataListener(int id)
           
static edu.davidson.tools.SDataListener getDataListener(java.lang.String key)
           
static edu.davidson.tools.SDataSource getDataSource(int id)
          Find the data source with the given id.
static edu.davidson.tools.SDataSource getDataSource(java.lang.String key)
          Find the data source with the given key.
 int getID()
           
 java.lang.Object getRunningID()
           
 java.lang.String getSourceData(int id, java.lang.String vStr)
          Return a comma delimited list of the data source data.
 java.lang.String getSourceVariables(int id)
          Return a comma delimited list of the data source variables.
 boolean isAutoRefresh()
          Test to see if the clock is running.
 boolean isClockRunning()
          Test to see if the clock is running.
 int makeDataConnection(int sourceID, int listenerID, int seriesID, java.lang.String xStr, java.lang.String yStr)
          Have the applet make a new data connection.
 void pause()
          Pause the clock.
 void removeDataListener(int key)
           
 void removeDataSource(int id)
          Remove the data source with the given id.
 void reset()
          Reset the clock to time=0.
 void reverse()
          Stop the clock.
 void setAutoRefresh(boolean ar)
          Repaint whenevers the system parameters are changed.
 void setClockContinous()
          Set the clock to run continously.
 void setClockCycle(double minTime, double maxTime)
          Set the clock to cycle between the minTime and maxTime.
 void setClockOneShot(double minTime, double maxTime)
          Set the clock to run from minTime to maxTime and stop.
 void setClockTime(double t)
          Set the clock time.
 boolean setConnectionBlock(int id, boolean block)
          Block data from passing through the data connection.
 boolean setConnectionListener(int id)
          Set the data listener for the data connection.
 boolean setConnectionSmoothing(int id, int num)
          Have the data connection smooth the data before it is sent to the data listener.
 boolean setConnectionSource(int id)
          Set the data source for the data connection.
 boolean setConnectionStride(int id, int num)
          Have the data connection skip every num-1 data points.
 void setDefault()
          Reset the clock to time=0.
 void setDt(double dt)
          Set the time increment.
 boolean setExternalClock(int id)
          Get the clock id for use as a data source.
 void setFPS(double fps)
          Set the frames per second.
 void setRunningID()
           
 void setRunningID(java.lang.Object id)
           
 void setTimeContinuous()
          Set the time increment.
 void setTimeCycle(double maxTime)
          Set the clock to cycle between the 0 and maxTime.
 void setTimeOneShot(double maxTime, java.lang.String msg)
          Set the clock to run from minTime to maxTime and stop.
 void startClock()
          Start the clock
 void stepClock()
          Step the clock by one tick, dt.
 void stepTime()
          Step the clock by dt.
 void stepTimeBack()
          Step the clock back by dt.
 void stepTimeForward()
          Step the clock forward by dt.
 void stopClock()
          Stop the clock
 void updateDataConnection(int id)
          Have a single data source update its data connections.
 void updateDataConnections()
          Have all data sources update their data connections.
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, init, 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, 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, paint, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, 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, mouseDown, 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
 

Field Detail

clock

public edu.davidson.tools.SClock clock

dataConnections

public java.util.Vector dataConnections

dataListeners

public static java.util.Hashtable dataListeners

dataSources

public static java.util.Hashtable dataSources

lock

public edu.davidson.tools.BusyFlag lock
Constructor Detail

SApplet

public SApplet()
Method Detail

addDataListener

public static final void addDataListener(java.lang.Object dl)

addDataSource

public static final void addDataSource(java.lang.Object ds)
Add a data source to the list.
Parameters:
ds - The data source object.

cleanupDataConnections

public final void cleanupDataConnections()
Remove dataConnections if either the source or the listener no longer exist.

clearAllData

public void clearAllData()
Delete all the data that has been sent to the DataConnections.

clearData

public void clearData(int id)
Delete all the data that has been sent to the DataConnections.
Parameters:
id - int The hashCode id of the data source.

deleteDataConnection

public void deleteDataConnection(int id)
Break the data connection identified by the id.
Parameters:
id - The data connection id.

deleteDataConnections

public void deleteDataConnections()
Break all data connections for this applet.

destroy

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

forward

public void forward()
Start clock.

getClockID

public final int getClockID()
Get the clock id for use as a data source.

getClockTime

public double getClockTime()
Get the time from the animation clock.
Returns:
double the time

getDataConnectionFromDL

public edu.davidson.tools.SDataConnection getDataConnectionFromDL(edu.davidson.tools.SDataListener dl)
Find the first data connection in the list that has a specific data listener.

getDataConnectionFromDS

public edu.davidson.tools.SDataConnection getDataConnectionFromDS(edu.davidson.tools.SDataSource ds)
Find the first data connection in the list that has a specific data source.

getDataFromDS

public java.lang.String getDataFromDS(int id)
Return the data as a string.

getDataListener

public static final edu.davidson.tools.SDataListener getDataListener(int id)

getDataListener

public static final edu.davidson.tools.SDataListener getDataListener(java.lang.String key)

getDataSource

public static final edu.davidson.tools.SDataSource getDataSource(int id)
Find the data source with the given id.
Parameters:
id - The integer id that identifies the data source.

getDataSource

public static final edu.davidson.tools.SDataSource getDataSource(java.lang.String key)
Find the data source with the given key. The key is the String representation of the hash code.
Parameters:
key - The string id that identifies the data source.

getID

public final int getID()

getRunningID

public final java.lang.Object getRunningID()

getSourceData

public java.lang.String getSourceData(int id,
                                      java.lang.String vStr)
Return a comma delimited list of the data source data.
Parameters:
id - the integer identifier of the data source.
str - the data source variable.
Returns:
string a list of doubles

getSourceVariables

public java.lang.String getSourceVariables(int id)
Return a comma delimited list of the data source variables.
Parameters:
id - the integer identifier of the data source.
Returns:
string a list of variables

isAutoRefresh

public boolean isAutoRefresh()
Test to see if the clock is running.
Returns:
true if clock is running.

isClockRunning

public boolean isClockRunning()
Test to see if the clock is running.
Returns:
true if clock is running.

makeDataConnection

public int makeDataConnection(int sourceID,
                              int listenerID,
                              int seriesID,
                              java.lang.String xStr,
                              java.lang.String yStr)
Have the applet make a new data connection.
Parameters:
sourceID - The id of the data source.
listenerID - The id of the data listener. This is usually an applet.
seriesID - The id of the series in the data listener.
xStr - The function of the data source variables to be plotted on the horizontal axis.
xStr - The function of the data source variables to be plotted on the vertical axis.
Returns:
SDataConnection The hasCode id of the newly created data connection.

pause

public void pause()
Pause the clock.

removeDataListener

public final void removeDataListener(int key)

removeDataSource

public final void removeDataSource(int id)
Remove the data source with the given id. Look for and remove data connections to this data source.
Parameters:
id - The integer id that identifies the data source.

reset

public void reset()
Reset the clock to time=0.

reverse

public void reverse()
Stop the clock.

setAutoRefresh

public void setAutoRefresh(boolean ar)
Repaint whenevers the system parameters are changed.
Parameters:
autoRefresh - Automatic repaint?

setClockContinous

public void setClockContinous()
Set the clock to run continously.
See Also:
setClockOneShot(double, double), setClockCycle(double, double)

setClockCycle

public void setClockCycle(double minTime,
                          double maxTime)
Set the clock to cycle between the minTime and maxTime.
Parameters:
minTime - The maximum time.
maxTime - The maximum time.

setClockOneShot

public void setClockOneShot(double minTime,
                            double maxTime)
Set the clock to run from minTime to maxTime and stop.
Parameters:
minTime - The maximum time.
maxTime - The maximum time.

setClockTime

public void setClockTime(double t)
Set the clock time.
Parameters:
t - The clock time.

setConnectionBlock

public final boolean setConnectionBlock(int id,
                                        boolean block)
Block data from passing through the data connection.

setConnectionListener

public final boolean setConnectionListener(int id)
Set the data listener for the data connection.

setConnectionSmoothing

public final boolean setConnectionSmoothing(int id,
                                            int num)
Have the data connection smooth the data before it is sent to the data listener.
Parameters:
id - int The id of of the data connection.
num - int The number of data points to smooth.
Returns:
boolean Return true if data connection found.

setConnectionSource

public final boolean setConnectionSource(int id)
Set the data source for the data connection.

setConnectionStride

public final boolean setConnectionStride(int id,
                                         int num)
Have the data connection skip every num-1 data points.

setDefault

public void setDefault()
Reset the clock to time=0.

setDt

public void setDt(double dt)
Set the time increment.

setExternalClock

public final boolean setExternalClock(int id)
Get the clock id for use as a data source.
Returns:
true if successful, false otherwise

setFPS

public void setFPS(double fps)
Set the frames per second.

setRunningID

public final void setRunningID()

setRunningID

public final void setRunningID(java.lang.Object id)

setTimeContinuous

public void setTimeContinuous()
Set the time increment.

setTimeCycle

public void setTimeCycle(double maxTime)
Set the clock to cycle between the 0 and maxTime.
Parameters:
maxTime - The maximum time.

setTimeOneShot

public void setTimeOneShot(double maxTime,
                           java.lang.String msg)
Set the clock to run from minTime to maxTime and stop.
Parameters:
minTime - The maximum time.
maxTime - The maximum time.

startClock

public void startClock()
Start the clock

stepClock

public void stepClock()
Step the clock by one tick, dt.

stepTime

public void stepTime()
Step the clock by dt.

stepTimeBack

public void stepTimeBack()
Step the clock back by dt.

stepTimeForward

public void stepTimeForward()
Step the clock forward by dt.

stopClock

public void stopClock()
Stop the clock

updateDataConnection

public void updateDataConnection(int id)
Have a single data source update its data connections.
Parameters:
id - The integer id of the data source.

updateDataConnections

public void updateDataConnections()
Have all data sources update their data connections.

Copyright Wolfgang Christian

Visit the Davidson CollegePhyslets Page