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

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

Introduction

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

Prototype

@Override
public Object clone() throws CloneNotSupportedException 

Source Link

Document

Returns a clone of the dataset.

Usage

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

/**
 * Confirm that cloning works.// www. j a  va 2s . c om
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    double[] values = { 1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5 };
    HistogramDataset d1 = new HistogramDataset();
    d1.addSeries("Series 1", values, 5);
    HistogramDataset d2 = (HistogramDataset) d1.clone();
    assertTrue(d1 != d2);
    assertTrue(d1.getClass() == d2.getClass());
    assertTrue(d1.equals(d2));

    // simple check for independence
    d1.addSeries("Series 2", new double[] { 1.0, 2.0, 3.0 }, 2);
    assertFalse(d1.equals(d2));
    d2.addSeries("Series 2", new double[] { 1.0, 2.0, 3.0 }, 2);
    assertTrue(d1.equals(d2));
}