public class HistogramPlot
extends java.lang.Object
Modifier and Type | Class and 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.
|
Modifier and Type | Field and Description |
---|---|
private JFreeChart |
chart |
private Range |
domainRange |
private HistogramPlot.HistogramDataset |
hilo |
private HistogramPlot.HistogramDataset |
histogram |
private XYPlot |
plot |
private Range |
rangeRange |
Constructor and Description |
---|
HistogramPlot(java.lang.String nameX,
java.lang.String nameY,
XYItemRenderer renderer)
Create a new HistogramPlot.
|
Modifier and Type | Method and Description |
---|---|
void |
addData(SqlResultIterator data,
java.util.Collection<PlotAnnotation> annotations,
float binSize,
HistogramPlot.YAggregate yAggregate,
HistogramPlot.YAggregate hiloAggregate)
Add data to the plot.
|
void |
addData(SqlResultIterator data,
java.lang.String name,
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.
|
JFreeChart |
getChart()
Get the underlying JFreeChar object.
|
private Range domainRange
private Range rangeRange
private XYPlot plot
private HistogramPlot.HistogramDataset histogram
private HistogramPlot.HistogramDataset hilo
private JFreeChart chart
public HistogramPlot(java.lang.String nameX, java.lang.String nameY, XYItemRenderer renderer)
nameX
- The label on the X-axisnameY
- The label on the Y-axisrenderer
- The renderer to use or null for the default (XYBarRenderer)public void addData(SqlResultIterator data, java.lang.String name, float binSize, HistogramPlot.YAggregate yAggregate, HistogramPlot.YAggregate hiloAggregate) throws java.sql.SQLException
SqlResultIterator
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
.
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 binjava.sql.SQLException
private void adjustRanges()
public void addData(SqlResultIterator data, java.util.Collection<PlotAnnotation> annotations, float binSize, HistogramPlot.YAggregate yAggregate, HistogramPlot.YAggregate hiloAggregate) throws java.sql.SQLException
SqlResultIterator
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
.
data
- The data to plotannotations
- Annotation information that maps each data spot to
an annotation (see ScatterPlot.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 binjava.sql.SQLException
public JFreeChart getChart()