SSF.Util.Plot
Class TimeSeriesComponent

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--SSF.Util.Plot.TimeSeriesComponent
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
TimeSeriesAppComponent

public class TimeSeriesComponent
extends java.awt.Container

Provides a programmatic API to the SSF.Util.Plot package. An AWT Container that holds the plot panels and provides an API to the plots. See constructors for more details.

$Id: TimeSeriesComponent.java,v 1.5 2003/02/13 19:34:00 mili Exp $

See Also:
Serialized Form

Nested Class Summary
 
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
 LivePlotter[] _plots
          Plot panels within the window
 boolean smallPlots
          Flag if we're doing many small plots in the 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, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TimeSeriesComponent(int numDatasets, int winYsize)
          Constructor common for this class and subclasses.
TimeSeriesComponent(int numDatasets, java.lang.String windowTitle, int winYsize)
          Constructs a component object with an encapsulating window (Frame).
 
Method Summary
 void addAllPoints(java.lang.Object[][] dataArray)
          Add all points for "static" plot.
 void addLegend(int dataSet, java.lang.String legend)
          Adds a legend to one of the plots.
 void addPoint(int plotIndex, double time, float value)
          Adds one data point to one of the plots.
 void addPoints(java.lang.Object[][] dataArray)
          Adds one round of data points to all plots for a "live" plot.
 void continueAll()
          Continues all plots.
 void exportAll(java.io.FileOutputStream fout)
          Exports all plots in EPS format.
 void fillAll()
          Fills all plots.
 TimeSeriesWindowCallback getCallbackWindow()
          Gets the handle to the parent window/application.
 LivePlotter getPlot(int index)
          Gets handle on a plot.
 boolean isCallbackImplemented(java.lang.Object win)
          Checks if callback interface is implemented.
protected  void plotLayout(int plotHeights)
          Layout plot panels in the container.
 void printAll(java.awt.Graphics printgraphics)
          Prints all plots.
 void resetAll()
          Resets all plots.
 void rezoom(double lowx, double highx, java.lang.Object caller)
          Called from from one plot when it is rescaled (zoomed) to rescale (rezoom) all other plots to the same time-scale.
 void setBinSize(float binSize)
          Sets time bin size of all plots.
 void setCallbackWindow(java.lang.Object win)
          Sets a handle to the window to the parent window/application for callbacks.
 void setRescaleStep(int rescaleStep)
          Sets number of steps before rescaling for all plots.
 void setTimeWindowSize(float winSize)
          Sets time window size of all plots for a moving window plot.
 void setTitle(java.lang.String title)
          Sets title of plot.
 void signalEndOfPlot()
          Signals to the parent that the plot has finished.
 void signalPlotWindowClosed()
          Signals to the plotting component that its window has been closed (deallocated).
 void startAll()
          Starts all plots.
 void stopAll()
          Stops all plots.
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getAccessibleContext, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, 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, isOpaque, 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, 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, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, 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
 

Field Detail

smallPlots

public boolean smallPlots
Flag if we're doing many small plots in the window. In that case, we'll try to same some "real estate"


_plots

public LivePlotter[] _plots
Plot panels within the window

Constructor Detail

TimeSeriesComponent

public TimeSeriesComponent(int numDatasets,
                           int winYsize)
Constructor common for this class and subclasses. If used to construct the component it will create it without an parent (encapsulating) window.
Creates LivePlotters and then calls plotLayout to display them.

Parameters:
numDatasets - Number of plots, i.e. plot panels.
winYsize - Total component Y size (pixels). Can be set to 0 to get a default.

TimeSeriesComponent

public TimeSeriesComponent(int numDatasets,
                           java.lang.String windowTitle,
                           int winYsize)
                    throws java.lang.Exception
Constructs a component object with an encapsulating window (Frame). First calls simpler constructor and then creates a Frame for the plot(s).

Parameters:
numDatasets - Number of plots, i.e. plot panels.
windowTitle - Window title text.
winYsize - Total component Y size (pixels). Can be set to 0 to get a default.
Method Detail

setCallbackWindow

public void setCallbackWindow(java.lang.Object win)
Sets a handle to the window to the parent window/application for callbacks.

Parameters:
win - Parent window.

getCallbackWindow

public TimeSeriesWindowCallback getCallbackWindow()
Gets the handle to the parent window/application.

Returns:
Reference to the callback interface for the parent window.

setTitle

public void setTitle(java.lang.String title)
Sets title of plot. Also repaints the plot.

Parameters:
title - Plot title text.

setBinSize

public void setBinSize(float binSize)
Sets time bin size of all plots.

Parameters:
binSize - Time-bin width in x-scale units.

setTimeWindowSize

public void setTimeWindowSize(float winSize)
Sets time window size of all plots for a moving window plot.

Parameters:
winSize - Moving window size in x-scale units.

setRescaleStep

public void setRescaleStep(int rescaleStep)
Sets number of steps before rescaling for all plots. For sparser rescaling.

Parameters:
rescaleStep - Number of points plotted before rescaling.

getPlot

public LivePlotter getPlot(int index)
Gets handle on a plot.

Parameters:
index - Index of plot, from 0.
Returns:
Reference to one of the plots in the component. Returns null if there are no plots.

addPoint

public void addPoint(int plotIndex,
                     double time,
                     float value)
Adds one data point to one of the plots. This is the preferred method for adding data points to the plots.

Parameters:
plotIndex - Index of plot panel, starting from 0.
time - x coordinate.
value - y coordinate.

addPoints

public void addPoints(java.lang.Object[][] dataArray)
Adds one round of data points to all plots for a "live" plot. The data array parameter should hold a row for each plot (panel) and a column for each data point plotted so far and including the new one. The plot keeps a counter by itself that progresses through the columns of the data array.
This method will be deprecated. Use addPoint or addAllPoints methods instead.

Parameters:
dataArray - Data to be plotted.

addAllPoints

public void addAllPoints(java.lang.Object[][] dataArray)
Add all points for "static" plot. Plots all the data in the data array parameter at once.

Parameters:
dataArray - Data to be plotted. One row for each plot and one column for each data point.

resetAll

public void resetAll()
Resets all plots.


startAll

public void startAll()
Starts all plots.


stopAll

public void stopAll()
Stops all plots.


continueAll

public void continueAll()
Continues all plots.


fillAll

public void fillAll()
Fills all plots.


printAll

public void printAll(java.awt.Graphics printgraphics)
Prints all plots.

Overrides:
printAll in class java.awt.Component

exportAll

public void exportAll(java.io.FileOutputStream fout)
Exports all plots in EPS format.


signalPlotWindowClosed

public void signalPlotWindowClosed()
Signals to the plotting component that its window has been closed (deallocated). The plotting component will continue to exist (presumably created by someone else) but will stop "responding" to method calls since the plot panels are dereferenced.


rezoom

public void rezoom(double lowx,
                   double highx,
                   java.lang.Object caller)
Called from from one plot when it is rescaled (zoomed) to rescale (rezoom) all other plots to the same time-scale.

Parameters:
lowx - Left x in x-axis units.
highx - Right x in x-axis units.
caller - Reference to calling plot (if plot) or other object.

addLegend

public void addLegend(int dataSet,
                      java.lang.String legend)
Adds a legend to one of the plots. Only one legend per plot allowed. Plotted in lower left-hand corner instead of standard ptplot position.

Parameters:
dataSet - Index to plot, from 0.

signalEndOfPlot

public void signalEndOfPlot()
Signals to the parent that the plot has finished.


isCallbackImplemented

public boolean isCallbackImplemented(java.lang.Object win)
Checks if callback interface is implemented.

Parameters:
win - Perform check on this GUI object. Presumably a parent window.
Returns:
True if win implements the callback interface, otherwise false.

plotLayout

protected void plotLayout(int plotHeights)
Layout plot panels in the container.

Parameters:
plotHeights - Height of each plot in pixels. Set to 0 for default.