adm
Class CStripChart

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--adm.CStripChart

public class CStripChart
extends java.awt.Panel
implements CConstants, java.awt.event.MouseListener, java.lang.Runnable

CStripChart is a container widget that holds up to 8 Pen instances. It does not implement DeviceListener but gets the data from each Pen at specified time intervals. The new data will be plotted on the right side of the strip chart and the old data will be shifted to the left.

The device name and property name must be set for each Pen added to the CStripChart. The color of the Pen is optional. The default Pen color will be used if it has not been set. The default Pen color defined in CStripChart class is brown, orange, green, blue, purple, pink, cyan, navy for pen[0], pen[1], ..., pen[7].

The Pen in the CStripChart can share a common display range (y-axis) using method setCommonAxis (true). By default, all the pens have their own display range.

Initially the information of the first Pen will be displayed on the y axis label and device/property name label in the color of the first Pen. The value and color of the label will change to a specific Pen if the user clicks on the plot line of that Pen. Due to a java 1.1.X bug, this feature only works with the jre 1.2.

The methods setDisplayRange (int, int), setDisplayHi (int) and setDisplayLo (int) in the CStripChart class will force setting the range style to RANGE_STATIC and common axis to true. When using a common axis, the minimum display low and the maximum display high of all pens are used as the display range if the user does not specify the display range. The display range of each pen can be set individually using the setDisplayHi(double)/setDispalyLo(double) or setDisplayRange(double, double) methods in the Pen class.

The y-axis is forced to a common axis when the range style is set to RANGE_AUTO.

Since:
adm0.2
See Also:
Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface adm.CConstants
ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, AXIS_BOTTOM, AXIS_LEFT, AXIS_RIGHT, AXIS_STYLE_LINEAR, AXIS_STYLE_LOG10, AXIS_TOP, CLASS_QUERY, CLRMOD_ALARM, CLRMOD_STATIC, COLUMN, DEVICE_QUERY, DIR_DOWN, DIR_LEFT, DIR_RIGHT, DIR_UP, FILL_FROM_CENTER, FILL_FROM_EDGE, FRMT_AUTO, FRMT_FLOAT, FRMT_HEX, FRMT_INTEGER, FRMT_OCTAL, FRMT_SCIENTIFIC, HORIZONTAL, LABEL_ALL, LABEL_AXIS, LABEL_NONE, LABEL_VALUE, PROPERTY_QUERY, RANGE_AUTO, RANGE_FROM_PROPERTY, RANGE_STATIC, ROW, STYLE_FILLUNDER, STYLE_LINE, STYLE_POINT, VERTICAL
 
Constructor Summary
CStripChart()
          Null Constructor
 
Method Summary
 java.awt.Component add(CPen pen)
          Overwrite the Container's add for visual tool
 void addPen(CPen newPen)
          Add a new pen to StripChart if there is a Pen available.
 void addPen(java.lang.String dName, java.lang.String pName)
          Add a new Pen to StripChart if there is a Pen available.
 void addPen(java.lang.String dName, java.lang.String pName, java.awt.Color penColor)
          Add a new Pen to StripChart if there is a Pen available.
 void addPen(java.lang.String dName, java.lang.String pName, java.awt.Color penColor, double min, double max)
          Add a new Pen to StripChart if there is a Pen available.
 double getDisplayHi()
          Return display high
 double getDisplayLo()
          Return display low
 int getDisplayPeriod()
          Return the displayPeriod in seconds.
 java.awt.Font getFont()
          Return the font of the text on the component
 int getLabelStyle()
          Return the label style property
 int getRangeStyle()
          Return the range style property
 boolean isCommonAxis()
          Return the commonAxis property.
 void mouseClicked(java.awt.event.MouseEvent me)
          For mouseListener interface handle mouse click If click on one of the drawing line, the y axis and channel name will show the value of that line.
 void mouseEntered(java.awt.event.MouseEvent me)
          For mouseListener interface
 void mouseExited(java.awt.event.MouseEvent me)
           
 void mousePressed(java.awt.event.MouseEvent me)
           
 void mouseReleased(java.awt.event.MouseEvent me)
           
 void paint(java.awt.Graphics g)
          Draw offscreen graphics and repaint it onto the screen.
 boolean pensAvailable()
          Returns true if there are Pen on the stripChart available (max available Pen is 8).
 void run()
          Sleep a updatePeriod and call repaint method to update the chart
 void setBackground(java.awt.Color newBg)
          Set component background color
 void setBounds(int x, int y, int w, int h)
          Set the bounds of the canvas.
 void setCommonAxis(boolean b)
          Set up commonAxis property.
 void setDisplayHi(double hi)
          Set the display high.
 void setDisplayLo(double lo)
          Set the display low.
 void setDisplayPeriod(int seconds)
          Set the total display time period.
 void setDisplayRange(double lo, double hi)
          Set the display limits.
 void setFont(java.awt.Font newFont)
          Set text font for labeling and displaying values.
 void setForeground(java.awt.Color newFg)
          Set compoenet foreground color
 void setLabelStyle(int label)
          Set the label style property of stripChart
 void setRangeStyle(int newRangeStyle)
          Set the range style property of stripChart
 void setSize(int newWidth, int newHeight)
          Overwrite parent setSize method to force repaint the background.
 void update(java.awt.Graphics g)
          Overwrite the parent update method so it only call this.paint(g)
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setCursor, setLayout, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBounds, setComponentOrientation, setDropTarget, setEnabled, setLocale, setLocation, setLocation, setName, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CStripChart

public CStripChart()
Null Constructor
Method Detail

pensAvailable

public boolean pensAvailable()
Returns true if there are Pen on the stripChart available (max available Pen is 8). Otherwise returns false.

addPen

public void addPen(CPen newPen)
Add a new pen to StripChart if there is a Pen available. The user must set the device and property name of the Pen before add to stripChart. The color of the Pen is option. The stripChart will use a default Pen color if the color of Pen is not be set in Pen class.
Parameters:
newPen - a new CPen class

addPen

public void addPen(java.lang.String dName,
                   java.lang.String pName)
Add a new Pen to StripChart if there is a Pen available. Specify the deviceName and propertyName it want to connect. Use the default pen color and get the displayHi/displayLo from the control system if the commonAxis is set to false.
Parameters:
dName - the device name for the pen to connect
pName - the property name for the pen to connect

addPen

public void addPen(java.lang.String dName,
                   java.lang.String pName,
                   java.awt.Color penColor)
Add a new Pen to StripChart if there is a Pen available. Get the display range from control system if the commonAxis is set to false.
Parameters:
dName - the device name for the pen to connect
pName - the property name for the pen to connect
penColor - the color of the pen

addPen

public void addPen(java.lang.String dName,
                   java.lang.String pName,
                   java.awt.Color penColor,
                   double min,
                   double max)
Add a new Pen to StripChart if there is a Pen available. Specify the deviceName/propertyName, Pen color and display range value.
Parameters:
dName - the device name for the pen to connect
pName - the property name for the pen to connect
penColor - the color of the pen
min - the display range Low
max - the display range High

add

public java.awt.Component add(CPen pen)
Overwrite the Container's add for visual tool
Parameters:
newPens - a CPen object.

setLabelStyle

public void setLabelStyle(int label)
Set the label style property of stripChart
Parameters:
newLab - the new label style, which may be one of:
  1. CConstants.LABEL_NONE
  2. CConstants.LABEL_AXIS
  3. CConstants.LABEL_ALL

getLabelStyle

public int getLabelStyle()
Return the label style property

setRangeStyle

public void setRangeStyle(int newRangeStyle)
Set the range style property of stripChart
Parameters:
newRangeStyle - the new range style, which may be one of:
  1. CConstants.RANGE_AUTO
  2. CConstants.RANGE_FROM_PROPERTY
  3. CConstants.RANGE_STATIC

getRangeStyle

public int getRangeStyle()
Return the range style property

setCommonAxis

public void setCommonAxis(boolean b)
Set up commonAxis property. If commonAxis = true, all the Pen shear one common axis (display range). Use the displayHi/displayLo of Pen[0] if the common display range (displayHi/displayLo) are not set by user.

isCommonAxis

public boolean isCommonAxis()
Return the commonAxis property. Shear same y axis if true. Otherwise each Pen has its own display range.

setDisplayPeriod

public void setDisplayPeriod(int seconds)
Set the total display time period. This is the time range displayed in the stripChart X axis. The unit of displayPeriod is seconds. The label of time axis (x axis) will shows minutes if the displayPeriod >= 120 seconds. In stripChart all Pens have same time axis (x axis).
Parameters:
seconds - the total display period in seconds

getDisplayPeriod

public int getDisplayPeriod()
Return the displayPeriod in seconds.

setDisplayRange

public void setDisplayRange(double lo,
                            double hi)
Set the display limits. The range style property will be forced to RANGE_STATIC. And the commonAxis will be forced to ture. The display range set in the Pen will be ignored.
Parameters:
lo - the display low
hi - the display high hi must be larger than lo otherwise nothing is changed.

setDisplayHi

public void setDisplayHi(double hi)
Set the display high. The range style property will be forced to RANGE_STATIC.
Parameters:
hi - the display high hi must be larger than displayLo otherwise nothing is changed.

setDisplayLo

public void setDisplayLo(double lo)
Set the display low. The range style property will be forced to RANGE_STATIC.
Parameters:
lo - the display low lo must be smaller than displayHi otherwise nothing is changed.

getDisplayHi

public double getDisplayHi()
Return display high

getDisplayLo

public double getDisplayLo()
Return display low

run

public void run()
Sleep a updatePeriod and call repaint method to update the chart
Specified by:
run in interface java.lang.Runnable

update

public final void update(java.awt.Graphics g)
Overwrite the parent update method so it only call this.paint(g)
Overrides:
update in class java.awt.Container

paint

public final void paint(java.awt.Graphics g)
Draw offscreen graphics and repaint it onto the screen. Calls derived class' paintForeground(g) and paintBackground(g).
Overrides:
paint in class java.awt.Container

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent me)
For mouseListener interface
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent me)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
For mouseListener interface handle mouse click If click on one of the drawing line, the y axis and channel name will show the value of that line. Otherwise nothing happens.
Specified by:
mouseClicked in interface java.awt.event.MouseListener

setSize

public void setSize(int newWidth,
                    int newHeight)
Overwrite parent setSize method to force repaint the background.
Overrides:
setSize in class java.awt.Component
Parameters:
newWidth - width of the component
newHeight - height of the component

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Set the bounds of the canvas.
Overrides:
setBounds in class java.awt.Component
Parameters:
x - component X location
y - component Y location
w - component width
h - component height

setFont

public void setFont(java.awt.Font newFont)
Set text font for labeling and displaying values.
Overrides:
setFont in class java.awt.Container
Parameters:
newFont - font for any text on the component

getFont

public java.awt.Font getFont()
Return the font of the text on the component
Overrides:
getFont in class java.awt.Component

setBackground

public void setBackground(java.awt.Color newBg)
Set component background color
Overrides:
setBackground in class java.awt.Component
Parameters:
newBg - the background color of component

setForeground

public void setForeground(java.awt.Color newFg)
Set compoenet foreground color
Overrides:
setForeground in class java.awt.Component
Parameters:
newFg - the foreground color of component