Documentation of 'edu.rit.numeric.plot.Plot' Java class
Plot
edu.rit.numeric.plot

Class Plot

  • All Implemented Interfaces:
    Displayable, Drawable, Viewable, java.io.Externalizable, java.io.Serializable


    public class Plot
    extends java.lang.Object
    implements Viewable, java.io.Externalizable
    Class Plot is a class for creating and displaying a plot.

    To create a plot, construct an instance of class Plot, and call the desired methods to specify attributes of the plot and to provide the data to be plotted.

    To display a plot, call the getFrame() method to get a DisplayableFrame that displays the plot in a window, then call the frame's setVisible(true) method. The frame has menus for zooming the display, for changing the plot's attributes (title, margins, grid, X axis, Y axis, etc.), and for saving the plot in a PNG or PostScript file.

    If the plot's attributes are changed after displaying the frame, call the frame's display() method, passing in a reference to the plot object. If the data in the plot's X-Y series are changed after displaying the frame, but the plot's attributes are not changed, call the frame's repaint() method.

    A Plot object can be written (serialized) into a file. The View program can be used to display the file.

    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static class  Plot.AxisKind
      Enum Plot.AxisKind enumerates the possible kinds of axis on a Plot.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static int ABOVE
      The label is positioned above its location.
      static int ABOVE_LEFT
      The label is positioned above and to the left of its location.
      static int ABOVE_RIGHT
      The label is positioned above and to the right of its location.
      static int BELOW
      The label is positioned below its location.
      static int BELOW_LEFT
      The label is positioned below and to the left of its location.
      static int BELOW_RIGHT
      The label is positioned below and to the right of its location.
      static int CENTER
      The label is centered on its location.
      static int LEFT
      The label is positioned to the left of its location.
      static Plot.AxisKind LINEAR
      Linear axis.
      static Plot.AxisKind LOGARITHMIC
      Logarithmic axis.
      static int PIXEL_COORDINATES
      The label's location is specified in pixel coordinates relative to the lower left corner of the plot area, rather than in plot coordinates.
      static int RIGHT
      The label is positioned to the right of its location.
      static int ROTATE_AROUND
      The label is rotated 180 degrees around.
      static int ROTATE_LEFT
      The label is rotated 90 degrees left (counterclockwise).
      static int ROTATE_RIGHT
      The label is rotated 90 degrees right (clockwise).
    • Constructor Summary

      Constructors 
      Constructor and Description
      Plot()
      Construct a new plot.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      Plot bottomMargin(double theMargin)
      Set the bottom margin for the plot.
      void draw(java.awt.Graphics2D g2d)
      Draw this drawable object in the given graphics context.
      Plot frameTitle(java.lang.String theTitle)
      Set the title for the frame that displays the plot.
      java.awt.Paint getBackgroundPaint()
      Returns this displayable object's background paint.
      java.awt.geom.Rectangle2D getBoundingBox()
      Returns this displayable object's bounding box.
      DisplayableFrame getFrame()
      Get a displayable frame in which to view this viewable object.
      java.lang.String getTitle()
      Get the title for the frame used to view this viewable object.
      Plot label(java.lang.String text, double x, double y)
      Add a label to this plot.
      Plot labelBackground(java.awt.Color theColor)
      Set the color to use for label backgrounds.
      Plot labelColor(java.awt.Color theColor)
      Set the color to use for labels.
      Plot labelFont(java.awt.Font theFont)
      Set the font to use for labels.
      Plot labelOffset(double theOffset)
      Set the offset to use for labels.
      Plot labelPosition(int thePosition)
      Set the positioning to use for labels.
      Plot leftMargin(double theMargin)
      Set the left margin for the plot.
      Plot majorGridLines(boolean theGridLines)
      Specify whether major division grid lines are drawn on the plot.
      Plot margins(double theMargin)
      Set the margins for the plot.
      Plot minorGridLines(boolean theGridLines)
      Specify whether minor division grid lines are drawn on the plot.
      Plot plotTitle(java.lang.String theTitle)
      Set the title for the plot.
      Plot plotTitleFont(java.awt.Font theTitleFont)
      Set the title font for the plot.
      Plot plotTitleOffset(double theTitleOffset)
      Set the offset from the plot area to the title for the plot.
      static Plot read(java.io.File theFile)
      Read a plot from the given file.
      static Plot read(java.lang.String theFileName)
      Read a plot from the file with the given name.
      void readExternal(java.io.ObjectInput in)
      Read this plot from the given object input stream.
      Plot rightMargin(double theMargin)
      Set the right margin for the plot.
      Plot segmentedSeries(double... theData)
      Add a segmented data series to this plot with data points taken from the arguments.
      Plot segmentedSeries(double[] theXArray, double[] theYArray)
      Add a segmented data series to this plot with data points taken from the two arrays.
      Plot segmentedSeries(java.io.File theFile)
      Add a segmented data series to this plot with data points read from the given file.
      Plot segmentedSeries(java.io.InputStream theInputStream)
      Add a segmented data series to this plot with data points read from the given input stream.
      Plot segmentedSeries(java.util.Scanner theScanner)
      Add a segmented data series to this plot with data points read from the given scanner.
      Plot segmentedSeries(java.lang.String theFileName)
      Add a segmented data series to this plot with data points read from the file with the given name.
      Plot segmentedSeries(XYSeries theXYSeries)
      Add a segmented data series to this plot with data points taken from the given XYSeries.
      Plot seriesColor(java.awt.Color theColor)
      Set the color to use for line segments when plotting a data series.
      Plot seriesDots(Dots theDots)
      Set the dots to use when plotting a data series.
      Plot seriesSmooth(boolean isSmooth)
      Specify whether to draw a smooth curve when plotting a data series.
      Plot seriesStroke(java.awt.BasicStroke theStroke)
      Set the stroke to use for line segments when plotting a data series.
      Plot topMargin(double theMargin)
      Set the top margin for the plot.
      static void write(Plot thePlot, java.io.File theFile)
      Write the given plot to the given file.
      static void write(Plot thePlot, java.lang.String theFileName)
      Write the given plot to the file with the given name.
      void writeExternal(java.io.ObjectOutput out)
      Write this plot to the given object output stream.
      Plot xAxisCrossing(double theCrossing)
      Set the perpendicular axis crossing value for the X axis.
      Plot xAxisEnd(double theEnd)
      Set the ending value for the X axis.
      Plot xAxisKind(Plot.AxisKind theKind)
      Set the kind of axis for the X axis.
      Plot xAxisLength(double theLength)
      Set the length of the X axis.
      Plot xAxisMajorDivisions(int theMajorDivisions)
      Set the number of major divisions for the X axis.
      Plot xAxisMinorDivisions(int theMinorDivisions)
      Set the number of minor divisions per major division for the X axis.
      Plot xAxisStart(double theStart)
      Set the starting value for the X axis.
      Plot xAxisTickFont(java.awt.Font theTickFont)
      Set the tick label font for the X axis.
      Plot xAxisTickFormat(java.text.DecimalFormat theTickFormat)
      Set the tick label format for the X axis.
      Plot xAxisTickScale(double theTickScale)
      Set the tick label scale factor for the X axis.
      Plot xAxisTitle(java.lang.String theTitle)
      Set the title for the X axis.
      Plot xAxisTitleFont(java.awt.Font theTitleFont)
      Set the title font for the X axis.
      Plot xAxisTitleOffset(double theTitleOffset)
      Set the offset from the axis to the title for the X axis.
      Plot xySeries(double... theData)
      Add an X-Y data series to this plot with data points taken from the arguments.
      Plot xySeries(double[] theXArray, double[] theYArray)
      Add an X-Y data series to this plot with data points taken from the two arrays.
      Plot xySeries(java.io.File theFile)
      Add an X-Y data series to this plot with data points read from the given file.
      Plot xySeries(java.io.InputStream theInputStream)
      Add an X-Y data series to this plot with data points read from the given input stream.
      Plot xySeries(java.util.Scanner theScanner)
      Add an X-Y data series to this plot with data points read from the given scanner.
      Plot xySeries(java.lang.String theFileName)
      Add an X-Y data series to this plot with data points read from the file with the given name.
      Plot xySeries(XYSeries theXYSeries)
      Add an X-Y data series to this plot with data points taken from the given XYSeries.
      Plot yAxisCrossing(double theCrossing)
      Set the perpendicular axis crossing value for the Y axis.
      Plot yAxisEnd(double theEnd)
      Set the ending value for the Y axis.
      Plot yAxisKind(Plot.AxisKind theKind)
      Set the kind of axis for the Y axis.
      Plot yAxisLength(double theLength)
      Set the length of the Y axis.
      Plot yAxisMajorDivisions(int theMajorDivisions)
      Set the number of major divisions for the Y axis.
      Plot yAxisMinorDivisions(int theMinorDivisions)
      Set the number of minor divisions per major division for the X axis.
      Plot yAxisStart(double theStart)
      Set the starting value for the Y axis.
      Plot yAxisTickFont(java.awt.Font theTickFont)
      Set the tick label font for the Y axis.
      Plot yAxisTickFormat(java.text.DecimalFormat theTickFormat)
      Set the tick label format for the Y axis.
      Plot yAxisTickScale(double theTickScale)
      Set the tick label scale factor for the Y axis.
      Plot yAxisTitle(java.lang.String theTitle)
      Set the title for the Y axis.
      Plot yAxisTitleFont(java.awt.Font theTitleFont)
      Set the title font for the Y axis.
      Plot yAxisTitleOffset(double theTitleOffset)
      Set the offset from the axis to the title for the Y axis.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGARITHMIC

        public static final Plot.AxisKind LOGARITHMIC
        Logarithmic axis.
      • ABOVE_LEFT

        public static final int ABOVE_LEFT
        The label is positioned above and to the left of its location.
        See Also:
        Constant Field Values
      • ABOVE

        public static final int ABOVE
        The label is positioned above its location.
        See Also:
        Constant Field Values
      • ABOVE_RIGHT

        public static final int ABOVE_RIGHT
        The label is positioned above and to the right of its location.
        See Also:
        Constant Field Values
      • LEFT

        public static final int LEFT
        The label is positioned to the left of its location.
        See Also:
        Constant Field Values
      • CENTER

        public static final int CENTER
        The label is centered on its location.
        See Also:
        Constant Field Values
      • RIGHT

        public static final int RIGHT
        The label is positioned to the right of its location.
        See Also:
        Constant Field Values
      • BELOW_LEFT

        public static final int BELOW_LEFT
        The label is positioned below and to the left of its location.
        See Also:
        Constant Field Values
      • BELOW

        public static final int BELOW
        The label is positioned below its location.
        See Also:
        Constant Field Values
      • BELOW_RIGHT

        public static final int BELOW_RIGHT
        The label is positioned below and to the right of its location.
        See Also:
        Constant Field Values
      • ROTATE_LEFT

        public static final int ROTATE_LEFT
        The label is rotated 90 degrees left (counterclockwise).
        See Also:
        Constant Field Values
      • ROTATE_RIGHT

        public static final int ROTATE_RIGHT
        The label is rotated 90 degrees right (clockwise).
        See Also:
        Constant Field Values
      • ROTATE_AROUND

        public static final int ROTATE_AROUND
        The label is rotated 180 degrees around.
        See Also:
        Constant Field Values
      • PIXEL_COORDINATES

        public static final int PIXEL_COORDINATES
        The label's location is specified in pixel coordinates relative to the lower left corner of the plot area, rather than in plot coordinates.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Plot

        public Plot()
        Construct a new plot.
    • Method Detail

      • frameTitle

        public Plot frameTitle(java.lang.String theTitle)
        Set the title for the frame that displays the plot. The default is the same as the plot title.
        Parameters:
        theTitle - Title.
        Returns:
        This plot object.
      • plotTitle

        public Plot plotTitle(java.lang.String theTitle)
        Set the title for the plot. The default is no title.
        Parameters:
        theTitle - Title.
        Returns:
        This plot object.
      • plotTitleFont

        public Plot plotTitleFont(java.awt.Font theTitleFont)
        Set the title font for the plot. The default is sans-serif, plain, 14 point.
        Parameters:
        theTitleFont - Title font.
        Returns:
        This plot object.
      • plotTitleOffset

        public Plot plotTitleOffset(double theTitleOffset)
        Set the offset from the plot area to the title for the plot. The default is 9 points.
        Parameters:
        theTitleOffset - Title offset (points).
        Returns:
        This plot object.
      • margins

        public Plot margins(double theMargin)
        Set the margins for the plot. This is the distance from the left, top, right, and bottom sides of the plot area to the left, top, right, and bottom sides of the display.
        Parameters:
        theMargin - Margin (points).
        Returns:
        This plot object.
      • leftMargin

        public Plot leftMargin(double theMargin)
        Set the left margin for the plot. This is the distance from the left side of the plot area to the left side of the display. The default is 54 points.
        Parameters:
        theMargin - Left margin (points).
        Returns:
        This plot object.
      • topMargin

        public Plot topMargin(double theMargin)
        Set the top margin for the plot. This is the distance from the top side of the plot area to the top side of the display. The default is 27 points.
        Parameters:
        theMargin - Top margin (points).
        Returns:
        This plot object.
      • rightMargin

        public Plot rightMargin(double theMargin)
        Set the right margin for the plot. This is the distance from the right side of the plot area to the right side of the display. The default is 27 points.
        Parameters:
        theMargin - Right margin (points).
        Returns:
        This plot object.
      • bottomMargin

        public Plot bottomMargin(double theMargin)
        Set the bottom margin for the plot. This is the distance from the bottom side of the plot area to the bottom side of the display. The default is 54 points.
        Parameters:
        theMargin - Bottom margin (points).
        Returns:
        This plot object.
      • majorGridLines

        public Plot majorGridLines(boolean theGridLines)
        Specify whether major division grid lines are drawn on the plot. The default is to draw major division grid lines.
        Parameters:
        theGridLines - True to draw major division grid lines, false not to draw them.
        Returns:
        This plot object.
      • minorGridLines

        public Plot minorGridLines(boolean theGridLines)
        Specify whether minor division grid lines are drawn on the plot. The default is not to draw minor division grid lines.
        Parameters:
        theGridLines - True to draw minor division grid lines, false not to draw them.
        Returns:
        This plot object.
      • xAxisKind

        public Plot xAxisKind(Plot.AxisKind theKind)
        Set the kind of axis for the X axis. The default is a linear axis.
        Parameters:
        theKind - LINEAR or LOGARITHMIC.
        Returns:
        This plot object.
      • xAxisStart

        public Plot xAxisStart(double theStart)
        Set the starting value for the X axis. For a linear axis, this is the actual starting value. For a logarithmic axis, this the base-10 logarithm of the starting value, and it is truncated to the nearest integer. The default is to determine the starting value automatically from the plotted data.
        Parameters:
        theStart - Starting value.
        Returns:
        This plot object.
      • xAxisEnd

        public Plot xAxisEnd(double theEnd)
        Set the ending value for the X axis. For a linear axis, this is the actual ending value. For a logarithmic axis, this the base-10 logarithm of the ending value, and it is truncated to the nearest integer. The default is to determine the ending value automatically from the plotted data.
        Parameters:
        theEnd - Ending value.
        Returns:
        This plot object.
      • xAxisMajorDivisions

        public Plot xAxisMajorDivisions(int theMajorDivisions)
        Set the number of major divisions for the X axis. The default is 10 major divisions.

        For a logarithmic axis, theMajorDivisions is ignored; each factor of 10 between the starting and ending values is one major division.

        Parameters:
        theMajorDivisions - Number of major divisions.
        Returns:
        This plot object.
      • xAxisMinorDivisions

        public Plot xAxisMinorDivisions(int theMinorDivisions)
        Set the number of minor divisions per major division for the X axis. The default is 1 minor division per major division.
        Parameters:
        theMinorDivisions - Number of minor divisions per major division.
        Returns:
        This plot object.
      • xAxisCrossing

        public Plot xAxisCrossing(double theCrossing)
        Set the perpendicular axis crossing value for the X axis. For a linear axis, this is the actual crossing value. For a logarithmic axis, this the base-10 logarithm of the crossing value, and it is truncated to the nearest integer. The default is for the perpendicular axis to cross at the X axis's starting value.
        Parameters:
        theCrossing - Perpendicular axis crossing value.
        Returns:
        This plot object.
      • xAxisLength

        public Plot xAxisLength(double theLength)
        Set the length of the X axis. The default is 288 points.
        Parameters:
        theLength - Axis length (points).
        Returns:
        This plot object.
      • xAxisTickFormat

        public Plot xAxisTickFormat(java.text.DecimalFormat theTickFormat)
        Set the tick label format for the X axis. If theTickFormat is null, tick labels will not be drawn on the X axis. The default is a decimal format of "0".
        Parameters:
        theTickFormat - Tick format, or null.
        Returns:
        This plot object.
      • xAxisTickScale

        public Plot xAxisTickScale(double theTickScale)
        Set the tick label scale factor for the X axis. Each tick mark's numerical value is divided by the scale factor before being displayed. The default is 1 (no scaling).
        Parameters:
        theTickScale - Tick scale factor.
        Returns:
        This plot object.
      • xAxisTickFont

        public Plot xAxisTickFont(java.awt.Font theTickFont)
        Set the tick label font for the X axis. The default is sans-serif, plain, 12 point.
        Parameters:
        theTickFont - Tick font.
        Returns:
        This plot object.
      • xAxisTitle

        public Plot xAxisTitle(java.lang.String theTitle)
        Set the title for the X axis. The default is no title.
        Parameters:
        theTitle - Title.
        Returns:
        This plot object.
      • xAxisTitleFont

        public Plot xAxisTitleFont(java.awt.Font theTitleFont)
        Set the title font for the X axis. The default is sans-serif, plain, 12 point.
        Parameters:
        theTitleFont - Title font.
        Returns:
        This plot object.
      • xAxisTitleOffset

        public Plot xAxisTitleOffset(double theTitleOffset)
        Set the offset from the axis to the title for the X axis. The default is 30 points.
        Parameters:
        theTitleOffset - Title offset (points).
        Returns:
        This plot object.
      • yAxisKind

        public Plot yAxisKind(Plot.AxisKind theKind)
        Set the kind of axis for the Y axis. The default is a linear axis.
        Parameters:
        theKind - LINEAR or LOGARITHMIC.
        Returns:
        This plot object.
      • yAxisStart

        public Plot yAxisStart(double theStart)
        Set the starting value for the Y axis. For a linear axis, this is the actual starting value. For a logarithmic axis, this the base-10 logarithm of the starting value, and it is truncated to the nearest integer. The default is to determine the starting value automatically from the plotted data.
        Parameters:
        theStart - Starting value.
        Returns:
        This plot object.
      • yAxisEnd

        public Plot yAxisEnd(double theEnd)
        Set the ending value for the Y axis. For a linear axis, this is the actual ending value. For a logarithmic axis, this the base-10 logarithm of the ending value, and it is truncated to the nearest integer. The default is to determine the ending value automatically from the plotted data.
        Parameters:
        theEnd - Ending value.
        Returns:
        This plot object.
      • yAxisMajorDivisions

        public Plot yAxisMajorDivisions(int theMajorDivisions)
        Set the number of major divisions for the Y axis. The default is 10 major divisions.

        For a logarithmic axis, theMajorDivisions is ignored; each factor of 10 between the starting and ending values is one major division.

        Parameters:
        theMajorDivisions - Number of major divisions.
        Returns:
        This plot object.
      • yAxisMinorDivisions

        public Plot yAxisMinorDivisions(int theMinorDivisions)
        Set the number of minor divisions per major division for the X axis. The default is 1 minor division per major division.
        Parameters:
        theMinorDivisions - Number of minor divisions per major division.
        Returns:
        This plot object.
      • yAxisCrossing

        public Plot yAxisCrossing(double theCrossing)
        Set the perpendicular axis crossing value for the Y axis. For a linear axis, this is the actual crossing value. For a logarithmic axis, this the base-10 logarithm of the crossing value, and it is truncated to the nearest integer. The default is for the perpendicular axis to cross at the Y axis's starting value.
        Parameters:
        theCrossing - Perpendicular axis crossing value.
        Returns:
        This plot object.
      • yAxisLength

        public Plot yAxisLength(double theLength)
        Set the length of the Y axis. The default is 288 points.
        Parameters:
        theLength - Axis length (points).
        Returns:
        This plot object.
      • yAxisTickFormat

        public Plot yAxisTickFormat(java.text.DecimalFormat theTickFormat)
        Set the tick label format for the Y axis. If theTickFormat is null, tick labels will not be drawn on the Y axis. The default is a decimal format of "0".
        Parameters:
        theTickFormat - Tick format, or null.
        Returns:
        This plot object.
      • yAxisTickScale

        public Plot yAxisTickScale(double theTickScale)
        Set the tick label scale factor for the Y axis. Each tick mark's numerical value is divided by the scale factor before being displayed. The default is 1 (no scaling).
        Parameters:
        theTickScale - Tick scale factor.
        Returns:
        This plot object.
      • yAxisTickFont

        public Plot yAxisTickFont(java.awt.Font theTickFont)
        Set the tick label font for the Y axis. The default is sans-serif, plain, 12 point.
        Parameters:
        theTickFont - Tick font.
        Returns:
        This plot object.
      • yAxisTitle

        public Plot yAxisTitle(java.lang.String theTitle)
        Set the title for the Y axis. The default is no title.
        Parameters:
        theTitle - Title.
        Returns:
        This plot object.
      • yAxisTitleFont

        public Plot yAxisTitleFont(java.awt.Font theTitleFont)
        Set the title font for the Y axis. The default is sans-serif, plain, 12 point.
        Parameters:
        theTitleFont - Title font.
        Returns:
        This plot object.
      • yAxisTitleOffset

        public Plot yAxisTitleOffset(double theTitleOffset)
        Set the offset from the axis to the title for the Y axis. The default is 36 points.
        Parameters:
        theTitleOffset - Title offset (points).
        Returns:
        This plot object.
      • seriesDots

        public Plot seriesDots(Dots theDots)
        Set the dots to use when plotting a data series. All data series added hereafter will use the given dots. The default is a solid black circle 5 points in diameter. See class Dots for other shapes.
        Parameters:
        theDots - Dots, or null not to plot dots.
        Returns:
        This plot object.
      • seriesStroke

        public Plot seriesStroke(java.awt.BasicStroke theStroke)
        Set the stroke to use for line segments when plotting a data series. All data series added hereafter will use the given stroke. The default is a solid stroke 2 points wide. See class Strokes for other strokes.
        Parameters:
        theStroke - Stroke, or null not to plot line segments.
        Returns:
        This plot object.
      • seriesColor

        public Plot seriesColor(java.awt.Color theColor)
        Set the color to use for line segments when plotting a data series. All data series added hereafter will use the given color. The default is black.
        Parameters:
        theColor - Color, or null not to plot line segments.
        Returns:
        This plot object.
      • seriesSmooth

        public Plot seriesSmooth(boolean isSmooth)
        Specify whether to draw a smooth curve when plotting a data series. All data series added hereafter will use the given smoothing. The default is false (draw straight line segments).
        Parameters:
        isSmooth - True to draw a smooth curve, false to draw straight line segments.
        Returns:
        This plot object.
      • xySeries

        public Plot xySeries(java.lang.String theFileName)
                      throws java.io.FileNotFoundException
        Add an X-Y data series to this plot with data points read from the file with the given name. Double values are read from the file until there are no more. Each pair of double values becomes an (x,y) point in the data series. Any leftover double value is discarded.

        A dot is drawn at each data point as specified by the seriesDot() method. A line segment is drawn from each data point to the next as specified by the seriesStroke() and seriesColor() methods. A smooth curve is drawn, or not, as specified by the seriesSmooth() method.

        Parameters:
        theFileName - File name.
        Returns:
        This plot object.
        Throws:
        java.io.FileNotFoundException - Thrown if the file could not be read.
      • xySeries

        public Plot xySeries(java.io.File theFile)
                      throws java.io.FileNotFoundException
        Add an X-Y data series to this plot with data points read from the given file. Double values are read from the file until there are no more. Each pair of double values becomes an (x,y) point in the data series. Any leftover double value is discarded.

        A dot is drawn at each data point as specified by the seriesDot() method. A line segment is drawn from each data point to the next as specified by the seriesStroke() and seriesColor() methods. A smooth curve is drawn, or not, as specified by the seriesSmooth() method.

        Parameters:
        theFile - File.
        Returns:
        This plot object.
        Throws:
        java.io.FileNotFoundException - Thrown if the file could not be read.
      • xySeries

        public Plot xySeries(java.io.InputStream theInputStream)
        Add an X-Y data series to this plot with data points read from the given input stream. Double values are read from the input stream until there are no more. Each pair of double values becomes an (x,y) point in the data series. Any leftover double value is discarded. After adding the data series, the input stream is closed.

        A dot is drawn at each data point as specified by the seriesDot() method. A line segment is drawn from each data point to the next as specified by the seriesStroke() and seriesColor() methods. A smooth curve is drawn, or not, as specified by the seriesSmooth() method.

        Parameters:
        theInputStream - Input stream.
        Returns:
        This plot object.
      • xySeries

        public Plot xySeries(java.util.Scanner theScanner)
        Add an X-Y data series to this plot with data points read from the given scanner. Double values are read from the scanner until there are no more. Each pair of double values becomes an (x,y) point in the data series. Any leftover double value is discarded. After constructing the data series, the scanner is closed.

        A dot is drawn at each data point as specified by the seriesDot() method. A line segment is drawn from each data point to the next as specified by the seriesStroke() and seriesColor() methods. A smooth curve is drawn, or not, as specified by the seriesSmooth() method.

        Parameters:
        theScanner - Scanner.
        Returns:
        This plot object.
      • xySeries

        public Plot xySeries(double... theData)
        Add an X-Y data series to this plot with data points taken from the arguments. The argument values are grouped into pairs, where the first argument value is the X value and the second argument value is the Y value. Each pair of argument values becomes one data point in the X-Y data series. It is assumed that there are an even number of argument values.

        A dot is drawn at each data point as specified by the seriesDot() method. A line segment is drawn from each data point to the next as specified by the seriesStroke() and seriesColor() methods. A smooth curve is drawn, or not, as specified by the seriesSmooth() method.

        Parameters:
        theData - Data point X and Y coordinates.
        Returns:
        This plot object.
      • xySeries

        public Plot xySeries(double[] theXArray,
                             double[] theYArray)
        Add an X-Y data series to this plot with data points taken from the two arrays. The first array contains the X coordinates, the second array contains the Y coordinates.

        A dot is drawn at each data point as specified by the seriesDot() method. A line segment is drawn from each data point to the next as specified by the seriesStroke() and seriesColor() methods. A smooth curve is drawn, or not, as specified by the seriesSmooth() method.

        Parameters:
        theXArray - Array of data point X coordinates.
        theYArray - Array of data point Y coordinates.
        Returns:
        This plot object.
      • xySeries

        public Plot xySeries(XYSeries theXYSeries)
        Add an X-Y data series to this plot with data points taken from the given XYSeries.

        A dot is drawn at each data point as specified by the seriesDot() method. A line segment is drawn from each data point to the next as specified by the seriesStroke() and seriesColor() methods. A smooth curve is drawn, or not, as specified by the seriesSmooth() method.

        Parameters:
        theXYSeries - X-Y series.
        Returns:
        This plot object.
      • segmentedSeries

        public Plot segmentedSeries(java.lang.String theFileName)
                             throws java.io.FileNotFoundException
        Add a segmented data series to this plot with data points read from the file with the given name. Double values are read from the file until there are no more. Each pair of double values becomes an (x,y) point in the data series. Any leftover double value is discarded.

        The data points are divided into pairs. Each pair of data points specifies the starting and ending coordinates of a line segment. A dot is drawn at each endpoint of each line segment. A line segment's starting coordinates need not be the same as the previous line segment's ending coordinates. If the data series has an odd number of data points, the last data point is ignored.

        Parameters:
        theFileName - File name.
        Returns:
        This plot object.
        Throws:
        java.io.FileNotFoundException - Thrown if the file could not be read.
      • segmentedSeries

        public Plot segmentedSeries(java.io.File theFile)
                             throws java.io.FileNotFoundException
        Add a segmented data series to this plot with data points read from the given file. Double values are read from the file until there are no more. Each pair of double values becomes an (x,y) point in the data series. Any leftover double value is discarded.

        The data points are divided into pairs. Each pair of data points specifies the starting and ending coordinates of a line segment. A dot is drawn at each endpoint of each line segment. A line segment's starting coordinates need not be the same as the previous line segment's ending coordinates. If the data series has an odd number of data points, the last data point is ignored.

        Parameters:
        theFile - File.
        Returns:
        This plot object.
        Throws:
        java.io.FileNotFoundException - Thrown if the file could not be read.
      • segmentedSeries

        public Plot segmentedSeries(java.io.InputStream theInputStream)
        Add a segmented data series to this plot with data points read from the given input stream. Double values are read from the input stream until there are no more. Each pair of double values becomes an (x,y) point in the data series. Any leftover double value is discarded. After adding the data series, the input stream is closed.

        The data points are divided into pairs. Each pair of data points specifies the starting and ending coordinates of a line segment. A dot is drawn at each endpoint of each line segment. A line segment's starting coordinates need not be the same as the previous line segment's ending coordinates. If the data series has an odd number of data points, the last data point is ignored.

        Parameters:
        theInputStream - Input stream.
        Returns:
        This plot object.
      • segmentedSeries

        public Plot segmentedSeries(java.util.Scanner theScanner)
        Add a segmented data series to this plot with data points read from the given scanner. Double values are read from the scanner until there are no more. Each pair of double values becomes an (x,y) point in the data series. Any leftover double value is discarded. After constructing the data series, the scanner is closed.

        The data points are divided into pairs. Each pair of data points specifies the starting and ending coordinates of a line segment. A dot is drawn at each endpoint of each line segment. A line segment's starting coordinates need not be the same as the previous line segment's ending coordinates. If the data series has an odd number of data points, the last data point is ignored.

        Parameters:
        theScanner - Scanner.
        Returns:
        This plot object.
      • segmentedSeries

        public Plot segmentedSeries(double... theData)
        Add a segmented data series to this plot with data points taken from the arguments. The argument values are grouped into pairs, where the first argument value is the X value and the second argument value is the Y value. Each pair of argument values becomes one data point in the segmented data series. It is assumed that there are an even number of argument values.

        The data points are divided into pairs. Each pair of data points specifies the starting and ending coordinates of a line segment. A dot is drawn at each endpoint of each line segment. A line segment's starting coordinates need not be the same as the previous line segment's ending coordinates. If the data series has an odd number of data points, the last data point is ignored.

        Parameters:
        theData - Data point X and Y coordinates.
        Returns:
        This plot object.
      • segmentedSeries

        public Plot segmentedSeries(double[] theXArray,
                                    double[] theYArray)
        Add a segmented data series to this plot with data points taken from the two arrays. The first array contains the X coordinates, the second array contains the Y coordinates.

        The data points are divided into pairs. Each pair of data points specifies the starting and ending coordinates of a line segment. A dot is drawn at each endpoint of each line segment. A line segment's starting coordinates need not be the same as the previous line segment's ending coordinates. If the data series has an odd number of data points, the last data point is ignored.

        Parameters:
        theXArray - Array of data point X coordinates.
        theYArray - Array of data point Y coordinates.
        Returns:
        This plot object.
      • segmentedSeries

        public Plot segmentedSeries(XYSeries theXYSeries)
        Add a segmented data series to this plot with data points taken from the given XYSeries.

        The data points are divided into pairs. Each pair of data points specifies the starting and ending coordinates of a line segment. A dot is drawn at each endpoint of each line segment. A line segment's starting coordinates need not be the same as the previous line segment's ending coordinates. If the data series has an odd number of data points, the last data point is ignored.

        Parameters:
        theXYSeries - X-Y series.
        Returns:
        This plot object.
      • labelPosition

        public Plot labelPosition(int thePosition)
        Set the positioning to use for labels. All labels added hereafter will use the given positioning. The label positioning argument must be one of the following constants to specify how the label is positioned relative to the label's (x,y) location: ABOVE_LEFT, ABOVE, ABOVE_RIGHT, LEFT, CENTER, RIGHT, BELOW_LEFT, BELOW, or BELOW_RIGHT. The default is CENTER.

        One of the following constants may be added to rotate the label around the label's (x,y) location: ROTATE_LEFT, ROTATE_RIGHT, or ROTATE_AROUND. For example, labelPosition(Plot.LEFT+Plot.ROTATE_LEFT) will rotate each label 90 degrees left and position it to the left of its (x,y) location. The default is no rotation.

        The following constant may also be added: PIXEL_COORDINATES. If this constant is omitted, the label's (x,y) location is specified in plot coordinates as determined by the X and Y axes' attributes. If this constant is included, the label's (x,y) location is specified in pixel coordinates relative to the lower left corner of the plot area, regardless of the X and Y axes' attributes.

        Parameters:
        thePosition - Label positioning.
        Returns:
        This plot object.
      • labelOffset

        public Plot labelOffset(double theOffset)
        Set the offset to use for labels. All labels added hereafter will use the given offset. The default is 0. The offset specifies, in pixel coordinates, how far away from the label's (x,y) location the label is positioned in the direction determined by the label positioning attribute.
        Parameters:
        theOffset - Label offset.
        Returns:
        This plot object.
      • labelFont

        public Plot labelFont(java.awt.Font theFont)
        Set the font to use for labels. All labels added hereafter will use the given font. The default is sans-serif, plain, 12 point.
        Parameters:
        theFont - Label offset.
        Returns:
        This plot object.
      • labelColor

        public Plot labelColor(java.awt.Color theColor)
        Set the color to use for labels. All labels added hereafter will use the given color. The default is black.
        Parameters:
        theColor - Label color.
        Returns:
        This plot object.
      • labelBackground

        public Plot labelBackground(java.awt.Color theColor)
        Set the color to use for label backgrounds. All labels added hereafter will use the given color for the background. The default is transparent.
        Parameters:
        theColor - Label background color, or null for transparent.
        Returns:
        This plot object.
      • label

        public Plot label(java.lang.String text,
                          double x,
                          double y)
        Add a label to this plot. The label's position is (x,y).

        The label supports a subset of HTML for specifying attributes of characters. The following HTML tags may be embedded in a label's text:

        • <B>Bold</B>
        • <I>Italic</I>
        • <SUP>Superscript</SUP>
        • <SUB>Subscript</SUB>

        To get literal less-than, greater-than, and ampersand characters in the text, use the following HTML character entities:

        • &lt; -- Less-than (<)
        • &gt; -- Greater-than (>)
        • &amp; -- Ampersand (&)
        Parameters:
        text - Label text.
        x - X coordinate of label position.
        y - Y coordinate of label position.
        Returns:
        This plot object.
      • draw

        public void draw(java.awt.Graphics2D g2d)
        Draw this drawable object in the given graphics context. Upon return from this method, the given graphics context's state (color, font, transform, clip, and so on) is the same as it was upon entry to this method.
        Specified by:
        draw in interface Drawable
        Parameters:
        g2d - 2-D graphics context.
      • getBoundingBox

        public java.awt.geom.Rectangle2D getBoundingBox()
        Returns this displayable object's bounding box. This is the smallest rectangle that encloses all of this displayable object.
        Specified by:
        getBoundingBox in interface Displayable
      • getBackgroundPaint

        public java.awt.Paint getBackgroundPaint()
        Returns this displayable object's background paint.
        Specified by:
        getBackgroundPaint in interface Displayable
      • getFrame

        public DisplayableFrame getFrame()
        Get a displayable frame in which to view this viewable object. Initially, the returned frame is displaying this viewable object.
        Specified by:
        getFrame in interface Viewable
        Returns:
        Displayable frame.
      • getTitle

        public java.lang.String getTitle()
        Get the title for the frame used to view this viewable object. If the title is null, a default title is used.
        Specified by:
        getTitle in interface Viewable
        Returns:
        Title.
      • writeExternal

        public void writeExternal(java.io.ObjectOutput out)
                           throws java.io.IOException
        Write this plot to the given object output stream.
        Specified by:
        writeExternal in interface java.io.Externalizable
        Parameters:
        out - Object output stream.
        Throws:
        java.io.IOException - Thrown if an I/O error occurred.
      • readExternal

        public void readExternal(java.io.ObjectInput in)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
        Read this plot from the given object input stream.
        Specified by:
        readExternal in interface java.io.Externalizable
        Parameters:
        in - Object input stream.
        Throws:
        java.io.IOException - Thrown if an I/O error occurred.
        java.lang.ClassNotFoundException - Thrown if a class needed to deserialize this plot was not found.
      • write

        public static void write(Plot thePlot,
                                 java.lang.String theFileName)
                          throws java.io.IOException
        Write the given plot to the file with the given name. thePlot is written in serialized form to the file.
        Parameters:
        thePlot - Plot.
        theFileName - File name.
        Throws:
        java.io.IOException - Thrown if an I/O error occurred.
      • write

        public static void write(Plot thePlot,
                                 java.io.File theFile)
                          throws java.io.IOException
        Write the given plot to the given file. thePlot is written in serialized form to theFile.
        Parameters:
        thePlot - Plot.
        theFile - File.
        Throws:
        java.io.IOException - Thrown if an I/O error occurred.
      • read

        public static Plot read(java.lang.String theFileName)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Read a plot from the file with the given name. The file must contain one instance of class Plot in serialized form; for example, as written by the static Plot.write() method.
        Parameters:
        theFileName - File name.
        Returns:
        Plot.
        Throws:
        java.io.IOException - Thrown if an I/O error occurred.
        java.lang.ClassNotFoundException - Thrown if any class needed to deserialize the plot cannot be found.
      • read

        public static Plot read(java.io.File theFile)
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException
        Read a plot from the given file. The file must contain one instance of class Plot in serialized form; for example, as written by the static Plot.write() method.
        Parameters:
        theFile - File.
        Returns:
        Plot.
        Throws:
        java.io.IOException - Thrown if an I/O error occurred.
        java.lang.ClassNotFoundException - Thrown if any class needed to deserialize the plot cannot be found.

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.