manometer
Class Manometer

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 manometer.Manometer
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 Manometer
extends edu.davidson.tools.SApplet
implements edu.davidson.tools.SDataListener, edu.davidson.tools.SDataSource

The Manometer.class applet simulates a U-tube manometer. The manometer is filled with a liquid. By default, the liquid has the color and density of mercury, though these properties can be altered. A sample of gas can be trapped in the left side of the manometer. The ideal gas law is used to predict the properties of the trapped gas.

The applet uses DataConnections.

Applet Parameters

NAME Variable Type Default Description
BGColor String null String representing an integer describing the RGB color for the applet background
Density double 13.5951 Density of the liquid in the manometer. The default is the density of mercury.
FractionLiquid double 0.60 Fraction of the calibrated volume of the manometer that is filled with liquid.
GasColor String null String containing an integer representation of the RGB color for the gas trapped in the closed end of the manometer. By default the applet background color is used.
IsReady String   JavaScript variable that will be set to true when applet has initialized. Must use MAYSCRIPT in APPLET tag to use this feature.
LiquidColor String #C0C0C0 String containing an integer representation of the RGB color for the liquid in the manometer. The default color is intended to resemble that of mercury.
Maximum double 1000.0 Maximum scale reading in millimeters.
Moles double 0.0 Moles of gas trapped in the closed end of the manometer. The gas is assumed to obey the ideal gas law.
Pressure double 0.0 Pressure in torr exerted on the open end of the manometer.
Temperature double 298.15 Temperature in Kelvin for the system. The temperature is used in the ideal gas law to compute pressures. The density and vapor pressure of the liquid is assumed to be independent of temperature.
TubeDiameter int 20 Inside diameter in pixels of the tube used in the manometer.
VaporPressure double 0.0 Vapor pressure in torr of the liquid in the manometer.

Version:
2.1
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
Manometer()
           
 
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()
           
 double getDiameter()
          Returns the diameter of a tube in millimeters
 double getFractionLiquid()
          Returns the fraction of available tube filled with mercury.
 double getLeftHeight()
          Returns the height of the left (closed side) column of mercury in millimeters.
 double getMaxVolume()
          Returns the volume of the left tube, excluding the base of the manometer.
 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 getPressure()
          Returns the pressure in torr
 double getRightHeight()
          Returns the height of the right (open side) column of mercury in millimeters.
 double getScaleMaximum()
          Returns the maximum height of the scale (at the last major tick mark) in millimeters.
 double[][] getVariables()
          SDataSource method returning the current variables.
 java.lang.String[] getVarStrings()
          SDataSource method returning variable strings.
 double getVolume()
          Returns the volume of the sealed tube above the liquid.
 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 setDensity(double _density)
          Sets the density of the liquid.
 void setDragable(boolean val)
          Determines whether the user can drag the liquid level in the manometer.
 void setFont(java.lang.String name, java.lang.String style, int size)
          Sets the font for the manometers labels.
 void setFractionLiquid(double _fraction)
          Sets the fraction of the functional volume of the manometer occupied by the liquid.
 void setMaximum(double _maximum)
          Sets the maximum scale value.
 void setMoles(double _moles)
          Sets the moles of trapped gas.
 void setOwner(edu.davidson.tools.SApplet owner)
          Sets the owner for SDataListener and SDataSource
 void setPressure(double _pressure)
          Sets the pressure.
 void setTemperature(double _temperature)
          Sets the temperature
 void setVaporPressure(double _pressure)
          Sets the vapor pressure of the liquid.
 void start()
           
 void stop()
           
 void updateDisplay()
          Updates the display to reflect changes in properties.
 
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

Manometer

public Manometer()
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

paint

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

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 x value is never used.

ID = 1, y value equals the system pressure

ID = 2, y value equals the system temperature

ID = 3, y value equals the moles of trapped gas

Specified by:
addData in interface edu.davidson.tools.SDataListener
Parameters:
ds - the data source supplying the information (not used).
id - the data identification (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. The x value is never used

ID = 1, y value equals the system pressure

ID = 2, y value equals the system temperature

ID = 3, y value equals the moles of trapped gas

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).

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

getDiameter

public double getDiameter()
Returns the diameter of a tube in millimeters


getFractionLiquid

public double getFractionLiquid()
Returns the fraction of available tube filled with mercury. (The curved base of the manometer is not regarded as being available.)


getLeftHeight

public double getLeftHeight()
Returns the height of the left (closed side) column of mercury in millimeters.


getMaxVolume

public double getMaxVolume()
Returns the volume of the left tube, excluding the base of the manometer. This value is useful in choosing an appropriate amount of gas to trap in the left tube. Note that a change in the scale will produce a change in this volume, because the dimensions of the manometer will change.

Returns:
volume of left tube in liters

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

getPressure

public double getPressure()
Returns the pressure in torr


getRightHeight

public double getRightHeight()
Returns the height of the right (open side) column of mercury in millimeters.


getScaleMaximum

public double getScaleMaximum()
Returns the maximum height of the scale (at the last major tick mark) in millimeters.


getVolume

public double getVolume()
Returns the volume of the sealed tube above the liquid. It is the "actual" volume in the simulated manometer. Because fractional pixels are not possible, this value will be in error by a fraction related to the length of the manometer.

Returns:
volume in liters

getVariables

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

[0][0] contains the system pressure in torr

[1][0] contains the moles of trapped gas

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

getVarStrings

public java.lang.String[] getVarStrings()
SDataSource method returning variable strings. P is the system pressure in torr. n is the moles of trapped gas.

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

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

setDensity

public void setDensity(double _density)
Sets the density of the liquid. If the argument is less than or equal to zero, the density is set to that of mercury.

Parameters:
_density - density of the liquid in g/mL

setDragable

public void setDragable(boolean val)
Determines whether the user can drag the liquid level in the manometer. Default is false.


setFont

public void setFont(java.lang.String name,
                    java.lang.String style,
                    int size)
Sets the font for the manometers labels. Resets pressure settings, so should be called during initialization.

Parameters:
name - name of font
style - font style (PLAIN, BOLD, ITALIC, BOLD|ITALIC)
size - font size

setFractionLiquid

public void setFractionLiquid(double _fraction)
Sets the fraction of the functional volume of the manometer occupied by the liquid. The functional volume is the volume of the vertical tubes of the manometer and does not include the volume of liquid in the base of the manometer.


setMaximum

public void setMaximum(double _maximum)
Sets the maximum scale value.

Parameters:
_maximum - maximum scale reading in millimeters

setMoles

public void setMoles(double _moles)
Sets the moles of trapped gas. (This value does not include vaporization of the liquid in the manometer, which is handled separately.)

See Also:
setVaporPressure(double)

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

setPressure

public void setPressure(double _pressure)
Sets the pressure.

Parameters:
_pressure - pressure in torr

setTemperature

public void setTemperature(double _temperature)
Sets the temperature

Parameters:
_temperature - temperature in Kelvin

setVaporPressure

public void setVaporPressure(double _pressure)
Sets the vapor pressure of the liquid. If the value is less than zero, the vapor pressure is set to zero.

Parameters:
_pressure - vapor pressure of the liquid in torr

updateDisplay

public void updateDisplay()
Updates the display to reflect changes in properties.