Back to index

wims  3.65+svn20090927
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Package Functions | Package Attributes | Private Member Functions | Private Attributes | Static Private Attributes
ptolemy.plot.EditablePlot Class Reference

This extension of Plot permits interactive modification of plotted data, one dataset at a time. More...

Inheritance diagram for ptolemy.plot.EditablePlot:
Inheritance graph
[legend]
Collaboration diagram for ptolemy.plot.EditablePlot:
Collaboration graph
[legend]

List of all members.

Classes

class  EditMouseListener
class  ModifyListener
class  UndoListener

Public Member Functions

 EditablePlot ()
 Constructor.
void addEditListener (EditListener listener)
 Add a listener to be informed when the user modifies a data set.
double[][] getData (int dataset)
 Get the data in the specified dataset.
void redo ()
 Redo the latest signal editing operation that was undone by calling undo(), if there was one.
void removeEditListener (EditListener listener)
 Unregister a edit listener.
void setEditable (int dataset)
 Specify which dataset is editable.
void undo ()
 Undo the latest signal editing operation, if there was one.
synchronized void addLegend (int dataset, String legend)
 Add a legend (displayed at the upper right) for the specified data set with the specified string.
synchronized void addPoint (final int dataset, final double x, final double y, final boolean connected)
 In the specified data set, add the specified x, y point to the plot.
synchronized void addPointWithErrorBars (final int dataset, final double x, final double y, final double yLowEB, final double yHighEB, final boolean connected)
 In the specified data set, add the specified x, y point to the plot with error bars.
synchronized void clear (final boolean format)
 Clear the plot of all data points.
synchronized void clear (final int dataset)
 Clear the plot of data points in the specified dataset.
synchronized void clear (boolean axes)
 If the argument is true, clear the axes.
synchronized void erasePoint (final int dataset, final int index)
 Erase the point at the given index in the given dataset.
synchronized void fillPlot ()
 Rescale so that the data that is currently plotted just fits.
boolean getConnected ()
 Return whether the default is to connect subsequent points with a line.
boolean getImpulses ()
 Return whether a line will be drawn from any plotted point down to the x axis.
synchronized String getMarksStyle ()
 Get the marks style, which is one of "none", "points", "dots", or "various".
int getMaxDataSets ()
 Return the maximum number of data sets.
synchronized int getNumDataSets ()
 Return the actual number of data sets.
boolean getReuseDatasets ()
 Return false if setReuseDatasets() has not yet been called or if setReuseDatasets(false) has been called.
void parseFile (String filespec, URL documentBase)
 Override the base class to indicate that a new data set is being read.
void parseFile (String filespec)
 Syntactic sugar for parseFile(filespec, documentBase).
synchronized void read (InputStream inputStream) throws IOException
 Read a file with the old syntax (non-XML).
synchronized void read (String command)
 Read a single line command provided as a string.
synchronized void samplePlot ()
 Create a sample plot.
void setBars (boolean on)
 Turn bars on or off (for bar charts).
synchronized 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.
synchronized void setConnected (boolean on, int dataset)
 If the first argument is true, then by default for the specified dataset, points will be connected by a line.
synchronized void setImpulses (boolean on)
 If the argument is true, then a line will be drawn from any plotted point down to the x axis.
synchronized 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.
synchronized void setMarksStyle (String style)
 Set the marks style to "none", "points", "dots", or "various".
synchronized void setMarksStyle (String style, int dataset)
 Set the marks style to "none", "points", "dots", "various", or "pixels" for the specified dataset.
void setNumSets (int numSets)
 Specify the number of data sets to be plotted together.
void setPointsPersistence (int persistence)
 Calling this method with a positive argument sets the persistence of the plot to the given number of points.
void setReuseDatasets (boolean on)
 If the argument is true, then datasets with the same name are merged into a single dataset.
void setXPersistence (double persistence)
 Calling this method with a positive argument sets the persistence of the plot to the given width in units of the horizontal axis.
synchronized void writeData (PrintWriter output)
 Write plot data information to the specified output stream in PlotML.
synchronized void writeFormat (PrintWriter output)
 Write plot format information to the specified output stream in PlotML, an XML scheme.
String ReadPlotApplet ()
synchronized void addXTick (String label, double position)
 Specify a tick mark for the X axis.
synchronized void addYTick (String label, double position)
 Specify a tick mark for the Y axis.
synchronized void clearLegends ()
 Clear all legends.
void deferIfNecessary (Runnable action)
 If this method is called in the event thread, then simply execute the specified action.
synchronized void export (OutputStream out)
 Export a description of the plot.
synchronized BufferedImage exportImage ()
 Create a BufferedImage and draw this plot to it.
synchronized BufferedImage exportImage (Rectangle rectangle)
 Create a BufferedImage the size of the given rectangle and draw this plot to it at the position specified by the rectangle.
synchronized BufferedImage exportImage (BufferedImage bufferedImage, Rectangle rectangle, RenderingHints hints, boolean transparent)
 Draw this plot onto the specified image at the position of the specified rectangle with the size of the specified rectangle.
synchronized BufferedImage exportImage (BufferedImage bufferedImage)
 Draw this plot onto the provided image.
boolean getColor ()
 Return whether the plot uses color.
Color[] getColors ()
 Get the point colors.
String getDataurl ()
 Get the file specification that was given by setDataurl.
URL getDocumentBase ()
 Get the document base that was set by setDocumentBase.
boolean getGrid ()
 Return whether the grid is drawn.
synchronized String getLegend (int dataset)
 Get the legend for a dataset, or null if there is none.
synchronized int getLegendDataset (String legend)
 Given a legend string, return the corresponding dataset or -1 if no legend was added with that legend string The legend would have been set by addLegend().
Rectangle getPlotRectangle ()
 If the size of the plot has been set by setSize(), then return that size.
synchronized Dimension getPreferredSize ()
 Get the preferred size of this component.
synchronized String getTitle ()
 Get the title of the graph, or an empty string if there is none.
synchronized double[] getXAutoRange ()
 Get the range for X values of the data points registered so far.
synchronized String getXLabel ()
 Get the label for the X (horizontal) axis, or null if none has been set.
boolean getXLog ()
 Return whether the X axis is drawn with a logarithmic scale.
synchronized double[] getXRange ()
 Get the X range.
synchronized Vector[] getXTicks ()
 Get the X ticks that have been specified, or null if none.
synchronized double[] getYAutoRange ()
 Get the range for Y values of the data points registered so far.
String getYLabel ()
 Get the label for the Y (vertical) axis, or null if none has been set.
boolean getYLog ()
 Return whether the Y axis is drawn with a logarithmic scale.
synchronized double[] getYRange ()
 Get the Y range.
synchronized Vector[] getYTicks ()
 Get the Y ticks that have been specified, or null if none.
void init ()
 Initialize the component, creating the fill button and parsing an input file, if one has been specified.
synchronized void paintComponent (Graphics graphics)
 Paint the component contents, which in this base class is only the axes.
synchronized int print (Graphics graphics, PageFormat format, int index) throws PrinterException
 Print the plot to a printer, represented by the specified graphics object.
synchronized void removeLegend (int dataset)
 Remove the legend (displayed at the upper right) for the specified data set.
synchronized void renameLegend (int dataset, String newName)
 Rename a legend.
synchronized void resetAxes ()
 Reset the X and Y axes to the ranges that were first specified using setXRange() and setYRange().
synchronized void setBackground (Color background)
 Set the background color.
synchronized void setBounds (int x, int y, int width, int height)
 Move and resize this component.
synchronized void setButtons (boolean visible)
 If the argument is true, make a fill button visible at the upper right.
synchronized void setColor (boolean useColor)
 If the argument is false, draw the plot without using color (in black and white).
synchronized void setColors (Color[] colors)
 Set the point colors.
void setDataurl (String filespec)
 Set the file to read when init() is called.
void setDocumentBase (URL documentBase)
 Set the document base to used when init() is called to read a URL.
synchronized void setForeground (Color foreground)
 Set the foreground color.
synchronized void setGrid (boolean grid)
 Control whether the grid is drawn.
synchronized void setLabelFont (String name)
 Set the label font, which is used for axis labels and legend labels.
synchronized void setPlotRectangle (Rectangle rectangle)
 Set the plot rectangle inside the axes.
synchronized void setSize (int width, int height)
 Set the size of the plot.
synchronized void setTitle (String title)
 Set the title of the graph.
synchronized void setTitleFont (String name)
 Set the title font.
synchronized void setWrap (boolean wrap)
 Specify whether the X axis is wrapped.
synchronized void setXLabel (String label)
 Set the label for the X (horizontal) axis.
synchronized void setXLog (boolean xlog)
 Specify whether the X axis is drawn with a logarithmic scale.
synchronized void setXRange (double min, double max)
 Set the X (horizontal) range of the plot.
synchronized void setYLabel (String label)
 Set the label for the Y (vertical) axis.
synchronized void setYLog (boolean ylog)
 Specify whether the Y axis is drawn with a logarithmic scale.
synchronized void setYRange (double min, double max)
 Set the Y (vertical) range of the plot.
void write (OutputStream out)
 Write the current data and plot configuration to the specified stream in PlotML syntax.
synchronized void write (OutputStream out, String dtd)
 Write the current data and plot configuration to the specified stream in PlotML syntax.
synchronized void write (Writer out, String dtd)
 Write the current data and plot configuration to the specified stream in PlotML syntax.
synchronized void writeOldSyntax (OutputStream out)
 Write the current data and plot configuration to the specified stream in the old PtPlot syntax.
synchronized void zoom (double lowx, double lowy, double highx, double highy)
 Zoom in or out to the specified rectangle.

Static Public Member Functions

static Color getColorByName (String name)
 Convert a color name into a Color.

Public Attributes

URL _documentBase = null
 Indicator that size has been set.

Static Public Attributes

static final String PTPLOT_RELEASE = "5.7"

Protected Member Functions

synchronized void _checkDatasetIndex (int dataset)
 Check the argument to ensure that it is a valid data set index.
void _drawBar (Graphics graphics, int dataset, long xpos, long ypos, boolean clip)
 Draw bar from the specified point to the y axis.
void _drawErrorBar (Graphics graphics, int dataset, long xpos, long yLowEBPos, long yHighEBPos, boolean clip)
 Draw an error bar for the specified yLowEB and yHighEB values.
void _drawImpulse (Graphics graphics, long xpos, long ypos, boolean clip)
 Draw a line from the specified point to the y axis.
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.
void _drawLine (Graphics graphics, int dataset, long startx, long starty, long endx, long endy, boolean clip, float width)
 Draw a line from the specified starting point to the specified ending point.
synchronized void _drawPlot (Graphics graphics, boolean clearfirst, Rectangle drawRectangle)
 Draw the axes and then plot all points.
synchronized void _drawPlot (Graphics graphics, boolean clearfirst)
 Draw the axes using the current range, label, and title information.
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.
boolean _parseLine (String line)
 Parse a line that gives plotting information.
void _setWidth (Graphics graphics, float width)
 If the graphics argument is an instance of Graphics2D, then set the current stroke to the specified width.
void _writeOldSyntax (PrintWriter output)
 Write plot information to the specified output stream in the "old syntax," which predates PlotML.
void _help ()
 Display basic information in its own window.
void _setButtonsVisibility (boolean vis)
 Set the visibility of the Fill button.
void _setPadding (double padding)
 Set the padding multiple.

Protected Attributes

int _currentdataset = -1
 The current dataset.
Vector _points = new Vector()
 A vector of datasets.
int _marks
 An indicator of the marks style.
transient double _yMax = 0
transient double _yMin = 0
transient double _xMax = 0
transient double _xMin = 0
double _padding = 0.05
 The factor we pad by so that we don't plot points on the axes.
transient boolean _xRangeGiven = false
transient boolean _yRangeGiven = false
transient boolean _rangesGivenByZooming = false
double _xlowgiven
 The given X and Y ranges.
double _xhighgiven
 The given X and Y ranges.
double _ylowgiven
 The given X and Y ranges.
double _yhighgiven
 The given X and Y ranges.
double _xBottom = Double.MAX_VALUE
 The minimum X value registered so for, for auto ranging.
double _xTop = -Double.MAX_VALUE
 The maximum X value registered so for, for auto ranging.
double _yBottom = Double.MAX_VALUE
 The minimum Y value registered so for, for auto ranging.
double _yTop = -Double.MAX_VALUE
 The maximum Y value registered so for, for auto ranging.
boolean _xlog = false
 Whether to draw the axes using a logarithmic scale.
boolean _ylog = false
 Whether to draw the axes using a logarithmic scale.
boolean _grid = true
 Whether to draw a background grid.
boolean _wrap = false
 Whether to wrap the X axis.
double _wrapHigh
 The high range of the X axis for wrapping.
double _wrapLow
 The low range of the X axis for wrapping.
Color _background = Color.white
 Color of the background, settable from HTML.
Color _foreground = Color.black
 Color of the foreground, settable from HTML.
int _topPadding = 10
 Top padding.
int _bottomPadding = 5
 Bottom padding.
int _rightPadding = 10
 Right padding.
int _leftPadding = 10
 Left padding.
int _ulx = 1
 The x value of the upper left corner of the plot rectangle in pixels.
int _uly = 1
 The y value of the upper left corner of the plot rectangle in pixels.
int _lrx = 100
 The x value of the lower right corner of the plot rectangle in pixels.
int _lry = 100
 The y value of the lower right corner of the plot rectangle in pixels.
Rectangle _specifiedPlotRectangle = null
 User specified plot rectangle, null if none specified.
double _yscale = 1.0
 Scaling used for the vertical axis in plotting points.
double _xscale = 1.0
 Scaling used for the horizontal axis in plotting points.
boolean _usecolor = true
 Indicator whether to use _colors.
int _width = 500
 Width and height of component in pixels.
int _height = 300
 Width and height of component in pixels.
int _preferredWidth = 500
 Width and height of component in pixels.
int _preferredHeight = 300
 Width and height of component in pixels.
transient BufferedImage _plotImage = null

Static Protected Attributes

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

Package Functions

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

Package Attributes

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

Private Member Functions

synchronized void _edit (int x, int y)
synchronized void _editPoint (int x, int y)
synchronized void _editStart (int x, int y)
void _notifyListeners (int dataset)
void _setData (int dataset, double[][] data)

Private Attributes

int[] _editSpecX
int[] _editSpecY
boolean[] _editSpecSet
int _currentEditX
int _currentEditY
int _dataset = 0
Stack _undoStack = new Stack()
Stack _redoStack = new Stack()
Vector _editListeners = null

Static Private Attributes

static final Color _editColor = Color.white

Detailed Description

This extension of Plot permits interactive modification of plotted data, one dataset at a time.

By default, you can modify dataset number zero (the first one given). To change this default, call setEditable(). To edit a plot, use the right mouse button. Click and drag to the left to trace out new values for the data. To read back the modified data, use getData(). To undo a change to the data, type Control-Z. To redo the change, type Control-Y. The undo history is infinite.

The style of editing is very particular. This class assumes the data specify a function of x. I.e., there there is exactly one y value for every x value. Thus, with the right mouse button, you are allowed to trace out new y values starting with some leftmost x value. You can only trace values to the right. This feature makes it easy to trace values with discontinuities. Just start at the left, and drag to the right to the point of the discontinuity, then drag to the left, then right again. You will have to try it... Notice that this style of editing probably does not make sense with error bars, since there is no mechanism for editing the error bars.

To be able to modify the data in a dataset, of course, there must be data in the dataset. Thus, you should create a dataset (for example by calling addPoint()) before editing it. Only the visible part of the dataset can be edited (that is, the portion of the dataset along the visible part of the horizontal axis). If you zoom in, then, you can edit particular points more precisely.

To be notified when the user sketches a new signal, create an object that implements the EditListener interface and add that listener using addEditListener().

Author:
Edward A. Lee
Version:
Id:
EditablePlot.java,v 1.39 2007/12/06 18:23:51 cxh Exp
Since:
Ptolemy II 0.4 .ProposedRating Red (cxh) .AcceptedRating Red (cxh)

Definition at line 84 of file EditablePlot.java.


Constructor & Destructor Documentation

Constructor.

Definition at line 87 of file EditablePlot.java.

                          {
        super();
        addMouseListener(new EditMouseListener());
        addMouseMotionListener(new ModifyListener());
        addKeyListener(new UndoListener());
    }

Member Function Documentation

synchronized void ptolemy.plot.Plot._checkDatasetIndex ( int  dataset) [inline, protected, inherited]

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:
datasetThe data set index.

Definition at line 951 of file Plot.java.

                                                                {
        if (dataset < 0) {
            throw new IllegalArgumentException(
                    "Plot._checkDatasetIndex: Cannot"
                            + " give a negative number for the data set index.");
        }

        while (dataset >= _points.size()) {
            _points.addElement(new Vector());
            _formats.addElement(new Format());
            _prevx.addElement(_initialPreviousValue);
            _prevy.addElement(_initialPreviousValue);
        }
    }

Here is the caller graph for this function:

void ptolemy.plot.Plot._drawBar ( Graphics  graphics,
int  dataset,
long  xpos,
long  ypos,
boolean  clip 
) [inline, protected, inherited]

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 paintComponent() should be called before calling this method so that _xscale and _yscale are properly set. This method should be called only from the event dispatch thread. It is not synchronized, so its caller should be.

Parameters:
graphicsThe graphics context.
datasetThe index of the dataset.
xposThe x position.
yposThe y position.
clipIf true, then do not draw outside the range.

Definition at line 980 of file Plot.java.

                                     {
        if (clip) {
            if (ypos < _uly) {
                ypos = _uly;
            }

            if (ypos > _lry) {
                ypos = _lry;
            }
        }

        if ((ypos <= _lry) && (xpos <= _lrx) && (xpos >= _ulx)) {
            // left x position of bar.
            int barlx = (int) (xpos - ((barWidth * _xscale) / 2) + (dataset
                    * _barOffset * _xscale));

            // right x position of bar
            int barrx = (int) (barlx + (barWidth * _xscale));

            if (barlx < _ulx) {
                barlx = _ulx;
            }

            if (barrx > _lrx) {
                barrx = _lrx;
            }

            // Make sure that a bar is always at least one pixel wide.
            if (barlx >= barrx) {
                barrx = barlx + 1;
            }

            // The y position of the zero line.
            long zeroypos = _lry - (long) ((0 - _yMin) * _yscale);

            if (_lry < zeroypos) {
                zeroypos = _lry;
            }

            if (_uly > zeroypos) {
                zeroypos = _uly;
            }

            if ((_yMin >= 0) || (ypos <= zeroypos)) {
                graphics.fillRect(barlx, (int) ypos, barrx - barlx,
                        (int) (zeroypos - ypos));
            } else {
                graphics.fillRect(barlx, (int) zeroypos, barrx - barlx,
                        (int) (ypos - zeroypos));
            }
        }
    }

Here is the caller graph for this function:

void ptolemy.plot.Plot._drawErrorBar ( Graphics  graphics,
int  dataset,
long  xpos,
long  yLowEBPos,
long  yHighEBPos,
boolean  clip 
) [inline, protected, inherited]

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. This method should be called only from the event dispatch thread. It is not synchronized, so its caller should be.

Parameters:
graphicsThe graphics context.
datasetThe index of the dataset.
xposThe x position.
yLowEBPosThe lower y position of the error bar.
yHighEBPosThe upper y position of the error bar.
clipIf true, then do not draw above the range.

Definition at line 1047 of file Plot.java.

                                                           {
        _drawLine(graphics, dataset, xpos - _ERRORBAR_LEG_LENGTH, yHighEBPos,
                xpos + _ERRORBAR_LEG_LENGTH, yHighEBPos, clip);
        _drawLine(graphics, dataset, xpos, yLowEBPos, xpos, yHighEBPos, clip);
        _drawLine(graphics, dataset, xpos - _ERRORBAR_LEG_LENGTH, yLowEBPos,
                xpos + _ERRORBAR_LEG_LENGTH, yLowEBPos, clip);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void ptolemy.plot.Plot._drawImpulse ( Graphics  graphics,
long  xpos,
long  ypos,
boolean  clip 
) [inline, protected, inherited]

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. This method should be called only from the event dispatch thread. It is not synchronized, so its caller should be.

Parameters:
graphicsThe graphics context.
xposThe x position.
yposThe y position.
clipIf true, then do not draw outside the range.

Definition at line 1067 of file Plot.java.

                          {
        if (clip) {
            if (ypos < _uly) {
                ypos = _uly;
            }

            if (ypos > _lry) {
                ypos = _lry;
            }
        }

        if ((ypos <= _lry) && (xpos <= _lrx) && (xpos >= _ulx)) {
            // The y position of the zero line.
            double zeroypos = _lry - (long) ((0 - _yMin) * _yscale);

            if (_lry < zeroypos) {
                zeroypos = _lry;
            }

            if (_uly > zeroypos) {
                zeroypos = _uly;
            }

            _setWidth(graphics, 1f);
            graphics.drawLine((int) xpos, (int) ypos, (int) xpos,
                    (int) zeroypos);
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void ptolemy.plot.Plot._drawLine ( Graphics  graphics,
int  dataset,
long  startx,
long  starty,
long  endx,
long  endy,
boolean  clip 
) [inline, protected, inherited]

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. This method draws a line one pixel wide. This method should be called only from the event dispatch thread. It is not synchronized, so its caller should be.

Parameters:
graphicsThe graphics context.
datasetThe index of the dataset.
startxThe starting x position.
startyThe starting y position.
endxThe ending x position.
endyThe ending y position.
clipIf true, then do not draw outside the range.

Definition at line 1111 of file Plot.java.

                                                             {
        _drawLine(graphics, dataset, startx, starty, endx, endy, clip, 1f);
    }

Here is the caller graph for this function:

void ptolemy.plot.Plot._drawLine ( Graphics  graphics,
int  dataset,
long  startx,
long  starty,
long  endx,
long  endy,
boolean  clip,
float  width 
) [inline, protected, inherited]

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. The width argument is ignored if the graphics argument is not an instance of Graphics2D. This method should be called only from the event dispatch thread. It is not synchronized, so its caller should be.

Parameters:
graphicsThe graphics context.
datasetThe index of the dataset.
startxThe starting x position.
startyThe starting y position.
endxThe ending x position.
endyThe ending y position.
clipIf true, then do not draw outside the range.
widthThe thickness of the line.

Definition at line 1132 of file Plot.java.

                                                                          {
        _setWidth(graphics, width);

        if (clip) {
            // Rule out impossible cases.
            if (!(((endx <= _ulx) && (startx <= _ulx))
                    || ((endx >= _lrx) && (startx >= _lrx))
                    || ((endy <= _uly) && (starty <= _uly)) || ((endy >= _lry) && (starty >= _lry)))) {
                // If the end point is out of x range, adjust
                // end point to boundary.
                // The integer arithmetic has to be done with longs so as
                // to not loose precision on extremely close zooms.
                if (startx != endx) {
                    if (endx < _ulx) {
                        endy = (int) (endy + (((starty - endy) * (_ulx - endx)) / (startx - endx)));
                        endx = _ulx;
                    } else if (endx > _lrx) {
                        endy = (int) (endy + (((starty - endy) * (_lrx - endx)) / (startx - endx)));
                        endx = _lrx;
                    }
                }

                // If end point is out of y range, adjust to boundary.
                // Note that y increases downward
                if (starty != endy) {
                    if (endy < _uly) {
                        endx = (int) (endx + (((startx - endx) * (_uly - endy)) / (starty - endy)));
                        endy = _uly;
                    } else if (endy > _lry) {
                        endx = (int) (endx + (((startx - endx) * (_lry - endy)) / (starty - endy)));
                        endy = _lry;
                    }
                }

                // Adjust current point to lie on the boundary.
                if (startx != endx) {
                    if (startx < _ulx) {
                        starty = (int) (starty + (((endy - starty) * (_ulx - startx)) / (endx - startx)));
                        startx = _ulx;
                    } else if (startx > _lrx) {
                        starty = (int) (starty + (((endy - starty) * (_lrx - startx)) / (endx - startx)));
                        startx = _lrx;
                    }
                }

                if (starty != endy) {
                    if (starty < _uly) {
                        startx = (int) (startx + (((endx - startx) * (_uly - starty)) / (endy - starty)));
                        starty = _uly;
                    } else if (starty > _lry) {
                        startx = (int) (startx + (((endx - startx) * (_lry - starty)) / (endy - starty)));
                        starty = _lry;
                    }
                }
            }

            // Are the new points in range?
            if ((endx >= _ulx) && (endx <= _lrx) && (endy >= _uly)
                    && (endy <= _lry) && (startx >= _ulx) && (startx <= _lrx)
                    && (starty >= _uly) && (starty <= _lry)) {
                graphics.drawLine((int) startx, (int) starty, (int) endx,
                        (int) endy);
            }
        } else {
            // draw unconditionally.
            graphics.drawLine((int) startx, (int) starty, (int) endx,
                    (int) endy);
        }
    }

Here is the call graph for this function:

synchronized void ptolemy.plot.Plot._drawPlot ( Graphics  graphics,
boolean  clearfirst,
Rectangle  drawRectangle 
) [inline, protected, inherited]

Draw the axes and then plot all points.

If the second argument is true, clear the display first. This method is called by paintComponent(). To cause it to be called you would normally call repaint(), which eventually causes paintComponent() to be called.

Note that this is synchronized so that points are not added by other threads while the drawing is occurring. This method should be called only from the event dispatch thread, consistent with swing policy.

Parameters:
graphicsThe graphics context.
clearfirstIf true, clear the plot before proceeding.
drawRectangleThe Rectangle to draw in.

Reimplemented from ptolemy.plot.PlotBox.

Definition at line 1217 of file Plot.java.

                                                         {
        if (_graphics == null) {
            _graphics = graphics;
        } else if (graphics != _graphics) {
            // If the graphics has changed, then we don't care about
            // the previous values.  Exporting to EPS uses a different
            // graphics, see test/onePointStem.plt for an example that
            // requires this change.
            _graphics = graphics;
            _prevx = new Vector();
            _prevy = new Vector();
            for (int dataset = 0; dataset < _points.size(); dataset++) {
                _prevx.addElement(_initialPreviousValue);
                _prevy.addElement(_initialPreviousValue);
            }
        }

        // We must call PlotBox._drawPlot() before calling _drawPlotPoint
        // so that _xscale and _yscale are set.
        super._drawPlot(graphics, clearfirst, drawRectangle);

        // Plot the points in reverse order so that the first colors
        // appear on top.
        for (int dataset = _points.size() - 1; dataset >= 0; dataset--) {
            Vector data = (Vector) _points.elementAt(dataset);

            for (int pointnum = 0; pointnum < data.size(); pointnum++) {
                _drawPlotPoint(graphics, dataset, pointnum);
            }
        }

        _showing = true;
    }

Here is the call graph for this function:

synchronized void ptolemy.plot.PlotBox._drawPlot ( Graphics  graphics,
boolean  clearfirst 
) [inline, protected, inherited]

Draw the axes using the current range, label, and title information.

If the second argument is true, clear the display before redrawing. This method is called by paintComponent(). To cause it to be called you would normally call repaint(), which eventually causes paintComponent() to be called.

Note that this is synchronized so that points are not added by other threads while the drawing is occurring. This method should be called only from the event dispatch thread, consistent with swing policy.

Parameters:
graphicsThe graphics context.
clearfirstIf true, clear the plot before proceeding.

Reimplemented in ptolemy.plot.Histogram.

Definition at line 1814 of file PlotBox.java.

                                                                                 {
        Rectangle bounds = getBounds();
        _drawPlot(graphics, clearfirst, bounds);
    }

Here is the caller graph for this function:

void ptolemy.plot.Plot._drawPoint ( Graphics  graphics,
int  dataset,
long  xpos,
long  ypos,
boolean  clip 
) [inline, protected, inherited]

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. This method should be called only from the event dispatch thread. It is not synchronized, so its caller should be.

Parameters:
graphicsThe graphics context.
datasetThe index of the dataset.
xposThe x position.
yposThe y position.
clipIf true, then do not draw outside the range.

Reimplemented from ptolemy.plot.PlotBox.

Definition at line 1266 of file Plot.java.

                                     {
        // If the point is not out of range, draw it.
        boolean pointinside = (ypos <= _lry) && (ypos >= _uly)
                && (xpos <= _lrx) && (xpos >= _ulx);

        if (!clip || pointinside) {
            int xposi = (int) xpos;
            int yposi = (int) ypos;

            // Check to see whether the dataset has a marks directive
            Format fmt = (Format) _formats.elementAt(dataset);
            int marks = _marks;

            if (!fmt.marksUseDefault) {
                marks = fmt.marks;
            }

            // If the point is out of range, and being drawn, then it is
            // probably a legend point.  When printing in black and white,
            // we want to use a line rather than a point for the legend.
            // (So that line patterns are visible). The only exception is
            // when the marks style uses distinct marks, or if there is
            // no line being drawn.
            // NOTE: It is unfortunate to have to test the class of graphics,
            // but there is no easy way around this that I can think of.
            if (!pointinside && (marks != 3) && _isConnected(dataset)
                    && (graphics instanceof EPSGraphics)) {
                graphics.drawLine(xposi - 6, yposi, xposi + 6, yposi);
            } else {
                // Color display.  Use normal legend.
                switch (marks) {
                case 0:

                    // If no mark style is given, draw a filled rectangle.
                    // This is used, for example, to draw the legend.
                    graphics.fillRect(xposi - 6, yposi - 6, 6, 6);
                    break;

                case 1:

                    // points -- use 3-pixel ovals.
                    graphics.fillOval(xposi - 1, yposi - 1, 3, 3);
                    break;

                case 2:

                    // dots
                    graphics.fillOval(xposi - _radius, yposi - _radius,
                            _diameter, _diameter);
                    break;

                case 3:

                    // various
                    int[] xpoints;

                    // various
                    int[] ypoints;

                    // Points are only distinguished up to _MAX_MARKS data sets.
                    int mark = dataset % _MAX_MARKS;

                    switch (mark) {
                    case 0:

                        // filled circle
                        graphics.fillOval(xposi - _radius, yposi - _radius,
                                _diameter, _diameter);
                        break;

                    case 1:

                        // cross
                        graphics.drawLine(xposi - _radius, yposi - _radius,
                                xposi + _radius, yposi + _radius);
                        graphics.drawLine(xposi + _radius, yposi - _radius,
                                xposi - _radius, yposi + _radius);
                        break;

                    case 2:

                        // square
                        graphics.drawRect(xposi - _radius, yposi - _radius,
                                _diameter, _diameter);
                        break;

                    case 3:

                        // filled triangle
                        xpoints = new int[4];
                        ypoints = new int[4];
                        xpoints[0] = xposi;
                        ypoints[0] = yposi - _radius;
                        xpoints[1] = xposi + _radius;
                        ypoints[1] = yposi + _radius;
                        xpoints[2] = xposi - _radius;
                        ypoints[2] = yposi + _radius;
                        xpoints[3] = xposi;
                        ypoints[3] = yposi - _radius;
                        graphics.fillPolygon(xpoints, ypoints, 4);
                        break;

                    case 4:

                        // diamond
                        xpoints = new int[5];
                        ypoints = new int[5];
                        xpoints[0] = xposi;
                        ypoints[0] = yposi - _radius;
                        xpoints[1] = xposi + _radius;
                        ypoints[1] = yposi;
                        xpoints[2] = xposi;
                        ypoints[2] = yposi + _radius;
                        xpoints[3] = xposi - _radius;
                        ypoints[3] = yposi;
                        xpoints[4] = xposi;
                        ypoints[4] = yposi - _radius;
                        graphics.drawPolygon(xpoints, ypoints, 5);
                        break;

                    case 5:

                        // circle
                        graphics.drawOval(xposi - _radius, yposi - _radius,
                                _diameter, _diameter);
                        break;

                    case 6:

                        // plus sign
                        graphics.drawLine(xposi, yposi - _radius, xposi, yposi
                                + _radius);
                        graphics.drawLine(xposi - _radius, yposi, xposi
                                + _radius, yposi);
                        break;

                    case 7:

                        // filled square
                        graphics.fillRect(xposi - _radius, yposi - _radius,
                                _diameter, _diameter);
                        break;

                    case 8:

                        // triangle
                        xpoints = new int[4];
                        ypoints = new int[4];
                        xpoints[0] = xposi;
                        ypoints[0] = yposi - _radius;
                        xpoints[1] = xposi + _radius;
                        ypoints[1] = yposi + _radius;
                        xpoints[2] = xposi - _radius;
                        ypoints[2] = yposi + _radius;
                        xpoints[3] = xposi;
                        ypoints[3] = yposi - _radius;
                        graphics.drawPolygon(xpoints, ypoints, 4);
                        break;

                    case 9:

                        // filled diamond
                        xpoints = new int[5];
                        ypoints = new int[5];
                        xpoints[0] = xposi;
                        ypoints[0] = yposi - _radius;
                        xpoints[1] = xposi + _radius;
                        ypoints[1] = yposi;
                        xpoints[2] = xposi;
                        ypoints[2] = yposi + _radius;
                        xpoints[3] = xposi - _radius;
                        ypoints[3] = yposi;
                        xpoints[4] = xposi;
                        ypoints[4] = yposi - _radius;
                        graphics.fillPolygon(xpoints, ypoints, 5);
                        break;
                    }

                    break;

                case 4:

                    // If the mark style is pixels, draw a filled rectangle.
                    graphics.fillRect(xposi, yposi, 1, 1);
                    break;

                default:
                    // none
                }
            }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized void ptolemy.plot.EditablePlot._edit ( int  x,
int  y 
) [inline, private]

Definition at line 208 of file EditablePlot.java.

                                                  {
        if (_dataset < 0) {
            return;
        }

        // Save for undo.
        Object[] save = new Object[2];
        save[0] = Integer.valueOf(_dataset);
        save[1] = getData(_dataset);

        // FIXME: Need a way to notify menus to enable items...
        _undoStack.push(save);

        // NOTE: the clear() method was added in jdk 1.2, so we don't
        // use it here for maximal compatibility...
        // _redoStack.clear();
        while (!_redoStack.empty()) {
            _redoStack.pop();
        }

        // constrain to be in range
        if (y > _lry) {
            y = _lry;
        }

        if (y < _uly) {
            y = _uly;
        }

        if (x > _lrx) {
            x = _lrx;
        }

        if (x < _ulx) {
            x = _ulx;
        }

        _editPoint(x, y);

        // Edit the points in the signal.
        Vector pts = (Vector) _points.elementAt(_dataset);

        for (int i = 0; i < pts.size(); i++) {
            PlotPoint pt = (PlotPoint) pts.elementAt(i);

            // Only bother with points in visual range
            if ((pt.x >= _xMin) && (pt.x <= _xMax)) {
                int index = (int) ((pt.x - _xMin) * _xscale)
                        - (_lrx - _ulx - _editSpecX.length);

                if ((index >= 0) && (index < _editSpecX.length)) {
                    if (_editSpecSet[index]) {
                        pt.y = _yMax - ((_editSpecY[index] - _uly) / _yscale);

                        // For auto-ranging, keep track of min and max.
                        if (pt.y < _yBottom) {
                            _yBottom = pt.y;
                        }

                        if (pt.y > _yTop) {
                            _yTop = pt.y;
                        }
                    }
                }
            }
        }

        // Ensure replot of offscreen buffer.
        _plotImage = null;
        repaint();

        // Erase the guide
        // I don't think we need to do this, since we call repaint().
        //         graphics.setXORMode(_editColor);
        //         for (int i = 0; i < _editSpecX.length; i++) {
        //             if (_editSpecSet[i]) {
        //                 graphics.drawLine(_editSpecX[i], _editSpecY[i]-1,
        //                         _editSpecX[i], _editSpecY[i]+1);
        //             }
        //         }
        //         graphics.setPaintMode();
        _notifyListeners(_dataset);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized void ptolemy.plot.EditablePlot._editPoint ( int  x,
int  y 
) [inline, private]

Definition at line 293 of file EditablePlot.java.

                                                       {
        if (_dataset < 0) {
            return;
        }

        Graphics graphics = getGraphics();

        // constrain to be in range
        if (y > _lry) {
            y = _lry;
        }

        if (y < _uly) {
            y = _uly;
        }

        if (x > _lrx) {
            x = _lrx;
        }

        if (x < _ulx) {
            x = _ulx;
        }

        if ((x <= _currentEditX) || (x >= _lrx)) {
            // ignore
            return;
        }

        int step = _currentEditX;

        while (step <= x) {
            int index = step - (_lrx - _editSpecX.length);
            double proportion = (step - _currentEditX)
                    / (double) (x - _currentEditX);
            int newY = (int) (_currentEditY + (proportion * (y - _currentEditY)));

            if (!_editSpecSet[index]) {
                _editSpecX[index] = step;
                _editSpecY[index] = newY;
                _editSpecSet[index] = true;

                // Draw point, linearly interpolated from previous point
                graphics.setXORMode(_editColor);
                graphics.drawLine(step, newY - 1, step, newY + 1);
                graphics.setPaintMode();
            }

            step++;
        }

        _currentEditX = x;
        _currentEditY = y;
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.EditablePlot._editStart ( int  x,
int  y 
) [inline, private]

Definition at line 349 of file EditablePlot.java.

                                                       {
        if (_dataset < 0) {
            return;
        }

        // constrain to be in range
        if (y > _lry) {
            y = _lry;
        }

        if (y < _uly) {
            y = _uly;
        }

        if (x > _lrx) {
            x = _lrx;
        }

        if (x < _ulx) {
            x = _ulx;
        }

        // Allocate a vector to store the points.
        int size = _lrx - x + 1;
        _editSpecX = new int[size];
        _editSpecY = new int[size];
        _editSpecSet = new boolean[size];

        _editSpecX[0] = x;
        _editSpecY[0] = y;
        _editSpecSet[0] = true;

        _currentEditX = x;
        _currentEditY = y;

        Graphics graphics = getGraphics();

        // Draw point (as a 3 pixel vertical line, for thickness)
        graphics.setXORMode(_editColor);
        graphics.drawLine(x, y - 1, x, y + 1);
        graphics.setPaintMode();
    }

Here is the caller graph for this function:

void ptolemy.plot.PlotBox._help ( ) [inline, protected, inherited]

Display basic information in its own window.

Definition at line 2543 of file PlotBox.java.

                           {
        String message = "Ptolemy plot package\n"
                + "By: Edward A. Lee\n"
                + "and Christopher Brooks\n"
                + "Version "
                + PTPLOT_RELEASE
                + ", Build: $Id: PlotBox.java,v 1.283.4.3 2008/04/01 01:19:02 cxh Exp $\n\n"
                + "Key bindings:\n"
                + "   Cntrl-c:  copy plot to clipboard (EPS format), if permitted\n"
                + "   D: dump plot data to standard out\n"
                + "   E: export plot to standard out (EPS format)\n"
                + "   F: fill plot\n"
                + "   H or ?: print help message (this message)\n"
                + "   Cntrl-D or Q: quit\n" + "For more information, see\n"
                + "http://ptolemy.eecs.berkeley.edu/java/ptplot\n";
        JOptionPane.showMessageDialog(this, message,
                "Ptolemy Plot Help Window", JOptionPane.INFORMATION_MESSAGE);
    }

Here is the caller graph for this function:

void ptolemy.plot.EditablePlot._notifyListeners ( int  dataset) [inline, private]

Definition at line 393 of file EditablePlot.java.

                                               {
        if (_editListeners == null) {
            return;
        } else {
            Enumeration listeners = _editListeners.elements();

            while (listeners.hasMoreElements()) {
                ((EditListener) listeners.nextElement()).editDataModified(this,
                        dataset);
            }
        }
    }

Here is the caller graph for this function:

boolean ptolemy.plot.Plot._parseLine ( String  line) [inline, protected, inherited]

Parse a line that gives plotting information.

Return true if the line is recognized. Lines with syntax errors are ignored. It is not synchronized, so its caller should be.

Parameters:
lineA command line.
Returns:
True if the line is recognized.

Reimplemented from ptolemy.plot.PlotBox.

Definition at line 1466 of file Plot.java.

                                              {
        boolean connected = false;

        if (_isConnected(_currentdataset)) {
            connected = true;
        }

        // parse only if the super class does not recognize the line.
        if (super._parseLine(line)) {
            return true;
        } else {
            // We convert the line to lower case so that the command
            // names are case insensitive
            String lcLine = line.toLowerCase();

            if (lcLine.startsWith("marks:")) {
                // If we have seen a dataset directive, then apply the
                // request to the current dataset only.
                String style = (line.substring(6)).trim();

                if (_sawFirstDataSet) {
                    setMarksStyle(style, _currentdataset);
                } else {
                    setMarksStyle(style);
                }

                return true;
            } else if (lcLine.startsWith("numsets:")) {
                // Ignore.  No longer relevant.
                return true;
            } else if (lcLine.startsWith("reusedatasets:")) {
                if (lcLine.indexOf("off", 16) >= 0) {
                    setReuseDatasets(false);
                } else {
                    setReuseDatasets(true);
                }

                return true;
            } else if (lcLine.startsWith("dataset:")) {
                if (_reuseDatasets && (lcLine.length() > 0)) {
                    String tlegend = (line.substring(8)).trim();
                    _currentdataset = -1;

                    int i;

                    for (i = 0; i <= _maxDataset; i++) {
                        if (getLegend(i).compareTo(tlegend) == 0) {
                            _currentdataset = i;
                        }
                    }

                    if (_currentdataset != -1) {
                        return true;
                    } else {
                        _currentdataset = _maxDataset;
                    }
                }

                // new data set
                _firstInSet = true;
                _sawFirstDataSet = true;
                _currentdataset++;

                if (lcLine.length() > 0) {
                    String legend = (line.substring(8)).trim();

                    if ((legend != null) && (legend.length() > 0)) {
                        addLegend(_currentdataset, legend);
                    }
                }

                _maxDataset = _currentdataset;
                return true;
            } else if (lcLine.startsWith("lines:")) {
                if (_sawFirstDataSet) {
                    // Backward compatbility with xgraph here.
                    // If we see some data sets, then they are drawn
                    // with lines, if we then see a Lines: off
                    // the current dataset and succeeding datasets
                    // will be drawn without lines.
                    // For each of the existing datasets, if
                    // it fmt.connectedUseDefault is true, then
                    // set fmt.connectedUseDefault to false and set
                    // the value of fmt.connected
                    Enumeration formats = _formats.elements();

                    while (formats.hasMoreElements()) {
                        Format format = (Format) formats.nextElement();

                        if (format.connectedUseDefault) {
                            format.connectedUseDefault = false;
                            format.connected = _connected;
                        }
                    }
                }

                if (lcLine.indexOf("off", 6) >= 0) {
                    setConnected(false);
                } else {
                    setConnected(true);
                }

                return true;
            } else if (lcLine.startsWith("impulses:")) {
                // If we have not yet seen a dataset, then this is interpreted
                // as the global default.  Otherwise, it is assumed to apply
                // only to the current dataset.
                if (_sawFirstDataSet) {
                    if (lcLine.indexOf("off", 9) >= 0) {
                        setImpulses(false, _currentdataset);
                    } else {
                        setImpulses(true, _currentdataset);
                    }
                } else {
                    if (lcLine.indexOf("off", 9) >= 0) {
                        setImpulses(false);
                    } else {
                        setImpulses(true);
                    }
                }

                return true;
            } else if (lcLine.startsWith("bars:")) {
                if (lcLine.indexOf("off", 5) >= 0) {
                    setBars(false);
                } else {
                    setBars(true);

                    int comma = line.indexOf(",", 5);
                    String barwidth;
                    String baroffset = null;

                    if (comma > 0) {
                        barwidth = (line.substring(5, comma)).trim();
                        baroffset = (line.substring(comma + 1)).trim();
                    } else {
                        barwidth = (line.substring(5)).trim();
                    }

                    try {
                        // Use Double.parseDouble() and avoid creating a Double
                        double bwidth = Double.parseDouble(barwidth);
                        double boffset = _barOffset;

                        if (baroffset != null) {
                            boffset = Double.parseDouble(baroffset);
                        }

                        setBars(bwidth, boffset);
                    } catch (NumberFormatException e) {
                        // ignore if format is bogus.
                    }
                }

                return true;
            } else if (line.startsWith("move:")) {
                // a disconnected point
                connected = false;

                // deal with 'move: 1 2' and 'move:2 2'
                line = line.substring(5, line.length()).trim();
            } else if (line.startsWith("move")) {
                // a disconnected point
                connected = false;

                // deal with 'move 1 2' and 'move2 2'
                line = line.substring(4, line.length()).trim();
            } else if (line.startsWith("draw:")) {
                // a connected point, if connect is enabled.
                line = line.substring(5, line.length()).trim();
            } else if (line.startsWith("draw")) {
                // a connected point, if connect is enabled.
                line = line.substring(4, line.length()).trim();
            }

            line = line.trim();

            // We can't use StreamTokenizer here because it can't
            // process numbers like 1E-01.
            // This code is somewhat optimized for speed, since
            // most data consists of two data points, we want
            // to handle that case as efficiently as possible.
            int fieldsplit = line.indexOf(",");

            if (fieldsplit == -1) {
                fieldsplit = line.indexOf(" ");
            }

            if (fieldsplit == -1) {
                fieldsplit = line.indexOf("\t"); // a tab
            }

            if (fieldsplit > 0) {
                String x = (line.substring(0, fieldsplit)).trim();
                String y = (line.substring(fieldsplit + 1)).trim();

                // Any more separators?
                int fieldsplit2 = y.indexOf(",");

                if (fieldsplit2 == -1) {
                    fieldsplit2 = y.indexOf(" ");
                }

                if (fieldsplit2 == -1) {
                    fieldsplit2 = y.indexOf("\t"); // a tab
                }

                if (fieldsplit2 > 0) {
                    line = (y.substring(fieldsplit2 + 1)).trim();
                    y = (y.substring(0, fieldsplit2)).trim();
                }

                try {
                    // Use Double.parseDouble() and avoid creating a Double.
                    double xpt = Double.parseDouble(x);
                    double ypt = Double.parseDouble(y);

                    if (fieldsplit2 > 0) {
                        // There was one separator after the y value, now
                        // look for another separator.
                        int fieldsplit3 = line.indexOf(",");

                        if (fieldsplit3 == -1) {
                            fieldsplit3 = line.indexOf(" ");
                        }

                        //if (fieldsplit3 == -1) {
                        //    fieldsplit2 = line.indexOf("\t"); // a tab
                        //}
                        if (fieldsplit3 > 0) {
                            // We have more numbers, assume that this is
                            // an error bar
                            String yl = (line.substring(0, fieldsplit3)).trim();
                            String yh = (line.substring(fieldsplit3 + 1))
                                    .trim();
                            double yLowEB = Double.parseDouble(yl);
                            double yHighEB = Double.parseDouble(yh);
                            connected = _addLegendIfNecessary(connected);
                            addPointWithErrorBars(_currentdataset, xpt, ypt,
                                    yLowEB, yHighEB, connected);
                            return true;
                        } else {
                            // It is unlikely that we have a fieldsplit2 >0
                            // but not fieldsplit3 >0, but just in case:
                            connected = _addLegendIfNecessary(connected);
                            addPoint(_currentdataset, xpt, ypt, connected);
                            return true;
                        }
                    } else {
                        // There were no more fields, so this is
                        // a regular pt.
                        connected = _addLegendIfNecessary(connected);
                        addPoint(_currentdataset, xpt, ypt, connected);
                        return true;
                    }
                } catch (NumberFormatException e) {
                    // ignore if format is bogus.
                }
            }
        }

        return false;
    }

Here is the call graph for this function:

void ptolemy.plot.PlotBox._setButtonsVisibility ( boolean  vis) [inline, protected, inherited]

Set the visibility of the Fill button.

This is deprecated. Use setButtons().

Deprecated:

Definition at line 2683 of file PlotBox.java.

                                                      {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _printButton.setVisible(vis);
        _fillButton.setVisible(vis);
        _formatButton.setVisible(vis);
        _resetButton.setVisible(vis);
    }
void ptolemy.plot.EditablePlot._setData ( int  dataset,
double  data[][] 
) [inline, private]

Definition at line 408 of file EditablePlot.java.

                                                        {
        _checkDatasetIndex(dataset);

        Vector pts = (Vector) _points.elementAt(dataset);
        int size = pts.size();

        if (data[0].length < size) {
            size = data[0].length;
        }

        for (int i = 0; i < size; i++) {
            PlotPoint pt = (PlotPoint) pts.elementAt(i);
            pt.x = data[0][i];
            pt.y = data[1][i];
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void ptolemy.plot.PlotBox._setPadding ( double  padding) [inline, protected, inherited]

Set the padding multiple.

The plot rectangle can be "padded" in each direction -x, +x, -y, and +y. If the padding is set to 0.05 (and the padding is used), then there is 10% more length on each axis than set by the setXRange() and setYRange() methods, 5% in each direction.

Parameters:
paddingThe padding multiple.

Definition at line 2700 of file PlotBox.java.

                                               {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _padding = padding;
    }
void ptolemy.plot.Plot._setWidth ( Graphics  graphics,
float  width 
) [inline, protected, inherited]

If the graphics argument is an instance of Graphics2D, then set the current stroke to the specified width.

Otherwise, do nothing.

Parameters:
graphicsThe graphics object.
widthThe width.

Definition at line 1735 of file Plot.java.

                                                             {
        // For historical reasons, the API here only assumes Graphics
        // objects, not Graphics2D.
        if (graphics instanceof Graphics2D) {
            // We cache the two most common cases.
            if (width == 1f) {
                ((Graphics2D) graphics).setStroke(_lineStroke1);
            } else if (width == 2f) {
                ((Graphics2D) graphics).setStroke(_lineStroke2);
            } else {
                ((Graphics2D) graphics).setStroke(new BasicStroke(width,
                        BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
            }
        }
    }

Here is the caller graph for this function:

void ptolemy.plot.Plot._writeOldSyntax ( PrintWriter  output) [inline, protected, inherited]

Write plot information to the specified output stream in the "old syntax," which predates PlotML.

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. It is not synchronized, so its caller should be.

Parameters:
outputA buffered print writer.
Deprecated:

Reimplemented from ptolemy.plot.PlotBox.

Definition at line 1760 of file Plot.java.

                                                       {
        super._writeOldSyntax(output);

        // NOTE: NumSets is obsolete, so we don't write it.
        if (_reuseDatasets) {
            output.println("ReuseDatasets: on");
        }

        if (!_connected) {
            output.println("Lines: off");
        }

        if (_bars) {
            output.println("Bars: " + barWidth + ", " + _barOffset);
        }

        // Write the defaults for formats that can be controlled by dataset
        if (_impulses) {
            output.println("Impulses: on");
        }

        switch (_marks) {
        case 1:
            output.println("Marks: points");
            break;

        case 2:
            output.println("Marks: dots");
            break;

        case 3:
            output.println("Marks: various");
            break;

        case 4:
            output.println("Marks: pixels");
            break;
        }

        for (int dataset = 0; dataset < _points.size(); dataset++) {
            // Write the dataset directive
            String legend = getLegend(dataset);

            if (legend != null) {
                output.println("DataSet: " + getLegend(dataset));
            } else {
                output.println("DataSet:");
            }

            // Write dataset-specific format information
            Format fmt = (Format) _formats.elementAt(dataset);

            if (!fmt.impulsesUseDefault) {
                if (fmt.impulses) {
                    output.println("Impulses: on");
                } else {
                    output.println("Impulses: off");
                }
            }

            if (!fmt.marksUseDefault) {
                switch (fmt.marks) {
                case 0:
                    output.println("Marks: none");
                    break;

                case 1:
                    output.println("Marks: points");
                    break;

                case 2:
                    output.println("Marks: dots");
                    break;

                case 3:
                    output.println("Marks: various");
                    break;

                case 4:
                    output.println("Marks: pixels");
                    break;
                }
            }

            // Write the data
            Vector pts = (Vector) _points.elementAt(dataset);

            for (int pointnum = 0; pointnum < pts.size(); pointnum++) {
                PlotPoint pt = (PlotPoint) pts.elementAt(pointnum);

                if (!pt.connected) {
                    output.print("move: ");
                }

                if (pt.errorBar) {
                    output.println(pt.x + ", " + pt.y + ", " + pt.yLowEB + ", "
                            + pt.yHighEB);
                } else {
                    output.println(pt.x + ", " + pt.y);
                }
            }
        }
    }

Here is the call graph for this function:

void ptolemy.plot.PlotBox._zoom ( int  x,
int  y 
) [inline, package, inherited]

Definition at line 3626 of file PlotBox.java.

                             {
        // FIXME: This is friendly because Netscape 4.0.3 cannot access it if
        // it is private!
        // NOTE: Due to a bug in JDK 1.1.7B, the BUTTON1_MASK does
        // not work on mouse drags, thus we have to use this variable
        // to determine whether we are actually zooming. It is used only
        // in _zoomBox, since calling this method is properly masked.
        _zooming = false;

        Graphics graphics = getGraphics();

        // Ignore if there is no graphics object to draw on.
        if (graphics == null) {
            return;
        }

        if ((_zoomin == true) && (_drawn == true)) {
            if ((_zoomxn != -1) || (_zoomyn != -1)) {
                // erase previous rectangle.
                int minx = Math.min(_zoomx, _zoomxn);
                int maxx = Math.max(_zoomx, _zoomxn);
                int miny = Math.min(_zoomy, _zoomyn);
                int maxy = Math.max(_zoomy, _zoomyn);
                graphics.setXORMode(_boxColor);
                graphics.drawRect(minx, miny, maxx - minx, maxy - miny);
                graphics.setPaintMode();

                // constrain to be in range
                if (y > _lry) {
                    y = _lry;
                }

                if (y < _uly) {
                    y = _uly;
                }

                if (x > _lrx) {
                    x = _lrx;
                }

                if (x < _ulx) {
                    x = _ulx;
                }

                // NOTE: ignore if total drag less than 5 pixels.
                if ((Math.abs(_zoomx - x) > 5) && (Math.abs(_zoomy - y) > 5)) {
                    double a = _xMin + ((_zoomx - _ulx) / _xscale);
                    double b = _xMin + ((x - _ulx) / _xscale);

                    // NOTE: It used to be that it was problematic to set
                    // the X range here because it conflicted with the wrap
                    // mechanism.  But now the wrap mechanism saves the state
                    // of the X range when the setWrap() method is called,
                    // so this is safe.
                    // EAL 6/12/00.
                    if (a < b) {
                        setXRange(a, b);
                    } else {
                        setXRange(b, a);
                    }

                    a = _yMax - ((_zoomy - _uly) / _yscale);
                    b = _yMax - ((y - _uly) / _yscale);

                    if (a < b) {
                        setYRange(a, b);
                    } else {
                        setYRange(b, a);
                    }
                }

                repaint();
            }
        } else if ((_zoomout == true) && (_drawn == true)) {
            // Erase previous rectangle.
            graphics.setXORMode(_boxColor);

            int x_diff = Math.abs(_zoomx - _zoomxn);
            int y_diff = Math.abs(_zoomy - _zoomyn);
            graphics.drawRect(_zoomx - 15 - x_diff, _zoomy - 15 - y_diff,
                    30 + (x_diff * 2), 30 + (y_diff * 2));
            graphics.setPaintMode();

            // Calculate zoom factor.
            double a = (Math.abs(_zoomx - x)) / 30.0;
            double b = (Math.abs(_zoomy - y)) / 30.0;
            double newx1 = _xMax + ((_xMax - _xMin) * a);
            double newx2 = _xMin - ((_xMax - _xMin) * a);

            // NOTE: To limit zooming out to the fill area, uncomment this...
            // if (newx1 > _xTop) newx1 = _xTop;
            // if (newx2 < _xBottom) newx2 = _xBottom;
            double newy1 = _yMax + ((_yMax - _yMin) * b);
            double newy2 = _yMin - ((_yMax - _yMin) * b);

            // NOTE: To limit zooming out to the fill area, uncomment this...
            // if (newy1 > _yTop) newy1 = _yTop;
            // if (newy2 < _yBottom) newy2 = _yBottom;
            zoom(newx2, newy2, newx1, newy1);
            repaint();
        } else if (_drawn == false) {
            repaint();
        }

        _drawn = false;
        _zoomin = _zoomout = false;
        _zoomxn = _zoomyn = _zoomx = _zoomy = -1;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void ptolemy.plot.PlotBox._zoomBox ( int  x,
int  y 
) [inline, package, inherited]

Definition at line 3746 of file PlotBox.java.

                                {
        // FIXME: This is friendly because Netscape 4.0.3 cannot access it if
        // it is private!
        // NOTE: Due to a bug in JDK 1.1.7B, the BUTTON1_MASK does
        // not work on mouse drags, thus we have to use this variable
        // to determine whether we are actually zooming.
        if (!_zooming) {
            return;
        }

        Graphics graphics = getGraphics();

        // Ignore if there is no graphics object to draw on.
        if (graphics == null) {
            return;
        }

        // Bound the rectangle so it doesn't go outside the box.
        if (y > _lry) {
            y = _lry;
        }

        if (y < _uly) {
            y = _uly;
        }

        if (x > _lrx) {
            x = _lrx;
        }

        if (x < _ulx) {
            x = _ulx;
        }

        // erase previous rectangle, if there was one.
        if (((_zoomx != -1) || (_zoomy != -1))) {
            // Ability to zoom out added by William Wu.
            // If we are not already zooming, figure out whether we
            // are zooming in or out.
            if ((_zoomin == false) && (_zoomout == false)) {
                if (y < _zoomy) {
                    _zoomout = true;

                    // Draw reference box.
                    graphics.setXORMode(_boxColor);
                    graphics.drawRect(_zoomx - 15, _zoomy - 15, 30, 30);
                } else if (y > _zoomy) {
                    _zoomin = true;
                }
            }

            if (_zoomin == true) {
                // Erase the previous box if necessary.
                if (((_zoomxn != -1) || (_zoomyn != -1)) && (_drawn == true)) {
                    int minx = Math.min(_zoomx, _zoomxn);
                    int maxx = Math.max(_zoomx, _zoomxn);
                    int miny = Math.min(_zoomy, _zoomyn);
                    int maxy = Math.max(_zoomy, _zoomyn);
                    graphics.setXORMode(_boxColor);
                    graphics.drawRect(minx, miny, maxx - minx, maxy - miny);
                }

                // Draw a new box if necessary.
                if (y > _zoomy) {
                    _zoomxn = x;
                    _zoomyn = y;

                    int minx = Math.min(_zoomx, _zoomxn);
                    int maxx = Math.max(_zoomx, _zoomxn);
                    int miny = Math.min(_zoomy, _zoomyn);
                    int maxy = Math.max(_zoomy, _zoomyn);
                    graphics.setXORMode(_boxColor);
                    graphics.drawRect(minx, miny, maxx - minx, maxy - miny);
                    _drawn = true;
                    return;
                } else {
                    _drawn = false;
                }
            } else if (_zoomout == true) {
                // Erase previous box if necessary.
                if (((_zoomxn != -1) || (_zoomyn != -1)) && (_drawn == true)) {
                    int x_diff = Math.abs(_zoomx - _zoomxn);
                    int y_diff = Math.abs(_zoomy - _zoomyn);
                    graphics.setXORMode(_boxColor);
                    graphics.drawRect(_zoomx - 15 - x_diff, _zoomy - 15
                            - y_diff, 30 + (x_diff * 2), 30 + (y_diff * 2));
                }

                if (y < _zoomy) {
                    _zoomxn = x;
                    _zoomyn = y;

                    int x_diff = Math.abs(_zoomx - _zoomxn);
                    int y_diff = Math.abs(_zoomy - _zoomyn);
                    graphics.setXORMode(_boxColor);
                    graphics.drawRect(_zoomx - 15 - x_diff, _zoomy - 15
                            - y_diff, 30 + (x_diff * 2), 30 + (y_diff * 2));
                    _drawn = true;
                    return;
                } else {
                    _drawn = false;
                }
            }
        }

        graphics.setPaintMode();
    }

Here is the caller graph for this function:

void ptolemy.plot.PlotBox._zoomStart ( int  x,
int  y 
) [inline, package, inherited]

Definition at line 3862 of file PlotBox.java.

                                  {
        // FIXME: This is friendly because Netscape 4.0.3 cannot access it if
        // it is private!
        // constrain to be in range
        if (y > _lry) {
            y = _lry;
        }

        if (y < _uly) {
            y = _uly;
        }

        if (x > _lrx) {
            x = _lrx;
        }

        if (x < _ulx) {
            x = _ulx;
        }

        _zoomx = x;
        _zoomy = y;
        _zooming = true;
    }

Here is the caller graph for this function:

Add a listener to be informed when the user modifies a data set.

Parameters:
listenerThe listener.
See also:
EditListener

Definition at line 101 of file EditablePlot.java.

                                                       {
        if (_editListeners == null) {
            _editListeners = new Vector();
        } else {
            if (_editListeners.contains(listener)) {
                return;
            }
        }

        _editListeners.addElement(listener);
    }
synchronized void ptolemy.plot.Plot.addLegend ( int  dataset,
String  legend 
) [inline, inherited]

Add a legend (displayed at the upper right) for the specified data set with the specified string.

Short strings generally fit better than long strings.

Parameters:
datasetThe dataset index.
legendThe label for the dataset.

Reimplemented from ptolemy.plot.PlotBox.

Definition at line 221 of file Plot.java.

                                                                   {
        _checkDatasetIndex(dataset);

        if (!_reuseDatasets) {
            super.addLegend(dataset, legend);
        } else {
            // If _reuseDataSets is true, then look to see if we
            // already have a dataset with the same legend.
            String possibleLegend = getLegend(dataset);

            if ((possibleLegend == null)
                    || ((possibleLegend != null) && !possibleLegend
                            .equals(legend))) {
                super.addLegend(dataset, legend);
            }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized void ptolemy.plot.Plot.addPoint ( final int  dataset,
final double  x,
final double  y,
final boolean  connected 
) [inline, inherited]

In the specified data set, add the specified x, y point to the plot.

Data set indices begin with zero. If the data set does not exist, create it. The fourth argument indicates whether the point should be connected by a line to the previous point. Regardless of the value of this argument, a line will not drawn if either there has been no previous point for this dataset or setConnected() has been called with a false argument.

In order to work well with swing and be thread safe, this method actually defers execution to the event dispatch thread, where all user interface actions are performed. Thus, the point will not be added immediately (unless you call this method from within the event dispatch thread). All the methods that do this deferring coordinate so that they are executed in the order that you called them.

Parameters:
datasetThe data set index.
xThe X position of the new point.
yThe Y position of the new point.
connectedIf true, a line is drawn to connect to the previous point.

Definition at line 261 of file Plot.java.

                                                     {
        Runnable doAddPoint = new Runnable() {
            public void run() {
                _addPoint(dataset, x, y, 0, 0, connected, false);
            }
        };

        deferIfNecessary(doAddPoint);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized void ptolemy.plot.Plot.addPointWithErrorBars ( final int  dataset,
final double  x,
final double  y,
final double  yLowEB,
final double  yHighEB,
final boolean  connected 
) [inline, inherited]

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 micha.nosp@m.el@e.nosp@m.mail..nosp@m.labm.nosp@m.ed.um.nosp@m.n.ed.nosp@m.u.

In order to work well with swing and be thread safe, this method actually defers execution to the event dispatch thread, where all user interface actions are performed. Thus, the point will not be added immediately (unless you call this method from within the event dispatch thread). All the methods that do this deferring coordinate so that they are executed in the order that you called them.

Parameters:
datasetThe data set index.
xThe X position of the new point.
yThe Y position of the new point.
yLowEBThe low point of the error bar.
yHighEBThe high point of the error bar.
connectedIf true, a line is drawn to connect to the previous point.

Definition at line 300 of file Plot.java.

                                                           {
        Runnable doAddPoint = new Runnable() {
            public void run() {
                _addPoint(dataset, x, y, yLowEB, yHighEB, connected, true);
            }
        };

        deferIfNecessary(doAddPoint);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotBox.addXTick ( String  label,
double  position 
) [inline, inherited]

Specify a tick mark for the X axis.

The label given is placed on the axis at the position given by position. If this is called once or more, automatic generation of tick marks is disabled. The tick mark will appear only if it is within the X range.

Parameters:
labelThe label for the tick mark.
positionThe position on the X axis.

Definition at line 308 of file PlotBox.java.

                                                                     {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        if (_xticks == null) {
            _xticks = new Vector();
            _xticklabels = new Vector();
        }

        _xticks.addElement(Double.valueOf(position));
        _xticklabels.addElement(label);
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotBox.addYTick ( String  label,
double  position 
) [inline, inherited]

Specify a tick mark for the Y axis.

The label given is placed on the axis at the position given by position. If this is called once or more, automatic generation of tick marks is disabled. The tick mark will appear only if it is within the Y range.

Parameters:
labelThe label for the tick mark.
positionThe position on the Y axis.

Definition at line 329 of file PlotBox.java.

                                                                     {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        if (_yticks == null) {
            _yticks = new Vector();
            _yticklabels = new Vector();
        }

        _yticks.addElement(Double.valueOf(position));
        _yticklabels.addElement(label);
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.Plot.clear ( final boolean  format) [inline, inherited]

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().

Parameters:
formatIf true, clear the format controls as well.

In order to work well with swing and be thread safe, this method actually defers execution to the event dispatch thread, where all user interface actions are performed. Thus, the clear will not be executed immediately (unless you call this method from within the event dispatch thread). All the methods that do this deferring coordinate so that they are executed in the order that you called them.

Definition at line 326 of file Plot.java.

                                                         {
        Runnable doClear = new Runnable() {
            public void run() {
                _clear(format);
            }
        };

        deferIfNecessary(doClear);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotBox.clear ( boolean  axes) [inline, inherited]

If the argument is true, clear the axes.

I.e., set all parameters controlling the axes to their initial conditions. For the change to take effect, call repaint(). If the argument is false, do nothing.

Parameters:
axesIf true, clear the axes parameters.

Definition at line 348 of file PlotBox.java.

                                                 {
        // We need to repaint the offscreen buffer.
        _plotImage = null;

        _xBottom = Double.MAX_VALUE;
        _xTop = -Double.MAX_VALUE;
        _yBottom = Double.MAX_VALUE;
        _yTop = -Double.MAX_VALUE;

        if (axes) {
            // Protected members first.
            _yMax = 0;
            _yMin = 0;
            _xMax = 0;
            _xMin = 0;
            _xRangeGiven = false;
            _yRangeGiven = false;
            _originalXRangeGiven = false;
            _originalYRangeGiven = false;
            _rangesGivenByZooming = false;
            _xlog = false;
            _ylog = false;
            _grid = true;
            _wrap = false;
            _usecolor = true;

            // Private members next...
            _filespec = null;
            _xlabel = null;
            _ylabel = null;
            _title = null;
            _legendStrings = new Vector();
            _legendDatasets = new Vector();
            _xticks = null;
            _xticklabels = null;
            _yticks = null;
            _yticklabels = null;
        }
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.Plot.clear ( final int  dataset) [inline, inherited]

Clear the plot of data points in the specified dataset.

This calls repaint() to request an update of the display.

In order to work well with swing and be thread safe, this method actually defers execution to the event dispatch thread, where all user interface actions are performed. Thus, the point will not be added immediately (unless you call this method from within the event dispatch thread). If you call this method, the addPoint() method, and the erasePoint() method in any order, they are assured of being processed in the order that you called them.

Parameters:
datasetThe dataset to clear.

Definition at line 349 of file Plot.java.

                                                      {
        Runnable doClear = new Runnable() {
            public void run() {
                _clear(dataset);
            }
        };

        deferIfNecessary(doClear);
    }

Here is the call graph for this function:

synchronized void ptolemy.plot.PlotBox.clearLegends ( ) [inline, inherited]

Clear all legends.

This will show up on the next redraw.

Definition at line 390 of file PlotBox.java.

                                            {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _legendStrings = new Vector();
        _legendDatasets = new Vector();
    }
void ptolemy.plot.PlotBox.deferIfNecessary ( Runnable  action) [inline, inherited]

If this method is called in the event thread, then simply execute the specified action.

Otherwise, if there are already deferred actions, then add the specified one to the list. Otherwise, create a list of deferred actions, if necessary, and request that the list be processed in the event dispatch thread.

Note that it does not work nearly as well to simply schedule the action yourself on the event thread because if there are a large number of actions, then the event thread will not be able to keep up. By grouping these actions, we avoid this problem.

This method is not synchronized, so the caller should be.

Parameters:
actionThe Runnable object to execute.

Definition at line 413 of file PlotBox.java.

                                                  {
        // In swing, updates to showing graphics must be done in the
        // event thread.  If we are in the event thread, then proceed.
        // Otherwise, queue a request or add to a pending request.
        if (EventQueue.isDispatchThread()) {
            action.run();
        } else {
            if (_deferredActions == null) {
                _deferredActions = new LinkedList();
            }

            // Add the specified action to the list of actions to perform.
            _deferredActions.add(action);

            // If it hasn't already been requested, request that actions
            // be performed in the event dispatch thread.
            if (!_actionsDeferred) {
                Runnable doActions = new Runnable() {
                    public void run() {
                        _executeDeferredActions();
                    }
                };

                try {
                    // NOTE: Using invokeAndWait() here risks causing
                    // deadlock.  Don't do it!
                    SwingUtilities.invokeLater(doActions);
                } catch (Exception ex) {
                    // Ignore InterruptedException.
                    // Other exceptions should not occur.
                }

                _actionsDeferred = true;
            }
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized void ptolemy.plot.Plot.erasePoint ( final int  dataset,
final int  index 
) [inline, inherited]

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.

In order to work well with swing and be thread safe, this method actually defers execution to the event dispatch thread, where all user interface actions are performed. Thus, the point will not be erased immediately (unless you call this method from within the event dispatch thread). All the methods that do this deferring coordinate so that they are executed in the order that you called them.

Parameters:
datasetThe data set index.
indexThe index of the point to erase.

Definition at line 376 of file Plot.java.

                                                                            {
        Runnable doErasePoint = new Runnable() {
            public void run() {
                _erasePoint(dataset, index);
            }
        };

        deferIfNecessary(doErasePoint);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotBox.export ( OutputStream  out) [inline, inherited]

Export a description of the plot.

Currently, only EPS is supported. But in the future, this may cause a dialog box to open to allow the user to select a format. If the argument is null, then the description goes to the clipboard. Otherwise, it goes to the specified file. To send it to standard output, use System.out as an argument.

Parameters:
outAn output stream to which to send the description.

Definition at line 459 of file PlotBox.java.

                                                      {
        try {
            EPSGraphics g = new EPSGraphics(out, _width, _height);
            _drawPlot(g, false);
            g.showpage();
        } catch (RuntimeException ex) {
            String message = "Export failed: " + ex.getMessage();
            JOptionPane.showMessageDialog(this, message,
                    "Ptolemy Plot Message", JOptionPane.ERROR_MESSAGE);

            // Rethrow the exception so that we don't report success,
            // and so the stack trace is displayed on standard out.
            throw (RuntimeException) ex.fillInStackTrace();
        }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized BufferedImage ptolemy.plot.PlotBox.exportImage ( ) [inline, inherited]

Create a BufferedImage and draw this plot to it.

The size of the returned image matches the current size of the plot. This method can be used, for example, by a servlet to produce an image, rather than requiring an applet to instantiate a PlotBox.

Returns:
An image filled by the plot.

Definition at line 490 of file PlotBox.java.

                                                    {
        Rectangle rectangle = new Rectangle(_preferredWidth, _preferredHeight);
        return exportImage(new BufferedImage(rectangle.width, rectangle.height,
                BufferedImage.TYPE_INT_ARGB), rectangle,
                _defaultImageRenderingHints(), false);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized BufferedImage ptolemy.plot.PlotBox.exportImage ( Rectangle  rectangle) [inline, inherited]

Create a BufferedImage the size of the given rectangle and draw this plot to it at the position specified by the rectangle.

The plot is rendered using anti-aliasing.

Parameters:
rectangleThe size of the plot. This method can be used, for example, by a servlet to produce an image, rather than requiring an applet to instantiate a PlotBox.
Returns:
An image containing the plot.

Definition at line 505 of file PlotBox.java.

                                                                       {
        return exportImage(new BufferedImage(rectangle.width, rectangle.height,
                BufferedImage.TYPE_INT_ARGB), rectangle,
                _defaultImageRenderingHints(), false);
    }

Here is the call graph for this function:

synchronized BufferedImage ptolemy.plot.PlotBox.exportImage ( BufferedImage  bufferedImage,
Rectangle  rectangle,
RenderingHints  hints,
boolean  transparent 
) [inline, inherited]

Draw this plot onto the specified image at the position of the specified rectangle with the size of the specified rectangle.

The plot is rendered using anti-aliasing. This can be used to paint a number of different plots onto a single buffered image. This method can be used, for example, by a servlet to produce an image, rather than requiring an applet to instantiate a PlotBox.

Parameters:
bufferedImageImage onto which the plot is drawn.
rectangleThe size and position of the plot in the image.
hintsRendering hints for this plot.
transparentIndicator that the background of the plot should not be painted.
Returns:
The modified bufferedImage.

Definition at line 525 of file PlotBox.java.

                                                                            {
        Graphics2D graphics = bufferedImage.createGraphics();
        graphics.addRenderingHints(_defaultImageRenderingHints());

        if (!transparent) {
            graphics.setColor(Color.white); // set the background color
            graphics.fill(rectangle);
        }

        _drawPlot(graphics, false, rectangle);
        return bufferedImage;
    }

Here is the call graph for this function:

synchronized BufferedImage ptolemy.plot.PlotBox.exportImage ( BufferedImage  bufferedImage) [inline, inherited]

Draw this plot onto the provided image.

This method does not paint the background, so the plot is transparent. The plot fills the image, and is rendered using anti-aliasing. This method can be used to overlay multiple plots on the same image, although you must use care to ensure that the axes and other labels are identical. Hence, it is usually better to simply combine data sets into a single plot.

Parameters:
bufferedImageThe image onto which to render the plot.
Returns:
The modified bufferedImage.

Definition at line 550 of file PlotBox.java.

                                                                               {
        return exportImage(bufferedImage, new Rectangle(bufferedImage
                .getWidth(), bufferedImage.getHeight()),
                _defaultImageRenderingHints(), true);
    }

Here is the call graph for this function:

synchronized void ptolemy.plot.Plot.fillPlot ( ) [inline, inherited]

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.

In order to work well with swing and be thread safe, this method actually defers execution to the event dispatch thread, where all user interface actions are performed. Thus, the fill will not occur immediately (unless you call this method from within the event dispatch thread). All the methods that do this deferring coordinate so that they are executed in the order that you called them.

Reimplemented from ptolemy.plot.PlotBox.

Definition at line 400 of file Plot.java.

                                        {
        Runnable doFill = new Runnable() {
            public void run() {
                _fillPlot();
            }
        };

        deferIfNecessary(doFill);
    }

Here is the call graph for this function:

boolean ptolemy.plot.PlotBox.getColor ( ) [inline, inherited]

Return whether the plot uses color.

Returns:
True if the plot uses color.

Definition at line 580 of file PlotBox.java.

                              {
        return _usecolor;
    }

Here is the caller graph for this function:

static Color ptolemy.plot.PlotBox.getColorByName ( String  name) [inline, static, inherited]

Convert a color name into a Color.

Currently, only a very limited set of color names is supported: black, white, red, green, and blue.

Parameters:
nameA color name, or null if not found.
Returns:
An instance of Color.

Definition at line 597 of file PlotBox.java.

                                                    {
        try {
            // Check to see if it is a hexadecimal
            if (name.startsWith("#")) {
                name = name.substring(1);
            }

            Color col = new Color(Integer.parseInt(name, 16));
            return col;
        } catch (NumberFormatException e) {
        }

        // FIXME: This is a poor excuse for a list of colors and values.
        // We should use a hash table here.
        // Note that Color decode() wants the values to start with 0x.
        String[][] names = { { "black", "00000" }, { "white", "ffffff" },
                { "red", "ff0000" }, { "green", "00ff00" },
                { "blue", "0000ff" } };

        for (int i = 0; i < names.length; i++) {
            if (name.equals(names[i][0])) {
                try {
                    Color col = new Color(Integer.parseInt(names[i][1], 16));
                    return col;
                } catch (NumberFormatException e) {
                }
            }
        }

        return null;
    }

Here is the caller graph for this function:

Color [] ptolemy.plot.PlotBox.getColors ( ) [inline, inherited]

Get the point colors.

Returns:
Array of colors
See also:
setColors(Color[])

Definition at line 588 of file PlotBox.java.

                               {
        return _colors;
    }
boolean ptolemy.plot.Plot.getConnected ( ) [inline, inherited]

Return whether the default is to connect subsequent points with a line.

If the result 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(). Also, a different default can be set for each dataset, overriding this global default.

Definition at line 417 of file Plot.java.

                                  {
        return _connected;
    }
double [][] ptolemy.plot.EditablePlot.getData ( int  dataset) [inline]

Get the data in the specified dataset.

This is returned as a two-dimensional array, where the first index specifies X or Y data (index 0 or 1 respectively), and the second index specifies the point.

Returns:
The data in the specified dataset.

Definition at line 119 of file EditablePlot.java.

                                           {
        _checkDatasetIndex(dataset);

        Vector pts = (Vector) _points.elementAt(dataset);
        int size = pts.size();
        double[][] result = new double[2][size];

        for (int i = 0; i < size; i++) {
            PlotPoint pt = (PlotPoint) pts.elementAt(i);
            result[0][i] = pt.x;
            result[1][i] = pt.y;
        }

        return result;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

String ptolemy.plot.PlotBox.getDataurl ( ) [inline, inherited]

Get the file specification that was given by setDataurl.

This method is deprecated. Use read() instead.

Deprecated:

Definition at line 633 of file PlotBox.java.

                               {
        return _filespec;
    }
URL ptolemy.plot.PlotBox.getDocumentBase ( ) [inline, inherited]

Get the document base that was set by setDocumentBase.

This method is deprecated. Use read() instead.

Deprecated:

Definition at line 641 of file PlotBox.java.

                                 {
        return _documentBase;
    }
boolean ptolemy.plot.PlotBox.getGrid ( ) [inline, inherited]

Return whether the grid is drawn.

Returns:
True if a grid is drawn.

Definition at line 648 of file PlotBox.java.

                             {
        return _grid;
    }

Here is the caller graph for this function:

boolean ptolemy.plot.Plot.getImpulses ( ) [inline, inherited]

Return whether a line will be drawn from any plotted point down to the x axis.

A plot with such lines is also known as a stem plot.

Definition at line 425 of file Plot.java.

                                 {
        return _impulses;
    }
synchronized String ptolemy.plot.PlotBox.getLegend ( int  dataset) [inline, inherited]

Get the legend for a dataset, or null if there is none.

The legend would have been set by addLegend().

Parameters:
datasetThe dataset index.
Returns:
The legend label, or null if there is none.

Definition at line 657 of file PlotBox.java.

                                                      {
        int idx = _legendDatasets.indexOf(Integer.valueOf(dataset), 0);

        if (idx != -1) {
            return (String) _legendStrings.elementAt(idx);
        } else {
            return null;
        }
    }

Here is the caller graph for this function:

synchronized int ptolemy.plot.PlotBox.getLegendDataset ( String  legend) [inline, inherited]

Given a legend string, return the corresponding dataset or -1 if no legend was added with that legend string The legend would have been set by addLegend().

Parameters:
legendThe String naming the legend
Returns:
The legend dataset, or -1 if not found.
Since:
Ptplot 5.2p1

Definition at line 674 of file PlotBox.java.

                                                            {
        int index = _legendStrings.indexOf(legend);

        if (index == -1) {
            return -1;
        }

        return ((Integer) _legendDatasets.get(index)).intValue();
    }
synchronized String ptolemy.plot.Plot.getMarksStyle ( ) [inline, inherited]

Get the marks style, which is one of "none", "points", "dots", or "various".

Returns:
A string specifying the style for points.

Definition at line 433 of file Plot.java.

                                               {
        // NOTE: If the number of marks increases, we will need to do
        // something better here...
        if (_marks == 0) {
            return "none";
        } else if (_marks == 1) {
            return "points";
        } else if (_marks == 2) {
            return "dots";
        } else if (_marks == 3) {
            return "various";
        } else {
            return "pixels";
        }
    }
int ptolemy.plot.Plot.getMaxDataSets ( ) [inline, inherited]

Return the maximum number of data sets.

This method is deprecated, since there is no longer an upper bound.

Deprecated:

Definition at line 453 of file Plot.java.

                                {
        return Integer.MAX_VALUE;
    }
synchronized int ptolemy.plot.Plot.getNumDataSets ( ) [inline, inherited]

Return the actual number of data sets.

Returns:
The number of data sets that have been created.

Definition at line 460 of file Plot.java.

                                             {
        return _points.size();
    }
Rectangle ptolemy.plot.PlotBox.getPlotRectangle ( ) [inline, inherited]

If the size of the plot has been set by setSize(), then return that size.

Otherwise, return what the superclass returns (which is undocumented, but apparently imposes no maximum size). Currently (JDK 1.3), only BoxLayout pays any attention to this.

Returns:
The maximum desired size. Get the minimum size of this component. This is simply the dimensions specified by setSize(), if this has been called. Otherwise, return whatever the base class returns, which is undocumented.
The minimum size. Get the current plot rectangle. Note that Rectangle returned by this method is calculated from the values of _ulx, _uly, _lrx and _lry. The value passed in by setPlotRectangle() is not directly used, thus calling getPlotRectangle() may not return the same rectangle that was passed in with setPlotRectangle().
Rectangle
See also:
setPlotRectangle(Rectangle)

Definition at line 722 of file PlotBox.java.

                                        {
        return new Rectangle(_ulx, _uly, _lrx - _ulx, _lry - _uly);
    }
synchronized Dimension ptolemy.plot.PlotBox.getPreferredSize ( ) [inline, inherited]

Get the preferred size of this component.

This is simply the dimensions specified by setSize(), if this has been called, or the default width and height otherwise (500 by 300).

Returns:
The preferred size.

Definition at line 732 of file PlotBox.java.

                                                     {
        return new Dimension(_preferredWidth, _preferredHeight);
    }

Return false if setReuseDatasets() has not yet been called or if setReuseDatasets(false) has been called.

Returns:
false if setReuseDatasets() has not yet been called or if setReuseDatasets(false) has been called.
Since:
Ptplot 5.3
See also:
setReuseDatasets(boolean)

Definition at line 471 of file Plot.java.

                                      {
        return _reuseDatasets;
    }
synchronized String ptolemy.plot.PlotBox.getTitle ( ) [inline, inherited]

Get the title of the graph, or an empty string if there is none.

Returns:
The title.

Definition at line 739 of file PlotBox.java.

                                          {
        if (_title == null) {
            return "";
        }

        return _title;
    }

Here is the caller graph for this function:

synchronized double [] ptolemy.plot.PlotBox.getXAutoRange ( ) [inline, inherited]

Get the range for X values of the data points registered so far.

Usually, derived classes handle managing the range by checking each new point against the current range.

Returns:
An array of two doubles where the first element is the minimum and the second element is the maximum.
See also:
getXRange()

Definition at line 754 of file PlotBox.java.

                                                 {
        double[] result = new double[2];
        result[0] = _xBottom;
        result[1] = _xTop;
        return result;
    }
synchronized String ptolemy.plot.PlotBox.getXLabel ( ) [inline, inherited]

Get the label for the X (horizontal) axis, or null if none has been set.

Returns:
The X label.

Definition at line 765 of file PlotBox.java.

                                           {
        return _xlabel;
    }

Here is the caller graph for this function:

boolean ptolemy.plot.PlotBox.getXLog ( ) [inline, inherited]

Return whether the X axis is drawn with a logarithmic scale.

Returns:
True if the X axis is logarithmic.

Definition at line 772 of file PlotBox.java.

                             {
        return _xlog;
    }
synchronized double [] ptolemy.plot.PlotBox.getXRange ( ) [inline, inherited]

Get the X range.

If setXRange(double, double) has been called, then this method returns the values passed in as arguments to setXRange(double, double). If setXRange(double, double) has not been called, then this method returns the range of the data to be plotted, which might not be all of the data due to zooming.

Returns:
An array of two doubles where the first element is the minimum and the second element is the maximum.
See also:
getXAutoRange()

Definition at line 786 of file PlotBox.java.

                                             {
        double[] result = new double[2];

        if (_xRangeGiven) {
            result[0] = _xlowgiven;
            result[1] = _xhighgiven;
        } else {
            // Have to first correct for the padding.
            result[0] = _xMin + ((_xMax - _xMin) * _padding);
            result[1] = _xMax - ((_xMax - _xMin) * _padding);
            ;
        }

        return result;
    }

Here is the caller graph for this function:

synchronized Vector [] ptolemy.plot.PlotBox.getXTicks ( ) [inline, inherited]

Get the X ticks that have been specified, or null if none.

The return value is an array with two vectors, the first of which specifies the X tick locations (as instances of Double), and the second of which specifies the corresponding labels.

Returns:
The X ticks.

Definition at line 808 of file PlotBox.java.

                                             {
        if (_xticks == null) {
            return null;
        }

        Vector[] result = new Vector[2];
        result[0] = _xticks;
        result[1] = _xticklabels;
        return result;
    }

Here is the caller graph for this function:

synchronized double [] ptolemy.plot.PlotBox.getYAutoRange ( ) [inline, inherited]

Get the range for Y values of the data points registered so far.

Usually, derived classes handle managing the range by checking each new point against the range.

Returns:
An array of two doubles where the first element is the minimum and the second element is the maximum.
See also:
getYRange()

Definition at line 826 of file PlotBox.java.

                                                 {
        double[] result = new double[2];
        result[0] = _yBottom;
        result[1] = _yTop;
        return result;
    }
String ptolemy.plot.PlotBox.getYLabel ( ) [inline, inherited]

Get the label for the Y (vertical) axis, or null if none has been set.

Returns:
The Y label.

Definition at line 837 of file PlotBox.java.

                              {
        return _ylabel;
    }

Here is the caller graph for this function:

boolean ptolemy.plot.PlotBox.getYLog ( ) [inline, inherited]

Return whether the Y axis is drawn with a logarithmic scale.

Returns:
True if the Y axis is logarithmic.

Definition at line 844 of file PlotBox.java.

                             {
        return _ylog;
    }
synchronized double [] ptolemy.plot.PlotBox.getYRange ( ) [inline, inherited]

Get the Y range.

If setYRange(double, double) has been called, then this method returns the values passed in as arguments to setYRange(double, double). If setYRange(double, double) has not been called, then this method returns the range of the data to be plotted, which might not be all of the data due to zooming.

Returns:
An array of two doubles where the first element is the minimum and the second element is the maximum.
See also:
getYAutoRange()

Definition at line 858 of file PlotBox.java.

                                             {
        double[] result = new double[2];

        if (_yRangeGiven) {
            result[0] = _ylowgiven;
            result[1] = _yhighgiven;
        } else {
            // Have to first correct for the padding.
            result[0] = _yMin + ((_yMax - _yMin) * _padding);
            result[1] = _yMax - ((_yMax - _yMin) * _padding);
            ;
        }

        return result;
    }

Here is the caller graph for this function:

synchronized Vector [] ptolemy.plot.PlotBox.getYTicks ( ) [inline, inherited]

Get the Y ticks that have been specified, or null if none.

The return value is an array with two vectors, the first of which specifies the Y tick locations (as instances of Double), and the second of which specifies the corresponding labels.

Returns:
The Y ticks.

Definition at line 880 of file PlotBox.java.

                                             {
        if (_yticks == null) {
            return null;
        }

        Vector[] result = new Vector[2];
        result[0] = _yticks;
        result[1] = _yticklabels;
        return result;
    }

Here is the caller graph for this function:

void ptolemy.plot.PlotBox.init ( ) [inline, inherited]

Initialize the component, creating the fill button and parsing an input file, if one has been specified.

This is deprecated. Call setButtons() and read() instead.

Deprecated:

Definition at line 896 of file PlotBox.java.

                       {
        setButtons(true);

        if (_filespec != null) {
            parseFile(_filespec, _documentBase);
        }
    }

Here is the call graph for this function:

synchronized void ptolemy.plot.PlotBox.paintComponent ( Graphics  graphics) [inline, inherited]

Paint the component contents, which in this base class is only the axes.

Parameters:
graphicsThe graphics context.

Definition at line 908 of file PlotBox.java.

                                                               {
        //  super.paintComponent(graphics);
        //         _drawPlot(graphics, true);
        BufferedImage newPlotImage = _plotImage;

        if (newPlotImage == null) {
            Rectangle bounds = getBounds();
            newPlotImage = new BufferedImage(bounds.width, bounds.height,
                    BufferedImage.TYPE_3BYTE_BGR);
            _plotImage = newPlotImage;

            Graphics2D offScreenGraphics = newPlotImage.createGraphics();
            super.paintComponent(offScreenGraphics);
            _drawPlot(offScreenGraphics, true);
        }

        // Blit the offscreen image onto the screen.
        graphics.drawImage(newPlotImage, 0, 0, null);

        // Acquire the focus so that key bindings work.
        // NOTE: no longer needed?
        // requestFocus();
    }

Here is the call graph for this function:

void ptolemy.plot.Plot.parseFile ( String  filespec,
URL  documentBase 
) [inline, inherited]

Override the base class to indicate that a new data set is being read.

This method is deprecated. Use read() instead (to read the old file format) or one of the classes in the plotml package to read the new (XML) file format.

Deprecated:

Reimplemented from ptolemy.plot.PlotBox.

Definition at line 481 of file Plot.java.

                                                             {
        _firstInSet = true;
        _sawFirstDataSet = false;
        super.parseFile(filespec, documentBase);
    }
void ptolemy.plot.PlotBox.parseFile ( String  filespec) [inline, inherited]

Syntactic sugar for parseFile(filespec, documentBase).

This method is deprecated. Use read() to read the old file format, or use one of the classes in the plotml package to read the XML-based file format.

Deprecated:

Definition at line 938 of file PlotBox.java.

                                           {
        parseFile(filespec, (URL) null);
    }

Here is the caller graph for this function:

synchronized int ptolemy.plot.PlotBox.print ( Graphics  graphics,
PageFormat  format,
int  index 
) throws PrinterException [inline, inherited]

Print the plot to a printer, represented by the specified graphics object.

Parameters:
graphicsThe context into which the page is drawn.
formatThe size and orientation of the page being drawn.
indexThe zero based index of the page to be drawn.
Returns:
PAGE_EXISTS if the page is rendered successfully, or NO_SUCH_PAGE if pageIndex specifies a non-existent page.
Exceptions:
PrinterExceptionIf the print job is terminated.

Definition at line 1032 of file PlotBox.java.

                                               {

        if (graphics == null) {
            return Printable.NO_SUCH_PAGE;
        }

        // We only print on one page.
        if (index >= 1) {
            return Printable.NO_SUCH_PAGE;
        }

        Graphics2D graphics2D = (Graphics2D) graphics;

        // Scale the printout to fit the pages.
        // Contributed by Laurent ETUR, Schlumberger Riboud Product Center
        double scalex = format.getImageableWidth() / getWidth();
        double scaley = format.getImageableHeight() / getHeight();
        double scale = Math.min(scalex, scaley);
        graphics2D.translate((int) format.getImageableX(), (int) format
                .getImageableY());
        graphics2D.scale(scale, scale);
        _drawPlot(graphics, true);
        return Printable.PAGE_EXISTS;
    }

Here is the call graph for this function:

synchronized void ptolemy.plot.Plot.read ( InputStream  inputStream) throws IOException [inline, inherited]

Read a file with the old syntax (non-XML).

Override the base class to register that we are reading a new data set.

Parameters:
inputStreamThe input stream.
Exceptions:
IOExceptionIf the stream cannot be read.

Reimplemented from ptolemy.plot.PlotBox.

Definition at line 493 of file Plot.java.

                                                                              {
        super.read(inputStream);
        _firstInSet = true;
        _sawFirstDataSet = false;
    }
synchronized void ptolemy.plot.PlotBox.read ( String  command) [inline, inherited]

Read a single line command provided as a string.

The commands can be any of those in the ASCII file format.

Parameters:
commandA command.

Definition at line 1118 of file PlotBox.java.

                                                  {
        _parseLine(command);
    }

Here is the call graph for this function:

String ptolemy.plot.PlotBox.ReadPlotApplet ( ) [inline, inherited]

Definition at line 246 of file PlotBox.java.

                                  {                                                                                                        
        String reply="error\nReadApplet() not implemented\nNO SENSIBLE USER INTERACTION PRESENT";                                          
        return reply;                                                                                                                      
    }                                                                                                                                      

Here is the caller graph for this function:

void ptolemy.plot.EditablePlot.redo ( ) [inline]

Redo the latest signal editing operation that was undone by calling undo(), if there was one.

Otherwise, do nothing.

Definition at line 138 of file EditablePlot.java.

                       {
        if (_redoStack.empty()) {
            return;
        }

        Object[] save = new Object[2];
        save[0] = Integer.valueOf(_dataset);
        save[1] = getData(_dataset);
        _undoStack.push(save);

        Object[] saved = (Object[]) _redoStack.pop();
        _setData(((Integer) saved[0]).intValue(), (double[][]) saved[1]);

        // Ensure replot of offscreen buffer.
        _plotImage = null;
        repaint();
        _notifyListeners(_dataset);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Unregister a edit listener.

If the specified listener has not been previously registered, then do nothing.

Parameters:
listenerThe listener to remove from the list of listeners to which edit events are sent.

Definition at line 162 of file EditablePlot.java.

                                                          {
        if (_editListeners == null) {
            return;
        }

        _editListeners.removeElement(listener);
    }
synchronized void ptolemy.plot.PlotBox.removeLegend ( int  dataset) [inline, inherited]

Remove the legend (displayed at the upper right) for the specified data set.

If the dataset is not found, nothing will occur. The PlotBox must be repainted in order for this to take effect.

Parameters:
datasetThe dataset index.

Definition at line 1127 of file PlotBox.java.

                                                       {
        final int len = _legendDatasets.size();
        int foundIndex = -1;
        boolean found = false;

        for (int i = 0; (i < len) && !found; ++i) {
            if (((Integer) _legendDatasets.get(i)).intValue() == dataset) {
                foundIndex = i;
                found = true;
            }
        }

        if (found) {
            _legendDatasets.remove(foundIndex);
            _legendStrings.remove(foundIndex);
        }
    }
synchronized void ptolemy.plot.PlotBox.renameLegend ( int  dataset,
String  newName 
) [inline, inherited]

Rename a legend.

Parameters:
datasetThe dataset of the legend to be renamed. If there is no dataset with this value, then nothing happens.
newNameThe new name of legend.
See also:
addLegend(int, String)

Definition at line 1151 of file PlotBox.java.

                                                                       {
        int index = _legendDatasets.indexOf(Integer.valueOf(dataset), 0);

        if (index != -1) {
            _legendStrings.setElementAt(newName, index);

            // Changing legend means we need to repaint the offscreen buffer.
            _plotImage = null;
        }
    }
synchronized void ptolemy.plot.PlotBox.resetAxes ( ) [inline, inherited]

Reset the X and Y axes to the ranges that were first specified using setXRange() and setYRange().

If these methods have not been called, then reset to the default ranges. This method calls repaint(), which eventually causes the display to be updated.

Definition at line 1168 of file PlotBox.java.

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized void ptolemy.plot.Plot.samplePlot ( ) [inline, inherited]

Create a sample plot.

This is not actually done immediately unless the calling thread is the event dispatch thread. Instead, it is deferred to the event dispatch thread. It is important that the calling thread not hold a synchronize lock on the Plot object, or deadlock will result (unless the calling thread is the event dispatch thread).

Reimplemented from ptolemy.plot.PlotBox.

Definition at line 506 of file Plot.java.

                                          {
        // This needs to be done in the event thread.
        Runnable sample = new Runnable() {
            public void run() {
                synchronized (Plot.this) {
                    // Create a sample plot.
                    clear(true);

                    setTitle("Sample plot");
                    setYRange(-4, 4);
                    setXRange(0, 100);
                    setXLabel("time");
                    setYLabel("value");
                    addYTick("-PI", -Math.PI);
                    addYTick("-PI/2", -Math.PI / 2);
                    addYTick("0", 0);
                    addYTick("PI/2", Math.PI / 2);
                    addYTick("PI", Math.PI);
                    setMarksStyle("none");
                    setImpulses(true);

                    boolean first = true;

                    for (int i = 0; i <= 100; i++) {
                        double xvalue = i;

                        // NOTE: jdk 1.3beta has a bug exhibited here.
                        // The value of the second argument in the calls
                        // to addPoint() below is corrupted the second
                        // time that this method is called.  The print
                        // statement below shows that the value is
                        // correct before the call.
                        // System.out.println("x value: " + xvalue);
                        // For some bizarre reason, this problem goes
                        // away when this code is executed in the event
                        // dispatch thread.
                        addPoint(0, xvalue, 5 * Math.cos((Math.PI * i) / 20),
                                !first);
                        addPoint(1, xvalue, 4.5 * Math.cos((Math.PI * i) / 25),
                                !first);
                        addPoint(2, xvalue, 4 * Math.cos((Math.PI * i) / 30),
                                !first);
                        addPoint(3, xvalue, 3.5 * Math.cos((Math.PI * i) / 35),
                                !first);
                        addPoint(4, xvalue, 3 * Math.cos((Math.PI * i) / 40),
                                !first);
                        addPoint(5, xvalue, 2.5 * Math.cos((Math.PI * i) / 45),
                                !first);
                        addPoint(6, xvalue, 2 * Math.cos((Math.PI * i) / 50),
                                !first);
                        addPoint(7, xvalue, 1.5 * Math.cos((Math.PI * i) / 55),
                                !first);
                        addPoint(8, xvalue, 1 * Math.cos((Math.PI * i) / 60),
                                !first);
                        addPoint(9, xvalue, 0.5 * Math.cos((Math.PI * i) / 65),
                                !first);
                        first = false;
                    } // for
                } // synchronized

                repaint();
            } // run method
        }; // Runnable class

        deferIfNecessary(sample);
    }

Here is the call graph for this function:

synchronized void ptolemy.plot.PlotBox.setBackground ( Color  background) [inline, inherited]

Set the background color.

Parameters:
backgroundThe background color.

Definition at line 1184 of file PlotBox.java.

                                                             {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _background = background;
        super.setBackground(_background);
    }

Here is the caller graph for this function:

void ptolemy.plot.Plot.setBars ( boolean  on) [inline, inherited]

Turn bars on or off (for bar charts).

Note that this is a global property, not per dataset.

Parameters:
onIf true, turn bars on.

Definition at line 577 of file Plot.java.

                                    {
        // Ensure replot of offscreen buffer.
        _plotImage = null;
        _bars = on;
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.Plot.setBars ( double  width,
double  offset 
) [inline, inherited]

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 i < sup>th data set is shifted to the right, so that it peeks out from behind the earlier data sets.

Parameters:
widthThe width of the bars.
offsetThe offset per data set.

Definition at line 590 of file Plot.java.

                                                                  {
        // Ensure replot of offscreen buffer.
        _plotImage = null;
        barWidth = width;
        _barOffset = offset;
        _bars = true;
    }
synchronized void ptolemy.plot.PlotBox.setBounds ( int  x,
int  y,
int  width,
int  height 
) [inline, inherited]

Move and resize this component.

The new location of the top-left corner is specified by x and y, and the new size is specified by width and height. This overrides the base class method to make a record of the new size.

Parameters:
xThe new x-coordinate of this component.
yThe new y-coordinate of this component.
widthThe new width of this component.
heightThe new height of this component.

Definition at line 1201 of file PlotBox.java.

                                                                            {
        _width = width;
        _height = height;

        // Resizing the component means we need to redraw the buffer.
        _plotImage = null;

        super.setBounds(x, y, _width, _height);
    }
synchronized void ptolemy.plot.PlotBox.setButtons ( boolean  visible) [inline, inherited]

If the argument is true, make a fill button visible at the upper right.

This button auto-scales the plot. NOTE: The button may infringe on the title space, if the title is long. In an application, it is preferable to provide a menu with the fill command. This way, when printing the plot, the printed plot will not have a spurious button. Thus, this method should be used only by applets, which normally do not have menus. This method should only be called from within the event dispatch thread, since it interacts with swing.

Reimplemented in ptolemy.plot.PlotLive.

Definition at line 1221 of file PlotBox.java.

                                                         {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        if (_printButton == null) {
            // Load the image by using the absolute path to the gif.
            URL img = null;
            try {
                // FindBugs: Usage of GetResource may be unsafe if
                // class is extended
                img = FileUtilities.nameToURL(
                        "$CLASSPATH/ptolemy/plot/img/print.gif", null, null);
            } catch (IOException ex) {
                ex.printStackTrace();
            }

            if (img != null) {
                ImageIcon printIcon = new ImageIcon(img);
                _printButton = new JButton(printIcon);
                _printButton.setBorderPainted(false);
            } else {
                // Backup in case something goes wrong with the
                // class loader.
                _printButton = new JButton("P");
            }

            // FIXME: If we failed to get an image, then the letter "P"
            // Is not likely to fit into a 20x20 button.
            _printButton.setPreferredSize(new Dimension(20, 20));
            _printButton.setToolTipText("Print the plot.");
            _printButton.addActionListener(new ButtonListener());
            add(_printButton);
        }

        _printButton.setVisible(visible);

        if (_resetButton == null) {
            // Load the image by using the absolute path to the gif.
            URL img = null;
            try {
                // FindBugs: Usage of GetResource may be unsafe if
                // class is extended
                img = FileUtilities.nameToURL(
                        "$CLASSPATH/ptolemy/plot/img/reset.gif", null, null);
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            if (img != null) {
                ImageIcon resetIcon = new ImageIcon(img);
                _resetButton = new JButton(resetIcon);
                _resetButton.setBorderPainted(false);
            } else {
                // Backup in case something goes wrong with the
                // class loader.
                _resetButton = new JButton("R");
            }

            // FIXME: If we failed to get an image, then the letter "R"
            // Is not likely to fit into a 20x20 button.
            _resetButton.setPreferredSize(new Dimension(20, 20));
            _resetButton
                    .setToolTipText("Reset X and Y ranges to their original values");
            _resetButton.addActionListener(new ButtonListener());
            add(_resetButton);
        }

        _resetButton.setVisible(visible);

        if (_formatButton == null) {
            // Load the image by using the absolute path to the gif.
            URL img = null;
            try {
                // FindBugs: Usage of GetResource may be unsafe if
                // class is extended
                img = FileUtilities.nameToURL(
                        "$CLASSPATH/ptolemy/plot/img/format.gif", null, null);
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            if (img != null) {
                ImageIcon formatIcon = new ImageIcon(img);
                _formatButton = new JButton(formatIcon);
                _formatButton.setBorderPainted(false);
            } else {
                // Backup in case something goes wrong with the
                // class loader.
                _formatButton = new JButton("S");
            }

            // FIXME: If we failed to get an image, then the letter "S"
            // Is not likely to fit into a 20x20 button.
            _formatButton.setPreferredSize(new Dimension(20, 20));
            _formatButton.setToolTipText("Set the plot format");
            _formatButton.addActionListener(new ButtonListener());
            add(_formatButton);
        }

        _formatButton.setVisible(visible);

        if (_fillButton == null) {
            // Load the image by using the absolute path to the gif.
            URL img = null;
            try {
                // FindBugs: Usage of GetResource may be unsafe if
                // class is extended
                img = FileUtilities.nameToURL(
                        "$CLASSPATH/ptolemy/plot/img/fill.gif", null, null);
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            if (img != null) {
                ImageIcon fillIcon = new ImageIcon(img);
                _fillButton = new JButton(fillIcon);
                _fillButton.setBorderPainted(false);
            } else {
                // Backup in case something goes wrong with the
                // class loader.
                _fillButton = new JButton("F");
            }

            // FIXME: If we failed to get an image, then the letter "F"
            // Is not likely to fit into a 20x20 button.
            _fillButton.setPreferredSize(new Dimension(20, 20));
            _fillButton.setToolTipText("Rescale the plot to fit the data");
            _fillButton.addActionListener(new ButtonListener());
            add(_fillButton);
        }

        _fillButton.setVisible(visible);

        // Request the focus so that key events are heard.
        // NOTE: no longer needed?
        // requestFocus();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotBox.setColor ( boolean  useColor) [inline, inherited]

If the argument is false, draw the plot without using color (in black and white).

Otherwise, draw it in color (the default).

Parameters:
useColorFalse to draw in back and white.

Definition at line 1360 of file PlotBox.java.

                                                        {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _usecolor = useColor;
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotBox.setColors ( Color[]  colors) [inline, inherited]

Set the point colors.

Note that the default colors have been carefully selected to maximize readability and that it is easy to use colors that result in a very ugly plot.

Parameters:
colorsArray of colors to use in succession for data sets.
See also:
getColors()

Definition at line 1373 of file PlotBox.java.

                                                       {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _colors = colors;
    }
void ptolemy.plot.Plot.setConnected ( boolean  on) [inline, inherited]

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(). Also, a different default can be set for each dataset, overriding this global default.

Parameters:
onIf true, draw lines between points.
See also:
setConnected(boolean, int)

Definition at line 607 of file Plot.java.

                                         {
        // Ensure replot of offscreen buffer.
        _plotImage = null;
        _connected = on;
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.Plot.setConnected ( boolean  on,
int  dataset 
) [inline, inherited]

If the first argument is true, then by default for the specified dataset, points will be connected by a line.

Otherwise, the points will not be connected. When points are by default connected, individual points can be not connected by giving the appropriate argument to addPoint(). Note that this method should be called before adding any points. Note further that this method should probably be called from the event thread.

Parameters:
onIf true, draw lines between points.
datasetThe dataset to which this should apply.
See also:
setConnected(boolean)

Definition at line 625 of file Plot.java.

                                                                   {
        // Ensure replot of offscreen buffer.
        _plotImage = null;
        _checkDatasetIndex(dataset);

        Format fmt = (Format) _formats.elementAt(dataset);
        fmt.connected = on;
        fmt.connectedUseDefault = false;
    }

Here is the call graph for this function:

void ptolemy.plot.PlotBox.setDataurl ( String  filespec) [inline, inherited]

Set the file to read when init() is called.

This method is deprecated. Use read() instead.

Deprecated:

Definition at line 1384 of file PlotBox.java.

                                            {
        _filespec = filespec;
    }
void ptolemy.plot.PlotBox.setDocumentBase ( URL  documentBase) [inline, inherited]

Set the document base to used when init() is called to read a URL.

This method is deprecated. Use read() instead.

Deprecated:

Definition at line 1392 of file PlotBox.java.

                                                  {
        _documentBase = documentBase;
    }
void ptolemy.plot.EditablePlot.setEditable ( int  dataset) [inline]

Specify which dataset is editable.

By default, if this method is not called, dataset number zero is editable. If you call this method with a negative number, then no dataset will be editable.

Parameters:
datasetThe editable dataset.

Definition at line 175 of file EditablePlot.java.

                                         {
        if (dataset >= 0) {
            _checkDatasetIndex(dataset);
        }

        _dataset = dataset;
    }

Here is the call graph for this function:

synchronized void ptolemy.plot.PlotBox.setForeground ( Color  foreground) [inline, inherited]

Set the foreground color.

Parameters:
foregroundThe foreground color.

Definition at line 1399 of file PlotBox.java.

                                                             {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _foreground = foreground;
        super.setForeground(_foreground);
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotBox.setGrid ( boolean  grid) [inline, inherited]

Control whether the grid is drawn.

Parameters:
gridIf true, a grid is drawn.

Definition at line 1410 of file PlotBox.java.

                                                   {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _grid = grid;
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.Plot.setImpulses ( boolean  on) [inline, inherited]

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:
onIf true, draw a stem plot.

Definition at line 640 of file Plot.java.

                                                     {
        // Ensure replot of offscreen buffer.
        _plotImage = null;
        _impulses = on;
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.Plot.setImpulses ( boolean  on,
int  dataset 
) [inline, inherited]

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:
onIf true, draw a stem plot.
datasetThe dataset to which this should apply.

Definition at line 653 of file Plot.java.

                                                                  {
        // Ensure replot of offscreen buffer.
        _plotImage = null;
        _checkDatasetIndex(dataset);

        Format fmt = (Format) _formats.elementAt(dataset);
        fmt.impulses = on;
        fmt.impulsesUseDefault = false;
    }

Here is the call graph for this function:

synchronized void ptolemy.plot.PlotBox.setLabelFont ( String  name) [inline, inherited]

Set the label font, which is used for axis labels and legend labels.

The font names understood are those understood by java.awt.Font.decode().

Parameters:
nameA font name.

Definition at line 1422 of file PlotBox.java.

                                                       {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _labelFont = Font.decode(name);
        _labelFontMetrics = getFontMetrics(_labelFont);
    }
synchronized void ptolemy.plot.Plot.setMarksStyle ( String  style) [inline, inherited]

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. This method should be called only from the event dispatch thread.

Parameters:
styleA string specifying the style for points.

Definition at line 669 of file Plot.java.

                                                         {
        // Ensure replot of offscreen buffer.
        _plotImage = null;

        if (style.equalsIgnoreCase("none")) {
            _marks = 0;
        } else if (style.equalsIgnoreCase("points")) {
            _marks = 1;
        } else if (style.equalsIgnoreCase("dots")) {
            _marks = 2;
        } else if (style.equalsIgnoreCase("various")) {
            _marks = 3;
        } else if (style.equalsIgnoreCase("pixels")) {
            _marks = 4;
        }
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.Plot.setMarksStyle ( String  style,
int  dataset 
) [inline, inherited]

Set the marks style to "none", "points", "dots", "various", or "pixels" for the specified dataset.

In the last case, unique marks are used for the first ten data sets, then recycled.

Parameters:
styleA string specifying the style for points.
datasetThe dataset to which this should apply.

Definition at line 693 of file Plot.java.

                                                                      {
        // Ensure replot of offscreen buffer.
        _plotImage = null;
        _checkDatasetIndex(dataset);

        Format fmt = (Format) _formats.elementAt(dataset);

        if (style.equalsIgnoreCase("none")) {
            fmt.marks = 0;
        } else if (style.equalsIgnoreCase("points")) {
            fmt.marks = 1;
        } else if (style.equalsIgnoreCase("dots")) {
            fmt.marks = 2;
        } else if (style.equalsIgnoreCase("various")) {
            fmt.marks = 3;
        } else if (style.equalsIgnoreCase("pixels")) {
            fmt.marks = 4;
        }

        fmt.marksUseDefault = false;
    }

Here is the call graph for this function:

void ptolemy.plot.Plot.setNumSets ( int  numSets) [inline, inherited]

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.

Parameters:
numSetsThe number of data sets.
Deprecated:

Definition at line 721 of file Plot.java.

                                        {
        // Ensure replot of offscreen buffer.
        _plotImage = null;

        if (numSets < 1) {
            throw new IllegalArgumentException("Number of data sets ("
                    + numSets + ") must be greater than 0.");
        }

        _currentdataset = -1;
        _points.removeAllElements();
        _formats.removeAllElements();
        _prevx.removeAllElements();
        _prevy.removeAllElements();

        for (int i = 0; i < numSets; i++) {
            _points.addElement(new Vector());
            _formats.addElement(new Format());
            _prevx.addElement(_initialPreviousValue);
            _prevy.addElement(_initialPreviousValue);
        }
    }
synchronized void ptolemy.plot.PlotBox.setPlotRectangle ( Rectangle  rectangle) [inline, inherited]

Set the plot rectangle inside the axes.

This method can be used to create two plots that share the same axes.

Parameters:
rectangleRectangle space inside axes.
See also:
getPlotRectangle()

Definition at line 1435 of file PlotBox.java.

                                                                   {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _specifiedPlotRectangle = rectangle;
    }
void ptolemy.plot.Plot.setPointsPersistence ( int  persistence) [inline, inherited]

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.

Setting the persistence greater than zero forces the plot to be drawn in XOR mode, which allows points to be quickly and efficiently erased. However, there is a bug in Java (as of version 1.3), where XOR mode does not work correctly with double buffering. Thus, if you call this with an argument greater than zero, then we turn off double buffering for this panel and all of its parents. This actually happens on the next call to addPoint().

Definition at line 760 of file Plot.java.

                                                      {
        // Ensure replot of offscreen buffer.
        _plotImage = null;

        // NOTE: No file format.  It's not clear it makes sense to have one.
        _pointsPersistence = persistence;
    }
void ptolemy.plot.Plot.setReuseDatasets ( boolean  on) [inline, inherited]

If the argument is true, then datasets with the same name are merged into a single dataset.

Parameters:
onIf true, then merge datasets.
See also:
getReuseDatasets()

Definition at line 773 of file Plot.java.

                                             {
        // Ensure replot of offscreen buffer.
        _plotImage = null;
        _reuseDatasets = on;
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotBox.setSize ( int  width,
int  height 
) [inline, inherited]

Set the size of the plot.

This overrides the base class to make it work. In particular, it records the specified size so that getMinimumSize() and getPreferredSize() return the specified value. However, it only works if the plot is placed in its own JPanel. This is because the JPanel asks the contained component for its preferred size before determining the size of the panel. If the plot is placed directly in the content pane of a JApplet, then, mysteriously, this method has no effect.

Parameters:
widthThe width, in pixels.
heightThe height, in pixels.

Definition at line 1453 of file PlotBox.java.

                                                            {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _width = width;
        _height = height;
        _preferredWidth = width;
        _preferredHeight = height;

        //_sizeHasBeenSet = true;
        super.setSize(width, height);
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotBox.setTitle ( String  title) [inline, inherited]

Set the title of the graph.

Parameters:
titleThe title.

Definition at line 1469 of file PlotBox.java.

                                                    {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _title = title;
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotBox.setTitleFont ( String  name) [inline, inherited]

Set the title font.

The font names understood are those understood by java.awt.Font.decode().

Parameters:
nameA font name.

Definition at line 1481 of file PlotBox.java.

                                                       {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _titleFont = Font.decode(name);
        _titleFontMetrics = getFontMetrics(_titleFont);
    }
synchronized void ptolemy.plot.PlotBox.setWrap ( boolean  wrap) [inline, inherited]

Specify whether the X axis is wrapped.

If it is, then X values that are out of range are remapped to be in range using modulo arithmetic. The X range is determined by the most recent call to setXRange() (or the most recent zoom). If the X range has not been set, then use the default X range, or if data has been plotted, then the current fill range.

Parameters:
wrapIf true, wrapping of the X axis is enabled.

Definition at line 1497 of file PlotBox.java.

                                                   {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _wrap = wrap;

        if (!_xRangeGiven) {
            if (_xBottom > _xTop) {
                // have nothing to go on.
                setXRange(0, 0);
            } else {
                setXRange(_xBottom, _xTop);
            }
        }

        _wrapLow = _xlowgiven;
        _wrapHigh = _xhighgiven;
    }

Here is the call graph for this function:

synchronized void ptolemy.plot.PlotBox.setXLabel ( String  label) [inline, inherited]

Set the label for the X (horizontal) axis.

Parameters:
labelThe label.

Definition at line 1519 of file PlotBox.java.

                                                     {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _xlabel = label;
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotBox.setXLog ( boolean  xlog) [inline, inherited]

Specify whether the X axis is drawn with a logarithmic scale.

If you would like to have the X axis drawn with a logarithmic axis, then setXLog(true) should be called before adding any data points.

Parameters:
xlogIf true, logarithmic axis is used.

Definition at line 1532 of file PlotBox.java.

                                                   {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _xlog = xlog;
    }
void ptolemy.plot.Plot.setXPersistence ( double  persistence) [inline, inherited]

Calling this method with a positive argument sets the persistence of the plot to the given width in units of the horizontal axis.

Calling with a zero argument turns off this feature, reverting to infinite memory (unless points persistence is set). If both X and points persistence are set then both are applied, meaning that points that are old by either criterion will be erased.

Setting the X persistence greater than zero forces the plot to be drawn in XOR mode, which allows points to be quickly and efficiently erased. However, there is a bug in Java (as of version 1.3), where XOR mode does not work correctly with double buffering. Thus, if you call this with an argument greater than zero, then we turn off double buffering for this panel and all of its parents. This actually happens on the next call to addPoint().

Definition at line 797 of file Plot.java.

                                                    {
        // Ensure replot of offscreen buffer.
        _plotImage = null;

        // NOTE: No file format.  It's not clear it makes sense to have one.
        _xPersistence = persistence;
    }
synchronized void ptolemy.plot.PlotBox.setXRange ( double  min,
double  max 
) [inline, inherited]

Set the X (horizontal) range of the plot.

If this is not done explicitly, then the range is computed automatically from data available when the plot is drawn. If min and max are identical, then the range is arbitrarily spread by 1.

Parameters:
minThe left extent of the range.
maxThe right extent of the range.

Definition at line 1546 of file PlotBox.java.

                                                               {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _xRangeGiven = true;
        _xlowgiven = min;
        _xhighgiven = max;
        _setXRange(min, max);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotBox.setYLabel ( String  label) [inline, inherited]

Set the label for the Y (vertical) axis.

Parameters:
labelThe label.

Definition at line 1559 of file PlotBox.java.

                                                     {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _ylabel = label;
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotBox.setYLog ( boolean  ylog) [inline, inherited]

Specify whether the Y axis is drawn with a logarithmic scale.

If you would like to have the Y axis drawn with a logarithmic axis, then setYLog(true) should be called before adding any data points.

Parameters:
ylogIf true, logarithmic axis is used.

Definition at line 1572 of file PlotBox.java.

                                                   {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _ylog = ylog;
    }
synchronized void ptolemy.plot.PlotBox.setYRange ( double  min,
double  max 
) [inline, inherited]

Set the Y (vertical) range of the plot.

If this is not done explicitly, then the range is computed automatically from data available when the plot is drawn. If min and max are identical, then the range is arbitrarily spread by 0.1.

Parameters:
minThe bottom extent of the range.
maxThe top extent of the range.

Definition at line 1586 of file PlotBox.java.

                                                               {
        // Changing legend means we need to repaint the offscreen buffer.
        _plotImage = null;

        _yRangeGiven = true;
        _ylowgiven = min;
        _yhighgiven = max;
        _setYRange(min, max);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void ptolemy.plot.EditablePlot.undo ( ) [inline]

Undo the latest signal editing operation, if there was one.

Otherwise, do nothing.

Definition at line 186 of file EditablePlot.java.

                       {
        if (_undoStack.empty()) {
            return;
        }

        Object[] save = new Object[2];
        save[0] = Integer.valueOf(_dataset);
        save[1] = getData(_dataset);
        _redoStack.push(save);

        Object[] saved = (Object[]) _undoStack.pop();
        _setData(((Integer) saved[0]).intValue(), (double[][]) saved[1]);

        // Ensure replot of offscreen buffer.
        _plotImage = null;
        repaint();
        _notifyListeners(_dataset);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void ptolemy.plot.PlotBox.write ( OutputStream  out) [inline, inherited]

Write the current data and plot configuration to the specified stream in PlotML syntax.

PlotML is an XML extension for plot data. The written information is standalone, in that it includes the DTD (document type definition). This makes is somewhat verbose. To get smaller files, use the two argument version of write(). The output is buffered, and is flushed and closed before exiting. Derived classes should override writeFormat and writeData rather than this method.

Parameters:
outAn output stream.

Definition at line 1607 of file PlotBox.java.

                                        {
        write(out, null);
    }

Here is the caller graph for this function:

synchronized void ptolemy.plot.PlotBox.write ( OutputStream  out,
String  dtd 
) [inline, inherited]

Write the current data and plot configuration to the specified stream in PlotML syntax.

PlotML is an XML scheme for plot data. The URL (relative or absolute) for the DTD is given as the second argument. If that argument is null, then the PlotML PUBLIC DTD is referenced, resulting in a file that can be read by a PlotML parser without any external file references, as long as that parser has local access to the DTD. The output is buffered, and is flushed and closed before exiting. Derived classes should override writeFormat and writeData rather than this method.

Parameters:
outAn output stream.
dtdThe reference (URL) for the DTD, or null to use the PUBLIC DTD.

Definition at line 1625 of file PlotBox.java.

                                                                 {
        write(new OutputStreamWriter(out), dtd);
    }

Here is the call graph for this function:

synchronized void ptolemy.plot.PlotBox.write ( Writer  out,
String  dtd 
) [inline, inherited]

Write the current data and plot configuration to the specified stream in PlotML syntax.

PlotML is an XML scheme for plot data. The URL (relative or absolute) for the DTD is given as the second argument. If that argument is null, then the PlotML PUBLIC DTD is referenced, resulting in a file that can be read by a PlotML parser without any external file references, as long as that parser has local access to the DTD. The output is buffered, and is flushed before exiting.

Parameters:
outAn output writer.
dtdThe reference (URL) for the DTD, or null to use the PUBLIC DTD.

Reimplemented in ptolemy.plot.Histogram.

Definition at line 1641 of file PlotBox.java.

                                                           {
        // Auto-flush is disabled.
        PrintWriter output = new PrintWriter(new BufferedWriter(out), false);

        if (dtd == null) {
            output.println("<?xml version=\"1.0\" standalone=\"yes\"?>");
            output
                    .println("<!DOCTYPE plot PUBLIC \"-//UC Berkeley//DTD PlotML 1//EN\"");
            output
                    .println("    \"http://ptolemy.eecs.berkeley.edu/xml/dtd/PlotML_1.dtd\">");
        } else {
            output.println("<?xml version=\"1.0\" standalone=\"no\"?>");
            output.println("<!DOCTYPE plot SYSTEM \"" + dtd + "\">");
        }

        output.println("<plot>");
        output.println("<!-- Ptolemy plot, version " + PTPLOT_RELEASE
                + " , PlotML format. -->");
        writeFormat(output);
        writeData(output);
        output.println("</plot>");
        output.flush();

        // NOTE: We used to close the stream, but if this is part
        // of an exportMoML operation, that is the wrong thing to do.
        // if (out != System.out) {
        //    output.close();
        // }
    }

Here is the call graph for this function:

synchronized void ptolemy.plot.Plot.writeData ( PrintWriter  output) [inline, inherited]

Write plot data information to the specified output stream in PlotML.

Parameters:
outputA buffered print writer.

Reimplemented from ptolemy.plot.PlotBox.

Definition at line 808 of file Plot.java.

                                                           {
        super.writeData(output);

        for (int dataset = 0; dataset < _points.size(); dataset++) {
            StringBuffer options = new StringBuffer();

            Format fmt = (Format) _formats.elementAt(dataset);

            if (!fmt.connectedUseDefault) {
                if (_isConnected(dataset)) {
                    options.append(" connected=\"yes\"");
                } else {
                    options.append(" connected=\"no\"");
                }
            }

            if (!fmt.impulsesUseDefault) {
                if (fmt.impulses) {
                    options.append(" stems=\"yes\"");
                } else {
                    output.println(" stems=\"no\"");
                }
            }

            if (!fmt.marksUseDefault) {
                switch (fmt.marks) {
                case 0:
                    options.append(" marks=\"none\"");
                    break;

                case 1:
                    options.append(" marks=\"points\"");
                    break;

                case 2:
                    options.append(" marks=\"dots\"");
                    break;

                case 3:
                    options.append(" marks=\"various\"");
                    break;

                case 4:
                    options.append(" marks=\"pixels\"");
                    break;
                }
            }

            String legend = getLegend(dataset);

            if (legend != null) {
                options.append(" name=\"" + getLegend(dataset) + "\"");
            }

            output.println("<dataset" + options.toString() + ">");

            // Write the data
            Vector pts = (Vector) _points.elementAt(dataset);

            for (int pointnum = 0; pointnum < pts.size(); pointnum++) {
                PlotPoint pt = (PlotPoint) pts.elementAt(pointnum);

                if (!pt.connected) {
                    output.print("<m ");
                } else {
                    output.print("<p ");
                }

                output.print("x=\"" + pt.x + "\" y=\"" + pt.y + "\"");

                if (pt.errorBar) {
                    output.print(" lowErrorBar=\"" + pt.yLowEB
                            + "\" highErrorBar=\"" + pt.yHighEB + "\"");
                }

                output.println("/>");
            }

            output.println("</dataset>");
        }
    }

Here is the call graph for this function:

synchronized void ptolemy.plot.Plot.writeFormat ( PrintWriter  output) [inline, inherited]

Write plot format information to the specified output stream in PlotML, an XML scheme.

Parameters:
outputA buffered print writer.

Reimplemented from ptolemy.plot.PlotBox.

Definition at line 894 of file Plot.java.

                                                             {
        super.writeFormat(output);

        if (_reuseDatasets) {
            output.println("<reuseDatasets/>");
        }

        StringBuffer defaults = new StringBuffer();

        if (!_connected) {
            defaults.append(" connected=\"no\"");
        }

        switch (_marks) {
        case 1:
            defaults.append(" marks=\"points\"");
            break;

        case 2:
            defaults.append(" marks=\"dots\"");
            break;

        case 3:
            defaults.append(" marks=\"various\"");
            break;

        case 4:
            defaults.append(" marks=\"pixels\"");
            break;
        }

        // Write the defaults for formats that can be controlled by dataset
        if (_impulses) {
            defaults.append(" stems=\"yes\"");
        }

        if (defaults.length() > 0) {
            output.println("<default" + defaults.toString() + "/>");
        }

        if (_bars) {
            output.println("<barGraph width=\"" + barWidth + "\" offset=\""
                    + _barOffset + "\"/>");
        }
    }
synchronized void ptolemy.plot.PlotBox.writeOldSyntax ( OutputStream  out) [inline, inherited]

Write the current data and plot configuration to the specified stream in the old PtPlot syntax.

The output is buffered, and is flushed and closed before exiting. Derived classes should override _writeOldSyntax() rather than this method.

Parameters:
outAn output stream.
Deprecated:

Definition at line 1767 of file PlotBox.java.

                                                              {
        // Auto-flush is disabled.
        PrintWriter output = new PrintWriter(new BufferedOutputStream(out),
                false);
        _writeOldSyntax(output);
        output.flush();

        // Avoid closing standard out.
        if (out != System.out) {
            output.close();
        }
    }

Here is the call graph for this function:

synchronized void ptolemy.plot.PlotBox.zoom ( double  lowx,
double  lowy,
double  highx,
double  highy 
) [inline, inherited]

Zoom in or out to the specified rectangle.

This method calls repaint().

Parameters:
lowxThe low end of the new X range.
lowyThe low end of the new Y range.
highxThe high end of the new X range.
highyThe high end of the new Y range.

Definition at line 1787 of file PlotBox.java.

                          {
        setXRange(lowx, highx);
        setYRange(lowy, highy);
        repaint();
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Color ptolemy.plot.PlotBox._background = Color.white [protected, inherited]

Color of the background, settable from HTML.

Definition at line 2885 of file PlotBox.java.

int ptolemy.plot.PlotBox._bottomPadding = 5 [protected, inherited]

Bottom padding.

Derived classes can increment these to make space around the plot.

Definition at line 2898 of file PlotBox.java.

Color [] ptolemy.plot.PlotBox._colors [static, protected, inherited]
Initial value:
 { new Color(0xff0000), 
            new Color(0x0000ff), 
            new Color(0x00aaaa), 
            new Color(0x000000), 
            new Color(0xffa500), 
            new Color(0x53868b), 
            new Color(0xff7f50), 
            new Color(0x45ab1f), 
            new Color(0x90422d), 
            new Color(0xa0a0a0), 
            new Color(0x14ff14), 
    }

Definition at line 2949 of file PlotBox.java.

int ptolemy.plot.Plot._currentdataset = -1 [protected, inherited]

The current dataset.

Definition at line 1868 of file Plot.java.

Definition at line 435 of file EditablePlot.java.

Definition at line 437 of file EditablePlot.java.

Definition at line 439 of file EditablePlot.java.

URL ptolemy.plot.PlotBox._documentBase = null [inherited]

Indicator that size has been set.

The document base we use to find the _filespec. NOTE: Use of this variable is deprecated. But it is made available to derived classes for backward compatibility. FIXME: Sun's appletviewer gives an exception if this is protected. Why?? So we make it temporarily public.

Definition at line 2983 of file PlotBox.java.

final Color ptolemy.plot.EditablePlot._editColor = Color.white [static, private]

Definition at line 444 of file EditablePlot.java.

Definition at line 452 of file EditablePlot.java.

Definition at line 433 of file EditablePlot.java.

Definition at line 427 of file EditablePlot.java.

Definition at line 431 of file EditablePlot.java.

Color ptolemy.plot.PlotBox._foreground = Color.black [protected, inherited]

Color of the foreground, settable from HTML.

Definition at line 2888 of file PlotBox.java.

boolean ptolemy.plot.PlotBox._grid = true [protected, inherited]

Whether to draw a background grid.

Definition at line 2873 of file PlotBox.java.

int ptolemy.plot.PlotBox._height = 300 [protected, inherited]

Width and height of component in pixels.

Definition at line 2966 of file PlotBox.java.

int ptolemy.plot.PlotBox._leftPadding = 10 [protected, inherited]

Left padding.

Derived classes can increment these to make space around the plot.

Definition at line 2908 of file PlotBox.java.

final double ptolemy.plot.PlotBox._LOG10SCALE = 1 / Math.log(10) [static, protected, inherited]

Definition at line 2870 of file PlotBox.java.

int ptolemy.plot.PlotBox._lrx = 100 [protected, inherited]

The x value of the lower right corner of the plot rectangle in pixels.

Definition at line 2921 of file PlotBox.java.

int ptolemy.plot.PlotBox._lry = 100 [protected, inherited]

The y value of the lower right corner of the plot rectangle in pixels.

Definition at line 2925 of file PlotBox.java.

int ptolemy.plot.Plot._marks [protected, inherited]

An indicator of the marks style.

See _parseLine method for interpretation.

Definition at line 1876 of file Plot.java.

double ptolemy.plot.PlotBox._originalXhigh = 0.0 [package, inherited]

Definition at line 4014 of file PlotBox.java.

double ptolemy.plot.PlotBox._originalXlow = 0.0 [package, inherited]

Definition at line 4011 of file PlotBox.java.

Definition at line 4005 of file PlotBox.java.

double ptolemy.plot.PlotBox._originalYhigh = 0.0 [package, inherited]

Definition at line 4020 of file PlotBox.java.

double ptolemy.plot.PlotBox._originalYlow = 0.0 [package, inherited]

Definition at line 4017 of file PlotBox.java.

Definition at line 4008 of file PlotBox.java.

double ptolemy.plot.PlotBox._padding = 0.05 [protected, inherited]

The factor we pad by so that we don't plot points on the axes.

Definition at line 2810 of file PlotBox.java.

transient BufferedImage ptolemy.plot.PlotBox._plotImage = null [protected, inherited]

Definition at line 4023 of file PlotBox.java.

Vector ptolemy.plot.Plot._points = new Vector() [protected, inherited]

A vector of datasets.

Definition at line 1871 of file Plot.java.

int ptolemy.plot.PlotBox._preferredHeight = 300 [protected, inherited]

Width and height of component in pixels.

Definition at line 2972 of file PlotBox.java.

int ptolemy.plot.PlotBox._preferredWidth = 500 [protected, inherited]

Width and height of component in pixels.

Definition at line 2969 of file PlotBox.java.

transient boolean ptolemy.plot.PlotBox._rangesGivenByZooming = false [protected, inherited]

Definition at line 2817 of file PlotBox.java.

Stack ptolemy.plot.EditablePlot._redoStack = new Stack() [private]

Definition at line 449 of file EditablePlot.java.

int ptolemy.plot.PlotBox._rightPadding = 10 [protected, inherited]

Right padding.

Derived classes can increment these to make space around the plot.

Definition at line 2903 of file PlotBox.java.

Rectangle ptolemy.plot.PlotBox._specifiedPlotRectangle = null [protected, inherited]

User specified plot rectangle, null if none specified.

See also:
setPlotRectangle(Rectangle)

Definition at line 2930 of file PlotBox.java.

int ptolemy.plot.PlotBox._topPadding = 10 [protected, inherited]

Top padding.

Derived classes can increment these to make space around the plot.

Definition at line 2893 of file PlotBox.java.

int ptolemy.plot.PlotBox._ulx = 1 [protected, inherited]

The x value of the upper left corner of the plot rectangle in pixels.

Definition at line 2914 of file PlotBox.java.

int ptolemy.plot.PlotBox._uly = 1 [protected, inherited]

The y value of the upper left corner of the plot rectangle in pixels.

Definition at line 2917 of file PlotBox.java.

Stack ptolemy.plot.EditablePlot._undoStack = new Stack() [private]

Definition at line 447 of file EditablePlot.java.

boolean ptolemy.plot.PlotBox._usecolor = true [protected, inherited]

Indicator whether to use _colors.

Definition at line 2943 of file PlotBox.java.

int ptolemy.plot.PlotBox._width = 500 [protected, inherited]

Width and height of component in pixels.

Definition at line 2963 of file PlotBox.java.

boolean ptolemy.plot.PlotBox._wrap = false [protected, inherited]

Whether to wrap the X axis.

Definition at line 2876 of file PlotBox.java.

double ptolemy.plot.PlotBox._wrapHigh [protected, inherited]

The high range of the X axis for wrapping.

Definition at line 2879 of file PlotBox.java.

double ptolemy.plot.PlotBox._wrapLow [protected, inherited]

The low range of the X axis for wrapping.

Definition at line 2882 of file PlotBox.java.

double ptolemy.plot.PlotBox._xBottom = Double.MAX_VALUE [protected, inherited]

The minimum X value registered so for, for auto ranging.

Definition at line 2852 of file PlotBox.java.

double ptolemy.plot.PlotBox._xhighgiven [protected, inherited]

The given X and Y ranges.

If they have been given the top and bottom of the x and y ranges. This is different from _xMin and _xMax, which actually represent the range of data that is plotted. This represents the range specified (which may be different due to zooming).

Definition at line 2833 of file PlotBox.java.

boolean ptolemy.plot.PlotBox._xlog = false [protected, inherited]

Whether to draw the axes using a logarithmic scale.

Definition at line 2864 of file PlotBox.java.

double ptolemy.plot.PlotBox._xlowgiven [protected, inherited]

The given X and Y ranges.

If they have been given the top and bottom of the x and y ranges. This is different from _xMin and _xMax, which actually represent the range of data that is plotted. This represents the range specified (which may be different due to zooming).

Definition at line 2825 of file PlotBox.java.

transient double ptolemy.plot.PlotBox._xMax = 0 [protected, inherited]

Definition at line 2801 of file PlotBox.java.

transient double ptolemy.plot.PlotBox._xMin = 0 [protected, inherited]

Definition at line 2806 of file PlotBox.java.

transient boolean ptolemy.plot.PlotBox._xRangeGiven = false [protected, inherited]

Definition at line 2813 of file PlotBox.java.

double ptolemy.plot.PlotBox._xscale = 1.0 [protected, inherited]

Scaling used for the horizontal axis in plotting points.

The units are pixels/unit, where unit is the units of the X axis.

Definition at line 2940 of file PlotBox.java.

double ptolemy.plot.PlotBox._xTop = -Double.MAX_VALUE [protected, inherited]

The maximum X value registered so for, for auto ranging.

Definition at line 2855 of file PlotBox.java.

double ptolemy.plot.PlotBox._yBottom = Double.MAX_VALUE [protected, inherited]

The minimum Y value registered so for, for auto ranging.

Definition at line 2858 of file PlotBox.java.

double ptolemy.plot.PlotBox._yhighgiven [protected, inherited]

The given X and Y ranges.

If they have been given the top and bottom of the x and y ranges. This is different from _xMin and _xMax, which actually represent the range of data that is plotted. This represents the range specified (which may be different due to zooming).

Definition at line 2849 of file PlotBox.java.

boolean ptolemy.plot.PlotBox._ylog = false [protected, inherited]

Whether to draw the axes using a logarithmic scale.

Definition at line 2867 of file PlotBox.java.

double ptolemy.plot.PlotBox._ylowgiven [protected, inherited]

The given X and Y ranges.

If they have been given the top and bottom of the x and y ranges. This is different from _xMin and _xMax, which actually represent the range of data that is plotted. This represents the range specified (which may be different due to zooming).

Definition at line 2841 of file PlotBox.java.

transient double ptolemy.plot.PlotBox._yMax = 0 [protected, inherited]

Definition at line 2791 of file PlotBox.java.

transient double ptolemy.plot.PlotBox._yMin = 0 [protected, inherited]

Definition at line 2796 of file PlotBox.java.

transient boolean ptolemy.plot.PlotBox._yRangeGiven = false [protected, inherited]

Definition at line 2815 of file PlotBox.java.

double ptolemy.plot.PlotBox._yscale = 1.0 [protected, inherited]

Scaling used for the vertical axis in plotting points.

The units are pixels/unit, where unit is the units of the Y axis.

Definition at line 2935 of file PlotBox.java.

double ptolemy.plot.PlotBox._yTop = -Double.MAX_VALUE [protected, inherited]

The maximum Y value registered so for, for auto ranging.

Definition at line 2861 of file PlotBox.java.

final String ptolemy.plot.PlotBox.PTPLOT_RELEASE = "5.7" [static, inherited]

Definition at line 1796 of file PlotBox.java.


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