Module org.jfree.chart
Package org.jfree.data.statistics
Class SimpleHistogramDataset<K extends Comparable<K>>
- java.lang.Object
-
- org.jfree.data.general.AbstractDataset
-
- org.jfree.data.general.AbstractSeriesDataset<S>
-
- org.jfree.data.xy.AbstractXYDataset<S>
-
- org.jfree.data.xy.AbstractIntervalXYDataset
-
- org.jfree.data.statistics.SimpleHistogramDataset<K>
-
- All Implemented Interfaces:
ObjectInputValidation,Serializable,Cloneable,EventListener,PublicCloneable,Dataset,SeriesChangeListener,SeriesDataset,IntervalXYDataset,XYDataset
public class SimpleHistogramDataset<K extends Comparable<K>> extends AbstractIntervalXYDataset implements IntervalXYDataset, Cloneable, PublicCloneable, Serializable
A dataset used for creating simple histograms with custom defined bins.- See Also:
HistogramDataset, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SimpleHistogramDataset(K key)Creates a new histogram dataset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBin(SimpleHistogramBin binToAdd)Adds a bin to the dataset.voidaddObservation(double value)Adds an observation to the dataset (by incrementing the item count for the appropriate bin).voidaddObservation(double value, boolean notify)Adds an observation to the dataset (by incrementing the item count for the appropriate bin).voidaddObservations(double[] values)Adds a set of values to the dataset and sends aDatasetChangeEventto all registered listeners.voidclearObservations()Removes all current observation data and sends aDatasetChangeEventto all registered listeners.Objectclone()Returns a clone of the dataset.booleanequals(Object obj)Compares the dataset for equality with an arbitrary object.booleangetAdjustForBinSize()Returns a flag that controls whether or not the bin count is divided by the bin size in thegetXValue(int, int)method.DomainOrdergetDomainOrder()Returns the order of the domain (or X) values returned by the dataset.NumbergetEndX(int series, int item)Returns the ending X value for the specified series and item.doublegetEndXValue(int series, int item)Returns the end x-value (as a double primitive) for an item within a series.NumbergetEndY(int series, int item)Returns the ending Y value for the specified series and item.doublegetEndYValue(int series, int item)Returns the end y-value (as a double primitive) for an item within a series.intgetItemCount(int series)Returns the number of items in a series.intgetSeriesCount()Returns the number of series in the dataset (always 1 for this dataset).KgetSeriesKey(int series)Returns the key for a series.NumbergetStartX(int series, int item)Returns the starting X value for the specified series and item.doublegetStartXValue(int series, int item)Returns the start x-value (as a double primitive) for an item within a series.NumbergetStartY(int series, int item)Returns the starting Y value for the specified series and item.doublegetStartYValue(int series, int item)Returns the start y-value (as a double primitive) for an item within a series.NumbergetX(int series, int item)Returns the x-value for an item within a series.doublegetXValue(int series, int item)Returns the x-value (as a double primitive) for an item within a series.NumbergetY(int series, int item)Returns the y-value for an item within a series.doublegetYValue(int series, int item)Returns the y-value (as a double primitive) for an item within a series.inthashCode()voidremoveAllBins()Removes all bins and sends aDatasetChangeEventto all registered listeners.voidsetAdjustForBinSize(boolean adjust)Sets the flag that controls whether or not the bin count is divided by the bin size in thegetYValue(int, int)method, and sends aDatasetChangeEventto all registered listeners.-
Methods inherited from class org.jfree.data.general.AbstractSeriesDataset
indexOf, seriesChanged
-
Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, fireDatasetChanged, getNotify, hasListener, notifyListeners, removeChangeListener, setNotify, validateObject
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jfree.data.general.Dataset
addChangeListener, removeChangeListener
-
Methods inherited from interface org.jfree.data.general.SeriesDataset
indexOf
-
-
-
-
Constructor Detail
-
SimpleHistogramDataset
public SimpleHistogramDataset(K key)
Creates a new histogram dataset. Note that theadjustForBinSizeflag defaults totrue.- Parameters:
key- the series key (nullnot permitted).
-
-
Method Detail
-
getAdjustForBinSize
public boolean getAdjustForBinSize()
Returns a flag that controls whether or not the bin count is divided by the bin size in thegetXValue(int, int)method.- Returns:
- A boolean.
- See Also:
setAdjustForBinSize(boolean)
-
setAdjustForBinSize
public void setAdjustForBinSize(boolean adjust)
Sets the flag that controls whether or not the bin count is divided by the bin size in thegetYValue(int, int)method, and sends aDatasetChangeEventto all registered listeners.- Parameters:
adjust- the flag.- See Also:
getAdjustForBinSize()
-
getSeriesCount
public int getSeriesCount()
Returns the number of series in the dataset (always 1 for this dataset).- Specified by:
getSeriesCountin interfaceSeriesDataset<K extends Comparable<K>>- Specified by:
getSeriesCountin classAbstractSeriesDataset- Returns:
- The series count.
-
getSeriesKey
public K getSeriesKey(int series)
Returns the key for a series. Since this dataset only stores a single series, theseriesargument is ignored.- Specified by:
getSeriesKeyin interfaceSeriesDataset<K extends Comparable<K>>- Specified by:
getSeriesKeyin classAbstractSeriesDataset- Parameters:
series- the series (zero-based index, ignored in this dataset).- Returns:
- The key for the series.
-
getDomainOrder
public DomainOrder getDomainOrder()
Returns the order of the domain (or X) values returned by the dataset.- Specified by:
getDomainOrderin interfaceXYDataset<K extends Comparable<K>>- Overrides:
getDomainOrderin classAbstractXYDataset- Returns:
- The order (never
null).
-
getItemCount
public int getItemCount(int series)
Returns the number of items in a series. Since this dataset only stores a single series, theseriesargument is ignored.- Specified by:
getItemCountin interfaceXYDataset<K extends Comparable<K>>- Parameters:
series- the series index (zero-based, ignored in this dataset).- Returns:
- The item count.
-
addBin
public void addBin(SimpleHistogramBin binToAdd)
Adds a bin to the dataset. An exception is thrown if the bin overlaps with any existing bin in the dataset.- Parameters:
binToAdd- the bin (nullnot permitted).- See Also:
removeAllBins()
-
addObservation
public void addObservation(double value)
Adds an observation to the dataset (by incrementing the item count for the appropriate bin). A runtime exception is thrown if the value does not fit into any bin.- Parameters:
value- the value.
-
addObservation
public void addObservation(double value, boolean notify)
Adds an observation to the dataset (by incrementing the item count for the appropriate bin). A runtime exception is thrown if the value does not fit into any bin.- Parameters:
value- the value.notify- sendDatasetChangeEventto listeners?
-
addObservations
public void addObservations(double[] values)
Adds a set of values to the dataset and sends aDatasetChangeEventto all registered listeners.- Parameters:
values- the values (nullnot permitted).- See Also:
clearObservations()
-
clearObservations
public void clearObservations()
Removes all current observation data and sends aDatasetChangeEventto all registered listeners.- Since:
- 1.0.6
- See Also:
addObservations(double[]),removeAllBins()
-
removeAllBins
public void removeAllBins()
Removes all bins and sends aDatasetChangeEventto all registered listeners.- Since:
- 1.0.6
- See Also:
addBin(SimpleHistogramBin)
-
getX
public Number getX(int series, int item)
Returns the x-value for an item within a series. The x-values may or may not be returned in ascending order, that is up to the class implementing the interface.- Specified by:
getXin interfaceXYDataset<K extends Comparable<K>>- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The x-value (never
null).
-
getXValue
public double getXValue(int series, int item)
Returns the x-value (as a double primitive) for an item within a series.- Specified by:
getXValuein interfaceXYDataset<K extends Comparable<K>>- Overrides:
getXValuein classAbstractXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The x-value.
-
getY
public Number getY(int series, int item)
Returns the y-value for an item within a series.- Specified by:
getYin interfaceXYDataset<K extends Comparable<K>>- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The y-value (possibly
null).
-
getYValue
public double getYValue(int series, int item)
Returns the y-value (as a double primitive) for an item within a series.- Specified by:
getYValuein interfaceXYDataset<K extends Comparable<K>>- Overrides:
getYValuein classAbstractXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The y-value.
- See Also:
getAdjustForBinSize()
-
getStartX
public Number getStartX(int series, int item)
Returns the starting X value for the specified series and item.- Specified by:
getStartXin interfaceIntervalXYDataset<K extends Comparable<K>>- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The value.
-
getStartXValue
public double getStartXValue(int series, int item)
Returns the start x-value (as a double primitive) for an item within a series.- Specified by:
getStartXValuein interfaceIntervalXYDataset<K extends Comparable<K>>- Overrides:
getStartXValuein classAbstractIntervalXYDataset- Parameters:
series- the series (zero-based index).item- the item (zero-based index).- Returns:
- The start x-value.
- See Also:
IntervalXYDataset.getStartX(int, int)
-
getEndX
public Number getEndX(int series, int item)
Returns the ending X value for the specified series and item.- Specified by:
getEndXin interfaceIntervalXYDataset<K extends Comparable<K>>- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The value.
-
getEndXValue
public double getEndXValue(int series, int item)
Returns the end x-value (as a double primitive) for an item within a series.- Specified by:
getEndXValuein interfaceIntervalXYDataset<K extends Comparable<K>>- Overrides:
getEndXValuein classAbstractIntervalXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The end x-value.
- See Also:
IntervalXYDataset.getEndX(int, int)
-
getStartY
public Number getStartY(int series, int item)
Returns the starting Y value for the specified series and item.- Specified by:
getStartYin interfaceIntervalXYDataset<K extends Comparable<K>>- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The value.
-
getStartYValue
public double getStartYValue(int series, int item)
Returns the start y-value (as a double primitive) for an item within a series.- Specified by:
getStartYValuein interfaceIntervalXYDataset<K extends Comparable<K>>- Overrides:
getStartYValuein classAbstractIntervalXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The start y-value.
- See Also:
IntervalXYDataset.getStartY(int, int)
-
getEndY
public Number getEndY(int series, int item)
Returns the ending Y value for the specified series and item.- Specified by:
getEndYin interfaceIntervalXYDataset<K extends Comparable<K>>- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The value.
-
getEndYValue
public double getEndYValue(int series, int item)
Returns the end y-value (as a double primitive) for an item within a series.- Specified by:
getEndYValuein interfaceIntervalXYDataset<K extends Comparable<K>>- Overrides:
getEndYValuein classAbstractIntervalXYDataset- Parameters:
series- the series index (zero-based).item- the item index (zero-based).- Returns:
- The end y-value.
- See Also:
IntervalXYDataset.getEndY(int, int)
-
equals
public boolean equals(Object obj)
Compares the dataset for equality with an arbitrary object.
-
clone
public Object clone() throws CloneNotSupportedException
Returns a clone of the dataset.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classAbstractDataset- Returns:
- A clone.
- Throws:
CloneNotSupportedException- not thrown by this class, but maybe by subclasses (if any).
-
-