com.pentec.gui.widgets
Class ATemperaturePanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.pentec.gui.widgets.ATemperaturePanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
OneWireTemperaturePanel

public class ATemperaturePanel
extends javax.swing.JPanel

Generic temperature panel with a unit combo box and graph button. This is often extended implementing Runnable to update itself as a temperature monitor.

Author:
Pender Technology
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  java.lang.String $Name
          Name of the temperature panel (used as a label for the button)
static java.lang.String[] a$Units
          Supported temperature units
static int DEGC
          Degrees Celsius index
static int DEGF
          Degrees Fahrenheit index
static int DEGR
          Degrees Rankin index
private  double dTemperatureDegC
          Current temperature in degrees Celsius
static double ERROR
          Value marking an error in reading/setting the temperature
private  int iDisplayPrecision
          Number of digits past the decimal point to display
private  int iNumDataPoints
          Number of history data points to maintain
private  int iUnits
          Currently displayed units
private  javax.swing.JButton jbGraph
          Button to graph temperature history (labeled with $Name
private  javax.swing.JComboBox jcbUnits
          Units selection combo box
private  javax.swing.JTextField jtfTemperature
          Text field the current temperature in the currently selected units is displayed in
static int KELVIN
          Kelvin index
private  long lFirstSampleTime
          First sample time
protected  java.util.ArrayList tempList
          List of temperatures for each data point
protected  java.util.ArrayList timeList
          List of elapsed times for each data point
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ATemperaturePanel(java.lang.String $Name, int iNumDataPoints, int iDisplayPrecision)
           
ATemperaturePanel(java.lang.String $Name, int iNumDataPoints, int iDisplayPrecision, java.awt.Dimension graphButtonSize)
           
ATemperaturePanel(java.lang.String $Name, int iNumDataPoints, int iDisplayPrecision, int iDefaultUnit)
           
ATemperaturePanel(java.lang.String $Name, int iNumDataPoints, int iDisplayPrecision, int iDefaultUnit, java.awt.Dimension graphButtonSize)
           
 
Method Summary
static double convertTemperatureFromCelsius(double dTemperature, int iUnit)
          Convert temperature from degrees Celsius to iUnit.
static double convertTemperatureToCelsius(double dTemperature, int iUnit)
          Convert temperature to degrees Celsius from iUnit.
static javax.swing.JComboBox createTemperatureComboBox()
           
static int decodeUnits(java.lang.String $Unit)
          Decode the String form of units into an integer index
 DataFrame generateGraph()
          Generate an APlot of the last iNumDataPoints recorded temperatures.
 java.lang.String getName()
           
private  void setTemperature(double dTemperature)
          Set and display the current temperature
 java.lang.String toString()
           
 void updateTemperature(double dTemperature)
          Set and record the current temperature
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

$Name

private java.lang.String $Name
Name of the temperature panel (used as a label for the button)


a$Units

public static final java.lang.String[] a$Units
Supported temperature units


DEGC

public static final int DEGC
Degrees Celsius index

See Also:
Constant Field Values

DEGF

public static final int DEGF
Degrees Fahrenheit index

See Also:
Constant Field Values

DEGR

public static final int DEGR
Degrees Rankin index

See Also:
Constant Field Values

dTemperatureDegC

private double dTemperatureDegC
Current temperature in degrees Celsius


ERROR

public static final double ERROR
Value marking an error in reading/setting the temperature

See Also:
Constant Field Values

iDisplayPrecision

private int iDisplayPrecision
Number of digits past the decimal point to display


iNumDataPoints

private int iNumDataPoints
Number of history data points to maintain


iUnits

private int iUnits
Currently displayed units


jbGraph

private javax.swing.JButton jbGraph
Button to graph temperature history (labeled with $Name


jcbUnits

private javax.swing.JComboBox jcbUnits
Units selection combo box


jtfTemperature

private javax.swing.JTextField jtfTemperature
Text field the current temperature in the currently selected units is displayed in


KELVIN

public static final int KELVIN
Kelvin index

See Also:
Constant Field Values

lFirstSampleTime

private long lFirstSampleTime
First sample time


tempList

protected java.util.ArrayList tempList
List of temperatures for each data point


timeList

protected java.util.ArrayList timeList
List of elapsed times for each data point

Constructor Detail

ATemperaturePanel

public ATemperaturePanel(java.lang.String $Name,
                         int iNumDataPoints,
                         int iDisplayPrecision)

ATemperaturePanel

public ATemperaturePanel(java.lang.String $Name,
                         int iNumDataPoints,
                         int iDisplayPrecision,
                         java.awt.Dimension graphButtonSize)

ATemperaturePanel

public ATemperaturePanel(java.lang.String $Name,
                         int iNumDataPoints,
                         int iDisplayPrecision,
                         int iDefaultUnit)

ATemperaturePanel

public ATemperaturePanel(java.lang.String $Name,
                         int iNumDataPoints,
                         int iDisplayPrecision,
                         int iDefaultUnit,
                         java.awt.Dimension graphButtonSize)
Method Detail

convertTemperatureFromCelsius

public static double convertTemperatureFromCelsius(double dTemperature,
                                                   int iUnit)
Convert temperature from degrees Celsius to iUnit. Returns NaN if iUnit is invalid.

Parameters:
dTemperature - temperature in degrees Celsius
iUnit - unit to convert to
Returns:
temperature in iUnit

convertTemperatureToCelsius

public static double convertTemperatureToCelsius(double dTemperature,
                                                 int iUnit)
Convert temperature to degrees Celsius from iUnit. Returns NaN if iUnit is invalid.

Parameters:
dTemperature - temperature in iUnit
iUnit - unit to convert from
Returns:
temperature in Celsius

createTemperatureComboBox

public static javax.swing.JComboBox createTemperatureComboBox()

decodeUnits

public static int decodeUnits(java.lang.String $Unit)
Decode the String form of units into an integer index

Parameters:
$Unit - String form of a supported unit
Returns:
integer index of $Unit, -1 on failure to decode (unsupported unit)

generateGraph

public DataFrame generateGraph()
Generate an APlot of the last iNumDataPoints recorded temperatures.

Returns:
DataFrame containing an APlot of recorded temperatures

getName

public java.lang.String getName()
Overrides:
getName in class java.awt.Component
Returns:
the name of this temperature panel

setTemperature

private void setTemperature(double dTemperature)
Set and display the current temperature

Parameters:
dTemperature - current temperature in degrees Celsius

toString

public java.lang.String toString()
Overrides:
toString in class java.awt.Component
Returns:
current displayed temperature in human readable form

updateTemperature

public void updateTemperature(double dTemperature)
Set and record the current temperature

Parameters:
dTemperature - current temperature in degrees Celsius