All Packages Class Hierarchy This Package Previous Next Index
Class ptplot.Plot
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----ptplot.PlotBox
|
+----ptplot.Plot
- public class Plot
- extends PlotBox
A flexible signal plotter. The plot can be configured and data can
be provided either through a file with commands or through direct
invocation of the public methods of the class or by passing pxgraph
arguments through the "pxgraphargs" parameter. If a file is used,
the file can be given as a URL through the setDataurl
method in the parent class. The file contains any number commands,
one per line. Unrecognized commands and commands with syntax
errors are ignored. Comments are denoted by a line starting with a
pound sign "#". The recognized commands include those supported by
the base class, plus a few more. The commands are case
insensitive, but are usually capitalized. The following command
defines the number of data sets to be plotted.
NumSets: positiveInteger
If data is provided for more data sets than this number, those
data are ignored. Each dataset can be optionally identified with
color (see the base class) or with unique marks. The style of
marks used to denote a data point is defined by one of the following
commands:
Marks: none
Marks: points
Marks: dots
Marks: various
Here, "points" are small dots, while "dots" are larger. If "various"
is specified, then unique marks are used for the first ten data sets,
and then recycled.
Using no marks is useful when lines connect the points in a plot,
which is done by default. To disable connecting lines, use:
Lines: off
To reenable them, use
Lines: on
You can also specify "impulses," which are lines drawn from a plotted point
down to the x axis. These are off by default, but can be turned on with the
command:
Impulses: on
or back off with the command
Impulses: off
To create a bar graph, turn off lines and use any of the following commands:
Bars: on
Bars: width
Bars: width, offset
The width is a real number specifying the width of the bars
in the units of the x axis. The offset is a real number
specifying how much the bar of the ith data set
is offset from the previous one. This allows bars to "peek out"
from behind the ones in front. Note that the frontmost data set
will be the last one. To turn off bars, use
Bars: off
To specify data to be plotted, start a data set with the following command:
DataSet: string
Here, string is a label that will appear in the legend.
It is not necessary to enclose the string in quotation marks.
The data itself is given by a sequence of commands with one of the
following forms:
x,y
draw: x,y
move: x,y
The "draw" command is optional, so the first two forms are equivalent.
The "move" command causes a break in connected points, if lines are
being drawn between points. The numbers x and y are
arbitrary numbers as supported by the Double parser in Java.
The numbers can be separated by commas, spaces or tabs.
This plotter has some limitations:
- Marks, impulses, and bars are assumed to apply to the entire
plot, i.e. to all data sets. Although it is possible to change
these styles for different data sets, the graph will not be
correctly redrawn when it gets redrawn due to zooming in or out
or due to a window exposure event.
- If you zoom in far enough, the plot becomes unreliable.
In particular, if the total extent of the plot is more than
232 times extent of the visible area, quantization
errors can result in displaying points or lines.
Note that 232 is over 4 billion.
- Version:
- @(#)Plot.java 1.66 10/30/97
- Author:
- Edward A. Lee, Christopher Hylands
-
_currentdataset
-
-
_marks
-
-
_numsets
-
-
_points
-
-
Plot()
-
-
_drawBar(Graphics, int, long, long, boolean)
- Draw bar from the specified point to the y axis.
-
_drawImpulse(Graphics, long, long, boolean)
- Draw an impulse from the specified point to the y axis.
-
_drawLine(Graphics, int, long, long, long, long, boolean)
- Draw a line from the specified starting point to the specified
ending point.
-
_drawPoint(Graphics, int, long, long, boolean)
- Put a mark corresponding to the specified dataset at the
specified x and y position.
-
_newFile()
- Hook for child classes to do any file preprocessing
-
_parseBinaryStream(DataInputStream)
- Read in a pxgraph format binary file.
-
_parseLine(String)
- Parse a line that gives plotting information.
-
addPoint(int, double, double, boolean)
- In the specified data set, add the specified x,y point to the
plot.
-
drawPlot(Graphics, boolean)
- Draw the axes and then plot all points.
-
erasePoint(int, int)
-
Erase the point at the given index in the given dataset.
-
getMaxDataSets()
- Return the maximum number of datasets
-
init()
- Initialize the plotter, parse any data files.
-
paint(Graphics)
- Draw the axes and the accumulated points.
-
parseArgs(String[])
- Parse pxgraph style command line arguments.
-
parsePxgraphargs(String)
-
-
resize(int, int)
-
Resize the plot.
Deprecated.
-
setBars(boolean)
- Turn bars on or off.
-
setBars(double, double)
-
Turn bars on and set the width and offset.
-
setConnected(boolean)
-
If the argument is true, then the default is to connect
subsequent points with a line.
-
setImpulses(boolean)
-
If the argument is true, then a line will be drawn from any
plotted point down to the x axis.
-
setMarksStyle(String)
- Set the marks style to "none", "points", "dots", or "various".
-
setNumSets(int)
-
Specify the number of data sets to be plotted together.
-
setPointsPersistence(int)
-
Calling this method with a positive argument sets the
persistence of the plot to the given number of points.
-
setSweepsPersistence(int)
-
A sweep is a sequence of points where the value of X is
increasing.
-
start()
- Start the plot.
-
stop()
- Stop the plot.
_currentdataset
protected int _currentdataset
_points
protected Vector _points[]
_marks
protected int _marks
_numsets
protected int _numsets
Plot
public Plot()
addPoint
public synchronized void addPoint(int dataset,
double x,
double y,
boolean connected)
- In the specified data set, add the specified x,y point to the
plot. Data set indices begin with zero. If the dataset
argument is out of range, ignore. The number of data sets is
given by calling *setNumSets()*. The fourth argument indicates
whether the point should be connected by a line to the previous
point.
drawPlot
public synchronized void drawPlot(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 calls
notify()
at the end so that a
thread can use wait()
to prevent it plotting
points before the axes have been first drawn. If the argument
is true, clear the display first.
- Overrides:
- drawPlot in class PlotBox
erasePoint
public synchronized 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.
getMaxDataSets
public int getMaxDataSets()
- Return the maximum number of datasets
init
public synchronized void init()
- Initialize the plotter, parse any data files.
- Overrides:
- init in class PlotBox
paint
public void paint(Graphics graphics)
- Draw the axes and the accumulated points.
- Overrides:
- paint in class PlotBox
parseArgs
public int parseArgs(String args[]) throws CmdLineArgException
- Parse pxgraph style command line arguments.
This method exists only for backward compatibility with the X11 pxgraph
program.
- Throws: CmdLineArgException
- if there is a problem parsing
the command line arguments passed in.
resize
public void resize(int width,
int height)
- Note: resize() is deprecated.
As of JDK1.1 in java.awt.component, but we need
to compile under 1.0.2 for netscape3.x compatibility.
- Resize the plot.
- Overrides:
- resize in class PlotBox
setBars
public void setBars(boolean on)
- Turn bars on or off.
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.
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.
setMarksStyle
public void setMarksStyle(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.
setNumSets
public void setNumSets(int numsets) throws NumberFormatException
- Specify the number of data sets to be plotted together.
Allocate a Vector to store each data set. Note that calling
this causes any previously plotted points to be forgotten.
This method should be called before
setPointsPersistence
.
- Throws: NumberFormatException
- if the number is less
than 1 or greater than an internal limit (usually 63).
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. This method should be called after
setNumSets()
.
FIXME: No file format yet.
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.
FIXME: No file format yet.
FIXME: Not implemented yet.
start
public void start()
- Start the plot.
This method is redefined in child classes, such as PlotLive.
stop
public void stop()
- Stop the plot.
This method is redefined in child classes, such as PlotLive.
_drawBar
protected void _drawBar(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.
_drawImpulse
protected void _drawImpulse(Graphics graphics,
long xpos,
long ypos,
boolean clip)
- Draw an impulse 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.
_drawLine
protected void _drawLine(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.
_drawPoint
protected void _drawPoint(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
_newFile
protected void _newFile()
- Hook for child classes to do any file preprocessing
- Overrides:
- _newFile in class PlotBox
_parseBinaryStream
protected void _parseBinaryStream(DataInputStream in) throws PlotDataException, IOException
- Read in a pxgraph format binary file.
- Throws: PlotDataException
- if there is a serious data format problem.
- Throws: IOException
- if an I/O error occurs.
- Overrides:
- _parseBinaryStream in class PlotBox
_parseLine
protected boolean _parseLine(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
parsePxgraphargs
public int parsePxgraphargs(String pxgraphargs) throws CmdLineArgException
All Packages Class Hierarchy This Package Previous Next Index