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));
}