Package es.upm.etsisi.cf4j.util.plot
Class Plot
- java.lang.Object
-
- es.upm.etsisi.cf4j.util.plot.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 Summary
Constructors Constructor Description Plot()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
draw()
Draws the plot into a JFramevoid
exportData(String filename)
Exports plot data into a CSV filevoid
exportData(String filename, boolean includeHeader)
Exports plot data into a CSV filevoid
exportData(String filename, String separator)
Exports plot data into a CSV filevoid
exportData(String filename, String separator, boolean includeHeader)
Exports plot data into a CSV filevoid
exportPlot(String filename)
Exports the plot to a PNG fileprotected abstract String[][]
getDataContent(String xAxisTicksFormat, String yAxisTicksFormat)
Returns an String matrix with the content of the plot's data.protected abstract String[]
getDataHeaders()
Returns an String array with the headers of the plot's dataprotected abstract de.erichseifert.gral.plots.AbstractPlot
getGralPlot()
Gets an AbstractPlot using GRALvoid
printData()
Prints the plot data into the standard outputvoid
printData(String axisTicksFormat)
Prints the plot data into the standard outputvoid
printData(String xAxisTicksFormat, String yAxisTicksFormat)
Prints the plot data into the standard outputString
toString()
String
toString(String axisTicksFormat)
Stringify the plot dataString
toString(String xAxisTicksFormat, String yAxisTicksFormat)
Stringify the plot data
-
-
-
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 nameseparator
- 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 nameincludeHeader
- 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 nameseparator
- 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 axisyAxisTicksFormat
- 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 axisyAxisTicksFormat
- 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 axisyAxisTicksFormat
- 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
-
-