List of usage examples for org.jfree.data.statistics SimpleHistogramBin accepts
public boolean accepts(double value)
true
if the specified value belongs in the bin, and false
otherwise. From source file:org.jfree.data.statistics.SimpleHistogramBinTest.java
/** * Some checks for the accepts() method. *//* ww w. j a va 2 s. c om*/ @Test public void testAccepts() { SimpleHistogramBin bin1 = new SimpleHistogramBin(1.0, 2.0); assertFalse(bin1.accepts(0.0)); assertTrue(bin1.accepts(1.0)); assertTrue(bin1.accepts(1.5)); assertTrue(bin1.accepts(2.0)); assertFalse(bin1.accepts(2.1)); assertFalse(bin1.accepts(Double.NaN)); SimpleHistogramBin bin2 = new SimpleHistogramBin(1.0, 2.0, false, false); assertFalse(bin2.accepts(0.0)); assertFalse(bin2.accepts(1.0)); assertTrue(bin2.accepts(1.5)); assertFalse(bin2.accepts(2.0)); assertFalse(bin2.accepts(2.1)); assertFalse(bin2.accepts(Double.NaN)); }
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 w w w. j av a 2s . co 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)); } }