Logo Search packages:      
Sourcecode: wims version File versions

ptolemy::plot::Plot Class Reference

Inheritance diagram for ptolemy::plot::Plot:

ptolemy::plot::PlotBox ptolemy::plot::EditablePlot ptolemy::plot::PlotLive

List of all members.


Detailed Description

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.

When calling the public methods, in most cases the changes will not be visible until paintComponent() is called. To request that this be done, call repaint(). One exception is addPoint(), which makes the new point visible immediately if the plot is visible on the screen and addPoint() is called from the event dispatching thread.

This base class supports a simple file syntax that has largely been replaced by the XML-based PlotML syntax. To read a file or a URL in this older syntax, use the read() method. This older syntax 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 number of data sets to be plotted does not need to be specified. Data sets are added as needed. 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
 Marks: pixels
 
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. If "pixels" are specified, then each point is drawn as one pixel. Using no marks is useful when lines connect the points in a plot, which is done by default. However, if persistence is set, then you may want to choose "pixels" because the lines may overlap, resulting in annoying gaps in the drawn line. If the above directive appears before any DataSet directive, then it specifies the default for all data sets. If it appears after a DataSet directive, then it applies only to that data set.

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. Plots with impulses are often called "stem plots." These are off by default, but can be turned on with the command:
 Impulses: on
 
or back off with the command
 Impulses: off
 
If that command appears before any DataSet directive, then the command applies to all data sets. Otherwise, it applies only to the current data set. 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 first 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. To start a new dataset without giving it a name, use:
 DataSet:
 
In this case, no item will appear in the legend. New datasets are plotted behind the previous ones. If the following directive occurs:
 ReuseDataSets: on
 
Then datasets with the same name will be merged. This makes it easier to combine multiple datafiles that contain the same datasets into one file. By default, this capability is turned off, so datasets with the same name are not merged. The data itself is given by a sequence of commands with one of the following forms:
 x, y
 draw: x, y
 move: x, y
 x, y, yLowErrorBar, yHighErrorBar
 draw: x, y, yLowErrorBar, yHighErrorBar
 move: x, y, yLowErrorBar, yHighErrorBar
 
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. If there are four numbers, then the last two numbers are assumed to be the lower and upper values for error bars. The numbers can be separated by commas, spaces or tabs.

Some of the methods, such as those that add points a plot, are executed in the event thread, possibly some time after they are called. If they are called from a thread different from the event thread, then the order in which changes to the plot take effect may be surprising. We recommend that any code you write that changes the plot in visible ways be executed in the event thread. You can accomplish this using the following template:

 Runnable doAction = new Runnable() {
 public void run() {
 ... make changes here (e.g. setMarksStyle()) ...
 }
 };
 plot.deferIfNecessary(doAction);
 

This plotter has some limitations:

Author:
Edward A. Lee, Christopher Brooks
Version:
Id
Plot.java,v 1.248 2007/12/16 07:29:47 cxh Exp
Since:
Ptolemy II 0.2 .ProposedRating Yellow (cxh) .AcceptedRating Yellow (cxh)

Definition at line 212 of file Plot.java.


Public Member Functions

synchronized void addLegend (int dataset, String legend)
synchronized void addPoint (final int dataset, final double x, final double y, final boolean connected)
synchronized void addPointWithErrorBars (final int dataset, final double x, final double y, final double yLowEB, final double yHighEB, final boolean connected)
synchronized void addXTick (String label, double position)
synchronized void addYTick (String label, double position)
synchronized void clear (boolean axes)
synchronized void clear (final int dataset)
synchronized void clear (final boolean format)
synchronized void clearLegends ()
void deferIfNecessary (Runnable action)
synchronized void erasePoint (final int dataset, final int index)
synchronized void export (OutputStream out)
synchronized BufferedImage exportImage (BufferedImage bufferedImage)
synchronized BufferedImage exportImage (BufferedImage bufferedImage, Rectangle rectangle, RenderingHints hints, boolean transparent)
synchronized BufferedImage exportImage (Rectangle rectangle)
synchronized BufferedImage exportImage ()
synchronized void fillPlot ()
boolean getColor ()
Color[] getColors ()
boolean getConnected ()
String getDataurl ()
URL getDocumentBase ()
boolean getGrid ()
boolean getImpulses ()
synchronized String getLegend (int dataset)
synchronized int getLegendDataset (String legend)
synchronized String getMarksStyle ()
int getMaxDataSets ()
synchronized int getNumDataSets ()
Rectangle getPlotRectangle ()
synchronized Dimension getPreferredSize ()
boolean getReuseDatasets ()
synchronized String getTitle ()
synchronized double[] getXAutoRange ()
synchronized String getXLabel ()
boolean getXLog ()
synchronized double[] getXRange ()
synchronized Vector[] getXTicks ()
synchronized double[] getYAutoRange ()
String getYLabel ()
boolean getYLog ()
synchronized double[] getYRange ()
synchronized Vector[] getYTicks ()
void init ()
synchronized void paintComponent (Graphics graphics)
void parseFile (String filespec)
void parseFile (String filespec, URL documentBase)
synchronized int print (Graphics graphics, PageFormat format, int index) throws PrinterException
synchronized void read (String command)
synchronized void read (InputStream inputStream) throws IOException
String ReadPlotApplet ()
synchronized void removeLegend (int dataset)
synchronized void renameLegend (int dataset, String newName)
synchronized void resetAxes ()
synchronized void samplePlot ()
synchronized void setBackground (Color background)
synchronized void setBars (double width, double offset)
void setBars (boolean on)
synchronized void setBounds (int x, int y, int width, int height)
synchronized void setButtons (boolean visible)
synchronized void setColor (boolean useColor)
synchronized void setColors (Color[] colors)
synchronized void setConnected (boolean on, int dataset)
void setConnected (boolean on)
void setDataurl (String filespec)
void setDocumentBase (URL documentBase)
synchronized void setForeground (Color foreground)
synchronized void setGrid (boolean grid)
synchronized void setImpulses (boolean on, int dataset)
synchronized void setImpulses (boolean on)
synchronized void setLabelFont (String name)
synchronized void setMarksStyle (String style, int dataset)
synchronized void setMarksStyle (String style)
void setNumSets (int numSets)
synchronized void setPlotRectangle (Rectangle rectangle)
void setPointsPersistence (int persistence)
void setReuseDatasets (boolean on)
synchronized void setSize (int width, int height)
synchronized void setTitle (String title)
synchronized void setTitleFont (String name)
synchronized void setWrap (boolean wrap)
synchronized void setXLabel (String label)
synchronized void setXLog (boolean xlog)
void setXPersistence (double persistence)
synchronized void setXRange (double min, double max)
synchronized void setYLabel (String label)
synchronized void setYLog (boolean ylog)
synchronized void setYRange (double min, double max)
synchronized void write (Writer out, String dtd)
synchronized void write (OutputStream out, String dtd)
void write (OutputStream out)
synchronized void writeData (PrintWriter output)
synchronized void writeFormat (PrintWriter output)
synchronized void writeOldSyntax (OutputStream out)
synchronized void zoom (double lowx, double lowy, double highx, double highy)

Static Public Member Functions

static Color getColorByName (String name)

Public Attributes

URL _documentBase = null

Static Public Attributes

static final String PTPLOT_RELEASE = "5.7"

Protected Member Functions

synchronized void _checkDatasetIndex (int dataset)
void _drawBar (Graphics graphics, int dataset, long xpos, long ypos, boolean clip)
void _drawErrorBar (Graphics graphics, int dataset, long xpos, long yLowEBPos, long yHighEBPos, boolean clip)
void _drawImpulse (Graphics graphics, long xpos, long ypos, boolean clip)
void _drawLine (Graphics graphics, int dataset, long startx, long starty, long endx, long endy, boolean clip, float width)
void _drawLine (Graphics graphics, int dataset, long startx, long starty, long endx, long endy, boolean clip)
synchronized void _drawPlot (Graphics graphics, boolean clearfirst)
synchronized void _drawPlot (Graphics graphics, boolean clearfirst, Rectangle drawRectangle)
void _drawPoint (Graphics graphics, int dataset, long xpos, long ypos, boolean clip)
void _help ()
boolean _parseLine (String line)
void _setButtonsVisibility (boolean vis)
void _setPadding (double padding)
void _setWidth (Graphics graphics, float width)
void _writeOldSyntax (PrintWriter output)

Protected Attributes

Color _background = Color.white
int _bottomPadding = 5
int _currentdataset = -1
Color _foreground = Color.black
boolean _grid = true
int _height = 300
int _leftPadding = 10
int _lrx = 100
int _lry = 100
int _marks
double _padding = 0.05
transient BufferedImage _plotImage = null
Vector _points = new Vector()
int _preferredHeight = 300
int _preferredWidth = 500
transient boolean _rangesGivenByZooming = false
int _rightPadding = 10
Rectangle _specifiedPlotRectangle = null
int _topPadding = 10
int _ulx = 1
int _uly = 1
boolean _usecolor = true
int _width = 500
boolean _wrap = false
double _wrapHigh
double _wrapLow
double _xBottom = Double.MAX_VALUE
double _xhighgiven
boolean _xlog = false
double _xlowgiven
transient double _xMax = 0
transient double _xMin = 0
transient boolean _xRangeGiven = false
double _xscale = 1.0
double _xTop = -Double.MAX_VALUE
double _yBottom = Double.MAX_VALUE
double _yhighgiven
boolean _ylog = false
double _ylowgiven
transient double _yMax = 0
transient double _yMin = 0
transient boolean _yRangeGiven = false
double _yscale = 1.0
double _yTop = -Double.MAX_VALUE

Static Protected Attributes

static Color[] _colors
static final double _LOG10SCALE = 1 / Math.log(10)

Package Functions

void _zoom (int x, int y)
void _zoomBox (int x, int y)
void _zoomStart (int x, int y)

Package Attributes

double _originalXhigh = 0.0
double _originalXlow = 0.0
boolean _originalXRangeGiven = false
double _originalYhigh = 0.0
double _originalYlow = 0.0
boolean _originalYRangeGiven = false

Private Member Functions

boolean _addLegendIfNecessary (boolean connected)
void _addPoint (int dataset, double x, double y, double yLowEB, double yHighEB, boolean connected, boolean errorBar)
void _clear (int dataset)
void _clear (boolean format)
void _drawPlotPoint (Graphics graphics, int dataset, int index)
void _erasePoint (int dataset, int index)
void _fillPlot ()
boolean _isConnected (int dataset)

Private Attributes

double _barOffset = 0.05
boolean _bars = false
boolean _connected = true
int _diameter = 6
boolean _firstInSet = true
Vector _formats = new Vector()
Graphics _graphics = null
boolean _impulses = false
int _maxDataset = -1
int _pointsPersistence = 0
Vector _prevx = new Vector()
Vector _prevy = new Vector()
int _radius = 3
boolean _reuseDatasets = false
boolean _sawFirstDataSet = false
boolean _showing = false
double _xPersistence = 0.0
boolean _xyInvalid = true
double barWidth = 0.5

Static Private Attributes

static final int _ERRORBAR_LEG_LENGTH = 5
static final Long _initialPreviousValue = Long.valueOf(0x0L)
static final BasicStroke _lineStroke1
static final BasicStroke _lineStroke2
static final int _MAX_MARKS = 10

Classes

class  Format

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index