org.haldean.simplegraph
Class StreamingGraphComponent<E extends java.lang.Number>

java.lang.Object
  extended by java.awt.Component
      extended by org.haldean.simplegraph.StreamingGraphComponent<E>
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class StreamingGraphComponent<E extends java.lang.Number>
extends java.awt.Component

A component which draws a graph when provided with a feed of real-time data. The graph automatically scales along the Y axis and can be manually scaled along the X axis.

Author:
Will Brown (will.h.brown@gmail.com)
See Also:
Serialized Form

Nested Class Summary
 
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
StreamingGraphComponent()
          Create a new StreamingGraphComponent with the default GraphConfiguration.
StreamingGraphComponent(GraphConfiguration gc)
          Create a new StreamingGraphComponent with the specified GraphConfiguration.
 
Method Summary
 void addValue(E value)
          Add a value to the data series.
 GraphConfiguration getGraphConfiguration()
          Get the GraphConfiguration of this component.
 void paint(java.awt.Graphics canvas)
          Paints the graph onto the provided graphics object
 void setGraphConfiguration(GraphConfiguration gc)
          Set the GraphConfiguration of the graph.
 void setMaximum(double max)
          Manually set the maximum.
 void setMinimum(double min)
          Manually set the minimum.
 void setSampleCount(int newSampleCount)
          Set the scale along the X axis.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StreamingGraphComponent

public StreamingGraphComponent()
Create a new StreamingGraphComponent with the default GraphConfiguration.


StreamingGraphComponent

public StreamingGraphComponent(GraphConfiguration gc)
Create a new StreamingGraphComponent with the specified GraphConfiguration.

Parameters:
gc - The GraphConfiguration to use.
Method Detail

setMaximum

public void setMaximum(double max)
Manually set the maximum. Note that if a data point larger than this maximum is added, the graph will automatically scale. This sets a lower bound on the actual maximum of the graph.

Parameters:
max - The lower bound for the maximum

setMinimum

public void setMinimum(double min)
Manually set the minimum. Note that if a data point smaller than this minimum is added, the graph will automatically scale. This sets an upper bound on the actual minimum of the graph.

Parameters:
min - The upper bound for the minimum

setGraphConfiguration

public void setGraphConfiguration(GraphConfiguration gc)
Set the GraphConfiguration of the graph.

Parameters:
gc - The configuration to assign.

getGraphConfiguration

public GraphConfiguration getGraphConfiguration()
Get the GraphConfiguration of this component.


setSampleCount

public void setSampleCount(int newSampleCount)
Set the scale along the X axis.

Parameters:
newSampleCount - The number of samples shown along the axis. The graph will automatically adjust to show the most recent sampleCount samples.

addValue

public void addValue(E value)
Add a value to the data series.

Parameters:
value - The value to add

paint

public void paint(java.awt.Graphics canvas)
Paints the graph onto the provided graphics object

Overrides:
paint in class java.awt.Component
Parameters:
canvas - The graphics object to paint onto