Example usage for org.jfree.data.xy XYBarDataset getUnderlyingDataset

List of usage examples for org.jfree.data.xy XYBarDataset getUnderlyingDataset

Introduction

In this page you can find the example usage for org.jfree.data.xy XYBarDataset getUnderlyingDataset.

Prototype

public XYDataset getUnderlyingDataset() 

Source Link

Document

Returns the underlying dataset that was specified via the constructor.

Usage

From source file:org.jfree.data.xy.XYBarDatasetTest.java

/**
 * Confirm that cloning works./*from ww  w.j  a va 2s.  co  m*/
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    DefaultXYDataset d1 = new DefaultXYDataset();
    double[] x1 = new double[] { 1.0, 2.0, 3.0 };
    double[] y1 = new double[] { 4.0, 5.0, 6.0 };
    double[][] data1 = new double[][] { x1, y1 };
    d1.addSeries("S1", data1);
    XYBarDataset bd1 = new XYBarDataset(d1, 5.0);
    XYBarDataset bd2 = (XYBarDataset) bd1.clone();
    assertTrue(bd1 != bd2);
    assertTrue(bd1.getClass() == bd2.getClass());
    assertTrue(bd1.equals(bd2));

    // check independence
    d1 = (DefaultXYDataset) bd1.getUnderlyingDataset();
    d1.addSeries("S2", new double[][] { { 1.0 }, { 2.0 } });
    assertFalse(bd1.equals(bd2));
    DefaultXYDataset d2 = (DefaultXYDataset) bd2.getUnderlyingDataset();
    d2.addSeries("S2", new double[][] { { 1.0 }, { 2.0 } });
    assertTrue(bd1.equals(bd2));
}

From source file:org.jfree.data.xy.junit.XYBarDatasetTest.java

/**
 * Confirm that cloning works./*w  ww  .  ja  va 2  s  .c o m*/
 */
public void testCloning() {
    DefaultXYDataset d1 = new DefaultXYDataset();
    double[] x1 = new double[] { 1.0, 2.0, 3.0 };
    double[] y1 = new double[] { 4.0, 5.0, 6.0 };
    double[][] data1 = new double[][] { x1, y1 };
    d1.addSeries("S1", data1);
    XYBarDataset bd1 = new XYBarDataset(d1, 5.0);
    XYBarDataset bd2 = null;
    try {
        bd2 = (XYBarDataset) bd1.clone();
    } catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(bd1 != bd2);
    assertTrue(bd1.getClass() == bd2.getClass());
    assertTrue(bd1.equals(bd2));

    // check independence
    d1 = (DefaultXYDataset) bd1.getUnderlyingDataset();
    d1.addSeries("S2", new double[][] { { 1.0 }, { 2.0 } });
    assertFalse(bd1.equals(bd2));
    DefaultXYDataset d2 = (DefaultXYDataset) bd2.getUnderlyingDataset();
    d2.addSeries("S2", new double[][] { { 1.0 }, { 2.0 } });
    assertTrue(bd1.equals(bd2));
}