Java Code Examples for org.jfree.data.xy.DefaultXYDataset#addSeries()
The following examples show how to use
org.jfree.data.xy.DefaultXYDataset#addSeries() .
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: MetadataPlotPanel.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
private void configureRangeAxis(int index, MetadataElement metadataElement, String yAttributeName, String[] recordElementNames, String refRecordName, double[] recordIndices) { double[] yAxisData = new double[recordIndices.length]; Arrays.setAll(yAxisData, i -> getDataAsDouble(metadataElement.getElement(recordElementNames[i]).getAttribute(yAttributeName).getData())); DefaultXYDataset dataset2 = new DefaultXYDataset(); dataset2.addSeries(yAttributeName, new double[][]{recordIndices, yAxisData}); xyPlot.setDataset(index, dataset2); xyPlot.mapDatasetToRangeAxis(index, index); int yDataType = getAttributeType(metadataElement.getElement(refRecordName).getAttribute(yAttributeName)); ValueAxis yAxis = configureRangeIndex(index, yDataType); String yUnit = metadataElement.getElement(refRecordName).getAttribute(yAttributeName).getUnit(); yAxis.setLabel(getYAxisLabel(yAttributeName, yUnit)); xyPlot.setRenderer(index, creatItemRenderer(index, yDataType)); }
Example 2
Source File: XYSeriesTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for an example using the toArray() method. */ public void testToArrayExample() { XYSeries s = new XYSeries("S"); s.add(1.0, 11.0); s.add(2.0, 22.0); s.add(3.5, 35.0); s.add(5.0, null); DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries("S", s.toArray()); assertEquals(1, dataset.getSeriesCount()); assertEquals(4, dataset.getItemCount(0)); assertEquals("S", dataset.getSeriesKey(0)); assertEquals(1.0, dataset.getXValue(0, 0), EPSILON); assertEquals(2.0, dataset.getXValue(0, 1), EPSILON); assertEquals(3.5, dataset.getXValue(0, 2), EPSILON); assertEquals(5.0, dataset.getXValue(0, 3), EPSILON); assertEquals(11.0, dataset.getYValue(0, 0), EPSILON); assertEquals(22.0, dataset.getYValue(0, 1), EPSILON); assertEquals(35.0, dataset.getYValue(0, 2), EPSILON); assertTrue(Double.isNaN(dataset.getYValue(0, 3))); }
Example 3
Source File: XYPlotTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * A test for drawing a plot where a series has zero items. With * JFreeChart 1.0.5+cvs this was throwing an exception at one point. */ public void testDrawSeriesWithZeroItems() { DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries("Series 1", new double[][] {{1.0, 2.0}, {3.0, 4.0}}); dataset.addSeries("Series 2", new double[][] {{}, {}}); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, true); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { e.printStackTrace(); success = false; } assertTrue(success); }
Example 4
Source File: XYPlotTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * A test for drawing a plot where a series has zero items. With * JFreeChart 1.0.5+cvs this was throwing an exception at one point. */ @Test public void testDrawSeriesWithZeroItems() { DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries("Series 1", new double[][] {{1.0, 2.0}, {3.0, 4.0}}); dataset.addSeries("Series 2", new double[][] {{}, {}}); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); } catch (Exception e) { fail("No exception should be thrown."); } }
Example 5
Source File: DefaultXYDatasetTests.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() { DefaultXYDataset d1 = new DefaultXYDataset(); DefaultXYDataset d2 = new DefaultXYDataset(); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; double[] x2 = new double[] {1.0, 2.0, 3.0}; double[] y2 = new double[] {4.0, 5.0, 6.0}; double[][] data2 = new double[][] {x2, y2}; d1.addSeries("S1", data1); assertFalse(d1.equals(d2)); d2.addSeries("S1", data2); assertTrue(d1.equals(d2)); }
Example 6
Source File: DefaultXYDatasetTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Creates a sample dataset for testing. * * @return A sample dataset. */ public DefaultXYDataset createSampleDataset1() { DefaultXYDataset d = new DefaultXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; d.addSeries("S1", data1); double[] x2 = new double[] {1.0, 2.0, 3.0}; double[] y2 = new double[] {4.0, 5.0, 6.0}; double[][] data2 = new double[][] {x2, y2}; d.addSeries("S2", data2); return d; }
Example 7
Source File: DefaultXYDatasetTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Creates a sample dataset for testing. * * @return A sample dataset. */ public DefaultXYDataset createSampleDataset1() { DefaultXYDataset d = new DefaultXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; d.addSeries("S1", data1); double[] x2 = new double[] {1.0, 2.0, 3.0}; double[] y2 = new double[] {4.0, 5.0, 6.0}; double[][] data2 = new double[][] {x2, y2}; d.addSeries("S2", data2); return d; }
Example 8
Source File: DatasetUtilitiesTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Check that NaN values in the dataset are ignored. */ @Test public void testIterateDomainBounds_NaN() { DefaultXYDataset dataset = new DefaultXYDataset(); double[] x = new double[] {1.0, 2.0, Double.NaN, 3.0}; double[] y = new double[] {9.0, 8.0, 7.0, 6.0}; dataset.addSeries("S1", new double[][] {x, y}); Range r = DatasetUtilities.iterateDomainBounds(dataset); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(3.0, r.getUpperBound(), EPSILON); }
Example 9
Source File: TimeSeriesURLGeneratorTest.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * A basic check for the generateURL() method. */ @Test public void testGenerateURL() { TimeSeriesURLGenerator g = new TimeSeriesURLGenerator(); DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries("Series '1'", new double[][] {{1.0, 2.0}, {3.0, 4.0}}); String s = g.generateURL(dataset, 0, 0); assertTrue(s.startsWith("index.html?series=Series+%271%27&item=")); }
Example 10
Source File: RendererUtilitiesTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Some checks for the findLiveItemsLowerBound() method when the dataset is * DESCENDING. */ public void testFindLiveItemsLowerBound_Descending() { DefaultXYDataset d = new DefaultXYDataset() { public DomainOrder getDomainOrder() { // we're doing this for testing only, and make sure that we // only add data in descending order by x-value return DomainOrder.DESCENDING; } }; // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, 11.0)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 1.1, 2.0)); // check a series with two items d.addSeries("S3", new double[][] {{2.0, 1.0}, {9.9, 9.9}}); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1, 0.5)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.1, 2.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.3, 4.0)); // check a series with three items d.addSeries("S4", new double[][] {{3.0, 2.0, 1.0}, {9.9, 9.9, 9.9}}); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, 1.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, 2.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, 4.0)); // check a series with four items d.addSeries("S5", new double[][] {{4.0, 3.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1, 0.5)); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1, 1.0)); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.1, 2.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.3, 4.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.4, 5.0)); // check a series with repeating items d.addSeries("S6", new double[][] {{3.0, 2.0, 2.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 3.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 2.0)); assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 1.0)); assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 0.5)); }
Example 11
Source File: RendererUtilitiesTest.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Some checks for the findLiveItemsLowerBound() method when the dataset is * unordered. */ @Test public void testFindLiveItemsLowerBound_Unordered() { DefaultXYDataset d = new DefaultXYDataset(); // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, 11.0)); // check a series with one item d.addSeries("S2", new double[][] {{0.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 2.0, 3.3)); // check a series with two items d.addSeries("S3", new double[][] {{0.0, 1.0}, {9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.0, 1.1)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.0, 3.3)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.0, 4.4)); // check a series with three items d.addSeries("S4", new double[][] {{1.0, 2.0, 1.5}, {9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, 3.3)); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, 4.4)); // check a series with four items d.addSeries("S5", new double[][] {{1.0, 2.0, 1.5, 1.8}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0, 3.3)); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0, 4.4)); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.0, 5.5)); }
Example 12
Source File: RendererUtilitiesTest.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Some checks for the findLiveItemsLowerBound() method when the dataset is * DESCENDING. */ @Test public void testFindLiveItemsLowerBound_Descending() { DefaultXYDataset d = new DefaultXYDataset() { @Override public DomainOrder getDomainOrder() { // we're doing this for testing only, and make sure that we // only add data in descending order by x-value return DomainOrder.DESCENDING; } }; // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, 11.0)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 1.1, 2.0)); // check a series with two items d.addSeries("S3", new double[][] {{2.0, 1.0}, {9.9, 9.9}}); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1, 0.5)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.1, 2.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.3, 4.0)); // check a series with three items d.addSeries("S4", new double[][] {{3.0, 2.0, 1.0}, {9.9, 9.9, 9.9}}); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, 1.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, 2.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, 4.0)); // check a series with four items d.addSeries("S5", new double[][] {{4.0, 3.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1, 0.5)); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1, 1.0)); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.1, 2.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.3, 4.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.4, 5.0)); // check a series with repeating items d.addSeries("S6", new double[][] {{3.0, 2.0, 2.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 3.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 2.0)); assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 1.0)); assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 0.5)); }
Example 13
Source File: RendererUtilitiesTest.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
/** * Some checks for the findLiveItemsUpperBound() method when the dataset is * unordered. */ @Test public void testFindLiveItemsUpperBound_Unordered() { DefaultXYDataset d = new DefaultXYDataset(); // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, 11.0)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 2.0, 3.3)); // check a series with two items d.addSeries("S3", new double[][] {{1.0, 2.0}, {9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.0, 1.1)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.0, 3.3)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.0, 4.4)); // check a series with three items d.addSeries("S4", new double[][] {{1.0, 2.0, 1.5}, {9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, 1.1)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, 2.2)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, 3.3)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, 4.4)); // check a series with four items d.addSeries("S5", new double[][] {{1.0, 2.0, 1.5, 1.8}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 1.1)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.0, 2.2)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.0, 3.3)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.0, 4.4)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.0, 5.5)); }
Example 14
Source File: RendererUtilitiesTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Some checks for the findLiveItemsLowerBound() method when the dataset is * unordered. */ public void testFindLiveItemsLowerBoundUnordered() { DefaultXYDataset d = new DefaultXYDataset(); // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, 11.0)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {2.0}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 2.0, 3.3)); // check a series with two items d.addSeries("S3", new double[][] {{1.0, 2.0}, {2.0, 2.0}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.0, 2.2)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.0, 3.3)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.0, 4.4)); // check a series with three items d.addSeries("S4", new double[][] {{1.0, 2.0, 1.5}, {2.0, 2.0, 2.0}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, 2.2)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, 3.3)); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, 4.4)); // check a series with four items d.addSeries("S5", new double[][] {{1.0, 2.0, 1.5, 1.8}, {2.0, 2.0, 2.0, 2.0}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0, 2.2)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0, 3.3)); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0, 4.4)); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.0, 5.5)); }
Example 15
Source File: RendererUtilitiesTest.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Some checks for the findLiveItemsUpperBound() method when the dataset is * DESCENDING. */ @Test public void testFindLiveItemsUpperBound_Descending() { DefaultXYDataset d = new DefaultXYDataset() { @Override public DomainOrder getDomainOrder() { // we're doing this for testing only, and make sure that we // only add data in descending order by x-value return DomainOrder.DESCENDING; } }; // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, 11.0)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 1.1, 2.0)); // check a series with two items d.addSeries("S3", new double[][] {{2.0, 1.0}, {9.9, 9.9}}); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.1, 0.5)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.1, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.1, 2.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.3, 4.0)); // check a series with three items d.addSeries("S4", new double[][] {{3.0, 2.0, 1.0}, {9.9, 9.9, 9.9}}); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, 1.0)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, 2.0)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, 4.0)); // check a series with four items d.addSeries("S5", new double[][] {{4.0, 3.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.1, 0.5)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.1, 1.0)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.1, 2.0)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.3, 4.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.4, 5.0)); // check a series with repeating items d.addSeries("S6", new double[][] {{3.0, 2.0, 2.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9, 9.9}}); assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 5, 0.0, 5.0)); assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 5, 1.0, 5.0)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 5, 2.0, 5.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 5, 3.0, 5.0)); }
Example 16
Source File: RendererUtilitiesTest.java From ccu-historian with GNU General Public License v3.0 | 4 votes |
/** * Some checks for the findLiveItemsUpperBound() method when the dataset is * unordered. */ @Test public void testFindLiveItemsUpperBound_Unordered() { DefaultXYDataset d = new DefaultXYDataset(); // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, 11.0)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 2.0, 3.3)); // check a series with two items d.addSeries("S3", new double[][] {{1.0, 2.0}, {9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.0, 1.1)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.0, 3.3)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.0, 4.4)); // check a series with three items d.addSeries("S4", new double[][] {{1.0, 2.0, 1.5}, {9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, 1.1)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, 2.2)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, 3.3)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, 4.4)); // check a series with four items d.addSeries("S5", new double[][] {{1.0, 2.0, 1.5, 1.8}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 1.1)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.0, 2.2)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.0, 3.3)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.0, 4.4)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.0, 5.5)); }
Example 17
Source File: RendererUtilitiesTest.java From ccu-historian with GNU General Public License v3.0 | 4 votes |
/** * Some checks for the findLiveItemsLowerBound() method when the dataset is * DESCENDING. */ @Test public void testFindLiveItemsLowerBound_Descending() { DefaultXYDataset d = new DefaultXYDataset() { @Override public DomainOrder getDomainOrder() { // we're doing this for testing only, and make sure that we // only add data in descending order by x-value return DomainOrder.DESCENDING; } }; // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, 11.0)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 1.1, 2.0)); // check a series with two items d.addSeries("S3", new double[][] {{2.0, 1.0}, {9.9, 9.9}}); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1, 0.5)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.1, 2.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.3, 4.0)); // check a series with three items d.addSeries("S4", new double[][] {{3.0, 2.0, 1.0}, {9.9, 9.9, 9.9}}); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, 1.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, 2.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, 4.0)); // check a series with four items d.addSeries("S5", new double[][] {{4.0, 3.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1, 0.5)); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1, 1.0)); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.1, 2.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.3, 4.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.4, 5.0)); // check a series with repeating items d.addSeries("S6", new double[][] {{3.0, 2.0, 2.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 3.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 2.0)); assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 1.0)); assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 0.5)); }
Example 18
Source File: RendererUtilitiesTest.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * Some checks for the findLiveItemsLowerBound() method when the dataset is * DESCENDING. */ @Test public void testFindLiveItemsLowerBound_Descending() { DefaultXYDataset d = new DefaultXYDataset() { @Override public DomainOrder getDomainOrder() { // we're doing this for testing only, and make sure that we // only add data in descending order by x-value return DomainOrder.DESCENDING; } }; // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, 11.0)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 1.1, 2.0)); // check a series with two items d.addSeries("S3", new double[][] {{2.0, 1.0}, {9.9, 9.9}}); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1, 0.5)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.1, 2.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.3, 4.0)); // check a series with three items d.addSeries("S4", new double[][] {{3.0, 2.0, 1.0}, {9.9, 9.9, 9.9}}); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, 1.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, 2.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, 4.0)); // check a series with four items d.addSeries("S5", new double[][] {{4.0, 3.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1, 0.5)); assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1, 1.0)); assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.1, 2.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.3, 4.0)); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.4, 5.0)); // check a series with repeating items d.addSeries("S6", new double[][] {{3.0, 2.0, 2.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 3.0)); assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 2.0)); assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 1.0)); assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 0.5)); }
Example 19
Source File: RendererUtilitiesTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Some checks for the findLiveItemsUpperBound() method when the dataset is * DESCENDING. */ public void testFindLiveItemsUpperBound_Descending() { DefaultXYDataset d = new DefaultXYDataset() { public DomainOrder getDomainOrder() { // we're doing this for testing only, and make sure that we // only add data in descending order by x-value return DomainOrder.DESCENDING; } }; // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, 11.0)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 1.1, 2.0)); // check a series with two items d.addSeries("S3", new double[][] {{2.0, 1.0}, {9.9, 9.9}}); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.1, 0.5)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.1, 1.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.1, 2.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.3, 4.0)); // check a series with three items d.addSeries("S4", new double[][] {{3.0, 2.0, 1.0}, {9.9, 9.9, 9.9}}); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, 1.0)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, 2.0)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, 4.0)); // check a series with four items d.addSeries("S5", new double[][] {{4.0, 3.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.1, 0.5)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.1, 1.0)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.1, 2.0)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.2, 3.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.3, 4.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.4, 5.0)); // check a series with repeating items d.addSeries("S6", new double[][] {{3.0, 2.0, 2.0, 2.0, 1.0}, {9.9, 9.9, 9.9, 9.9, 9.9}}); assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 5, 0.0, 5.0)); assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 5, 1.0, 5.0)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 5, 2.0, 5.0)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 5, 3.0, 5.0)); }
Example 20
Source File: RendererUtilitiesTest.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * Some checks for the findLiveItemsUpperBound() method when the dataset is * ASCENDING. */ @Test public void testFindLiveItemsUpperBound_Ascending() { DefaultXYDataset d = new DefaultXYDataset() { @Override public DomainOrder getDomainOrder() { // we're doing this for testing only, and make sure that we // only add data in ascending order by x-value return DomainOrder.ASCENDING; } }; // check a series with no items d.addSeries("S1", new double[][] {{}, {}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, 11.1)); // check a series with one item d.addSeries("S2", new double[][] {{1.0}, {9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, 1.1)); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 2.0, 2.2)); // check a series with two items d.addSeries("S3", new double[][] {{1.0, 2.0}, {9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.0, 1.0)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.0, 2.2)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.0, 3.3)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.0, 4.4)); // check a series with three items d.addSeries("S4", new double[][] {{1.0, 2.0, 3.0}, {9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, 1.1)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, 2.2)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, 3.3)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, 4.4)); // check a series with four items d.addSeries("S5", new double[][] {{1.0, 2.0, 3.0, 4.0}, {9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 1.1)); assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.0, 2.2)); assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.0, 3.3)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.0, 4.4)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.0, 5.5)); // check a series with repeating items d.addSeries("S5", new double[][] {{1.0, 2.0, 2.0, 2.0, 3.0}, {9.9, 9.9, 9.9, 9.9, 9.9}}); assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 1.0)); assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 2.0)); assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 3.0)); assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 4.0)); }