Package org.jfree.data.statistics
Class SimpleHistogramDataset
- java.lang.Object
-
- org.jfree.data.general.AbstractDataset
-
- org.jfree.data.general.AbstractSeriesDataset
-
- org.jfree.data.xy.AbstractXYDataset
-
- org.jfree.data.xy.AbstractIntervalXYDataset
-
- org.jfree.data.statistics.SimpleHistogramDataset
-
- All Implemented Interfaces:
java.io.ObjectInputValidation
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,PublicCloneable
,Dataset
,SeriesChangeListener
,SeriesDataset
,IntervalXYDataset
,XYDataset
public class SimpleHistogramDataset extends AbstractIntervalXYDataset implements IntervalXYDataset, java.lang.Cloneable, PublicCloneable, java.io.Serializable
A dataset used for creating simple histograms with custom defined bins.- See Also:
HistogramDataset
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
adjustForBinSize
A flag that controls whether or not the bin count is divided by the bin size.private java.util.List
bins
The bins.private java.lang.Comparable
key
The series key.private static long
serialVersionUID
For serialization.
-
Constructor Summary
Constructors Constructor Description SimpleHistogramDataset(java.lang.Comparable key)
Creates a new histogram dataset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBin(SimpleHistogramBin bin)
Adds a bin to the dataset.void
addObservation(double value)
Adds an observation to the dataset (by incrementing the item count for the appropriate bin).void
addObservation(double value, boolean notify)
Adds an observation to the dataset (by incrementing the item count for the appropriate bin).void
addObservations(double[] values)
Adds a set of values to the dataset and sends aDatasetChangeEvent
to all registered listeners.void
clearObservations()
Removes all current observation data and sends aDatasetChangeEvent
to all registered listeners.java.lang.Object
clone()
Returns a clone of the dataset.boolean
equals(java.lang.Object obj)
Compares the dataset for equality with an arbitrary object.boolean
getAdjustForBinSize()
Returns a flag that controls whether or not the bin count is divided by the bin size in thegetXValue(int, int)
method.DomainOrder
getDomainOrder()
Returns the order of the domain (or X) values returned by the dataset.java.lang.Number
getEndX(int series, int item)
Returns the ending X value for the specified series and item.double
getEndXValue(int series, int item)
Returns the end x-value (as a double primitive) for an item within a series.java.lang.Number
getEndY(int series, int item)
Returns the ending Y value for the specified series and item.double
getEndYValue(int series, int item)
Returns the end y-value (as a double primitive) for an item within a series.int
getItemCount(int series)
Returns the number of items in a series.int
getSeriesCount()
Returns the number of series in the dataset (always 1 for this dataset).java.lang.Comparable
getSeriesKey(int series)
Returns the key for a series.java.lang.Number
getStartX(int series, int item)
Returns the starting X value for the specified series and item.double
getStartXValue(int series, int item)
Returns the start x-value (as a double primitive) for an item within a series.java.lang.Number
getStartY(int series, int item)
Returns the starting Y value for the specified series and item.double
getStartYValue(int series, int item)
Returns the start y-value (as a double primitive) for an item within a series.java.lang.Number
getX(int series, int item)
Returns the x-value for an item within a series.double
getXValue(int series, int item)
Returns the x-value (as a double primitive) for an item within a series.java.lang.Number
getY(int series, int item)
Returns the y-value for an item within a series.double
getYValue(int series, int item)
Returns the y-value (as a double primitive) for an item within a series.void
removeAllBins()
Removes all bins and sends aDatasetChangeEvent
to all registered listeners.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 aDatasetChangeEvent
to all registered listeners.-
Methods inherited from class org.jfree.data.general.AbstractSeriesDataset
indexOf, seriesChanged
-
Methods inherited from class org.jfree.data.general.AbstractDataset
addChangeListener, canEqual, fireDatasetChanged, getGroup, getNotify, hashCode, hasListener, notifyListeners, removeChangeListener, setGroup, 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, getGroup, removeChangeListener, setGroup
-
Methods inherited from interface org.jfree.data.general.SeriesDataset
indexOf
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
key
private java.lang.Comparable key
The series key.
-
bins
private java.util.List bins
The bins.
-
adjustForBinSize
private boolean adjustForBinSize
A flag that controls whether or not the bin count is divided by the bin size.
-
-
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 aDatasetChangeEvent
to 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:
getSeriesCount
in interfaceSeriesDataset
- Specified by:
getSeriesCount
in classAbstractSeriesDataset
- Returns:
- The series count.
-
getSeriesKey
public java.lang.Comparable getSeriesKey(int series)
Returns the key for a series. Since this dataset only stores a single series, theseries
argument is ignored.- Specified by:
getSeriesKey
in interfaceSeriesDataset
- Specified by:
getSeriesKey
in 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:
getDomainOrder
in interfaceXYDataset
- Overrides:
getDomainOrder
in 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, theseries
argument is ignored.- Specified by:
getItemCount
in interfaceXYDataset
- Parameters:
series
- the series index (zero-based, ignored in this dataset).- Returns:
- The item count.
-
addBin
public void addBin(SimpleHistogramBin bin)
Adds a bin to the dataset. An exception is thrown if the bin overlaps with any existing bin in the dataset.- Parameters:
bin
- the bin (null
not 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
- sendDatasetChangeEvent
to listeners?
-
addObservations
public void addObservations(double[] values)
Adds a set of values to the dataset and sends aDatasetChangeEvent
to all registered listeners.- Parameters:
values
- the values (null
not permitted).- See Also:
clearObservations()
-
clearObservations
public void clearObservations()
Removes all current observation data and sends aDatasetChangeEvent
to all registered listeners.- See Also:
addObservations(double[])
,removeAllBins()
-
removeAllBins
public void removeAllBins()
Removes all bins and sends aDatasetChangeEvent
to all registered listeners.- See Also:
addBin(SimpleHistogramBin)
-
getX
public java.lang.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.
-
getXValue
public double getXValue(int series, int item)
Returns the x-value (as a double primitive) for an item within a series.- Specified by:
getXValue
in interfaceXYDataset
- Overrides:
getXValue
in classAbstractXYDataset
- Parameters:
series
- the series index (zero-based).item
- the item index (zero-based).- Returns:
- The x-value.
-
getY
public java.lang.Number getY(int series, int item)
Returns the y-value for an item within a series.
-
getYValue
public double getYValue(int series, int item)
Returns the y-value (as a double primitive) for an item within a series.- Specified by:
getYValue
in interfaceXYDataset
- Overrides:
getYValue
in classAbstractXYDataset
- Parameters:
series
- the series index (zero-based).item
- the item index (zero-based).- Returns:
- The y-value.
- See Also:
getAdjustForBinSize()
-
getStartX
public java.lang.Number getStartX(int series, int item)
Returns the starting X value for the specified series and item.- Specified by:
getStartX
in interfaceIntervalXYDataset
- 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:
getStartXValue
in interfaceIntervalXYDataset
- Overrides:
getStartXValue
in 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 java.lang.Number getEndX(int series, int item)
Returns the ending X value for the specified series and item.- Specified by:
getEndX
in interfaceIntervalXYDataset
- 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:
getEndXValue
in interfaceIntervalXYDataset
- Overrides:
getEndXValue
in 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 java.lang.Number getStartY(int series, int item)
Returns the starting Y value for the specified series and item.- Specified by:
getStartY
in interfaceIntervalXYDataset
- 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:
getStartYValue
in interfaceIntervalXYDataset
- Overrides:
getStartYValue
in 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 java.lang.Number getEndY(int series, int item)
Returns the ending Y value for the specified series and item.- Specified by:
getEndY
in interfaceIntervalXYDataset
- 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:
getEndYValue
in interfaceIntervalXYDataset
- Overrides:
getEndYValue
in 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(java.lang.Object obj)
Compares the dataset for equality with an arbitrary object.- Overrides:
equals
in classAbstractDataset
- Parameters:
obj
- the object (null
permitted).- Returns:
- A boolean.
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Returns a clone of the dataset.- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classAbstractDataset
- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException
- not thrown by this class, but maybe by subclasses (if any).
-
-