Package net.sf.basedb.util.plot
Class HistogramPlot
- java.lang.Object
-
- net.sf.basedb.util.plot.HistogramPlot
-
public class HistogramPlot extends Object
A simple plot utility for generating histogram 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) $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
HistogramPlot.HistogramBin
Represents a single bin in a histogram.private static class
HistogramPlot.HistogramDataset
An dataset implementation for histogram data that allows us to send data to JFreeChart the way we want.private static class
HistogramPlot.HistogramSeries
Collects information about one histogram series.private static class
HistogramPlot.TempSeries
Helper class for storing histogram data that needs to split into different annotations.static class
HistogramPlot.YAggregate
Defines what to to plot on the y axis in a histogram plot.
-
Field Summary
Fields Modifier and Type Field Description private org.jfree.chart.JFreeChart
chart
private org.jfree.data.Range
domainRange
private HistogramPlot.HistogramDataset
hilo
private HistogramPlot.HistogramDataset
histogram
private org.jfree.chart.plot.XYPlot
plot
private org.jfree.data.Range
rangeRange
-
Constructor Summary
Constructors Constructor Description HistogramPlot(String nameX, String nameY, org.jfree.chart.renderer.xy.XYItemRenderer renderer)
Create a new HistogramPlot.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addData(SqlResultIterator data, String name, float binSize, HistogramPlot.YAggregate yAggregate, HistogramPlot.YAggregate hiloAggregate)
Add data to the plot.void
addData(SqlResultIterator data, Collection<PlotAnnotation> annotations, float binSize, HistogramPlot.YAggregate yAggregate, HistogramPlot.YAggregate hiloAggregate)
Add data to the plot.private void
adjustRanges()
Auto-size of the x and y range doesn't seem to work, so we have to do it manually.org.jfree.chart.JFreeChart
getChart()
Get the underlying JFreeChar object.
-
-
-
Field Detail
-
domainRange
private org.jfree.data.Range domainRange
-
rangeRange
private org.jfree.data.Range rangeRange
-
plot
private org.jfree.chart.plot.XYPlot plot
-
histogram
private HistogramPlot.HistogramDataset histogram
-
hilo
private HistogramPlot.HistogramDataset hilo
-
chart
private org.jfree.chart.JFreeChart chart
-
-
Method Detail
-
addData
public void addData(SqlResultIterator data, String name, float binSize, HistogramPlot.YAggregate yAggregate, HistogramPlot.YAggregate hiloAggregate) 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, if used, the y value in the second position.The y value is not used if the yAggregate parameter is
HistogramPlot.YAggregate.COUNT
.- Parameters:
data
- The data to plotname
- The name of the data seriesbinSize
- The size (= range on x-axis) of each histogram binyAggregate
- What to plot on the y-axishiloAggregate
- Optional parameter specifying if high/low values shold be drawn for each bin- Throws:
SQLException
-
adjustRanges
private void adjustRanges()
Auto-size of the x and y range doesn't seem to work, so we have to do it manually.
-
addData
public void addData(SqlResultIterator data, Collection<PlotAnnotation> annotations, float binSize, HistogramPlot.YAggregate yAggregate, HistogramPlot.YAggregate hiloAggregate) throws SQLException
Add data to the plot. TheSqlResultIterator
should return the annotation value in the first position, ie.data.getInt(1)
, the x value as a float in the second position, and, if used, the y value in the third position.The y value is not used if the yAggregate parameter is
HistogramPlot.YAggregate.COUNT
.- Parameters:
data
- The data to plotannotations
- Annotation information that maps each data spot to an annotation (seeScatterPlot.addData(SqlResultIterator, Collection)
binSize
- The size (= range on x-axis) of each histogram binyAggregate
- What to plot on the y-axishiloAggregate
- Optional parameter specifying if high/low values shold be drawn for each bin- Throws:
SQLException
-
getChart
public org.jfree.chart.JFreeChart getChart()
Get the underlying JFreeChar object. Use this method to polish up everything and save the image.
-
-