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) $
  • Field Details

  • Constructor Details

    • HistogramPlot

      public HistogramPlot​(String nameX, String nameY, XYItemRenderer renderer)
      Create a new HistogramPlot.
      Parameters:
      nameX - The label on the X-axis
      nameY - The label on the Y-axis
      renderer - 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. The 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.

      Parameters:
      data - The data to plot
      name - The name of the data series
      binSize - The size (= range on x-axis) of each histogram bin
      yAggregate - What to plot on the y-axis
      hiloAggregate - 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. The 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.

      Parameters:
      data - The data to plot
      annotations - 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 bin
      yAggregate - What to plot on the y-axis
      hiloAggregate - Optional parameter specifying if high/low values shold be drawn for each bin
      Throws:
      SQLException
    • getChart

      public JFreeChart getChart()
      Get the underlying JFreeChar object. Use this method to polish up everything and save the image.