bulbs
Class Bulbs

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 bulbs.Bulbs
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class Bulbs
extends java.applet.Applet

This applet displays a pair of bulbs separated by stopcock.

Applet Parameters

NAME Variable Type Default Description
BGColor String null String containing a representation of an integer describing the RGB color for the applet background.
HoleDiameter int 4 Diameter in pixels of the hole in the stopcock.
IsReady String   JavaScript variable that will be set to true when applet has initialized. Must use MAYSCRIPT in APPLET tag to use this feature.
LeftColor String #FFA0A0 String containing a representation of an integer describing the RGB color of the gas in the left bulb.
LeftDiameter int 0 Diameter in pixels of the left bulb. If the value is zero, the applet automatically sets the diameter to fill the available area.
LeftVolume double 1.0 Volume in liters for the left bulb. The volume of the right bulb is determined by the volume of the left bulb and the relative diameters of the two bulbs.
MixtureColor String #A0A0FF String representation of an integer describing the RGB color of the gas mixture, which the gas when the stopcock is open.
RightColor String #A0FFA0 String representation of an integer describing the RGB color of the gas in the right bulb.
RightDiameter int 0 Diameter in pixels of the right bulb. If the value is zero, the applet automatically sets the diameter so the bulb fills the available display.
StopcockBorder int 3 Width in pixels of the extent of the stopcock above and below the tube.
StopcockDiameter int 10 Diameter in pixels of the body of the stopcock.
StopcockWidth int 16 Width in pixels of the stopcock knob in the open position.
TubeLength int 20 Length in pixels of the tube bearing the stopcock and situated between the two bulbs.
TubeWidth int 8 Width in pixels of the tube bearing the stopcock and situated between the two bulbs.

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 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
Bulbs()
           
 
Method Summary
 void destroy()
           
 java.lang.String getAppletInfo()
           
 double getLeftVolume()
          Returns the volume of the left bulb in liters
 java.lang.String getParameter(java.lang.String key, java.lang.String def)
           
 java.lang.String[][] getParameterInfo()
           
 double getRightVolume()
          Returns the volume of the right bulb in liters
 double getVolume()
          Returns the volume of the two bulbs in liters.
 void init()
           
 void paint(java.awt.Graphics g)
           
 void setDiameters(int _leftDiameter, int _rightDiameter)
          Sets the diameters of the two bulbs.
 void setLeftColor(int _red, int _green, int _blue)
          Sets the color of the gas in the left bulb.
 void setLeftColor(java.lang.String _color)
          Sets the color of the gas in the left bulb.
 void setLeftVolume(double _volume)
          Sets the volume of the left bulb.
 void setMixtureColor(int _red, int _green, int _blue)
          Sets the color of the gas mixture.
 void setMixtureColor(java.lang.String _color)
          Sets the color of the gas mixture.
 void setRightColor(int _red, int _green, int _blue)
          Sets the color of the gas in the right bulb.
 void setRightColor(java.lang.String _color)
          Sets the color of the gas in the right bulb.
 void setRightVolume(double _volume)
          Sets the volume of the right bulb.
 void setStopcockState(boolean _state)
          Sets the state of the stopcock.
 void start()
           
 void stop()
           
 
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
 

Constructor Detail

Bulbs

public Bulbs()
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 java.applet.Applet

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

getLeftVolume

public double getLeftVolume()
Returns the volume of the left bulb in liters


getRightVolume

public double getRightVolume()
Returns the volume of the right bulb in liters


getVolume

public double getVolume()
Returns the volume of the two bulbs in liters.


paint

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

setDiameters

public void setDiameters(int _leftDiameter,
                         int _rightDiameter)
Sets the diameters of the two bulbs. Using zero for either values results in the bulb size being set to fill the display area. The stopcock is set to the closed state.

Parameters:
_leftDiameter - diameter in pixels of the left bulb
_rightDiameter - diameter in pixels of the right bulb

setLeftColor

public void setLeftColor(java.lang.String _color)
Sets the color of the gas in the left bulb. This color is applied only if the stopcock is closed.

Parameters:
_color - integer value used to construct color

setLeftColor

public void setLeftColor(int _red,
                         int _green,
                         int _blue)
Sets the color of the gas in the left bulb. This color is applied only if the stopcock is closed.

Parameters:
_red - red component of the color
_green - green component of the color
_blue - blue component of the color

setLeftVolume

public void setLeftVolume(double _volume)
Sets the volume of the left bulb. Changing this value also changes the volume of the right bulb. The relative volumes of the two bulbs are established by the relative diameters of the two bulbs.

Parameters:
_volume - volume in liters of left bulb

setMixtureColor

public void setMixtureColor(java.lang.String _color)
Sets the color of the gas mixture. This color is applied only if the stopcock is open.

Parameters:
_color - integer value used to construct color

setMixtureColor

public void setMixtureColor(int _red,
                            int _green,
                            int _blue)
Sets the color of the gas mixture. This color is applied only if the stopcock is open.

Parameters:
_red - red component of the color
_green - green component of the color
_blue - blue component of the color

setRightColor

public void setRightColor(java.lang.String _color)
Sets the color of the gas in the right bulb. This color is applied only if the stopcock is closed.

Parameters:
_color - integer value used to construct color

setRightColor

public void setRightColor(int _red,
                          int _green,
                          int _blue)
Sets the color of the gas in the right bulb. This color is applied only if the stopcock is closed.

Parameters:
_red - red component of the color
_green - green component of the color
_blue - blue component of the color

setRightVolume

public void setRightVolume(double _volume)
Sets the volume of the right bulb. Changing this value also changes the volume of the left bulb. The relative volumes of the two bulbs are established by the relative diameters of the two bulbs.

Parameters:
_volume - volume in liters of right bulb

setStopcockState

public void setStopcockState(boolean _state)
Sets the state of the stopcock. If true, the stopcock is open. If false the stopcock is closed.