Java Code Examples for org.jfree.data.xy.XYIntervalSeries#add()
The following examples show how to use
org.jfree.data.xy.XYIntervalSeries#add() .
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: XYBarRendererTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * A test for the findRangeBounds method to ensure it correctly accounts * for the series visibility. */ @Test public void testFindRangeBounds2() { XYIntervalSeries s1 = new XYIntervalSeries("S1"); s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5); s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3); XYIntervalSeries s2 = new XYIntervalSeries("S2"); s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5); s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0); XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); XYBarRenderer renderer = new XYBarRenderer(); renderer.setUseYInterval(false); Range r = renderer.findRangeBounds(dataset); assertEquals(9.0, r.getLowerBound(), EPSILON); assertEquals(30.0, r.getUpperBound(), EPSILON); renderer.setSeriesVisible(1, Boolean.FALSE); r = renderer.findRangeBounds(dataset); assertEquals(10.0, r.getLowerBound(), EPSILON); assertEquals(20.0, r.getUpperBound(), EPSILON); }
Example 2
Source File: DatasetUtilitiesTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Yet another test for bug 2849731. */ @Test public void testBug2849731_3() { XYIntervalSeriesCollection d = new XYIntervalSeriesCollection(); XYIntervalSeries s = new XYIntervalSeries("S1"); s.add(1.0, Double.NaN, Double.NaN, 1.5, Double.NaN, Double.NaN); d.addSeries(s); Range r = DatasetUtilities.iterateRangeBounds(d); assertEquals(1.5, r.getLowerBound(), EPSILON); assertEquals(1.5, r.getUpperBound(), EPSILON); s.add(1.0, 1.5, Double.NaN, Double.NaN, Double.NaN, 2.5); r = DatasetUtilities.iterateRangeBounds(d); assertEquals(1.5, r.getLowerBound(), EPSILON); assertEquals(2.5, r.getUpperBound(), EPSILON); s.add(1.0, Double.NaN, 0.5, Double.NaN, 3.5, Double.NaN); r = DatasetUtilities.iterateRangeBounds(d); assertEquals(1.5, r.getLowerBound(), EPSILON); assertEquals(3.5, r.getUpperBound(), EPSILON); }
Example 3
Source File: XYIntervalSeriesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection(); XYIntervalSeriesCollection c2 = new XYIntervalSeriesCollection(); assertEquals(c1, c2); // add a series XYIntervalSeries s1 = new XYIntervalSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5); c1.addSeries(s1); assertFalse(c1.equals(c2)); XYIntervalSeries s2 = new XYIntervalSeries("Series"); s2.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5); c2.addSeries(s2); assertTrue(c1.equals(c2)); // add an empty series c1.addSeries(new XYIntervalSeries("Empty Series")); assertFalse(c1.equals(c2)); c2.addSeries(new XYIntervalSeries("Empty Series")); assertTrue(c1.equals(c2)); }
Example 4
Source File: DatasetUtilitiesTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Another test for bug 2849731. */ @Test public void testBug2849731_2() { XYIntervalSeriesCollection d = new XYIntervalSeriesCollection(); XYIntervalSeries s = new XYIntervalSeries("S1"); s.add(1.0, Double.NaN, Double.NaN, Double.NaN, 1.5, Double.NaN); d.addSeries(s); Range r = DatasetUtilities.iterateDomainBounds(d); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(1.0, r.getUpperBound(), EPSILON); s.add(1.0, 1.5, Double.NaN, Double.NaN, 1.5, Double.NaN); r = DatasetUtilities.iterateDomainBounds(d); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(1.5, r.getUpperBound(), EPSILON); s.add(1.0, Double.NaN, 0.5, Double.NaN, 1.5, Double.NaN); r = DatasetUtilities.iterateDomainBounds(d); assertEquals(0.5, r.getLowerBound(), EPSILON); assertEquals(1.5, r.getUpperBound(), EPSILON); }
Example 5
Source File: DatasetUtilitiesTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Another test for bug 2849731. */ @Test public void testBug2849731_2() { XYIntervalSeriesCollection d = new XYIntervalSeriesCollection(); XYIntervalSeries s = new XYIntervalSeries("S1"); s.add(1.0, Double.NaN, Double.NaN, Double.NaN, 1.5, Double.NaN); d.addSeries(s); Range r = DatasetUtilities.iterateDomainBounds(d); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(1.0, r.getUpperBound(), EPSILON); s.add(1.0, 1.5, Double.NaN, Double.NaN, 1.5, Double.NaN); r = DatasetUtilities.iterateDomainBounds(d); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(1.5, r.getUpperBound(), EPSILON); s.add(1.0, Double.NaN, 0.5, Double.NaN, 1.5, Double.NaN); r = DatasetUtilities.iterateDomainBounds(d); assertEquals(0.5, r.getLowerBound(), EPSILON); assertEquals(1.5, r.getUpperBound(), EPSILON); }
Example 6
Source File: DatasetUtilitiesTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Yet another test for bug 2849731. */ @Test public void testBug2849731_3() { XYIntervalSeriesCollection d = new XYIntervalSeriesCollection(); XYIntervalSeries s = new XYIntervalSeries("S1"); s.add(1.0, Double.NaN, Double.NaN, 1.5, Double.NaN, Double.NaN); d.addSeries(s); Range r = DatasetUtilities.iterateRangeBounds(d); assertEquals(1.5, r.getLowerBound(), EPSILON); assertEquals(1.5, r.getUpperBound(), EPSILON); s.add(1.0, 1.5, Double.NaN, Double.NaN, Double.NaN, 2.5); r = DatasetUtilities.iterateRangeBounds(d); assertEquals(1.5, r.getLowerBound(), EPSILON); assertEquals(2.5, r.getUpperBound(), EPSILON); s.add(1.0, Double.NaN, 0.5, Double.NaN, 3.5, Double.NaN); r = DatasetUtilities.iterateRangeBounds(d); assertEquals(1.5, r.getLowerBound(), EPSILON); assertEquals(3.5, r.getUpperBound(), EPSILON); }
Example 7
Source File: XYIntervalSeriesTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the add() method for an UNSORTED series. */ public void testAdd() { XYIntervalSeries series = new XYIntervalSeries("Series", false, true); series.add(5.0, 5.50, 5.50, 5.50, 5.50, 5.50); series.add(5.1, 5.51, 5.51, 5.51, 5.51, 5.51); series.add(6.0, 6.6, 6.6, 6.6, 6.6, 6.6); series.add(3.0, 3.3, 3.3, 3.3, 3.3, 3.3); series.add(4.0, 4.4, 4.4, 4.4, 4.4, 4.4); series.add(2.0, 2.2, 2.2, 2.2, 2.2, 2.2); series.add(1.0, 1.1, 1.1, 1.1, 1.1, 1.1); assertEquals(5.5, series.getYValue(0), EPSILON); assertEquals(5.51, series.getYValue(1), EPSILON); assertEquals(6.6, series.getYValue(2), EPSILON); assertEquals(3.3, series.getYValue(3), EPSILON); assertEquals(4.4, series.getYValue(4), EPSILON); assertEquals(2.2, series.getYValue(5), EPSILON); assertEquals(1.1, series.getYValue(6), EPSILON); }
Example 8
Source File: DatasetUtilitiesTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Another test for bug 2849731. */ public void testBug2849731_2() { XYIntervalSeriesCollection d = new XYIntervalSeriesCollection(); XYIntervalSeries s = new XYIntervalSeries("S1"); s.add(1.0, Double.NaN, Double.NaN, Double.NaN, 1.5, Double.NaN); d.addSeries(s); Range r = DatasetUtilities.iterateDomainBounds(d); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(1.0, r.getUpperBound(), EPSILON); s.add(1.0, 1.5, Double.NaN, Double.NaN, 1.5, Double.NaN); r = DatasetUtilities.iterateDomainBounds(d); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(1.5, r.getUpperBound(), EPSILON); s.add(1.0, Double.NaN, 0.5, Double.NaN, 1.5, Double.NaN); r = DatasetUtilities.iterateDomainBounds(d); assertEquals(0.5, r.getLowerBound(), EPSILON); assertEquals(1.5, r.getUpperBound(), EPSILON); }
Example 9
Source File: XYIntervalSeriesTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the add() method for an UNSORTED series. */ public void testAdd() { XYIntervalSeries series = new XYIntervalSeries("Series", false, true); series.add(5.0, 5.50, 5.50, 5.50, 5.50, 5.50); series.add(5.1, 5.51, 5.51, 5.51, 5.51, 5.51); series.add(6.0, 6.6, 6.6, 6.6, 6.6, 6.6); series.add(3.0, 3.3, 3.3, 3.3, 3.3, 3.3); series.add(4.0, 4.4, 4.4, 4.4, 4.4, 4.4); series.add(2.0, 2.2, 2.2, 2.2, 2.2, 2.2); series.add(1.0, 1.1, 1.1, 1.1, 1.1, 1.1); assertEquals(5.5, series.getYValue(0), EPSILON); assertEquals(5.51, series.getYValue(1), EPSILON); assertEquals(6.6, series.getYValue(2), EPSILON); assertEquals(3.3, series.getYValue(3), EPSILON); assertEquals(4.4, series.getYValue(4), EPSILON); assertEquals(2.2, series.getYValue(5), EPSILON); assertEquals(1.1, series.getYValue(6), EPSILON); }
Example 10
Source File: DatasetUtilitiesTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Yet another test for bug 2849731. */ @Test public void testBug2849731_3() { XYIntervalSeriesCollection d = new XYIntervalSeriesCollection(); XYIntervalSeries s = new XYIntervalSeries("S1"); s.add(1.0, Double.NaN, Double.NaN, 1.5, Double.NaN, Double.NaN); d.addSeries(s); Range r = DatasetUtilities.iterateRangeBounds(d); assertEquals(1.5, r.getLowerBound(), EPSILON); assertEquals(1.5, r.getUpperBound(), EPSILON); s.add(1.0, 1.5, Double.NaN, Double.NaN, Double.NaN, 2.5); r = DatasetUtilities.iterateRangeBounds(d); assertEquals(1.5, r.getLowerBound(), EPSILON); assertEquals(2.5, r.getUpperBound(), EPSILON); s.add(1.0, Double.NaN, 0.5, Double.NaN, 3.5, Double.NaN); r = DatasetUtilities.iterateRangeBounds(d); assertEquals(1.5, r.getLowerBound(), EPSILON); assertEquals(3.5, r.getUpperBound(), EPSILON); }
Example 11
Source File: ScatterPlotPanel.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
private XYIntervalSeries computeRegressionData(double xStart, double xEnd) { if (scatterpointsDataset.getItemCount(0) > 1) { final double[] coefficients = Regression.getOLSRegression(scatterpointsDataset, 0); final Function2D curve = new LineFunction2D(coefficients[0], coefficients[1]); final XYSeries regressionData = DatasetUtilities.sampleFunction2DToSeries(curve, xStart, xEnd, 100, "regression line"); final XYIntervalSeries xyIntervalRegression = new XYIntervalSeries(regressionData.getKey()); for (int i = 0; i < regressionData.getItemCount(); i++) { XYDataItem item = regressionData.getDataItem(i); final double x = item.getXValue(); final double y = item.getYValue(); xyIntervalRegression.add(x, x, x, y, y, y); } return xyIntervalRegression; } else { Dialogs.showInformation("Unable to compute regression line.\n" + "At least 2 values are needed to compute regression coefficients."); return null; } }
Example 12
Source File: XYIntervalSeriesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the new accessor methods added in 1.0.5. */ public void testValues() { XYIntervalSeries s1 = new XYIntervalSeries("S1"); s1.add(2.0, 1.0, 3.0, 5.0, 4.0, 6.0); assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(1.0, s1.getXLowValue(0), EPSILON); assertEquals(3.0, s1.getXHighValue(0), EPSILON); assertEquals(5.0, s1.getYValue(0), EPSILON); assertEquals(4.0, s1.getYLowValue(0), EPSILON); assertEquals(6.0, s1.getYHighValue(0), EPSILON); }
Example 13
Source File: XYIntervalSeriesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A simple check that the maximumItemCount attribute is working. */ public void testSetMaximumItemCount() { XYIntervalSeries s1 = new XYIntervalSeries("S1"); assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); s1.setMaximumItemCount(2); assertEquals(2, s1.getMaximumItemCount()); s1.add(1.0, 1.1, 1.1, 1.1, 1.1, 1.1); s1.add(2.0, 2.2, 2.2, 2.2, 2.2, 2.2); s1.add(3.0, 3.3, 3.3, 3.3, 3.3, 3.3); assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); }
Example 14
Source File: XYIntervalSeriesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Simple test for the remove() method. */ public void testRemove() { XYIntervalSeries s1 = new XYIntervalSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 2.0, 1.9, 2.1); s1.add(2.0, 2.0, 2.0, 2.0, 1.9, 2.1); s1.add(3.0, 3.0, 3.0, 3.0, 2.9, 3.1); assertEquals(3, s1.getItemCount()); s1.remove(new Double(2.0)); assertEquals(new Double(3.0), s1.getX(1)); s1.remove(new Double(1.0)); assertEquals(new Double(3.0), s1.getX(0)); }
Example 15
Source File: XYIntervalSeriesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A check for the indexOf() method for an unsorted series. */ public void testIndexOf2() { XYIntervalSeries s1 = new XYIntervalSeries("Series 1", false, true); s1.add(1.0, 1.0, 1.0, 2.0, 1.9, 2.1); s1.add(3.0, 3.0, 3.0, 3.0, 2.9, 3.1); s1.add(2.0, 2.0, 2.0, 2.0, 1.9, 2.1); assertEquals(0, s1.indexOf(new Double(1.0))); assertEquals(1, s1.indexOf(new Double(3.0))); assertEquals(2, s1.indexOf(new Double(2.0))); }
Example 16
Source File: XYIntervalSeriesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Simple test for the indexOf() method. */ public void testIndexOf() { XYIntervalSeries s1 = new XYIntervalSeries("Series 1"); s1.add(1.0, 1.0, 1.0, 2.0, 1.9, 2.1); s1.add(2.0, 2.0, 2.0, 3.0, 2.9, 3.1); s1.add(3.0, 3.0, 3.0, 4.0, 3.9, 4.1); assertEquals(0, s1.indexOf(new Double(1.0))); }
Example 17
Source File: XYIntervalSeriesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the clear() method. */ public void testClear() { XYIntervalSeries s1 = new XYIntervalSeries("S1"); s1.addChangeListener(this); s1.clear(); assertNull(this.lastEvent); assertTrue(s1.isEmpty()); s1.add(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); assertFalse(s1.isEmpty()); s1.clear(); assertNotNull(this.lastEvent); assertTrue(s1.isEmpty()); }
Example 18
Source File: XYIntervalSeriesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Check that the maximum item count can be applied retrospectively. */ public void testSetMaximumItemCount2() { XYIntervalSeries s1 = new XYIntervalSeries("S1"); s1.add(1.0, 1.1, 1.1, 1.1, 1.1, 1.1); s1.add(2.0, 2.2, 2.2, 2.2, 2.2, 2.2); s1.add(3.0, 3.3, 3.3, 3.3, 2.2, 2.2); s1.setMaximumItemCount(2); assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); }
Example 19
Source File: XYIntervalSeriesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the clear() method. */ public void testClear() { XYIntervalSeries s1 = new XYIntervalSeries("S1"); s1.addChangeListener(this); s1.clear(); assertNull(this.lastEvent); assertTrue(s1.isEmpty()); s1.add(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); assertFalse(s1.isEmpty()); s1.clear(); assertNotNull(this.lastEvent); assertTrue(s1.isEmpty()); }
Example 20
Source File: ChartJFreeChartOutputScatter.java From gama with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings ("unchecked") @Override protected void resetSerie(final IScope scope, final String serieid) { // TODO Auto-generated method stub final ChartDataSeries dataserie = chartdataset.getDataSeries(scope, serieid); final XYIntervalSeries serie = ((XYIntervalSeriesCollection) jfreedataset.get(IdPosition.get(dataserie.getSerieId(scope)))) .getSeries(0); serie.clear(); final ArrayList<Double> XValues = dataserie.getXValues(scope); final ArrayList<Double> YValues = dataserie.getYValues(scope); final ArrayList<Double> SValues = dataserie.getSValues(scope); boolean secondaxis = false; if (dataserie.getMysource().getUseSecondYAxis(scope)) { secondaxis = true; this.setUseSecondYAxis(scope, true); } if (XValues.size() > 0) { final NumberAxis domainAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis(); final NumberAxis rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(0); final int ids = IdPosition.get(dataserie.getSerieId(scope)); if (secondaxis) { // rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(1); // ((XYPlot) this.chart.getPlot()).setRangeAxis(IdPosition.get(dataserie.getSerieId(scope)),rangeAxis); // ((XYPlot) this.chart.getPlot()).setRangeAxis(IdPosition.get(dataserie.getSerieId(scope)),rangeAxis); ((XYPlot) this.chart.getPlot()).mapDatasetToRangeAxis(ids, 1); } else { // ((XYPlot) this.chart.getPlot()).setRangeAxis(IdPosition.get(dataserie.getSerieId(scope)),rangeAxis); ((XYPlot) this.chart.getPlot()).mapDatasetToRangeAxis(ids, 0); } domainAxis.setAutoRange(false); rangeAxis.setAutoRange(false); // domainAxis.setRange(Math.min((double)(Collections.min(XValues)),0), // Math.max(Collections.max(XValues),Collections.min(XValues)+1)); // rangeAxis.setRange(Math.min((double)(Collections.min(YValues)),0), // Math.max(Collections.max(YValues),Collections.min(YValues)+1)); XYIntervalDataItem newval; for (int i = 0; i < XValues.size(); i++) { if (dataserie.isUseYErrValues()) { if (dataserie.isUseXErrValues()) { newval = new XYIntervalDataItem(XValues.get(i), dataserie.xerrvaluesmin.get(i), dataserie.xerrvaluesmax.get(i), YValues.get(i), dataserie.yerrvaluesmin.get(i), dataserie.yerrvaluesmax.get(i)); // serie.add(XValues.get(i),dataserie.xerrvaluesmin.get(i),dataserie.xerrvaluesmax.get(i),YValues.get(i),dataserie.yerrvaluesmin.get(i),dataserie.yerrvaluesmax.get(i)); } else { newval = new XYIntervalDataItem(XValues.get(i), XValues.get(i), XValues.get(i), YValues.get(i), dataserie.yerrvaluesmin.get(i), dataserie.yerrvaluesmax.get(i)); // serie.add(XValues.get(i),XValues.get(i),XValues.get(i),YValues.get(i),dataserie.yerrvaluesmin.get(i),dataserie.yerrvaluesmax.get(i)); } } else { if (dataserie.isUseXErrValues()) { newval = new XYIntervalDataItem(XValues.get(i), dataserie.xerrvaluesmin.get(i), dataserie.xerrvaluesmax.get(i), YValues.get(i), YValues.get(i), YValues.get(i)); // serie.add(XValues.get(i),dataserie.xerrvaluesmin.get(i),dataserie.xerrvaluesmax.get(i),YValues.get(i),YValues.get(i),YValues.get(i)); } else { newval = new XYIntervalDataItem(XValues.get(i), XValues.get(i), XValues.get(i), YValues.get(i), YValues.get(i), YValues.get(i)); // serie.add(XValues.get(i),XValues.get(i),XValues.get(i),YValues.get(i),YValues.get(i),YValues.get(i)); } } serie.add(newval, false); } // domainAxis.setAutoRange(true); // rangeAxis.setAutoRange(true); } // resetAutorange(scope); if (SValues.size() > 0) { MarkerScale.remove(serieid); final ArrayList<Double> nscale = (ArrayList<Double>) SValues.clone(); MarkerScale.put(serieid, nscale); } this.resetRenderer(scope, serieid); }