/** * Some checks for the constructor. */ public void testConstructor1() { XYIntervalDataItem item1 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, 1.9, 2.1); assertEquals(new Double(1.0), item1.getX()); assertEquals(0.5, item1.getXLowValue(), EPSILON); assertEquals(1.5, item1.getXHighValue(), EPSILON); assertEquals(2.0, item1.getYValue(), EPSILON); assertEquals(1.9, item1.getYLowValue(), EPSILON); assertEquals(2.1, item1.getYHighValue(), EPSILON); }
/** * Add a point to the specified graph series. * @param seriesKey Key of series to update. * @param dataItem XYDataItem object to insert into this series. */ public void addPointToSeries(SeriesKey seriesKey, XYIntervalDataItem dataItem) { synchronized (seriesCollection) { XYIntervalSeries series = keyToSeries.get(seriesKey); series.add(dataItem.getX(), dataItem.getXLowValue(), dataItem.getXHighValue(), dataItem.getYValue(), dataItem.getYLowValue(), dataItem.getYHighValue()); } }
/** * Plots the series which is referenced by seriesKey. * @param seriesKey the key to the series that has to be plotted */ public void plotSeries(SeriesKey seriesKey){ double range = (maxProb - minProb) / (double)numOfBuckets; // Our range for which the histogram will be shown for(int i = 0 ; i < numOfBuckets ; i++){ double minRange = minProb + (range*i); double maxRange = minRange + range; double height; if(i == (numOfBuckets-1)) // include the first value height = countProbabilities(minRange, maxRange, true); else height = countProbabilities(minRange, maxRange, false); double x = (minRange + maxRange) / 2.0; addPointToSeries(seriesKey, new XYIntervalDataItem(x, minRange, maxRange, height, height, height)); /**Only update the x axis tick marks if this is the first series which is being plotted*/ if(isNew){ if(i == 0) ticks.add(minRange); ticks.add(maxRange); } } /**Set the visible range of the plot*/ plot.getDomainAxis().setRange(minProb-0.02, maxProb+0.02); /** clear the cache, we don't need it anymore*/ dataCache.clear(); }