piston3
Class Piston3

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 piston3.Piston3
All Implemented Interfaces:
edu.davidson.tools.SDataListener, edu.davidson.tools.SDataSource, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class Piston3
extends edu.davidson.tools.SApplet
implements edu.davidson.tools.SDataListener, edu.davidson.tools.SDataSource

A piston with a movable barrier is displayed. This applet displays a pair of bulbs separated by stopcock.

Applet Parameters

NAME Variable Type Default Description
BarrierColor String #808040 String containing a representation of an integer describing the RGB color for the movable barrier.
BarrierHeight int 20 Height in pixels of the barrier.
BGColor String null String containing a representation of an integer describing the RGB color for the applet background.
Color1 String null String containing a representation of an integer describing the RGB color for region 1 (the lowest region) in the piston.
Color2 String null String containing a representation of an integer describing the RGB color for region 2 (the middle region) in the piston.
Color3 String null String containing a representation of an integer describing the RGB color for region 3 (the upper region) in the piston.
IsReady String   JavaScript variable that will be set to true when applet has initialized. Must use MAYSCRIPT in APPLET tag to use this feature.
MaximumVolume double 10.0 Maximum volume for the piston
MinimumVolume double 0.0 Minimum volume for the piston
PistonHeight int 0 Height in pixels of the piston. If zero, the applet sets the piston height to fill the applet area.
PistonWidth int 0 Width in pixels of the piston. If zero, the applet sets the piston width to fill the applet area.
ScaleMaximum double 10.0 Sets the maximum value for the scale.
ScalePosition boolean true If true, the scale is shown at the left side of the piston; otherwise the scale is shown at the right side.
ScaleWidth int 40 Width in pixels of the scale.
ShowScale boolean true Indicates whether of not to show the scale.
WallColor String #804000 String containing a representation of an integer describing the RGB color for the piston wall.
WallWidth int 20 Width in pixels of the piston walls.

Version:
2.0
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
Piston3()
           
 
Method Summary
 void addData(edu.davidson.tools.SDataSource ds, int id, double[] xVal, double[] yVal)
          Adds an array of data points via DataConnections.
 void addDatum(edu.davidson.tools.SDataSource ds, int id, double xVal, double yVal)
          The data source and id are not used.
 void clearSeries(int id)
          This method is required by SDataListener but is not used in this class.
 void deleteSeries(int id)
          This method is required by SDataListener but is not used in this class.
 void destroy()
           
 java.lang.String getAppletInfo()
           
 edu.davidson.tools.SApplet getOwner()
          Gets the owner of this DataListener and DataSource
 java.lang.String getParameter(java.lang.String key, java.lang.String def)
           
 java.lang.String[][] getParameterInfo()
           
 double[][] getVariables()
          SDataSource method returning the current variables.
 java.lang.String[] getVarStrings()
          SDataSource method returning variable strings.
 double getVolume()
          Returns the volume (in mL) of the piston
 double getVolume(int _region)
          Returns the volume (in mL) of the region (1, 2, or 3).
 double[] getVolumes()
          Returns an array containing the volumes (in mL) of regions 1, 2, and 3.
 void init()
           
 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)
           
 void setAutoUpdate(boolean val)
          Sets the autoUpdate parameter.
 void setColor(int _region, int _red, int _green, int _blue)
          Sets the color of the indicated region (1, 2, or 3).
 void setColor(int _region, java.lang.String _color)
          Sets the color of the indicated region (1, 2, or 3).
 void setColors(int _r1, int _g1, int _b1, int _r2, int _g2, int _b2, int _r3, int _g3, int _b3)
          Sets the colors of all three regions.
 void setColors(java.lang.String _color1, java.lang.String _color2, java.lang.String _color3)
          Sets the colors of all three regions.
 void setDragable(boolean val)
          Determines whether the user can drag the barrier.
 void setMaxVolume(double _volume)
          Sets the maximum volume for the piston.
 void setMaxVolume(double _volume, double _scaleReading)
          Sets the maximum volume for the piston based upon the volume at a given scale reading.
 void setMinVolume(double _volume)
          Sets the minimum volume for the piston.
 void setOwner(edu.davidson.tools.SApplet owner)
          Sets the owner for SDataListener and SDataSource
 void setScaleMaximum(double _max)
          Sets the maximum value of the scale.
 void setVolume(double _volume)
          Sets the volume (in mL) of the piston.
 void setVolume(int _region, double _volume)
          Sets the volume (in mL) of a region (1, 2, or 3)
 void setVolumes(double _volume1, double _volume2, double _volume3)
          Sets the volumes (in mL) of all three regions.
 void start()
           
 void stop()
           
 void updateDisplay()
          Updates the position of the barrier in the piston
 
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, mouseEnter, mouseExit, mouseMove, 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.SDataListener
getID
 
Methods inherited from interface edu.davidson.tools.SDataSource
getID
 

Constructor Detail

Piston3

public Piston3()
Method Detail

getParameter

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

init

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

start

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

stop

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

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

getParameterInfo

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

addData

public void addData(edu.davidson.tools.SDataSource ds,
                    int id,
                    double[] xVal,
                    double[] yVal)
Adds an array of data points via DataConnections. The data source and id are not used.

xVal[0] sets the total volume

xVal[1] sets the size of region 1

xVal[2] sets the size of region 2

xVal[3] sets the size of region 3

The volumes of the individual regions take priority over the volume in element 0. For total volumes that exceed the maximum volume, the volume of the lower numbered regions takes precedence. The value of yVal is not used

Specified by:
addData in interface edu.davidson.tools.SDataListener
Parameters:
ds - the data source supplying the information (not used)
id - the data identification
xVal - volume of the region
yVal - not used

addDatum

public void addDatum(edu.davidson.tools.SDataSource ds,
                     int id,
                     double xVal,
                     double yVal)
The data source and id are not used. xVal sets the volume in mL. yVal is not used.

Specified by:
addDatum in interface edu.davidson.tools.SDataListener
Parameters:
ds - the data source supplying the information (not used).
id - the data identification (not used).
xVal - volume
yVal - not used

clearSeries

public void clearSeries(int id)
This method is required by SDataListener but is not used in this class.

Specified by:
clearSeries in interface edu.davidson.tools.SDataListener

deleteSeries

public void deleteSeries(int id)
This method is required by SDataListener but is not used in this class.

Specified by:
deleteSeries in interface edu.davidson.tools.SDataListener

getOwner

public edu.davidson.tools.SApplet getOwner()
Gets the owner of this DataListener and DataSource

Specified by:
getOwner in interface edu.davidson.tools.SDataListener
Specified by:
getOwner in interface edu.davidson.tools.SDataSource
Returns:
the owner

getVariables

public double[][] getVariables()
SDataSource method returning the current variables.

[0][0] contains the system volume

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

getVarStrings

public java.lang.String[] getVarStrings()
SDataSource method returning variable strings. V is the volume of the piston.

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

getVolume

public double getVolume()
Returns the volume (in mL) of the piston


getVolume

public double getVolume(int _region)
Returns the volume (in mL) of the region (1, 2, or 3). Region 0 returns the total volume


getVolumes

public double[] getVolumes()
Returns an array containing the volumes (in mL) of regions 1, 2, and 3. Element 0 contains the total volume.


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

paint

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

setColor

public void setColor(int _region,
                     java.lang.String _color)
Sets the color of the indicated region (1, 2, or 3). The color is a string representation of a 24-bit integer.


setAutoUpdate

public void setAutoUpdate(boolean val)
Sets the autoUpdate parameter. If true, the display is automatically updated after every change to conditions. Otherwise no update occurs, unless the updateDisplay method is explicitly called. This parameter does not affect information passed by DataConnections.


setColor

public void setColor(int _region,
                     int _red,
                     int _green,
                     int _blue)
Sets the color of the indicated region (1, 2, or 3). Color values lies in the range 0 to 255.


setColors

public void setColors(java.lang.String _color1,
                      java.lang.String _color2,
                      java.lang.String _color3)
Sets the colors of all three regions. Each color is represented by a string representation of a 24-bit integer.


setColors

public void setColors(int _r1,
                      int _g1,
                      int _b1,
                      int _r2,
                      int _g2,
                      int _b2,
                      int _r3,
                      int _g3,
                      int _b3)
Sets the colors of all three regions. Color values lie in the range 0 to 255.


setDragable

public void setDragable(boolean val)
Determines whether the user can drag the barrier. Default is false.


setMaxVolume

public void setMaxVolume(double _volume)
Sets the maximum volume for the piston.


setMaxVolume

public void setMaxVolume(double _volume,
                         double _scaleReading)
Sets the maximum volume for the piston based upon the volume at a given scale reading. This method facilitates establishing a simple relation between the scale reading and the piston volume. This calibration is most accurate when the scale reading corresponds with a tick mark.


setMinVolume

public void setMinVolume(double _volume)
Sets the minimum volume for the piston. When the barrier is fully depressed the volume is always zero. This value determines how far the barrier can be depressed. The actual minimum volume might be somewhat less than this value because dragging the barrier is based upon the pixel position.


setOwner

public void setOwner(edu.davidson.tools.SApplet owner)
Sets the owner for SDataListener and SDataSource

Specified by:
setOwner in interface edu.davidson.tools.SDataListener
Specified by:
setOwner in interface edu.davidson.tools.SDataSource
Parameters:
owner - the owner of this DataListener

setScaleMaximum

public void setScaleMaximum(double _max)
Sets the maximum value of the scale. The actual maximum will probably differ from this value as the scale is adjusted to coincide with pixel positions.


setVolume

public void setVolume(double _volume)
Sets the volume (in mL) of the piston.


setVolume

public void setVolume(int _region,
                      double _volume)
Sets the volume (in mL) of a region (1, 2, or 3)


setVolumes

public void setVolumes(double _volume1,
                       double _volume2,
                       double _volume3)
Sets the volumes (in mL) of all three regions. The total volume is set to the sum of the volumes of the three regions.


updateDisplay

public void updateDisplay()
Updates the position of the barrier in the piston