|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ptolemy.plot.compat.PxgraphParser
public class PxgraphParser
This class provides backwards compatibility with an older plotting program, pxgraph. It provides two methods, one for parsing command-line arguments, and one for reading binary data from a file. In pxgraph, the binary files have no format information; all format information is provided by command line arguments.
Below we describe the pxgraph
arguments. The
text is based on the xgraph
Unix man page written
by David Harrison (University of California).
To see the command line options, you can type
pxgraph -help
.
The pxgraph
program draws a graph on a display given data
read from either data files or from standard input if one of the
arguments is a dash. It can display up to 64 independent
data sets using different colors and/or line styles for each
set. It annotates the graph with a title, axis labels,
grid lines or tick marks, grid labels, and a legend. There
are options to control the appearance of most components of
the graph.
The input format is similar to graph(1G)
but differs
slightly. The data consists of a number of data sets. Data
sets are separated by a blank line. A new data set is also
assumed at the start of each input file. A data set consists
of an ordered list of points of the form directive
X Y
.
The directive is either draw
or move
and can
be omitted (Note that with binary data files, you must have a directive,
the above statement only applies to ascii format data files). If the
directive is draw
, a line will be drawn
between the previous point and the current point (if a line
graph is chosen). Specifying a move
directive tells
xgraph not to draw a line between the points. If the directive
is omitted, draw
is assumed for all points in a data
set except the first point where move
is assumed. The
move
directive is used most often to allow discontinuous
data in a data set.
After pxgraph
has read the data, it will create a new window
to graphically display the data.
Once the window has been opened, all of the data sets will
be displayed graphically (subject to the options explained
below) with a legend in the upper right corner of the
screen. To zoom in on a portion of the graph, depress a
mouse button in the window and sweep out a region. pxgraph
will then the window will be redrawn with just that portion of
the graph. pxgraph
also presents four control buttons in
the lower left corner of each window: Exit
,
Print
, HTML
and About
.
The Exit
button will exit the process. You can also
type Control-D
, Control-C
or q
to exit.
The Print
button brings up a print dialog window.
The About
button brings up a message about
pxgraph
.
The HTML
button prints an HTML file to stdout that
can be used to display the file with applet Plot
classes
(Experimental).
pxgraph
accepts a large number of command line options.
A list of these options is given below.
=WxH+X+Y
-<digit> <name>
-bar
-brb
.
Usually, the -nl
flag is used with this option.
The point itself is located at the center of the bar.
-bb
-tk
).
Ignored in the Java version because the plotting area is a different
color than the border where the axes are labeled.
-bd
<color>
pxgraph
window.
Unsupported in the Java version.
-bg
<color>
fffff
), not color names. Note that the background
of the data plotting region is always white because the dataset colors
were designed for a white background.
-bigendian
-binary
command line argument documentation
below for details about the format.
If you are on a little-endian machine, such as a machine
with an Intel x86 chip, and you would like to read a binary
format file, created on a big-endian machine, such as a Sun SPARC,
use the -bigendian
flag.
-binary
-binary
argument is the primary difference between xgraph
and pxgraph
. The
Ptolemy Project software
makes extensive use of -binary
.
d
, then
we assume that the file contains 4 byte floats in big-endian ordering
with no plot commands.
d
, then
we assume that the plot commands are encoded as single characters,
and the numeric data is a 4 byte float encoded in the
native endian format of the machine that the java interpreter is
running on.
d <4byte float> <4byte float>
e
n <dataset name>\n
\n
m <4byte float> <4byte float>
od
command. Note that the first character is a d
followed by eight bytes of data consisting of two floats of four bytes.
cxh@carson 324% od -c data/integrator1.plt 0000000 d \0 \0 \0 \0 \0 \0 \0 \0 d ? 200 \0 \0 ? 200 0000020 \0 \0 d @ \0 \0 \0 @ , 314 315 d @ @ \0 \0For further information about endian-ism, see the
-bigendian
and -littleendian
command
line argument documentation.
-brb
<base>
-brw
<width>
-bw
<size>
pxgraph
window.
Unsupported in the Java version.
-db
-fg
<color>
fffff
), not color names.
-gw
-gs
-impulses
pxgraph
,
but it is similar to -nl -bar
).
-lf
<fontname>
helvetica-PLAIN-12
.
-littleendian
-binary
command line argument documentation
above for details about the format.
If you are on a big-endian machine, such as a Sun Sparc,
and you would like to read a binary
format file created on a little-endian machine, such as Intel x86
machine, then use the -littleendian
flag.
-lnx
-lnx
is present, then
x values must be greater than zero.
-lny
-lny
is present, then
y values must be greater than zero.
-lw
width
-lx
<xl,xh>
-ly
) can be used
to zoom in on a particularly interesting portion of a
larger graph.
-ly
<yl,yh>
-m
-M
-m
but markers are assigned uniquely to each
eight consecutive data sets (this corresponds to each
different line style on color machines).
-nl
-m
,
-M
, -p
, or -P
this can be used
to produce scatter plots. When used with -bar, it can be used to
produce standard bar graphs.
-o
output filename
/tmp/t.ps
. See also the
-print
option.
-p
-P
-p
but marks each pixel with a large dot.
-print
Ok
button. See also the -o
option.
-rv
-t
<string>
-tf
<fontname>
-lf
description above
for how to specify fonts.
The default is helvetica-BOLD-14
-tk
pxgraph
to draw tick marks rather
than full grid lines. The -bb
option is also useful
when viewing graphs with tick marks only.
-x
<unitname>
-y
<unitname>
-zg
<color>
-zw
<width>
xgraph
program allowed many formatting
directives inside the file. This version only supports
draw
and move
.
xgraph
program allowed blank lines
to separate datasets. This version does not. Instead, use the
move X Y
directive.
pxgraph
takes longer to start up
than the X11 version. This is an inherent problem with standalone
Java applications. One guess is that most of the startup time comes
from paging in the shared libraries.
For further information about this tool, see the Java Plot Website.
PxgraphApplication
,
PxgraphApplet
red (cxh) |
red (eal) |
Field Summary | |
---|---|
private static int |
_BIG_ENDIAN
|
private boolean |
_binary
|
private boolean |
_connected
|
protected int |
_currentdataset
The current dataset, used for handling multiple files. |
private int |
_endian
|
private boolean |
_firstInSet
|
private static int |
_LITTLE_ENDIAN
|
private static int |
_NATIVE_ENDIAN
|
protected Plot |
_plot
The plot object to which to apply commands. |
private boolean |
_sawFirstDataset
|
Constructor Summary | |
---|---|
PxgraphParser(Plot plot)
Construct a parser to configure the specified plot. |
Method Summary | |
---|---|
private boolean |
_addLegendIfNecessary(boolean connected)
|
private double[] |
_parseDoubles(java.lang.String spec)
|
int |
parseArgs(java.lang.String[] args)
Parse pxgraph style command-line arguments. |
int |
parseArgs(java.lang.String[] args,
java.net.URL base)
Parse pxgraph style command-line arguments, using the specified base URL for any relative URL references. |
int |
parsePxgraphargs(java.lang.String pxgraphargs,
java.net.URL base)
Split a string containing pxgraph-compatible command-line arguments into an array and call parseArgs() on the array. |
void |
read(java.io.InputStream inputStream)
Read a pxgraph-compatible binary or ASCII encoded file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int _currentdataset
protected Plot _plot
private static final int _NATIVE_ENDIAN
private static final int _BIG_ENDIAN
private static final int _LITTLE_ENDIAN
private boolean _binary
private boolean _connected
private int _endian
private boolean _firstInSet
private boolean _sawFirstDataset
Constructor Detail |
---|
public PxgraphParser(Plot plot)
plot
- The Plot object that is configured.Method Detail |
---|
public int parseArgs(java.lang.String[] args) throws CmdLineArgException, java.io.FileNotFoundException, java.io.IOException
args
- A set of command-line arguments.
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.public int parseArgs(java.lang.String[] args, java.net.URL base) throws CmdLineArgException, java.io.FileNotFoundException, java.io.IOException
args
- A set of command-line arguments.base
- A base URL for relative URL references, or null if
there is none.
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.public int parsePxgraphargs(java.lang.String pxgraphargs, java.net.URL base) throws CmdLineArgException, java.io.FileNotFoundException, java.io.IOException
pxgraphargs
- The command line arguments.base
- A base URL for relative URL references, or null if
there is none.
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.public void read(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- The input stream.
java.io.IOException
- If an I/O error occurs.private boolean _addLegendIfNecessary(boolean connected)
private double[] _parseDoubles(java.lang.String spec)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |