@Test public void testAddSeries() { DefaultXYDataset d = new DefaultXYDataset(); d.addSeries("S1", new double[][] {{1.0}, {2.0}}); assertEquals(1, d.getSeriesCount()); assertEquals("S1", d.getSeriesKey(0)); d.addSeries("S1", new double[][] {{11.0}, {12.0}}); assertEquals(1, d.getSeriesCount()); assertEquals(12.0, d.getYValue(0, 0), EPSILON); try { d.addSeries(null, new double[][] {{1.0}, {2.0}}); fail("IllegalArgumentException should have been thrown on null key"); } catch (IllegalArgumentException e) { assertEquals("The 'seriesKey' cannot be null.", e.getMessage()); } }
public void addSeries(Comparable seriesKey, double[][] data) { if (seriesKey == null) { throw new IllegalArgumentException( "The 'seriesKey' cannot be null."); } if (data == null) { throw new IllegalArgumentException("The 'data' is null."); } if (data.length != 2) { throw new IllegalArgumentException( "The 'data' array must have length == 2."); } if (data[0].length != data[1].length) { throw new IllegalArgumentException( "The 'data' array must contain two arrays with equal length."); } int seriesIndex = indexOf(seriesKey); if (seriesIndex == -1) { this.seriesKeys.add(seriesKey); this.seriesList.add(data); } else { this.seriesList.remove(seriesIndex); this.seriesList.add(seriesIndex, data); } notifyListeners(new DatasetChangeEvent(this, this)); }
DefaultXYDataset extends AbstractXYDataset implements XYDataset, PublicCloneable { public void addSeries(Comparable seriesKey, double[][] data) { if (seriesKey == null) { throw new IllegalArgumentException( "The 'seriesKey' cannot be null."); } if (data == null) { throw new IllegalArgumentException("The 'data' is null."); } if (data.length != 2) { throw new IllegalArgumentException( "The 'data' array must have length == 2."); } if (data[0].length != data[1].length) { throw new IllegalArgumentException( "The 'data' array must contain two arrays with equal length."); } int seriesIndex = indexOf(seriesKey); if (seriesIndex == -1) { this.seriesKeys.add(seriesKey); this.seriesList.add(data); } else { this.seriesList.remove(seriesIndex); this.seriesList.add(seriesIndex, data); } notifyListeners(new DatasetChangeEvent(this, this)); } }
DefaultXYDataset extends AbstractXYDataset implements XYDataset, PublicCloneable { public void addSeries(Comparable seriesKey, double[][] data) { if (seriesKey == null) { throw new IllegalArgumentException( "The 'seriesKey' cannot be null."); } if (data == null) { throw new IllegalArgumentException("The 'data' is null."); } if (data.length != 2) { throw new IllegalArgumentException( "The 'data' array must have length == 2."); } if (data[0].length != data[1].length) { throw new IllegalArgumentException( "The 'data' array must contain two arrays with equal length."); } int seriesIndex = indexOf(seriesKey); if (seriesIndex == -1) { this.seriesKeys.add(seriesKey); this.seriesList.add(data); } else { this.seriesList.remove(seriesIndex); this.seriesList.add(seriesIndex, data); } notifyListeners(new DatasetChangeEvent(this, this)); } DefaultXYDataset(); }
DefaultXYDataset extends AbstractXYDataset implements XYDataset, PublicCloneable { public void addSeries(Comparable seriesKey, double[][] data) { if (seriesKey == null) { throw new IllegalArgumentException( "The 'seriesKey' cannot be null."); } if (data == null) { throw new IllegalArgumentException("The 'data' is null."); } if (data.length != 2) { throw new IllegalArgumentException( "The 'data' array must have length == 2."); } if (data[0].length != data[1].length) { throw new IllegalArgumentException( "The 'data' array must contain two arrays with equal length."); } int seriesIndex = indexOf(seriesKey); if (seriesIndex == -1) { this.seriesKeys.add(seriesKey); this.seriesList.add(data); } else { this.seriesList.remove(seriesIndex); this.seriesList.add(seriesIndex, data); } notifyListeners(new DatasetChangeEvent(this, this)); } DefaultXYDataset(); @Override int getSeriesCount(); @Override Comparable getSeriesKey(int series); @Override int indexOf(Comparable seriesKey); @Override DomainOrder getDomainOrder(); @Override int getItemCount(int series); @Override double getXValue(int series, int item); @Override Number getX(int series, int item); @Override double getYValue(int series, int item); @Override Number getY(int series, int item); void addSeries(Comparable seriesKey, double[][] data); void removeSeries(Comparable seriesKey); @Override boolean equals(Object obj); @Override int hashCode(); @Override Object clone(); }
DefaultXYDataset extends AbstractXYDataset implements XYDataset, PublicCloneable { public void addSeries(Comparable seriesKey, double[][] data) { if (seriesKey == null) { throw new IllegalArgumentException( "The 'seriesKey' cannot be null."); } if (data == null) { throw new IllegalArgumentException("The 'data' is null."); } if (data.length != 2) { throw new IllegalArgumentException( "The 'data' array must have length == 2."); } if (data[0].length != data[1].length) { throw new IllegalArgumentException( "The 'data' array must contain two arrays with equal length."); } int seriesIndex = indexOf(seriesKey); if (seriesIndex == -1) { this.seriesKeys.add(seriesKey); this.seriesList.add(data); } else { this.seriesList.remove(seriesIndex); this.seriesList.add(seriesIndex, data); } notifyListeners(new DatasetChangeEvent(this, this)); } DefaultXYDataset(); @Override int getSeriesCount(); @Override Comparable getSeriesKey(int series); @Override int indexOf(Comparable seriesKey); @Override DomainOrder getDomainOrder(); @Override int getItemCount(int series); @Override double getXValue(int series, int item); @Override Number getX(int series, int item); @Override double getYValue(int series, int item); @Override Number getY(int series, int item); void addSeries(Comparable seriesKey, double[][] data); void removeSeries(Comparable seriesKey); @Override boolean equals(Object obj); @Override int hashCode(); @Override Object clone();  }