sdt.gui
Class Plot

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--sdt.gui.PlotBox
                                |
                                +--sdt.gui.Plot

public class Plot
extends PlotBox

See Also:
Serialized Form

Inner classes inherited from class sdt.gui.PlotBox
PlotBox.DragListener, PlotBox.ZoomListener
 
Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
protected  int _currentdataset
           
protected  int _marks
           
protected  boolean _painted
           
protected  java.util.Vector _points
           
protected  java.util.Hashtable _pointsb
           
 
Fields inherited from class sdt.gui.PlotBox
_background, _bottomPadding, _colors, _documentBase, _foreground, _grid, _height, _leftPadding, _LOG10SCALE, _lrx, _lry, _PADDING, _rightPadding, _topPadding, _ulx, _uly, _usecolor, _width, _xBottom, _xlog, _xMax, _xMin, _xRangeGiven, _xscale, _xTop, _yBottom, _ylog, _yMax, _yMin, _yRangeGiven, _yscale, _yTop
 
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
 
Constructor Summary
Plot()
           
 
Method Summary
protected  void _checkDatasetIndex(int dataset)
          Check the argument to ensure that it is a valid data set index.
protected  void _checkDatasetIndexb(int dataset, int y)
           
protected  void _drawBar(java.awt.Graphics graphics, int dataset, long xpos, long ypos, boolean clip)
          Draw bar from the specified point to the y axis.
protected  void _drawBar1(java.awt.Graphics graphics, int dataset, long xpos, long ypos, long prevx, long prevy, boolean clip)
           
protected  void _drawErrorBar(java.awt.Graphics graphics, int dataset, long xpos, long yLowEBPos, long yHighEBPos, boolean clip)
          Draw an error bar for the specified yLowEB and yHighEB values.
protected  void _drawImpulse(java.awt.Graphics graphics, long xpos, long ypos, boolean clip)
          Draw a line from the specified point to the y axis.
protected  void _drawLine(java.awt.Graphics graphics, int dataset, long startx, long starty, long endx, long endy, boolean clip)
          Draw a line from the specified starting point to the specified ending point.
protected  void _drawLine1(java.awt.Graphics graphics, int dataset, long startx, long starty, long endx, long endy, boolean clip)
           
protected  void _drawPlot(java.awt.Graphics graphics, boolean clearfirst)
          Draw the axes and then plot all points.
protected  void _drawPlot1(java.awt.Graphics graphics, boolean clearfirst)
           
protected  void _drawPoint(java.awt.Graphics graphics, int dataset, long xpos, long ypos, boolean clip)
          Put a mark corresponding to the specified dataset at the specified x and y position.
protected  boolean _parseLine(java.lang.String line)
          Parse a line that gives plotting information.
protected  void _write(java.io.PrintWriter output)
          Write plot information to the specified output stream.
 void addLegend(int dataset, java.lang.String legend)
           
 void addPoint(int dataset, double x, double y, boolean connected)
           
 void addPointWithErrorBars(int dataset, double x, double y, double yLowEB, double yHighEB, boolean connected)
          In the specified data set, add the specified x, y point to the plot with error bars.
 void clear(boolean format)
          Clear the plot of all data points.
 void erasePoint(int dataset, int index)
          Erase the point at the given index in the given dataset.
 void fillPlot()
          Rescale so that the data that is currently plotted just fits.
 java.lang.String getCmdLineFilename()
          Return the last file name seen on the command-line arguments parsed by parseArgs().
 int getMaxDataSets()
          Deprecated.  
 void paint(java.awt.Graphics graphics)
          Start a new thread to paint the component contents.
 int parseArgs(java.lang.String[] args)
          Parse pxgraph style command line arguments.
 void parseFile(java.lang.String filespec, java.net.URL documentBase)
          Deprecated.  
 int parsePxgraphargs(java.lang.String pxgraphargs)
          Split a string containing pxgraph-compatible command-line arguments into an array and call parseArgs() on the array.
 void read(java.io.InputStream in)
          Override the base class to register that we are reading a new data set.
 void readPxgraph(java.io.InputStream inputstream)
          Read a pxgraph-compatible binary encoded file.
 void setBarGraph(boolean _bargraph)
           
 void setBars(boolean on)
          Turn bars on or off (for bar charts).
 void setBars(double width, double offset)
          Turn bars on and set the width and offset.
 void setConnected(boolean on)
          If the argument is true, then the default is to connect subsequent points with a line.
 void setImpulses(boolean on)
          If the argument is true, then a line will be drawn from any plotted point down to the x axis.
 void setImpulses(boolean on, int dataset)
          If the first argument is true, then a line will be drawn from any plotted point in the specified dataset down to the x axis.
 void setMarksStyle(java.lang.String style)
          Set the marks style to "none", "points", "dots", or "various".
 void setMarksStyle(java.lang.String style, int dataset)
          Set the marks style to "none", "points", "dots", or "various" for the specified dataset.
 void setNumSets(int numsets)
          Deprecated.  
 void setPointsPersistence(int persistence)
          Calling this method with a positive argument sets the persistence of the plot to the given number of points.
 void setStatus(boolean show)
           
 void setSweepsPersistence(int persistence)
          A sweep is a sequence of points where the value of X is increasing.
 void update(java.awt.Graphics g)
          Override the base class to not clear the component first.
 
Methods inherited from class sdt.gui.PlotBox
_setButtonsVisibility, _zoom, _zoomBox, _zoomStart, addXTick, addYTick, getColorByName, getDataurl, getDocumentBase, getLegend, getMinimumSize, getPreferredSize, init, parseFile, setBackground, setBinary, setBounds, setButtons, setDataurl, setDocumentBase, setForeground, setGrid, setLabelFont, setSize, setTitle, setTitleFont, setXLabel, setXLog, setXRange, setYLabel, setYLog, setYRange, write, zoom
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_currentdataset

protected int _currentdataset

_points

protected java.util.Vector _points

_pointsb

protected java.util.Hashtable _pointsb

_marks

protected int _marks

_painted

protected boolean _painted
Constructor Detail

Plot

public Plot()
Method Detail

setStatus

public void setStatus(boolean show)

setBarGraph

public void setBarGraph(boolean _bargraph)

addLegend

public void addLegend(int dataset,
                      java.lang.String legend)
Overrides:
addLegend in class PlotBox

addPoint

public void addPoint(int dataset,
                     double x,
                     double y,
                     boolean connected)

addPointWithErrorBars

public void addPointWithErrorBars(int dataset,
                                  double x,
                                  double y,
                                  double yLowEB,
                                  double yHighEB,
                                  boolean connected)
In the specified data set, add the specified x, y point to the plot with error bars. Data set indices begin with zero. If the dataset does not exist, create it. yLowEB and yHighEB are the lower and upper error bars. The sixth argument indicates whether the point should be connected by a line to the previous point. The new point will be made visible if the plot is visible on the screen. Otherwise, it will be drawn the next time the plot is drawn on the screen. This method is based on a suggestion by Michael Altmann .
Parameters:
dataset - The data set index.
x - The X position of the new point.
y - The Y position of the new point.
yLowEB - The low point of the error bar.
yHighEB - The high point of the error bar.
connected - If true, a line is drawn to connect to the previous point.

clear

public void clear(boolean format)
Clear the plot of all data points. If the argument is true, then reset all parameters to their initial conditions, including the persistence, plotting format, and axes formats. For the change to take effect, you must call repaint().
Overrides:
clear in class PlotBox
Parameters:
format - If true, clear the format controls as well.

erasePoint

public void erasePoint(int dataset,
                       int index)
Erase the point at the given index in the given dataset. If lines are being drawn, also erase the line to the next points (note: not to the previous point). The point is not checked to see whether it is in range, so care must be taken by the caller to ensure that it is. The change will be made visible if the plot is visible on the screen. Otherwise, it will take effect the next time the plot is drawn on the screen.
Parameters:
dataset - The data set index.
index - The index of the point to erase.

fillPlot

public void fillPlot()
Rescale so that the data that is currently plotted just fits. This overrides the base class method to ensure that the protected variables _xBottom, _xTop, _yBottom, and _yTop are valid. This method calls repaint(), which eventually causes the display to be updated.
Overrides:
fillPlot in class PlotBox

getCmdLineFilename

public java.lang.String getCmdLineFilename()
Return the last file name seen on the command-line arguments parsed by parseArgs(). If there was none, return null.
Returns:
A file name, or null if there is none.

getMaxDataSets

public int getMaxDataSets()
Deprecated.  

Return the maximum number of data sets. This method is deprecated, since there is no longer an upper bound.

paint

public void paint(java.awt.Graphics graphics)
Start a new thread to paint the component contents. This is done in a new thread so that large data sets can can be displayed without freezing the user interface. When repainting is completed, the protected variable _painted is set to true, and notifyAll() is called.
Overrides:
paint in class PlotBox
Parameters:
graphics - The graphics context.

parseArgs

public int parseArgs(java.lang.String[] args)
              throws CmdLineArgException,
                     java.io.FileNotFoundException,
                     java.io.IOException
Parse pxgraph style command line arguments. This method exists only for backward compatibility with the X11 pxgraph program.
Parameters:
args - A set of command-line arguments.
Returns:
The number of arguments read.
Throws:
CmdLineArgException - If there is a problem parsing the command line arguments.
java.io.FileNotFoundException - If a file is specified that is not found.
java.io.IOException - If an error occurs reading an input file.

parseFile

public void parseFile(java.lang.String filespec,
                      java.net.URL documentBase)
Deprecated.  

Override the base class to indicate that a new data set is being read. This method is deprecated. Use read() or readPxgraph() instead.
Overrides:
parseFile in class PlotBox

parsePxgraphargs

public int parsePxgraphargs(java.lang.String pxgraphargs)
                     throws CmdLineArgException,
                            java.io.FileNotFoundException,
                            java.io.IOException
Split a string containing pxgraph-compatible command-line arguments into an array and call parseArgs() on the array. This is used in the rare circumstance that you want to control the format of a plot from an applet HTML file rather than in the plot data file.
Returns:
The number of arguments read.
Throws:
CmdLineArgException - If there is a problem parsing the command line arguments.
java.io.FileNotFoundException - If a file is specified that is not found.
java.io.IOException - If an error occurs reading an input file.

read

public void read(java.io.InputStream in)
          throws java.io.IOException
Override the base class to register that we are reading a new data set.
Overrides:
read in class PlotBox
Parameters:
inputstream - The input stream.

readPxgraph

public void readPxgraph(java.io.InputStream inputstream)
                 throws java.io.IOException
Read a pxgraph-compatible binary encoded file.
Parameters:
in - The input stream.
Throws:
java.io.IOException - If an I/O error occurs.

setBars

public void setBars(boolean on)
Turn bars on or off (for bar charts).
Parameters:
on - If true, turn bars on.

setBars

public void setBars(double width,
                    double offset)
Turn bars on and set the width and offset. Both are specified in units of the x axis. The offset is the amount by which the ith data set is shifted to the right, so that it peeks out from behind the earlier data sets.
Parameters:
width - The width of the bars.
offset - The offset per data set.

setConnected

public void setConnected(boolean on)
If the argument is true, then the default is to connect subsequent points with a line. If the argument is false, then points are not connected. When points are by default connected, individual points can be not connected by giving the appropriate argument to addPoint().

setImpulses

public void setImpulses(boolean on)
If the argument is true, then a line will be drawn from any plotted point down to the x axis. Otherwise, this feature is disabled. A plot with such lines is also known as a stem plot.
Parameters:
on - If true, draw a stem plot.

setImpulses

public void setImpulses(boolean on,
                        int dataset)
If the first argument is true, then a line will be drawn from any plotted point in the specified dataset down to the x axis. Otherwise, this feature is disabled. A plot with such lines is also known as a stem plot.
Parameters:
on - If true, draw a stem plot.
dataset - The dataset to which this should apply.

setMarksStyle

public void setMarksStyle(java.lang.String style)
Set the marks style to "none", "points", "dots", or "various". In the last case, unique marks are used for the first ten data sets, then recycled.
Parameters:
style - A string specifying the style for points.

setMarksStyle

public void setMarksStyle(java.lang.String style,
                          int dataset)
Set the marks style to "none", "points", "dots", or "various" for the specified dataset. In the last case, unique marks are used for the first ten data sets, then recycled.
Parameters:
style - A string specifying the style for points.
dataset - The dataset to which this should apply.

setNumSets

public void setNumSets(int numsets)
Deprecated.  

Specify the number of data sets to be plotted together. This method is deprecated, since it is no longer necessary to specify the number of data sets ahead of time. It has the effect of clearing all previously plotted points. This method should be called before setPointsPersistence(). This method throws IllegalArgumentException if the number is less than 1. This is a runtime exception, so it need not be declared.
Parameters:
numsets - The number of data sets.

setPointsPersistence

public void setPointsPersistence(int persistence)
Calling this method with a positive argument sets the persistence of the plot to the given number of points. Calling with a zero argument turns off this feature, reverting to infinite memory (unless sweeps persistence is set). If both sweeps and points persistence are set then sweeps take precedence.

setSweepsPersistence

public void setSweepsPersistence(int persistence)
A sweep is a sequence of points where the value of X is increasing. A point that is added with a smaller x than the previous point increments the sweep count. Calling this method with a non-zero argument sets the persistence of the plot to the given number of sweeps. Calling with a zero argument turns off this feature. If both sweeps and points persistence are set then sweeps take precedence. This feature is not implemented yet, so this method has no effect.

update

public void update(java.awt.Graphics g)
Override the base class to not clear the component first.
Overrides:
update in class javax.swing.JComponent
Parameters:
graphics - The graphics context.

_checkDatasetIndex

protected void _checkDatasetIndex(int dataset)
Check the argument to ensure that it is a valid data set index. If it is less than zero, throw an IllegalArgumentException (which is a runtime exception). If it does not refer to an existing data set, then fill out the _points Vector so that it does refer to an existing data set. All other dataset-related vectors are similarly filled out.
Parameters:
dataset - The data set index.

_checkDatasetIndexb

protected void _checkDatasetIndexb(int dataset,
                                   int y)

_drawBar

protected void _drawBar(java.awt.Graphics graphics,
                        int dataset,
                        long xpos,
                        long ypos,
                        boolean clip)
Draw bar from the specified point to the y axis. If the specified point is below the y axis or outside the x range, do nothing. If the clip argument is true, then do not draw above the y range. Note that paint() should be called before calling this method so that _xscale and _yscale are properly set.
Parameters:
graphics - The graphics context.
dataset - The index of the dataset.
xpos - The x position.
ypos - The y position.
clip - If true, then do not draw outside the range.

_drawBar1

protected void _drawBar1(java.awt.Graphics graphics,
                         int dataset,
                         long xpos,
                         long ypos,
                         long prevx,
                         long prevy,
                         boolean clip)

_drawErrorBar

protected void _drawErrorBar(java.awt.Graphics graphics,
                             int dataset,
                             long xpos,
                             long yLowEBPos,
                             long yHighEBPos,
                             boolean clip)
Draw an error bar for the specified yLowEB and yHighEB values. If the specified point is below the y axis or outside the x range, do nothing. If the clip argument is true, then do not draw above the y range.
Parameters:
graphics - The graphics context.
dataset - The index of the dataset.
xpos - The x position.
yLowEBPos - The lower y position of the error bar.
yHighEBPos - The upper y position of the error bar.
clip - If true, then do not draw above the range.

_drawImpulse

protected void _drawImpulse(java.awt.Graphics graphics,
                            long xpos,
                            long ypos,
                            boolean clip)
Draw a line from the specified point to the y axis. If the specified point is below the y axis or outside the x range, do nothing. If the clip argument is true, then do not draw above the y range.
Parameters:
graphics - The graphics context.
xpos - The x position.
ypos - The y position.
clip - If true, then do not draw outside the range.

_drawLine1

protected void _drawLine1(java.awt.Graphics graphics,
                          int dataset,
                          long startx,
                          long starty,
                          long endx,
                          long endy,
                          boolean clip)

_drawLine

protected void _drawLine(java.awt.Graphics graphics,
                         int dataset,
                         long startx,
                         long starty,
                         long endx,
                         long endy,
                         boolean clip)
Draw a line from the specified starting point to the specified ending point. The current color is used. If the clip argument is true, then draw only that portion of the line that lies within the plotting rectangle.
Parameters:
graphics - The graphics context.
dataset - The index of the dataset.
startx - The starting x position.
starty - The starting y position.
endx - The ending x position.
endy - The ending y position.
clip - If true, then do not draw outside the range.

_drawPlot

protected void _drawPlot(java.awt.Graphics graphics,
                         boolean clearfirst)
Draw the axes and then plot all points. This is synchronized to prevent multiple threads from drawing the plot at the same time. It sets _painted true and calls notifyAll() at the end so that a thread can use wait() to prevent it plotting points before the axes have been first drawn. If the second argument is true, clear the display first. This method is called by paint(). To cause it to be called you would normally call repaint(), which eventually causes paint() to be called.
Overrides:
_drawPlot in class PlotBox
Parameters:
graphics - The graphics context.
clearfirst - If true, clear the plot before proceeding.

_drawPlot1

protected void _drawPlot1(java.awt.Graphics graphics,
                          boolean clearfirst)

_drawPoint

protected void _drawPoint(java.awt.Graphics graphics,
                          int dataset,
                          long xpos,
                          long ypos,
                          boolean clip)
Put a mark corresponding to the specified dataset at the specified x and y position. The mark is drawn in the current color. What kind of mark is drawn depends on the _marks variable and the dataset argument. If the fourth argument is true, then check the range and plot only points that are in range.
Overrides:
_drawPoint in class PlotBox
Parameters:
graphics - The graphics context.
dataset - The index of the dataset.
xpos - The x position.
ypos - The y position.
clip - If true, then do not draw outside the range.

_parseLine

protected boolean _parseLine(java.lang.String line)
Parse a line that gives plotting information. Return true if the line is recognized. Lines with syntax errors are ignored.
Overrides:
_parseLine in class PlotBox
Parameters:
line - A command line.
Returns:
True if the line is recognized.

_write

protected void _write(java.io.PrintWriter output)
Write plot information to the specified output stream. Derived classes should override this method to first call the parent class method, then add whatever additional information they wish to add to the stream.
Overrides:
_write in class PlotBox
Parameters:
output - A buffered print writer.