Package ptolemy.plot

Interface PlotInterface

    • Method Detail

      • addLegend

        void addLegend​(int dataset,
                       java.lang.String legend)
        Description copied from interface: PlotBoxInterface
        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. If the string is empty, or the argument is null, then no legend is added.
        Specified by:
        addLegend in interface PlotBoxInterface
        Parameters:
        dataset - The dataset index.
        legend - The label for the dataset.
        See Also:
        PlotBoxInterface.renameLegend(int, String)
      • addPoint

        default void addPoint​(int dataset,
                              double x,
                              double y,
                              boolean connected)
        In the specified data set, add the specified x, y point to the plot. Data set indices begin with zero. If the 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:
        dataset - The data set index.
        x - The X position of the new point.
        y - The Y position of the new point.
        connected - If true, a line is drawn to connect to the previous point.
      • addPoint

        void addPoint​(int dataset,
                      double x,
                      double y,
                      double[] derivatives,
                      boolean connected)
        In the specified data set, add the specified x, y point to the plot, with derivatives optionally provided for polynomial extrapolation. 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:
        dataset - The data set index.
        x - The X position of the new point.
        y - The Y position of the new point.
        derivatives - The derivatives at the new point (optional). (The array will be copied as needed.)
        connected - If true, a line is drawn to connect to the previous point.
      • addPointWithErrorBars

        void addPointWithErrorBars​(int dataset,
                                   double x,
                                   double y,
                                   double[] derivatives,
                                   double yLowEB,
                                   double yHighEB,
                                   boolean connected)
        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 (michael@email.labmed.umn.edu).

        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:
        dataset - The data set index.
        x - The X position of the new point.
        y - The Y position of the new point.
        derivatives - The derivatives at the new point. (The array will be copied as needed.)
        yLowEB - The low point of the error bar.
        yHighEB - The high point of the error bar.
        connected - If true, a line is drawn to connect to the previous point.
      • clear

        void clear​(boolean format)
        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().
        Specified by:
        clear in interface PlotBoxInterface
        Parameters:
        format - If 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.

      • clear

        void clear​(int dataset)
        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:
        dataset - The dataset to clear.
      • erasePoint

        void erasePoint​(int dataset,
                        int index)
        Erase the point at the given index in the given dataset. If lines are being drawn, these lines are erased and if necessary new ones will be drawn. 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:
        dataset - The data set index.
        index - The index of the point to erase.
      • fillPlot

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

        Specified by:
        fillPlot in interface PlotBoxInterface
      • getConnected

        boolean getConnected()
        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.
        Returns:
        True if points will be connected by default
        See Also:
        setConnected(boolean)
      • getImpulses

        boolean getImpulses()
        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.
        Returns:
        True if this is an impulse plot
        See Also:
        setImpulses(boolean)
      • getLineStyles

        boolean getLineStyles()
        Return false if setLineStyles() has not yet been called or if setLineStyles(false) has been called, which signifies that different line styles are not to be used. Otherwise, return true.
        Returns:
        True if line styles are to be used.
        See Also:
        setLineStyles(boolean)
      • getMarksStyle

        java.lang.String getMarksStyle()
        Get the marks style, which is one of "none", "points", "dots", or "various".
        Returns:
        A string specifying the style for points.
        See Also:
        setMarksStyle(java.lang.String)
      • getMaxDataSets

        @Deprecated
        int getMaxDataSets()
        Deprecated.
        Return the maximum number of data sets. This method is deprecated, since there is no longer an upper bound.
        Returns:
        The maximum number of data sets
      • getNumDataSets

        int getNumDataSets()
        Return the actual number of data sets.
        Returns:
        The number of data sets that have been created.
      • getReuseDatasets

        boolean getReuseDatasets()
        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:
        Ptolemy II 10.0
        See Also:
        setReuseDatasets(boolean)
      • parseFile

        @Deprecated
        void parseFile​(java.lang.String filespec,
                       java.net.URL documentBase)
        Deprecated.
        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.
        Specified by:
        parseFile in interface PlotBoxInterface
        Parameters:
        filespec - The file to be read.
        documentBase - The base of the URL
      • markDisconnections

        void markDisconnections​(boolean value)
        Mark the disconnections with a Dot in case value equals true, otherwise these points are not marked.
        Parameters:
        value - True when disconnections should be marked.
      • read

        void read​(java.io.InputStream inputStream)
           throws java.io.IOException
        Read a file with the old syntax (non-XML). Override the base class to register that we are reading a new data set.
        Specified by:
        read in interface PlotBoxInterface
        Parameters:
        inputStream - The input stream.
        Throws:
        java.io.IOException - If the stream cannot be read.
      • samplePlot

        void samplePlot()
        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).
        Specified by:
        samplePlot in interface PlotBoxInterface
      • setBars

        void setBars​(boolean on)
        Turn bars on or off (for bar charts). Note that this is a global property, not per dataset.
        Parameters:
        on - If true, turn bars on.
      • setBars

        void setBars​(double width,
                     double offset)
        Turn bars on and set the width and offset. Both are specified in units of the x axis. The offset is the amount by which the i th data set is shifted to the right, so that it peeks out from behind the earlier data sets.
        Parameters:
        width - The width of the bars.
        offset - The offset per data set.
      • setConnected

        void setConnected​(boolean on)
        If the argument is true, then the default is to connect subsequent points with a line. If the argument is false, then points are not connected. When points are by default connected, individual points can be not connected by giving the appropriate argument to addPoint(). Also, a different default can be set for each dataset, overriding this global default. setConnected will also change the behavior of points that were already drawn if the graph is redrawn. If it isn't the points are not touched. If you change back the setConnected state, the again see what was visible before.
        Parameters:
        on - If true, draw lines between points.
        See Also:
        setConnected(boolean, int), getConnected()
      • setConnected

        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. 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:
        on - If true, draw lines between points.
        dataset - The dataset to which this should apply.
        See Also:
        setConnected(boolean), getConnected()
      • setImpulses

        void setImpulses​(boolean on)
        If the argument is true, then a line will be drawn from any plotted point down to the x axis. Otherwise, this feature is disabled. A plot with such lines is also known as a stem plot.
        Parameters:
        on - If true, draw a stem plot.
        See Also:
        getImpulses()
      • setImpulses

        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. Otherwise, this feature is disabled. A plot with such lines is also known as a stem plot.
        Parameters:
        on - If true, draw a stem plot.
        dataset - The dataset to which this should apply.
        See Also:
        getImpulses()
      • setLineStyle

        void setLineStyle​(java.lang.String styleString,
                          int dataset)
        Set the style of the lines joining marks.
        Parameters:
        styleString - A string specifying the color for points. The following styles are permitted: "solid", "dotted", "dashed", "dotdashed", "dotdotdashed".
        dataset - The data set index.
      • setLineStyles

        void setLineStyles​(boolean lineStyles)
        If the argument is true, draw the data sets with different line styles. Otherwise, use one line style.
        Parameters:
        lineStyles - True if the data sets are to be drawn in different line styles.
        See Also:
        getLineStyles()
      • setMarksStyle

        void setMarksStyle​(java.lang.String style)
        Set the marks style to "none", "points", "dots", or "various". In the last case, unique marks are used for the first ten data sets, then recycled. This method should be called only from the event dispatch thread.
        Parameters:
        style - A string specifying the style for points.
        See Also:
        getMarksStyle()
      • setMarksStyle

        void setMarksStyle​(java.lang.String style,
                           int dataset)
        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:
        style - A string specifying the style for points.
        dataset - The dataset to which this should apply.
        See Also:
        getMarksStyle()
      • setNumSets

        @Deprecated
        void setNumSets​(int numSets)
        Deprecated.
        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:
        numSets - The number of data sets.
      • setPointsPersistence

        void setPointsPersistence​(int persistence)
        Calling this method with a positive argument sets the persistence of the plot to the given number of points. Calling with a zero argument turns off this feature, reverting to infinite memory (unless sweeps persistence is set). If both sweeps and points persistence are set then sweeps take precedence.

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

        Parameters:
        persistence - Number of points to persist for.
      • setReuseDatasets

        void setReuseDatasets​(boolean on)
        If the argument is true, then datasets with the same name are merged into a single dataset.
        Parameters:
        on - If true, then merge datasets.
        See Also:
        getReuseDatasets()
      • setXPersistence

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

        Parameters:
        persistence - Persistence in units of the horizontal axis.
      • writeData

        void writeData​(java.io.PrintWriter output)
        Write plot data information to the specified output stream in PlotML.
        Specified by:
        writeData in interface PlotBoxInterface
        Parameters:
        output - A buffered print writer.
      • writeFormat

        void writeFormat​(java.io.PrintWriter output)
        Write plot format information to the specified output stream in PlotML, an XML scheme.
        Specified by:
        writeFormat in interface PlotBoxInterface
        Parameters:
        output - A buffered print writer.