Example usage for org.jfree.data.time TimePeriodValue clone

List of usage examples for org.jfree.data.time TimePeriodValue clone

Introduction

In this page you can find the example usage for org.jfree.data.time TimePeriodValue clone.

Prototype

@Override
public Object clone() 

Source Link

Document

Clones the object.

Usage

From source file:org.jfree.data.time.TimePeriodValues.java

/**
 * Creates a new instance by copying a subset of the data in this 
 * collection./* w ww  .  j av a  2 s .  co  m*/
 *
 * @param start  the index of the first item to copy.
 * @param end  the index of the last item to copy.
 *
 * @return A copy of a subset of the items.
 * 
 * @throws CloneNotSupportedException if there is a cloning problem.
 */
public TimePeriodValues createCopy(int start, int end) throws CloneNotSupportedException {

    TimePeriodValues copy = (TimePeriodValues) super.clone();

    copy.data = new ArrayList();
    if (this.data.size() > 0) {
        for (int index = start; index <= end; index++) {
            TimePeriodValue item = (TimePeriodValue) this.data.get(index);
            TimePeriodValue clone = (TimePeriodValue) item.clone();
            try {
                copy.add(clone);
            } catch (SeriesException e) {
                System.err.println("Failed to add cloned item.");
            }
        }
    }
    return copy;

}