@Test public void testSerialization() throws IOException, ClassNotFoundException { DefaultXYDataset d1 = new DefaultXYDataset(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); DefaultXYDataset d2 = (DefaultXYDataset) in.readObject(); in.close(); assertEquals(d1, d2); 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}; d1.addSeries("S1", data1); buffer = new ByteArrayOutputStream(); out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (DefaultXYDataset) in.readObject(); in.close(); assertEquals(d1, d2); }
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();  }