A dataset used for creating simple histograms with custom defined bins.
| Method from org.jfree.data.statistics.SimpleHistogramDataset Detail: |
public void addBin(SimpleHistogramBin bin) {
// check that the new bin doesn't overlap with any existing bin
Iterator iterator = this.bins.iterator();
while (iterator.hasNext()) {
SimpleHistogramBin existingBin
= (SimpleHistogramBin) iterator.next();
if (bin.overlapsWith(existingBin)) {
throw new RuntimeException("Overlapping bin");
}
}
this.bins.add(bin);
Collections.sort(this.bins);
}
Adds a bin to the dataset. An exception is thrown if the bin overlaps
with any existing bin in the dataset. |
public void addObservation(double value) {
addObservation(value, true);
}
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. |
public void addObservation(double value,
boolean notify) {
boolean placed = false;
Iterator iterator = this.bins.iterator();
while (iterator.hasNext() && !placed) {
SimpleHistogramBin bin = (SimpleHistogramBin) iterator.next();
if (bin.accepts(value)) {
bin.setItemCount(bin.getItemCount() + 1);
placed = true;
}
}
if (!placed) {
throw new RuntimeException("No bin.");
}
if (notify) {
notifyListeners(new DatasetChangeEvent(this, this));
}
}
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. |
public void addObservations(double[] values) {
for (int i = 0; i < values.length; i++) {
addObservation(values[i], false);
}
notifyListeners(new DatasetChangeEvent(this, this));
}
Adds a set of values to the dataset and sends a
DatasetChangeEvent to all registered listeners. |
public void clearObservations() {
Iterator iterator = this.bins.iterator();
while (iterator.hasNext()) {
SimpleHistogramBin bin = (SimpleHistogramBin) iterator.next();
bin.setItemCount(0);
}
notifyListeners(new DatasetChangeEvent(this, this));
}
Removes all current observation data and sends a
DatasetChangeEvent to all registered listeners. |
public Object clone() throws CloneNotSupportedException {
SimpleHistogramDataset clone = (SimpleHistogramDataset) super.clone();
clone.bins = (List) ObjectUtilities.deepClone(this.bins);
return clone;
}
Returns a clone of the dataset. |
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof SimpleHistogramDataset)) {
return false;
}
SimpleHistogramDataset that = (SimpleHistogramDataset) obj;
if (!this.key.equals(that.key)) {
return false;
}
if (this.adjustForBinSize != that.adjustForBinSize) {
return false;
}
if (!this.bins.equals(that.bins)) {
return false;
}
return true;
}
Compares the dataset for equality with an arbitrary object. |
public boolean getAdjustForBinSize() {
return this.adjustForBinSize;
}
Returns a flag that controls whether or not the bin count is divided by
the bin size in the #getXValue(int, int) method. |
public DomainOrder getDomainOrder() {
return DomainOrder.ASCENDING;
}
Returns the order of the domain (or X) values returned by the dataset. |
public Number getEndX(int series,
int item) {
return new Double(getEndXValue(series, item));
}
Returns the ending X value for the specified series and item. |
public double getEndXValue(int series,
int item) {
SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item);
return bin.getUpperBound();
}
Returns the end x-value (as a double primitive) for an item within a
series. |
public Number getEndY(int series,
int item) {
return getY(series, item);
}
Returns the ending Y value for the specified series and item. |
public double getEndYValue(int series,
int item) {
return getYValue(series, item);
}
Returns the end y-value (as a double primitive) for an item within a
series. |
public int getItemCount(int series) {
return this.bins.size();
}
Returns the number of items in a series. Since this dataset only stores
a single series, the series argument is ignored. |
public int getSeriesCount() {
return 1;
}
Returns the number of series in the dataset (always 1 for this dataset). |
public Comparable getSeriesKey(int series) {
return this.key;
}
Returns the key for a series. Since this dataset only stores a single
series, the series argument is ignored. |
public Number getStartX(int series,
int item) {
return new Double(getStartXValue(series, item));
}
Returns the starting X value for the specified series and item. |
public double getStartXValue(int series,
int item) {
SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item);
return bin.getLowerBound();
}
Returns the start x-value (as a double primitive) for an item within a
series. |
public Number getStartY(int series,
int item) {
return getY(series, item);
}
Returns the starting Y value for the specified series and item. |
public double getStartYValue(int series,
int item) {
return getYValue(series, item);
}
Returns the start y-value (as a double primitive) for an item within a
series. |
public Number getX(int series,
int item) {
return new Double(getXValue(series, 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. |
public double getXValue(int series,
int item) {
SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item);
return (bin.getLowerBound() + bin.getUpperBound()) / 2.0;
}
Returns the x-value (as a double primitive) for an item within a series. |
public Number getY(int series,
int item) {
return new Double(getYValue(series, item));
}
Returns the y-value for an item within a series. |
public double getYValue(int series,
int item) {
SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item);
if (this.adjustForBinSize) {
return bin.getItemCount()
/ (bin.getUpperBound() - bin.getLowerBound());
}
else {
return bin.getItemCount();
}
}
Returns the y-value (as a double primitive) for an item within a series. |
public void removeAllBins() {
this.bins = new ArrayList();
notifyListeners(new DatasetChangeEvent(this, this));
}
|
public void setAdjustForBinSize(boolean adjust) {
this.adjustForBinSize = adjust;
notifyListeners(new DatasetChangeEvent(this, this));
}
|