Package ptolemy.plot

Class EditablePlot

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, javax.accessibility.Accessible, PlotBoxInterface, PlotInterface

    public class EditablePlot
    extends Plot
    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().

    Since:
    Ptolemy II 0.4
    Version:
    $Id$
    Author:
    Edward A. Lee
    See Also:
    Serialized Form
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (cxh)
    • Constructor Detail

      • EditablePlot

        public EditablePlot()
        Constructor.
    • Method Detail

      • getData

        public double[][] getData​(int dataset)
        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.
        Parameters:
        dataset - The dataset.
        Returns:
        The data in the specified dataset.
      • redo

        public void redo()
        Redo the latest signal editing operation that was undone by calling undo(), if there was one. Otherwise, do nothing.
      • removeEditListener

        public void removeEditListener​(EditListener listener)
        Unregister a edit listener. If the specified listener has not been previously registered, then do nothing.
        Parameters:
        listener - The listener to remove from the list of listeners to which edit events are sent.
        See Also:
        addEditListener(EditListener)
      • setEditable

        public void setEditable​(int dataset)
        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:
        dataset - The editable dataset.
      • undo

        public void undo()
        Undo the latest signal editing operation, if there was one. Otherwise, do nothing.