org.jfree.data.statistics.HistogramBin Java Examples

The following examples show how to use org.jfree.data.statistics.HistogramBin. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HistogramPlotDataset.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the y-value for a bin (calculated to take into account the histogram type).
 *
 * @param series the series index (in the range <code>0</code> to
 *        <code>getSeriesCount() - 1</code>).
 * @param item the item index (zero based).
 *
 * @return The y-value.
 *
 * @throws IndexOutOfBoundsException if <code>series</code> is outside the specified range.
 */
@Override
public Number getY(int series, int item) {
  List<?> bins = getBins(series);
  HistogramBin bin = (HistogramBin) bins.get(item);
  double total = getTotal(series);
  double binWidth = getBinWidth(series);

  if (this.type == HistogramType.FREQUENCY) {
    return new Double(bin.getCount());
  } else if (this.type == HistogramType.RELATIVE_FREQUENCY) {
    return new Double(bin.getCount() / total);
  } else if (this.type == HistogramType.SCALE_AREA_TO_1) {
    return new Double(bin.getCount() / (binWidth * total));
  } else { // pretty sure this shouldn't ever happen
    throw new IllegalStateException();
  }
}
 
Example #2
Source File: HistogramPlotDataset.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the y-value for a bin (calculated to take into account the histogram type).
 * 
 * @param series the series index (in the range <code>0</code> to
 *        <code>getSeriesCount() - 1</code>).
 * @param item the item index (zero based).
 * 
 * @return The y-value.
 * 
 * @throws IndexOutOfBoundsException if <code>series</code> is outside the specified range.
 */
public Number getY(int series, int item) {
  List<?> bins = getBins(series);
  HistogramBin bin = (HistogramBin) bins.get(item);
  double total = getTotal(series);
  double binWidth = getBinWidth(series);

  if (this.type == HistogramType.FREQUENCY) {
    return new Double(bin.getCount());
  } else if (this.type == HistogramType.RELATIVE_FREQUENCY) {
    return new Double(bin.getCount() / total);
  } else if (this.type == HistogramType.SCALE_AREA_TO_1) {
    return new Double(bin.getCount() / (binWidth * total));
  } else { // pretty sure this shouldn't ever happen
    throw new IllegalStateException();
  }
}
 
Example #3
Source File: HistogramBinTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    double start = 10.0;
    double end = 20.0;
    HistogramBin b1 = new HistogramBin(start, end);
    HistogramBin b2 = new HistogramBin(start, end);

    assertTrue(b1.equals(b2));
    assertTrue(b2.equals(b1));

}
 
Example #4
Source File: HistogramBinTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    
    double start = 10.0;
    double end = 20.0;
    HistogramBin b1 = new HistogramBin(start, end);
    HistogramBin b2 = new HistogramBin(start, end);
    
    assertTrue(b1.equals(b2));
    assertTrue(b2.equals(b1));

}
 
Example #5
Source File: HistogramPlotDataset.java    From mzmine3 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the X value for a bin. This value won't be used for plotting histograms, since the
 * renderer will ignore it. But other renderers can use it (for example, you could use the dataset
 * to create a line chart).
 *
 * @param series the series index (in the range <code>0</code> to
 *        <code>getSeriesCount() - 1</code>).
 * @param item the item index (zero based).
 *
 * @return The start value.
 *
 * @throws IndexOutOfBoundsException if <code>series</code> is outside the specified range.
 */
@Override
public Number getX(int series, int item) {
  List<?> bins = getBins(series);
  HistogramBin bin = (HistogramBin) bins.get(item);
  double x = (bin.getStartBoundary() + bin.getEndBoundary()) / 2.;
  return new Double(x);
}
 
Example #6
Source File: HistogramPlotDataset.java    From mzmine3 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the start value for a bin.
 *
 * @param series the series index (in the range <code>0</code> to
 *        <code>getSeriesCount() - 1</code>).
 * @param item the item index (zero based).
 *
 * @return The start value.
 *
 * @throws IndexOutOfBoundsException if <code>series</code> is outside the specified range.
 */
@Override
public Number getStartX(int series, int item) {
  List<?> bins = getBins(series);
  HistogramBin bin = (HistogramBin) bins.get(item);
  return new Double(bin.getStartBoundary());
}
 
Example #7
Source File: HistogramPlotDataset.java    From mzmine3 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the end value for a bin.
 *
 * @param series the series index (in the range <code>0</code> to
 *        <code>getSeriesCount() - 1</code>).
 * @param item the item index (zero based).
 *
 * @return The end value.
 *
 * @throws IndexOutOfBoundsException if <code>series</code> is outside the specified range.
 */
@Override
public Number getEndX(int series, int item) {
  List<?> bins = getBins(series);
  HistogramBin bin = (HistogramBin) bins.get(item);
  return new Double(bin.getEndBoundary());
}
 
Example #8
Source File: HistogramPlotDataset.java    From mzmine2 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns the X value for a bin. This value won't be used for plotting histograms, since the
 * renderer will ignore it. But other renderers can use it (for example, you could use the dataset
 * to create a line chart).
 * 
 * @param series the series index (in the range <code>0</code> to
 *        <code>getSeriesCount() - 1</code>).
 * @param item the item index (zero based).
 * 
 * @return The start value.
 * 
 * @throws IndexOutOfBoundsException if <code>series</code> is outside the specified range.
 */
public Number getX(int series, int item) {
  List<?> bins = getBins(series);
  HistogramBin bin = (HistogramBin) bins.get(item);
  double x = (bin.getStartBoundary() + bin.getEndBoundary()) / 2.;
  return new Double(x);
}
 
Example #9
Source File: HistogramPlotDataset.java    From mzmine2 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the start value for a bin.
 * 
 * @param series the series index (in the range <code>0</code> to
 *        <code>getSeriesCount() - 1</code>).
 * @param item the item index (zero based).
 * 
 * @return The start value.
 * 
 * @throws IndexOutOfBoundsException if <code>series</code> is outside the specified range.
 */
public Number getStartX(int series, int item) {
  List<?> bins = getBins(series);
  HistogramBin bin = (HistogramBin) bins.get(item);
  return new Double(bin.getStartBoundary());
}
 
Example #10
Source File: HistogramPlotDataset.java    From mzmine2 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the end value for a bin.
 * 
 * @param series the series index (in the range <code>0</code> to
 *        <code>getSeriesCount() - 1</code>).
 * @param item the item index (zero based).
 * 
 * @return The end value.
 * 
 * @throws IndexOutOfBoundsException if <code>series</code> is outside the specified range.
 */
public Number getEndX(int series, int item) {
  List<?> bins = getBins(series);
  HistogramBin bin = (HistogramBin) bins.get(item);
  return new Double(bin.getEndBoundary());
}