List of usage examples for org.jfree.data.xy XYSeriesCollection addSeries
public void addSeries(XYSeries series)
From source file:de.hs.mannheim.modUro.diagram.JTimeSeriesDiagram.java
private XYDataset createDataset(TimeSeries timeSeries) { XYSeriesCollection dataset = new XYSeriesCollection(); for (String dataName : timeSeries.getDataSeriesNames()) { XYSeries xySerie = new XYSeries(dataName); for (int i = 0; i < timeSeries.getTimePointsSize(); i++) { double x = timeSeries.getTimeSeries()[i]; double y = timeSeries.getData(dataName)[i]; xySerie.add(x, y);// w ww. j a va 2 s . c o m } dataset.addSeries(xySerie); } return dataset; }
From source file:de.hs.mannheim.modUro.diagram.JTimeSeriesDiagram.java
private XYDataset createDatasetList(List<TimeSeries> timeSeriesList) { XYSeriesCollection dataset = new XYSeriesCollection(); int n = 1;/* w w w. j a va 2 s. c o m*/ for (TimeSeries timeSeries : timeSeriesList) { XYSeries xySerie = new XYSeries(n++ + ""); for (int i = 0; i < timeSeries.getTimePointsSize(); i++) { double x = timeSeries.getTimeSeries()[i]; double y = timeSeries.getData()[i]; xySerie.add(x, y); } dataset.addSeries(xySerie); } return dataset; }
From source file:speedbagalg.OscopeView.java
private void plotXCheckBoxStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_plotXCheckBoxStateChanged {//GEN-HEADEREND:event_plotXCheckBoxStateChanged if (plotX == plotXCheckBox.isSelected()) return;/*from w ww . java 2 s .com*/ plotX = plotXCheckBox.isSelected(); XYSeriesCollection s = (XYSeriesCollection) chart.getXYPlot().getDataset(); if (plotX) s.addSeries(xData); else s.removeSeries(xData); }
From source file:speedbagalg.OscopeView.java
private void plotYCheckBoxStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_plotYCheckBoxStateChanged {//GEN-HEADEREND:event_plotYCheckBoxStateChanged if (plotY == plotYCheckBox.isSelected()) return;/*from w w w . ja va 2 s . c o m*/ plotY = plotYCheckBox.isSelected(); XYSeriesCollection s = (XYSeriesCollection) chart.getXYPlot().getDataset(); if (plotY) s.addSeries(yData); else s.removeSeries(yData); }
From source file:speedbagalg.OscopeView.java
private void plotZCheckBoxStateChanged(javax.swing.event.ChangeEvent evt)//GEN-FIRST:event_plotZCheckBoxStateChanged {//GEN-HEADEREND:event_plotZCheckBoxStateChanged if (plotZ == plotZCheckBox.isSelected()) return;// w ww. j a v a 2s. com plotZ = plotZCheckBox.isSelected(); XYSeriesCollection s = (XYSeriesCollection) chart.getXYPlot().getDataset(); if (plotZ) s.addSeries(zData); else s.removeSeries(zData); }
From source file:TradeMonitorGui.java
private void startGui() { XYSeriesCollection dataset = new XYSeriesCollection(); createChartFrame(dataset);/*from w w w .j av a2 s .co m*/ EntryAddedUpdatedListener<String, KeyedWindowResult<String, Double>> listener = (key, value) -> { if (!TICKERS.contains(key)) { return; } Long ts = value.end(); double val = value.result() / 100.0; int idx = dataset.getSeriesIndex(key); XYSeries series; if (idx == -1) { series = new XYSeries(key, true, false); dataset.addSeries(series); } else { series = dataset.getSeries(idx); } series.addOrUpdate((long) ts, val); }; this.listenerId = avgPrices.addEntryListener(listener, true); }
From source file:org.jfree.data.xy.XYSeriesCollectionTest.java
/** * Some basic checks for the addSeries() method. *///from w w w . ja v a 2 s. c om @Test public void testAddSeries() { XYSeriesCollection c = new XYSeriesCollection(); XYSeries s1 = new XYSeries("s1"); c.addSeries(s1); // the dataset should prevent the addition of a series with the // same name as an existing series in the dataset XYSeries s2 = new XYSeries("s1"); try { c.addSeries(s2); fail("Should have thrown IllegalArgumentException on duplicate key"); } catch (IllegalArgumentException e) { assertEquals("This dataset already contains a series with the key s1", e.getMessage()); } assertEquals(1, c.getSeriesCount()); }
From source file:tw.edu.sju.ee.eea.module.iepe.file.IepeVoltageElement.java
private void repaintChart() { // JFreeChart chart = ((ChartPanel) chartPanel).getChart(); // chart = null; // ((ChartPanel) chartPanel).setChart(createChart()); XYSeriesCollection sc = ((XYSeriesCollection) ((ChartPanel) chartPanel).getChart().getXYPlot() .getDataset());/*from www.j a v a2s . c o m*/ // XYSeries series = sc.getSeries(0); // series.clear(); // SampledStream ss = new sc.removeAllSeries(); sc.addSeries(SampledChart.series("Ch_0", info.getInputStream(), index, info.getSamplerate(), length)); chartScroll = true; }
From source file:org.jfree.data.xy.XYSeriesCollectionTest.java
/** * Some basic checks for the getSeries() method. *//*from w w w.j a va 2s . c o m*/ @Test public void testGetSeries() { XYSeriesCollection c = new XYSeriesCollection(); XYSeries s1 = new XYSeries("s1"); c.addSeries(s1); assertEquals("s1", c.getSeries(0).getKey()); try { c.getSeries(-1); fail("Should have thrown IndexOutOfBoundsException on negative key"); } catch (IllegalArgumentException e) { assertEquals("Series index out of bounds", e.getMessage()); } try { c.getSeries(1); fail("Should have thrown IndexOutOfBoundsException on key out of range"); } catch (IllegalArgumentException e) { assertEquals("Series index out of bounds", e.getMessage()); } }
From source file:org.jfree.data.xy.XYSeriesCollectionTest.java
/** * Some checks for the getSeries(Comparable) method. *///w ww . ja va 2 s . co m @Test public void testGetSeriesByKey() { XYSeriesCollection c = new XYSeriesCollection(); XYSeries s1 = new XYSeries("s1"); c.addSeries(s1); assertEquals("s1", c.getSeries("s1").getKey()); try { c.getSeries("s2"); fail("Should have thrown UnknownKeyException on unknown key"); } catch (UnknownKeyException e) { assertEquals("Key not found: s2", e.getMessage()); } try { c.getSeries(null); fail("Should have thrown IndexOutOfBoundsException on null key"); } catch (IllegalArgumentException e) { assertEquals("Null 'key' argument.", e.getMessage()); } }