/** * Creates a new series by copying a subset of the data in this time series. * * @param start the index of the first item to copy. * @param end the index of the last item to copy. * @return A series containing a copy of this series from start until end. * @throws CloneNotSupportedException if there is a cloning problem. */ public XYSeries createCopy(int start, int end) throws CloneNotSupportedException { XYSeries copy = (XYSeries) super.clone(); copy.data = new java.util.ArrayList(); if (this.data.size() > 0) { for (int index = start; index <= end; index++) { XYDataItem item = (XYDataItem) this.data.get(index); XYDataItem clone = (XYDataItem) item.clone(); try { copy.add(clone); } catch (SeriesException e) { System.err.println("Unable to add cloned data item."); } } } return copy; }
/** * Returns a clone of the series. * * @return A clone of the series. * @throws CloneNotSupportedException if there is a cloning problem. */ @Override public Object clone() throws CloneNotSupportedException { XYSeries clone = (XYSeries) super.clone(); clone.data = (List) ObjectUtilities.deepClone(this.data); return clone; }