Example usage for org.jfree.data.general DefaultKeyedValueDataset clone

List of usage examples for org.jfree.data.general DefaultKeyedValueDataset clone

Introduction

In this page you can find the example usage for org.jfree.data.general DefaultKeyedValueDataset clone.

Prototype

@Override
public Object clone() throws CloneNotSupportedException 

Source Link

Document

Creates a clone of the dataset.

Usage

From source file:org.jfree.data.general.DefaultKeyedValueDatasetTest.java

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

From source file:org.jfree.data.general.DefaultKeyedValueDatasetTest.java

/**
 * Confirm that the clone is independent of the original.
 *///from www.ja  v a2s  .c o  m
@Test
public void testCloneIndependence() throws CloneNotSupportedException {
    DefaultKeyedValueDataset d1 = new DefaultKeyedValueDataset("Key", new Double(10.0));
    DefaultKeyedValueDataset d2 = (DefaultKeyedValueDataset) d1.clone();
    assertTrue(d1.equals(d2));
    d2.updateValue(new Double(99.9));
    assertFalse(d1.equals(d2));
    d2.updateValue(new Double(10.0));
    assertTrue(d1.equals(d2));
}