Java Code Examples for org.jfree.data.time.TimeSeriesCollection#removeSeries()
The following examples show how to use
org.jfree.data.time.TimeSeriesCollection#removeSeries() .
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: TimeSeriesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Tests the remove series method. */ public void testRemoveSeries() { TimeSeriesCollection c1 = new TimeSeriesCollection(); TimeSeries s1 = new TimeSeries("Series 1"); TimeSeries s2 = new TimeSeries("Series 2"); TimeSeries s3 = new TimeSeries("Series 3"); TimeSeries s4 = new TimeSeries("Series 4"); c1.addSeries(s1); c1.addSeries(s2); c1.addSeries(s3); c1.addSeries(s4); c1.removeSeries(s3); TimeSeries s = c1.getSeries(2); boolean b1 = s.equals(s4); assertTrue(b1); }
Example 2
Source File: TimeSeriesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the {@link TimeSeriesCollection#removeSeries(int)} * method. */ public void testRemoveSeries_int() { TimeSeriesCollection c1 = new TimeSeriesCollection(); TimeSeries s1 = new TimeSeries("Series 1"); TimeSeries s2 = new TimeSeries("Series 2"); TimeSeries s3 = new TimeSeries("Series 3"); TimeSeries s4 = new TimeSeries("Series 4"); c1.addSeries(s1); c1.addSeries(s2); c1.addSeries(s3); c1.addSeries(s4); c1.removeSeries(2); assertTrue(c1.getSeries(2).equals(s4)); c1.removeSeries(0); assertTrue(c1.getSeries(0).equals(s2)); assertEquals(2, c1.getSeriesCount()); }
Example 3
Source File: TimeSeriesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some tests for the indexOf() method. */ public void testIndexOf() { TimeSeries s1 = new TimeSeries("S1"); TimeSeries s2 = new TimeSeries("S2"); TimeSeriesCollection dataset = new TimeSeriesCollection(); assertEquals(-1, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s1); assertEquals(0, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s2); assertEquals(0, dataset.indexOf(s1)); assertEquals(1, dataset.indexOf(s2)); dataset.removeSeries(s1); assertEquals(-1, dataset.indexOf(s1)); assertEquals(0, dataset.indexOf(s2)); TimeSeries s2b = new TimeSeries("S2"); assertEquals(0, dataset.indexOf(s2b)); }
Example 4
Source File: TimeSeriesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Tests the remove series method. */ public void testRemoveSeries() { TimeSeriesCollection c1 = new TimeSeriesCollection(); TimeSeries s1 = new TimeSeries("Series 1"); TimeSeries s2 = new TimeSeries("Series 2"); TimeSeries s3 = new TimeSeries("Series 3"); TimeSeries s4 = new TimeSeries("Series 4"); c1.addSeries(s1); c1.addSeries(s2); c1.addSeries(s3); c1.addSeries(s4); c1.removeSeries(s3); TimeSeries s = c1.getSeries(2); boolean b1 = s.equals(s4); assertTrue(b1); }
Example 5
Source File: TimeSeriesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some tests for the indexOf() method. */ public void testIndexOf() { TimeSeries s1 = new TimeSeries("S1"); TimeSeries s2 = new TimeSeries("S2"); TimeSeriesCollection dataset = new TimeSeriesCollection(); assertEquals(-1, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s1); assertEquals(0, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s2); assertEquals(0, dataset.indexOf(s1)); assertEquals(1, dataset.indexOf(s2)); dataset.removeSeries(s1); assertEquals(-1, dataset.indexOf(s1)); assertEquals(0, dataset.indexOf(s2)); TimeSeries s2b = new TimeSeries("S2"); assertEquals(0, dataset.indexOf(s2b)); }
Example 6
Source File: GraphPanel.java From swift-k with Apache License 2.0 | 5 votes |
protected void removeSeries(JFreeChart chart, int seriesIndex) { Color color = (Color) chart.getPlot().getLegendItems().get(seriesIndex).getLinePaint(); palette.release(color); String key = enabled.remove(seriesIndex); XYPlot plot = chart.getXYPlot(); Series<?> series = sampler.getSeries(key); Unit unit = series.getUnit(); Integer datasetIndex = datasetMapping.get(unit); TimeSeriesCollection col = (TimeSeriesCollection) plot.getDataset(datasetIndex); List<String> colIndices = seriesMapping.get(unit); int colIndex = colIndices.indexOf(key); colIndices.remove(key); col.removeSeries(colIndex); if (col.getSeriesCount() == 0) { plot.setDataset(datasetIndex, null); plot.setRangeAxis(datasetIndex, null); seriesMapping.remove(unit); datasetMapping.remove(unit); } rebuildLegend(); repaint(); gp.saveLayout(); }
Example 7
Source File: TimeSeriesCollectionTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some tests for the equals() method. */ public void testEquals() { TimeSeriesCollection c1 = new TimeSeriesCollection(); TimeSeriesCollection c2 = new TimeSeriesCollection(); TimeSeries s1 = new TimeSeries("Series 1"); TimeSeries s2 = new TimeSeries("Series 2"); // newly created collections should be equal boolean b1 = c1.equals(c2); assertTrue("b1", b1); // add series to collection 1, should be not equal c1.addSeries(s1); c1.addSeries(s2); boolean b2 = c1.equals(c2); assertFalse("b2", b2); // now add the same series to collection 2 to make them equal again... c2.addSeries(s1); c2.addSeries(s2); boolean b3 = c1.equals(c2); assertTrue("b3", b3); // now remove series 2 from collection 2 c2.removeSeries(s2); boolean b4 = c1.equals(c2); assertFalse("b4", b4); // now remove series 2 from collection 1 to make them equal again c1.removeSeries(s2); boolean b5 = c1.equals(c2); assertTrue("b5", b5); }
Example 8
Source File: TimeSeriesCollectionTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some tests for the equals() method. */ public void testEquals() { TimeSeriesCollection c1 = new TimeSeriesCollection(); TimeSeriesCollection c2 = new TimeSeriesCollection(); TimeSeries s1 = new TimeSeries("Series 1"); TimeSeries s2 = new TimeSeries("Series 2"); // newly created collections should be equal boolean b1 = c1.equals(c2); assertTrue("b1", b1); // add series to collection 1, should be not equal c1.addSeries(s1); c1.addSeries(s2); boolean b2 = c1.equals(c2); assertFalse("b2", b2); // now add the same series to collection 2 to make them equal again... c2.addSeries(s1); c2.addSeries(s2); boolean b3 = c1.equals(c2); assertTrue("b3", b3); // now remove series 2 from collection 2 c2.removeSeries(s2); boolean b4 = c1.equals(c2); assertFalse("b4", b4); // now remove series 2 from collection 1 to make them equal again c1.removeSeries(s2); boolean b5 = c1.equals(c2); assertTrue("b5", b5); }