Ejemplo n.º 1
0
 /**
  * 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.
  * @see #getAdjustForBinSize()
  */
 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();
   }
 }
Ejemplo n.º 2
0
 /**
  * Removes all current observation data and sends a {@link DatasetChangeEvent} to all registered
  * listeners.
  *
  * @since 1.0.6
  * @see #addObservations(double[])
  * @see #removeAllBins()
  */
 public void clearObservations() {
   Iterator iterator = this.bins.iterator();
   while (iterator.hasNext()) {
     SimpleHistogramBin bin = (SimpleHistogramBin) iterator.next();
     bin.setItemCount(0);
   }
   notifyListeners(new DatasetChangeEvent(this, this));
 }
Ejemplo n.º 3
0
 /**
  * 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.
  *
  * @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));
   }
 }
Ejemplo n.º 4
0
 /**
  * Adds a bin to the dataset. An exception is thrown if the bin overlaps with any existing bin in
  * the dataset.
  *
  * @param bin the bin (<code>null</code> not permitted).
  * @see #removeAllBins()
  */
 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);
 }
Ejemplo n.º 5
0
 /**
  * Returns the end x-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 end x-value.
  */
 public double getEndXValue(int series, int item) {
   SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item);
   return bin.getUpperBound();
 }
Ejemplo n.º 6
0
 /**
  * Returns the x-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 x-value.
  */
 public double getXValue(int series, int item) {
   SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item);
   return (bin.getLowerBound() + bin.getUpperBound()) / 2.0;
 }