Package net.sf.basedb.util.plot
Class HistogramPlot
java.lang.Object
net.sf.basedb.util.plot.HistogramPlot
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
Modifier and TypeClassDescriptionprivate static class
Represents a single bin in a histogram.private static class
An dataset implementation for histogram data that allows us to send data to JFreeChart the way we want.private static class
Collects information about one histogram series.private static class
Helper class for storing histogram data that needs to split into different annotations.static enum
Defines what to to plot on the y axis in a histogram plot. -
Field Summary
Modifier and TypeFieldDescriptionprivate JFreeChart
private Range
private HistogramPlot.HistogramDataset
private HistogramPlot.HistogramDataset
private XYPlot
private Range
-
Constructor Summary
ConstructorDescriptionHistogramPlot
(String nameX, String nameY, XYItemRenderer renderer) Create a new HistogramPlot. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
Auto-size of the x and y range doesn't seem to work, so we have to do it manually.getChart()
Get the underlying JFreeChar object.
-
Field Details
-
domainRange
-
rangeRange
-
plot
-
histogram
-
hilo
-
chart
-
-
Constructor Details
-
HistogramPlot
Create a new HistogramPlot.- Parameters:
nameX
- The label on the X-axisnameY
- The label on the Y-axisrenderer
- The renderer to use or null for the default (XYBarRenderer)
-
-
Method Details
-
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
Get the underlying JFreeChar object. Use this method to polish up everything and save the image.
-