Example usage for org.jfree.data.statistics DefaultMultiValueCategoryDataset clone

List of usage examples for org.jfree.data.statistics DefaultMultiValueCategoryDataset clone

Introduction

In this page you can find the example usage for org.jfree.data.statistics DefaultMultiValueCategoryDataset clone.

Prototype

@Override
public Object clone() throws CloneNotSupportedException 

Source Link

Document

Returns a clone of this instance.

Usage

From source file:org.jfree.data.statistics.DefaultMultiValueCategoryDatasetTest.java

/**
 * Confirm that cloning works./*from   w  ww  .ja  v  a2  s.  c o  m*/
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    DefaultMultiValueCategoryDataset d1 = new DefaultMultiValueCategoryDataset();
    DefaultMultiValueCategoryDataset d2 = (DefaultMultiValueCategoryDataset) d1.clone();
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));

    // try a dataset with some content...
    List values = new ArrayList();
    values.add(new Integer(99));
    d1.add(values, "R1", "C1");
    d2 = (DefaultMultiValueCategoryDataset) d1.clone();
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));

    // check that the clone doesn't share the same underlying arrays.
    List values2 = new ArrayList();
    values2.add(new Integer(111));
    d1.add(values2, "R2", "C2");
    assertFalse(d1.equals(d2));
    d2.add(values2, "R2", "C2");
    assertTrue(d1.equals(d2));
}