Package net.sf.basedb.util.plot
Class ScatterPlot
- java.lang.Object
-
- net.sf.basedb.util.plot.ScatterPlot
-
public class ScatterPlot extends Object
A simple plot utility for generating scatter plots without the need to delve deep into the JFreePlot package. Note! This class is experimental and it is likely that the implementation will change in the future.- Version:
- 2.0
- Author:
- Nicklas
- Last modified
- $Date: 2015-05-12 11:27:08 +0200 (ti, 12 maj 2015) $
-
-
Field Summary
Fields Modifier and Type Field Description private XYSeriesCollection
allSeries
private JFreeChart
chart
private XYPlot
plot
-
Constructor Summary
Constructors Constructor Description ScatterPlot(String nameX, String nameY)
Create a new ScatterPlot.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addData(SqlResultIterator data, String... names)
Add data to the plot.void
addData(SqlResultIterator data, Collection<PlotAnnotation> annotations)
Add data to the plot.JFreeChart
getChart()
Get the underlying JFreeChar object.
-
-
-
Field Detail
-
plot
private XYPlot plot
-
allSeries
private XYSeriesCollection allSeries
-
chart
private JFreeChart chart
-
-
Method Detail
-
addData
public void addData(SqlResultIterator data, String... names) throws SQLException
Add data to the plot. TheSqlResultIterator
should return the x value as a float in the first position, ie.data.getFloat(1)
and y values in the positions 2 and up.- Parameters:
data
- The data to plotnames
- An array of series names, x-value for series 'i' is found indata.getFloat(2+i)
- Throws:
SQLException
-
addData
public void addData(SqlResultIterator data, Collection<PlotAnnotation> annotations) throws SQLException
Add data to the plot. The SqlResultIterator must return at least 3 columns. The first column in the result is used to determine which annotation/series the spot belongs to. The second column is the x value and the third column is the y value. Additional columns are not used.The annotations collection contains the mappings from the actual value to the annotation. Ie. if the result contains a 1 in the first column we check which annotation returns a 1 in it's
PlotAnnotation.getValues()
method. One value may not be used by more than one annotation.- Parameters:
data
- The data to plotannotations
- Annotation information that maps each data spot to an annotation- Throws:
SQLException
-
getChart
public JFreeChart getChart()
Get the underlying JFreeChar object. Use this method to polish up everything and save the image.
-
-