weka.gui.beans
Class StripChart

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byweka.gui.beans.StripChart
All Implemented Interfaces:
javax.accessibility.Accessible, BeanCommon, ChartListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, UserRequestAcceptor, Visible

public class StripChart
extends javax.swing.JPanel
implements ChartListener, Visible, BeanCommon, UserRequestAcceptor, java.io.Serializable

Bean that can display a horizontally scrolling strip chart. Can display multiple plots simultaneously

Version:
$Revision: 1.8 $
Author:
Mark Hall
See Also:
Serialized Form

Nested Class Summary
private  class StripChart.StripPlotter
           
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.awt.Color[] m_colorList
          default colours for colouring lines
private  java.util.LinkedList m_dataList
          Holds the data to be plotted.
private  int m_iheight
          Width and height of the off screen image
private  int m_iwidth
           
private  java.awt.Font m_labelFont
           
private  java.awt.FontMetrics m_labelMetrics
           
private  javax.swing.JPanel m_legendPanel
          Class providing a panel for the legend
private  java.util.Vector m_legendText
           
private  java.lang.Object m_listenee
           
private  Logger m_log
           
private  double m_max
          Max value for the y axis
private  double m_min
          Min value for the y axis
private  double m_oldMax
           
private  double m_oldMin
           
private  java.awt.Image m_osi
          The off screen image for rendering to
private  javax.swing.JFrame m_outputFrame
           
private  StripChart.StripPlotter m_plotPanel
           
private  double[] m_previousY
           
private  int m_refreshFrequency
          Plot every m_refreshFrequency'th point
private  int m_refreshWidth
          Shift the plot by this many pixels every time a point is plotted
private  javax.swing.JPanel m_scalePanel
          Class providing a panel for displaying the y axis
private  java.lang.Thread m_updateHandler
           
protected  BeanVisual m_visual
           
private  int m_xCount
           
private  int m_xValFreq
          Print x axis labels every m_xValFreq points
private  boolean m_yScaleUpdate
          Scale update requested
 
Fields inherited from class javax.swing.JPanel
 
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.Container
 
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
StripChart()
           
 
Method Summary
 void acceptDataPoint(ChartEvent e)
          Accept a data point (encapsulated in a chart event) to plot
 void acceptDataPoint(double[] dataPoint)
          Accept a data point to plot
 boolean connectionAllowed(java.lang.String eventName)
          Returns true if, at this time, the object will accept a connection via the named event
 void connectionNotification(java.lang.String eventName, java.lang.Object source)
          Notify this object that it has been registered as a listener with a source for recieving events described by the named event This object is responsible for recording this fact.
private  int convertToPanelY(double yval)
           
 void disconnectionNotification(java.lang.String eventName, java.lang.Object source)
          Notify this object that it has been deregistered as a listener with a source for named event.
 java.util.Enumeration enumerateRequests()
          Describe enumerateRequests method here.
 int getRefreshFreq()
          Get the refresh frequency
 BeanVisual getVisual()
          Get the visual appearance of this bean
 int getXLabelFreq()
          Get the frequency by which x axis values are printed
 java.lang.String globalInfo()
          Global info for this bean
private  void initPlot()
           
static void main(java.lang.String[] args)
          Tests out the StripChart from the command line
private static java.lang.String numToString(double num)
           
 void performRequest(java.lang.String request)
          Describe performRequest method here.
private  void readObject(java.io.ObjectInputStream ois)
          Provide some necessary initialization after object has been deserialized.
 java.lang.String refreshFreqTipText()
          GUI Tip text
 void setLog(Logger logger)
          Set a logger
 void setRefreshFreq(int freq)
          Set how often (in x axis points) to refresh the display
private  void setRefreshWidth()
           
 void setVisual(BeanVisual newVisual)
          Set the visual appearance of this bean
 void setXLabelFreq(int freq)
          Set the frequency for printing x label values
 void showChart()
          Popup the chart panel
private  void startHandler()
           
 void stop()
          Stop any processing that the bean might be doing.
protected  void updateChart(double[] dataPoint)
          Update the plot
 void useDefaultVisual()
          Use the default visual appearance for this bean
 java.lang.String xLabelFreqTipText()
          GUI Tip text
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_colorList

protected java.awt.Color[] m_colorList
default colours for colouring lines


m_outputFrame

private transient javax.swing.JFrame m_outputFrame

m_plotPanel

private transient StripChart.StripPlotter m_plotPanel

m_osi

private transient java.awt.Image m_osi
The off screen image for rendering to


m_iheight

private int m_iheight
Width and height of the off screen image


m_iwidth

private int m_iwidth

m_max

private double m_max
Max value for the y axis


m_min

private double m_min
Min value for the y axis


m_yScaleUpdate

private boolean m_yScaleUpdate
Scale update requested


m_oldMax

private double m_oldMax

m_oldMin

private double m_oldMin

m_labelFont

private java.awt.Font m_labelFont

m_labelMetrics

private java.awt.FontMetrics m_labelMetrics

m_legendText

private java.util.Vector m_legendText

m_scalePanel

private javax.swing.JPanel m_scalePanel
Class providing a panel for displaying the y axis


m_legendPanel

private javax.swing.JPanel m_legendPanel
Class providing a panel for the legend


m_dataList

private java.util.LinkedList m_dataList
Holds the data to be plotted. Entries in the list are arrays of y points.


m_previousY

private double[] m_previousY

m_updateHandler

private transient java.lang.Thread m_updateHandler

m_visual

protected BeanVisual m_visual

m_listenee

private java.lang.Object m_listenee

m_log

private transient Logger m_log

m_xValFreq

private int m_xValFreq
Print x axis labels every m_xValFreq points


m_xCount

private int m_xCount

m_refreshWidth

private int m_refreshWidth
Shift the plot by this many pixels every time a point is plotted


m_refreshFrequency

private int m_refreshFrequency
Plot every m_refreshFrequency'th point

Constructor Detail

StripChart

public StripChart()
Method Detail

globalInfo

public java.lang.String globalInfo()
Global info for this bean

Returns:
a String value

xLabelFreqTipText

public java.lang.String xLabelFreqTipText()
GUI Tip text

Returns:
a String value

setXLabelFreq

public void setXLabelFreq(int freq)
Set the frequency for printing x label values

Parameters:
freq - an int value

getXLabelFreq

public int getXLabelFreq()
Get the frequency by which x axis values are printed

Returns:
an int value

refreshFreqTipText

public java.lang.String refreshFreqTipText()
GUI Tip text

Returns:
a String value

setRefreshFreq

public void setRefreshFreq(int freq)
Set how often (in x axis points) to refresh the display

Parameters:
freq - an int value

getRefreshFreq

public int getRefreshFreq()
Get the refresh frequency

Returns:
an int value

setRefreshWidth

private void setRefreshWidth()

readObject

private void readObject(java.io.ObjectInputStream ois)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Provide some necessary initialization after object has been deserialized.

Parameters:
ois - an ObjectInputStream value
Throws:
java.io.IOException - if an error occurs
java.lang.ClassNotFoundException - if an error occurs

initPlot

private void initPlot()

startHandler

private void startHandler()

showChart

public void showChart()
Popup the chart panel


convertToPanelY

private int convertToPanelY(double yval)

updateChart

protected void updateChart(double[] dataPoint)
Update the plot

Parameters:
dataPoint - contains y values to plot

numToString

private static java.lang.String numToString(double num)

acceptDataPoint

public void acceptDataPoint(ChartEvent e)
Accept a data point (encapsulated in a chart event) to plot

Specified by:
acceptDataPoint in interface ChartListener
Parameters:
e - a ChartEvent value

acceptDataPoint

public void acceptDataPoint(double[] dataPoint)
Accept a data point to plot

Parameters:
dataPoint - a double[] value

setVisual

public void setVisual(BeanVisual newVisual)
Set the visual appearance of this bean

Specified by:
setVisual in interface Visible
Parameters:
newVisual - a BeanVisual value

getVisual

public BeanVisual getVisual()
Get the visual appearance of this bean

Specified by:
getVisual in interface Visible
Returns:
a BeanVisual value

useDefaultVisual

public void useDefaultVisual()
Use the default visual appearance for this bean

Specified by:
useDefaultVisual in interface Visible

stop

public void stop()
Stop any processing that the bean might be doing.

Specified by:
stop in interface BeanCommon

setLog

public void setLog(Logger logger)
Set a logger

Specified by:
setLog in interface BeanCommon
Parameters:
logger - a weka.gui.Logger value

connectionAllowed

public boolean connectionAllowed(java.lang.String eventName)
Returns true if, at this time, the object will accept a connection via the named event

Specified by:
connectionAllowed in interface BeanCommon
Parameters:
eventName - the name of the event
Returns:
true if the object will accept a connection

connectionNotification

public void connectionNotification(java.lang.String eventName,
                                   java.lang.Object source)
Notify this object that it has been registered as a listener with a source for recieving events described by the named event This object is responsible for recording this fact.

Specified by:
connectionNotification in interface BeanCommon
Parameters:
eventName - the event
source - the source with which this object has been registered as a listener

disconnectionNotification

public void disconnectionNotification(java.lang.String eventName,
                                      java.lang.Object source)
Notify this object that it has been deregistered as a listener with a source for named event. This object is responsible for recording this fact.

Specified by:
disconnectionNotification in interface BeanCommon
Parameters:
eventName - the event
source - the source with which this object has been registered as a listener

enumerateRequests

public java.util.Enumeration enumerateRequests()
Describe enumerateRequests method here.

Specified by:
enumerateRequests in interface UserRequestAcceptor
Returns:
an Enumeration value

performRequest

public void performRequest(java.lang.String request)
Describe performRequest method here.

Specified by:
performRequest in interface UserRequestAcceptor
Parameters:
request - a String value
Throws:
java.lang.IllegalArgumentException - if an error occurs

main

public static void main(java.lang.String[] args)
Tests out the StripChart from the command line

Parameters:
args - ignored