List of usage examples for org.jfree.data.xy XYSeries equals
@Override public boolean equals(Object obj)
From source file:org.jfree.data.xy.DefaultTableXYDataset.java
/** * Adds any unique x-values from 'series' to the dataset, and also adds any * x-values that are in the dataset but not in 'series' to the series. * * @param series the series (<code>null</code> not permitted). *//* www . j av a 2s . com*/ private void updateXPoints(XYSeries series) { ParamChecks.nullNotPermitted(series, "series"); HashSet seriesXPoints = new HashSet(); boolean savedState = this.propagateEvents; this.propagateEvents = false; for (int itemNo = 0; itemNo < series.getItemCount(); itemNo++) { Number xValue = series.getX(itemNo); seriesXPoints.add(xValue); if (!this.xPoints.contains(xValue)) { this.xPoints.add(xValue); int seriesCount = this.data.size(); for (int seriesNo = 0; seriesNo < seriesCount; seriesNo++) { XYSeries dataSeries = (XYSeries) this.data.get(seriesNo); if (!dataSeries.equals(series)) { dataSeries.add(xValue, null); } } } } Iterator iterator = this.xPoints.iterator(); while (iterator.hasNext()) { Number xPoint = (Number) iterator.next(); if (!seriesXPoints.contains(xPoint)) { series.add(xPoint, null); } } this.propagateEvents = savedState; }
From source file:org.jfree.data.xy.XYSeriesTest.java
/** * Another test of the clone() method./*from w w w . j a v a2 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 the equals method can distinguish all the required fields. *///from www .j a v a 2s .co m @Test public void testEquals() { XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("Series"); s2.add(1.0, 1.1); assertTrue(s1.equals(s2)); assertTrue(s2.equals(s1)); s1.setKey("Series X"); assertFalse(s1.equals(s2)); s2.setKey("Series X"); assertTrue(s1.equals(s2)); s1.add(2.0, 2.2); assertFalse(s1.equals(s2)); s2.add(2.0, 2.2); assertTrue(s1.equals(s2)); }
From source file:org.jfree.data.xy.XYSeriesTest.java
/** * Another test of the clone() method.//from w w w . jav a 2s. c om */ @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)); }
From source file:org.jfree.data.xy.XYSeriesTest.java
/** * Confirm that cloning works./* w w w. j a v a 2 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)); }