spectrophotometer
Class Spectrophotometer

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 edu.davidson.tools.SApplet
                      extended by spectrophotometer.Spectrophotometer
All Implemented Interfaces:
edu.davidson.tools.SDataSource, edu.davidson.tools.SStepable, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class Spectrophotometer
extends edu.davidson.tools.SApplet
implements edu.davidson.tools.SStepable, edu.davidson.tools.SDataSource

Simulation of a spectrophotometer. The simulation employs a particulate model for light, which is represented as photons (small balls) traveling from the light source to the detector. While passing through the cell, there is a chance the photons will be absorbed.

Applet Parameters

BGColor : background color (uses #FFFFFF notation)
Concentration : analyte concentration in mole/L (default 0.00100)
ControlPosition : position of the controls, 0=North, 1=East, 2=South, 3=West (default 2)
Dt : simulation time increment (fps = 1/Dt) (default 0.010)
Intensity : light source intensity in photons/sec (default 10)
IsReady : JavaScript variable set to true when this applet has loaded and initialized LiquidColor : color of liquid in cell (uses #FFFFFF notation)
MolarAbsorptivity : analyte molar absorptivity in L/(mole cm) (default 199)
PathLength : cell path length in cm (default 1.00)
PixelsPerCM : pixels per cm in the display (default 33)
ShowControls : true to show controls (default)
Speed : speed of photons (default 50 pixels/sec)
Wavelength : wavelength of light in nm, used to set photon color (default 400)

Version:
2.0, September 2008
Author:
David N. Blauch
See Also:
Serialized Form

Nested Class Summary
 
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class edu.davidson.tools.SApplet
autoRefresh, clock, dataConnections, dataListeners, dataSources, lock, oneShotMsg
 
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
Spectrophotometer()
           
 
Method Summary
 void destroy()
           
 java.lang.String getAppletInfo()
           
 java.awt.Color getColor(double val)
          Returns the color associated with the specified wavelength.
 edu.davidson.tools.SApplet getOwner()
          Gets the owner of the data source.
 java.lang.String getParameter(java.lang.String key, java.lang.String def)
           
 java.lang.String[][] getParameterInfo()
           
 double getTime()
          Gets the current timer time.
 double[][] getVariables()
          Gets the values of the variables for SDataSource.
element [0][0] is the time as provided by the timer, which might be disabled
element [0][1] is the number of photons emitted by the light source
element [0][2] is the number of photons detected by the detector
element [0][3] is the intensity (photons/sec), which is zero if the timer is off
element [0][4] is the transmittance, which is zero if the timer is off
element [0][5] is the absorbance, which is zero if the timer is off
The transmittance and absorbance are determined using the reference intensity, if it is defined; otherwise the source intensity is used.
 java.lang.String[] getVarStrings()
          Returns an array of the variable names supplied by this SDataSource.
t is the simulation time in seconds
s is the number of photons emitted by the source
d is the number of photons that have reached the detector
I is the measured photon intensity
T is the measured transmittance
A is the measured absorbance
 void init()
           
 void paint(java.awt.Graphics g)
           
 void resetSimulation()
          Resets the simulation.
 void setAutoTimer(boolean val)
          If true, the timer is automatically started when the first photon reaches the detector.
 void setBackgroundColor(java.lang.String rgb)
          Sets the background color of the applet.
 void setBackgroundScattering(double val)
          Sets the probability of background scattering when a photon encounters the cell walls
 void setConcentration(double val)
          Sets the concentration of the absorbing species
 void setIntensity(double val)
          Sets the source intensity, the rate at which photons are emitted from the light source.
 void setLiquidColor(java.lang.String rgb)
          Sets the color of the liquid in the cell.
 void setMolarAbsorptivity(double val)
          Sets the molar absorptivity of the absorbing species
 void setOwner(edu.davidson.tools.SApplet owner)
          Sets the owner for the SDataSource.
 void setPathLength(double val)
          Sets the cell path length.
 void setPhotonRadius(int val)
          Sets the radius of the photons.
 void setPixelsPerCM(int val)
          Sets the number of pixels per centimeter.
 void setReferenceIntensity(double val)
          Sets the reference intensity.
 void setScalingFactor(double val)
          Sets the scaling factor.
 void setSpeed(double val)
          Sets the speed with which a photon moves across the screen.
 void setTimeIncrement(double val)
          Sets the simulation time increment, the time between points in the simulation.
 void setWavelength(double val)
          Sets the wavelength of the photons.
 void start()
           
 void startSimulation()
          Starts the simulation by starting the clock.
 void startTimer()
          Starts the timer.
 void step(double dt, double tm)
          Calculates state of system at each step in the simulation.
 void stop()
           
 void stopSimulation()
          Stops the simulation.
 void stopTimer()
          Stops the timer.
 void useCell(boolean val)
          Determines whether the cell is used in the simulation
 
Methods inherited from class edu.davidson.tools.SApplet
addDataListener, addDataSource, cleanupDataConnections, clearAllData, clearData, cyclingClock, deleteDataConnection, deleteDataConnections, forward, getClockID, getClockTime, getDataConnectionFromDL, getDataConnectionFromDS, getDataFromDS, getDataListener, getDataListener, getDataSource, getDataSource, getID, getRunningID, getSourceData, getSourceVariables, isAutoRefresh, isClockRunning, makeDataConnection, pause, pausingClock, removeDataListener, removeDataSource, reset, reverse, setAutoRefresh, setClockContinous, setClockCycle, setClockOneShot, setClockTime, setConnectionBlock, setConnectionListener, setConnectionSmoothing, setConnectionSource, setConnectionStride, setDefault, setDt, setExternalClock, setFPS, setRunningID, setRunningID, setTimeContinuous, setTimeCycle, setTimeOneShot, startClock, stepClock, stepTime, stepTimeBack, stepTimeForward, stopClock, stoppingClock, updateDataConnection, updateDataConnections
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, 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, 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, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, 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
 
Methods inherited from interface edu.davidson.tools.SDataSource
getID
 

Constructor Detail

Spectrophotometer

public Spectrophotometer()
Method Detail

destroy

public void destroy()
Overrides:
destroy in class edu.davidson.tools.SApplet

getAppletInfo

public java.lang.String getAppletInfo()
Overrides:
getAppletInfo in class java.applet.Applet

getColor

public java.awt.Color getColor(double val)
Returns the color associated with the specified wavelength. The wavelength must lie between 380 and 780 nm.

Parameters:
val - wavelength in nanometers

getOwner

public edu.davidson.tools.SApplet getOwner()
Gets the owner of the data source.

Specified by:
getOwner in interface edu.davidson.tools.SDataSource
Returns:
owner of the data source, which is this applet

getParameter

public java.lang.String getParameter(java.lang.String key,
                                     java.lang.String def)

getParameterInfo

public java.lang.String[][] getParameterInfo()
Overrides:
getParameterInfo in class java.applet.Applet

getTime

public double getTime()
Gets the current timer time. This value is zero if the timer is not running or if a simulation is not running.

Returns:
time in seconds

getVariables

public double[][] getVariables()
Gets the values of the variables for SDataSource.
element [0][0] is the time as provided by the timer, which might be disabled
element [0][1] is the number of photons emitted by the light source
element [0][2] is the number of photons detected by the detector
element [0][3] is the intensity (photons/sec), which is zero if the timer is off
element [0][4] is the transmittance, which is zero if the timer is off
element [0][5] is the absorbance, which is zero if the timer is off
The transmittance and absorbance are determined using the reference intensity, if it is defined; otherwise the source intensity is used.

Specified by:
getVariables in interface edu.davidson.tools.SDataSource
Returns:
a one-by-three array

getVarStrings

public java.lang.String[] getVarStrings()
Returns an array of the variable names supplied by this SDataSource.
t is the simulation time in seconds
s is the number of photons emitted by the source
d is the number of photons that have reached the detector
I is the measured photon intensity
T is the measured transmittance
A is the measured absorbance

Specified by:
getVarStrings in interface edu.davidson.tools.SDataSource

paint

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

resetSimulation

public void resetSimulation()
Resets the simulation. This method calls the stopSimulation() method and then clears the display.


setAutoTimer

public void setAutoTimer(boolean val)
If true, the timer is automatically started when the first photon reaches the detector. This procedure compensates for the time delay between emission of a photon (which increments the source count) and the detection of a photon (which increments the detector count). The timer is automatically started only once. Calling the setAutoTimer method again re-enables this option. Calling the resetSimulation method also re-enables this option.

See Also:
resetSimulation()

setBackgroundColor

public void setBackgroundColor(java.lang.String rgb)
Sets the background color of the applet.

Parameters:
rgb - this string is converted into a 24-bit integer that defines the color

setBackgroundScattering

public void setBackgroundScattering(double val)
Sets the probability of background scattering when a photon encounters the cell walls

Parameters:
val - probability (default 0.00)

setConcentration

public void setConcentration(double val)
Sets the concentration of the absorbing species

Parameters:
val - concentration in mole/L

setIntensity

public void setIntensity(double val)
Sets the source intensity, the rate at which photons are emitted from the light source.

Parameters:
val - intensity in photons per second

setLiquidColor

public void setLiquidColor(java.lang.String rgb)
Sets the color of the liquid in the cell.

Parameters:
rgb - this string is converted into a 24-bit integer that defines the color

setMolarAbsorptivity

public void setMolarAbsorptivity(double val)
Sets the molar absorptivity of the absorbing species

Parameters:
val - molar absorptivity in L/(mole cm)

setOwner

public void setOwner(edu.davidson.tools.SApplet owner)
Sets the owner for the SDataSource. (In this implementation, this method does not do anything.

Specified by:
setOwner in interface edu.davidson.tools.SDataSource
Parameters:
owner - owner of the data source

setPathLength

public void setPathLength(double val)
Sets the cell path length. The cell path length cannot be altered if a simulation is running.

Parameters:
val - cell path length in centimeters

setPhotonRadius

public void setPhotonRadius(int val)
Sets the radius of the photons.

Parameters:
val - photon radius in pixels

setPixelsPerCM

public void setPixelsPerCM(int val)
Sets the number of pixels per centimeter. The number of pixels per centimeter cannot be altered if a simulation is running.

Parameters:
val - number of pixels per centimeter

setReferenceIntensity

public void setReferenceIntensity(double val)
Sets the reference intensity. The reference intensity is the intensity observed in the absence of analyte (but the cell and solution are typically present). If no reference intensity is set or if a zero or negative value is supplied, the source intensity and background scattering is used to calculate the transmittance.

Parameters:
val - reference intensity in photons per second

setScalingFactor

public void setScalingFactor(double val)
Sets the scaling factor. The standard simulation operates with a scaling factor of zero. For scaling factors above zero, additional photons that are not displayed are added to the source and detector counts. If the intensity if 10/sec and the scaling factor is 9, the effective intensity is 10/sec (1+9) = 100/sec.


setSpeed

public void setSpeed(double val)
Sets the speed with which a photon moves across the screen.

Parameters:
val - speed in pixels per second

setTimeIncrement

public void setTimeIncrement(double val)
Sets the simulation time increment, the time between points in the simulation. The simulation is always set to run in real time.

Parameters:
val - time increment in seconds

setWavelength

public void setWavelength(double val)
Sets the wavelength of the photons. The wavelength is used to set the photon color. This is a visible spectrometer; the wavelength must lie between 380 and 780 nm.

Parameters:
val - wavelength in nanometers

start

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

startSimulation

public void startSimulation()
Starts the simulation by starting the clock. No other conditions are altered. This method can be used to resume a simulation after the stop method has been called.

See Also:
SApplet.stopClock()

startTimer

public void startTimer()
Starts the timer. A simulation must be running for the timer to run. This method can also be used to reset the timer while it is running.


step

public void step(double dt,
                 double tm)
Calculates state of system at each step in the simulation. Called only by the clock.

Specified by:
step in interface edu.davidson.tools.SStepable

stop

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

stopSimulation

public void stopSimulation()
Stops the simulation.


stopTimer

public void stopTimer()
Stops the timer.


useCell

public void useCell(boolean val)
Determines whether the cell is used in the simulation


init

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