org.jfree.data
Class HistogramDataset

java.lang.Object
  extended byorg.jfree.data.AbstractDataset
      extended byorg.jfree.data.HistogramDataset
All Implemented Interfaces:
java.lang.Cloneable, Dataset, IntervalXYDataset, java.io.ObjectInputValidation, java.io.Serializable, SeriesDataset, XYDataset

public class HistogramDataset
extends AbstractDataset
implements IntervalXYDataset

A dataset that can be used for creating histograms.

See the HistogramDemo.java file in the JFreeChart distribution for an example.

Author:
Jelai Wang, jelaiw AT mindspring.com
See Also:
Serialized Form

Field Summary
static org.jfree.data.HistogramDataset.HistogramType FREQUENCY
          A constant to indicate a frequency histogram, also the default.
static org.jfree.data.HistogramDataset.HistogramType RELATIVE_FREQUENCY
          A constant to indicate a relative frequency histogram.
static org.jfree.data.HistogramDataset.HistogramType SCALE_AREA_TO_1
          A constant to indicate a histogram where the total area is scaled to 1.
 
Constructor Summary
HistogramDataset()
           
 
Method Summary
 void addSeries(java.lang.String name, double[] values, int numberOfBins)
          Adds a series.
 java.lang.Number getEndXValue(int series, int item)
          Returns the end value for a bin.
 java.lang.Number getEndYValue(int series, int item)
          Returns the Y value for a bin.
 int getItemCount(int series)
          Returns the number of data items for a series.
 int getSeriesCount()
          Returns the number of series in the dataset.
 java.lang.String getSeriesName(int series)
          Returns the name for a series.
 java.lang.Number getStartXValue(int series, int item)
          Returns the start value for a bin.
 java.lang.Number getStartYValue(int series, int item)
          Returns the Y value for a bin.
 org.jfree.data.HistogramDataset.HistogramType getType()
          Returns the histogram type.
 java.lang.Number getXValue(int series, int item)
          Returns the X value for a bin.
 java.lang.Number getYValue(int series, int item)
          Returns the Y value for a bin.
 void setType(org.jfree.data.HistogramDataset.HistogramType type)
          Sets the histogram type.
 
Methods inherited from class org.jfree.data.AbstractDataset
addChangeListener, clone, fireDatasetChanged, getGroup, notifyListeners, removeChangeListener, setGroup, validateObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jfree.data.Dataset
addChangeListener, getGroup, removeChangeListener, setGroup
 

Field Detail

FREQUENCY

public static final org.jfree.data.HistogramDataset.HistogramType FREQUENCY
A constant to indicate a frequency histogram, also the default.


RELATIVE_FREQUENCY

public static org.jfree.data.HistogramDataset.HistogramType RELATIVE_FREQUENCY
A constant to indicate a relative frequency histogram.


SCALE_AREA_TO_1

public static org.jfree.data.HistogramDataset.HistogramType SCALE_AREA_TO_1
A constant to indicate a histogram where the total area is scaled to 1.

Constructor Detail

HistogramDataset

public HistogramDataset()
Method Detail

setType

public void setType(org.jfree.data.HistogramDataset.HistogramType type)
Sets the histogram type.

Parameters:
type - the type (null not permitted).

getType

public org.jfree.data.HistogramDataset.HistogramType getType()
Returns the histogram type.

Returns:
The type.

addSeries

public void addSeries(java.lang.String name,
                      double[] values,
                      int numberOfBins)
Adds a series.

Parameters:
name - the series name.
values - the values (null not permitted).
numberOfBins - the number of bins (must be at least 1).

getSeriesCount

public int getSeriesCount()
Returns the number of series in the dataset.

Specified by:
getSeriesCount in interface SeriesDataset
Returns:
The series count.

getSeriesName

public java.lang.String getSeriesName(int series)
Returns the name for a series.

Specified by:
getSeriesName in interface SeriesDataset
Parameters:
series - the series index (zero based).
Returns:
The series name.

getItemCount

public int getItemCount(int series)
Returns the number of data items for a series.

Specified by:
getItemCount in interface XYDataset
Parameters:
series - the series index (zero based).
Returns:
The item count.

getXValue

public java.lang.Number getXValue(int series,
                                  int item)
Returns the X value for a bin.

This value won't be used for plotting histograms, since the renderer will ignore it. But other renderers can use it (for example, you could use the dataset to create a line chart).

Specified by:
getXValue in interface XYDataset
Parameters:
series - the series index (zero based).
item - the item index (zero based).
Returns:
The start value.

getYValue

public java.lang.Number getYValue(int series,
                                  int item)
Returns the Y value for a bin.

Specified by:
getYValue in interface XYDataset
Parameters:
series - the series index (zero based).
item - the item index (zero based).
Returns:
The Y value.

getStartXValue

public java.lang.Number getStartXValue(int series,
                                       int item)
Returns the start value for a bin.

Specified by:
getStartXValue in interface IntervalXYDataset
Parameters:
series - the series index (zero based).
item - the item index (zero based).
Returns:
The start value.

getEndXValue

public java.lang.Number getEndXValue(int series,
                                     int item)
Returns the end value for a bin.

Specified by:
getEndXValue in interface IntervalXYDataset
Parameters:
series - the series index (zero based).
item - the item index (zero based).
Returns:
The end value.

getStartYValue

public java.lang.Number getStartYValue(int series,
                                       int item)
Returns the Y value for a bin.

Specified by:
getStartYValue in interface IntervalXYDataset
Parameters:
series - the series index (zero based).
item - the item index (zero based).
Returns:
The Y value.

getEndYValue

public java.lang.Number getEndYValue(int series,
                                     int item)
Returns the Y value for a bin.

Specified by:
getEndYValue in interface IntervalXYDataset
Parameters:
series - the series index (zero based).
item - the item index (zero based).
Returns:
The Y value.