List of usage examples for org.jfree.data.statistics HistogramDataset getEndXValue
@Override public double getEndXValue(int series, int item)
From source file:biz.ixnay.pivot.charts.skin.jfree.HistogramViewSkin.java
public Element getElementAt(int x, int y) { ChartView.Element element = null; ChartEntity chartEntity = getChartEntityAt(x, y); if (chartEntity instanceof XYItemEntity) { XYItemEntity xyItemEntity = (XYItemEntity) chartEntity; HistogramDataset dataSet = (HistogramDataset) ((XYItemEntity) chartEntity).getDataset(); int series = xyItemEntity.getSeriesIndex(); int item = xyItemEntity.getItem(); double binStart = dataSet.getStartXValue(series, item); double binEnd = dataSet.getEndXValue(series, item); double binValue = dataSet.getXValue(series, item); double frequency = dataSet.getYValue(series, item); element = new HistogramView.HistogramBin(series, item, binStart, binValue, binEnd, frequency); }// w w w .ja v a 2s .c om return element; }
From source file:org.jfree.data.statistics.HistogramDatasetTest.java
/** * Some checks for the addSeries() method. *//* w ww. j a va2 s.co m*/ @Test public void testAddSeries() { double[] values = { -1.0, 0.0, 0.1, 0.9, 1.0, 1.1, 1.9, 2.0, 3.0 }; HistogramDataset d = new HistogramDataset(); d.addSeries("S1", values, 2, 0.0, 2.0); assertEquals(0.0, d.getStartXValue(0, 0), EPSILON); assertEquals(1.0, d.getEndXValue(0, 0), EPSILON); assertEquals(4.0, d.getYValue(0, 0), EPSILON); assertEquals(1.0, d.getStartXValue(0, 1), EPSILON); assertEquals(2.0, d.getEndXValue(0, 1), EPSILON); assertEquals(5.0, d.getYValue(0, 1), EPSILON); }
From source file:org.jfree.data.statistics.HistogramDatasetTest.java
/** * Another check for the addSeries() method. *//*from ww w . j a v a 2 s . co m*/ @Test public void testAddSeries2() { double[] values = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }; HistogramDataset hd = new HistogramDataset(); hd.addSeries("S1", values, 5); assertEquals(0.0, hd.getStartXValue(0, 0), EPSILON); assertEquals(1.0, hd.getEndXValue(0, 0), EPSILON); assertEquals(1.0, hd.getYValue(0, 0), EPSILON); assertEquals(1.0, hd.getStartXValue(0, 1), EPSILON); assertEquals(2.0, hd.getEndXValue(0, 1), EPSILON); assertEquals(1.0, hd.getYValue(0, 1), EPSILON); assertEquals(2.0, hd.getStartXValue(0, 2), EPSILON); assertEquals(3.0, hd.getEndXValue(0, 2), EPSILON); assertEquals(1.0, hd.getYValue(0, 2), EPSILON); assertEquals(3.0, hd.getStartXValue(0, 3), EPSILON); assertEquals(4.0, hd.getEndXValue(0, 3), EPSILON); assertEquals(1.0, hd.getYValue(0, 3), EPSILON); assertEquals(4.0, hd.getStartXValue(0, 4), EPSILON); assertEquals(5.0, hd.getEndXValue(0, 4), EPSILON); assertEquals(2.0, hd.getYValue(0, 4), EPSILON); }
From source file:org.jfree.data.statistics.HistogramDatasetTest.java
/** * Some checks for bug 1553088. An IndexOutOfBoundsException is thrown * when a data value is *very* close to the upper limit of the last bin. *///from w ww.j a v a 2 s. c o m @Test public void test1553088() { double[] values = { -1.0, 0.0, -Double.MIN_VALUE, 3.0 }; HistogramDataset d = new HistogramDataset(); d.addSeries("S1", values, 2, -1.0, 0.0); assertEquals(-1.0, d.getStartXValue(0, 0), EPSILON); assertEquals(-0.5, d.getEndXValue(0, 0), EPSILON); assertEquals(1.0, d.getYValue(0, 0), EPSILON); assertEquals(-0.5, d.getStartXValue(0, 1), EPSILON); assertEquals(0.0, d.getEndXValue(0, 1), EPSILON); assertEquals(3.0, d.getYValue(0, 1), EPSILON); }
From source file:org.jfree.data.statistics.HistogramDatasetTest.java
/** * This test is derived from a reported bug. *//* w w w . j a v a2s . c o m*/ @Test public void testBinBoundaries() { double[] values = { -5.000000000000286E-5 }; int bins = 1260; double minimum = -0.06307522528160199; double maximum = 0.06297522528160199; HistogramDataset d = new HistogramDataset(); d.addSeries("S1", values, bins, minimum, maximum); assertEquals(0.0, d.getYValue(0, 629), EPSILON); assertEquals(1.0, d.getYValue(0, 630), EPSILON); assertEquals(0.0, d.getYValue(0, 631), EPSILON); assertTrue(values[0] > d.getStartXValue(0, 630)); assertTrue(values[0] < d.getEndXValue(0, 630)); }