List of usage examples for org.jfree.data.xy XYSeries clone
@Override public Object clone() throws CloneNotSupportedException
From source file:org.jfree.data.xy.DefaultTableXYDataset.java
/** * Returns an independent copy of this dataset. * * @return A clone.// w w w . j ava 2 s . c o m * * @throws CloneNotSupportedException if there is some reason that cloning * cannot be performed. */ @Override public Object clone() throws CloneNotSupportedException { DefaultTableXYDataset clone = (DefaultTableXYDataset) super.clone(); int seriesCount = this.data.size(); clone.data = new java.util.ArrayList(seriesCount); for (int i = 0; i < seriesCount; i++) { XYSeries series = (XYSeries) this.data.get(i); clone.data.add(series.clone()); } clone.intervalDelegate = new IntervalXYDelegate(clone); // need to configure the intervalDelegate to match the original clone.intervalDelegate.setFixedIntervalWidth(getIntervalWidth()); clone.intervalDelegate.setAutoWidth(isAutoWidth()); clone.intervalDelegate.setIntervalPositionFactor(getIntervalPositionFactor()); clone.updateXPoints(); return clone; }
From source file:org.jfree.data.xy.XYSeriesTest.java
/** * Another test of the clone() method.//from w ww . j a v a 2 s . co m */ @Test public void testCloning3() throws CloneNotSupportedException { XYSeries s1 = new XYSeries("S1"); XYSeries s2 = (XYSeries) s1.clone(); assertTrue(s1.equals(s2)); // check independence s2.add(4.0, 300.0); assertFalse(s1.equals(s2)); s1.add(4.0, 300.0); assertTrue(s1.equals(s2)); }
From source file:org.jfree.data.xy.XYSeriesTest.java
/** * Confirm that cloning works.//from ww w . ja v a2 s . c o m */ @Test public void testCloning() throws CloneNotSupportedException { XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeries s2 = (XYSeries) s1.clone(); assertTrue(s1 != s2); assertTrue(s1.getClass() == s2.getClass()); assertTrue(s1.equals(s2)); }
From source file:org.jfree.data.xy.XYSeriesTest.java
/** * Another test of the clone() method./*ww w. j a v a2 s.c o m*/ */ @Test public void testCloning2() throws CloneNotSupportedException { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 100.0); s1.add(2.0, null); s1.add(3.0, 200.0); XYSeries s2 = (XYSeries) s1.clone(); assertTrue(s1.equals(s2)); // check independence s2.add(4.0, 300.0); assertFalse(s1.equals(s2)); s1.add(4.0, 300.0); assertTrue(s1.equals(s2)); }