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

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

Introduction

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

Prototype

@Override
public Object clone() throws CloneNotSupportedException 

Source Link

Document

Returns a clone of this time series collection.

Usage

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

/**
 * Basic checks for cloning./*from w w  w.  j  a v a 2s.c  o  m*/
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    TimeSeries s1 = new TimeSeries("Series");
    s1.add(new Year(2009), 1.1);
    TimeSeriesCollection c1 = new TimeSeriesCollection();
    c1.addSeries(s1);
    TimeSeriesCollection c2 = (TimeSeriesCollection) c1.clone();
    assertTrue(c1 != c2);
    assertTrue(c1.getClass() == c2.getClass());
    assertTrue(c1.equals(c2));

    // check independence
    s1.setDescription("XYZ");
    assertFalse(c1.equals(c2));
    c2.getSeries(0).setDescription("XYZ");
    assertTrue(c1.equals(c2));
}