Example usage for org.jfree.data.statistics SimpleHistogramBin getItemCount

List of usage examples for org.jfree.data.statistics SimpleHistogramBin getItemCount

Introduction

In this page you can find the example usage for org.jfree.data.statistics SimpleHistogramBin getItemCount.

Prototype

public int getItemCount() 

Source Link

Document

Returns the item count.

Usage

From source file:org.jfree.data.statistics.SimpleHistogramDataset.java

/**
 * Returns the y-value (as a double primitive) for an item within a series.
 *
 * @param series  the series index (zero-based).
 * @param item  the item index (zero-based).
 *
 * @return The y-value./* w  ww  . j  a v  a 2  s . c o  m*/
 *
 * @see #getAdjustForBinSize()
 */
@Override
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();
    }
}

From source file:org.jfree.data.statistics.SimpleHistogramDataset.java

/**
 * 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.//from  www  .  j av a2 s.c  o m
 *
 * @param value  the value.
 * @param notify  send {@link DatasetChangeEvent} to listeners?
 */
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));
    }
}