Class Plot

  • Direct Known Subclasses:
    ColumnPlot, HistogramPlot, LinePlot, ScatterPlot, XYPlot

    public abstract class Plot
    extends Object
    Abstract class that represents a CF4J plot. With a CF4J plot final users can:
    • Draw the plot.
    • Export the plot into a PNG image.
    • Print the plot data into the standard output.
    • Export the plot data into a CSV file.
    • Constructor Detail

      • Plot

        public Plot()
    • Method Detail

      • exportData

        public void exportData​(String filename)
                        throws IOException
        Exports plot data into a CSV file
        Parameters:
        filename - File name
        Throws:
        IOException - When file is not found or is locked.
      • exportData

        public void exportData​(String filename,
                               String separator)
                        throws IOException
        Exports plot data into a CSV file
        Parameters:
        filename - File name
        separator - CSV separator field. By default: colon character (,)
        Throws:
        IOException - When file is not found or is locked.
      • exportData

        public void exportData​(String filename,
                               boolean includeHeader)
                        throws IOException
        Exports plot data into a CSV file
        Parameters:
        filename - File name
        includeHeader - Include CSV header line. By default: true
        Throws:
        IOException - When file is not found or is locked.
      • exportData

        public void exportData​(String filename,
                               String separator,
                               boolean includeHeader)
                        throws IOException
        Exports plot data into a CSV file
        Parameters:
        filename - File name
        separator - CSV separator field. By default: colon character (,)
        includeHeader - Include CSV header line. By default: true
        Throws:
        IOException - When file is not found or is locked.
      • printData

        public void printData()
        Prints the plot data into the standard output
      • printData

        public void printData​(String axisTicksFormat)
        Prints the plot data into the standard output
        Parameters:
        axisTicksFormat - Number format of the axis
      • printData

        public void printData​(String xAxisTicksFormat,
                              String yAxisTicksFormat)
        Prints the plot data into the standard output
        Parameters:
        xAxisTicksFormat - Number format of the x axis
        yAxisTicksFormat - Number format of the y axis
      • toString

        public String toString​(String axisTicksFormat)
        Stringify the plot data
        Parameters:
        axisTicksFormat - Number format for the values of the axis
        Returns:
        Plot's data stringified
      • toString

        public String toString​(String xAxisTicksFormat,
                               String yAxisTicksFormat)
        Stringify the plot data
        Parameters:
        xAxisTicksFormat - Number format for the values of the x axis
        yAxisTicksFormat - Number format for the values of the x axis
        Returns:
        Plot's data stringified
      • getDataHeaders

        protected abstract String[] getDataHeaders()
        Returns an String array with the headers of the plot's data
        Returns:
        Headers of the plot's data
      • getDataContent

        protected abstract String[][] getDataContent​(String xAxisTicksFormat,
                                                     String yAxisTicksFormat)
        Returns an String matrix with the content of the plot's data. First dimension denotes the row and second dimension denotes the column that must be correlated with the header returned by getDataHeaders().
        Parameters:
        xAxisTicksFormat - Number format for the values of the x axis
        yAxisTicksFormat - Number format for the values of the x axis
        Returns:
        String matrix with the content of the plot's data
      • draw

        public void draw()
        Draws the plot into a JFrame
      • exportPlot

        public void exportPlot​(String filename)
                        throws IOException
        Exports the plot to a PNG file
        Parameters:
        filename - PNG file name
        Throws:
        IOException - When file is not found or is locked.
      • getGralPlot

        protected abstract de.erichseifert.gral.plots.AbstractPlot getGralPlot()
        Gets an AbstractPlot using GRAL
        Returns:
        GRAL's AbstractPlot