From: <mu...@us...> - 2012-05-10 04:09:22
|
Revision: 2468 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=2468&view=rev Author: mungady Date: 2012-05-10 04:09:15 +0000 (Thu, 10 May 2012) Log Message: ----------- 2012-05-10 David Gilbert <dav...@ob...> * org/jfree/chart/renderer/xy/XYBarRenderer.java (findDomainBounds): call new method in super-class to take account of non-visible series, (findRangeBounds): likewise; * tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java (testFindDomainBounds2): new test; (testFindRangeBounds2): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYBarRenderer.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2012-03-11 16:22:21 UTC (rev 2467) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2012-05-10 04:09:15 UTC (rev 2468) @@ -1,3 +1,13 @@ +2012-05-10 David Gilbert <dav...@ob...> + + * org/jfree/chart/renderer/xy/XYBarRenderer.java + (findDomainBounds): call new method in super-class to take account of + non-visible series, + (findRangeBounds): likewise; + * tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java + (testFindDomainBounds2): new test; + (testFindRangeBounds2): Likewise. + 2012-03-11 Martin Hoeller <mar...@xs...> Patch 3500621 by Simon Kaczor Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYBarRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYBarRenderer.java 2012-03-11 16:22:21 UTC (rev 2467) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYBarRenderer.java 2012-05-10 04:09:15 UTC (rev 2468) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2011, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2012, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------------ * XYBarRenderer.java * ------------------ - * (C) Copyright 2001-2011, by Object Refinery Limited. + * (C) Copyright 2001-2012, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Richard Atkinson; @@ -96,6 +96,8 @@ * 24-Jun-2008 : Added new barPainter mechanism (DG); * 03-Feb-2009 : Added defaultShadowsVisible flag (DG); * 05-Feb-2009 : Added barAlignmentFactor (DG); + * 10-May-2012 : Fix findDomainBounds() and findRangeBounds() to account for + * non-visible series (DG); * */ @@ -1179,12 +1181,7 @@ * <code>null</code> or empty). */ public Range findDomainBounds(XYDataset dataset) { - if (dataset != null) { - return DatasetUtilities.findDomainBounds(dataset, true); - } - else { - return null; - } + return findDomainBounds(dataset, true); } /** @@ -1198,13 +1195,7 @@ * <code>null</code> or empty). */ public Range findRangeBounds(XYDataset dataset) { - if (dataset != null) { - return DatasetUtilities.findRangeBounds(dataset, - this.useYInterval); - } - else { - return null; - } + return findRangeBounds(dataset, this.useYInterval); } /** Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java 2012-03-11 16:22:21 UTC (rev 2467) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java 2012-05-10 04:09:15 UTC (rev 2468) @@ -69,6 +69,8 @@ import org.jfree.data.Range; import org.jfree.data.xy.DefaultIntervalXYDataset; import org.jfree.data.xy.XYBarDataset; +import org.jfree.data.xy.XYIntervalSeries; +import org.jfree.data.xy.XYIntervalSeriesCollection; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.jfree.ui.GradientPaintTransformType; @@ -302,6 +304,32 @@ assertFalse(bounds.contains(2.8)); } + /** + * A test for the findDomainBounds method to ensure it correctly accounts + * for the series visibility. + */ + public void testFindDomainBounds2() { + XYIntervalSeries s1 = new XYIntervalSeries("S1"); + s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5); + s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3); + XYIntervalSeries s2 = new XYIntervalSeries("S2"); + s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5); + s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0); + XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection(); + dataset.addSeries(s1); + dataset.addSeries(s2); + + XYBarRenderer renderer = new XYBarRenderer(); + Range r = renderer.findDomainBounds(dataset); + assertEquals(0.5, r.getLowerBound(), EPSILON); + assertEquals(4.1, r.getUpperBound(), EPSILON); + + renderer.setSeriesVisible(1, Boolean.FALSE); + r = renderer.findDomainBounds(dataset); + assertEquals(0.5, r.getLowerBound(), EPSILON); + assertEquals(2.1, r.getUpperBound(), EPSILON); + } + private static final double EPSILON = 0.0000000001; /** @@ -330,6 +358,33 @@ } /** + * A test for the findRangeBounds method to ensure it correctly accounts + * for the series visibility. + */ + public void testFindRangeBounds2() { + XYIntervalSeries s1 = new XYIntervalSeries("S1"); + s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5); + s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3); + XYIntervalSeries s2 = new XYIntervalSeries("S2"); + s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5); + s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0); + XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection(); + dataset.addSeries(s1); + dataset.addSeries(s2); + + XYBarRenderer renderer = new XYBarRenderer(); + renderer.setUseYInterval(false); + Range r = renderer.findRangeBounds(dataset); + assertEquals(9.0, r.getLowerBound(), EPSILON); + assertEquals(30.0, r.getUpperBound(), EPSILON); + + renderer.setSeriesVisible(1, Boolean.FALSE); + r = renderer.findRangeBounds(dataset); + assertEquals(10.0, r.getLowerBound(), EPSILON); + assertEquals(20.0, r.getUpperBound(), EPSILON); + } + + /** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |