package nl.tudelft.simulation.jstats.charts.histogram; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.jfree.data.general.DatasetChangeEvent; import org.jfree.data.general.DatasetChangeListener; import org.jfree.data.statistics.SimpleHistogramDataset; import org.jfree.data.xy.IntervalXYDataset; /** * The dataset defines a histogram data set. A dataset contains multiple series each containing the entries to display. *
* (c) copyright 2002-2004 Delft University of Technology , the
* Netherlands.
* See for project information www.simulation.tudelft.nl
* License of use: Lesser General Public License (LGPL) , no
* warranty.
* @author Alexander Verbraeck
* Peter Jacobs
* @version $Revision: 1.1 $ $Date: 2010/08/10 11:39:02 $
* @since 1.5
*/
public class HistogramDataset extends SimpleHistogramDataset implements IntervalXYDataset, DatasetChangeListener
{
/** domain is the minimal value to be displayed in this set. */
protected double[] domain = null;
/** range is the maximum value to be displayed in the set. */
protected double[] range = null;
/** numberOfBins is the number of bins (or categories between min-max) */
protected int numberOfBins = 0;
/** series the series in this set. */
protected HistogramSeries[] series = new HistogramSeries[0];
/**
* constructs a new HistogramDataset.
* @param domain the domain of the set.
* @param range the range of the set.
* @param numberOfBins the number of bins
*/
public HistogramDataset(final Comparable> key, final double[] domain, final double[] range, final int numberOfBins)
{
super(key);
this.domain = domain;
this.range = range;
this.numberOfBins = numberOfBins;
}
/**
* adds a series to the dataset.
* @param name the name of the series.
* @return HistogramSeries.
*/
public synchronized HistogramSeries addSeries(final String name)
{
HistogramSeries histogramSeries = new HistogramSeries(name, this.domain, this.range, this.numberOfBins);
this.addSeries(histogramSeries);
return histogramSeries;
}
/**
* adds a series to the dataset
* @param newSeries the set to add.
*/
public synchronized void addSeries(final HistogramSeries newSeries)
{
newSeries.addChangeListener(this);
List