From: <mu...@us...> - 2008-03-19 20:30:44
|
Revision: 748 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=748&view=rev Author: mungady Date: 2008-03-19 13:30:39 -0700 (Wed, 19 Mar 2008) Log Message: ----------- 2008-03-19 David Gilbert <dav...@ob...> * source/org/jfree/chart/plot/PiePlot3D.java (getMaximumExplodePercent): Check for null dataset, (initialise): Likewise, * tests/org/jfree/chart/plot/junit/PiePlot3DTests.java (testDrawWithNullDataset): New test method. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/PiePlot3DTests.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-02-26 02:30:43 UTC (rev 747) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-03-19 20:30:39 UTC (rev 748) @@ -1,3 +1,11 @@ +2008-03-19 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/plot/PiePlot3D.java + (getMaximumExplodePercent): Check for null dataset, + (initialise): Likewise, + * tests/org/jfree/chart/plot/junit/PiePlot3DTests.java + (testDrawWithNullDataset): New test method. + 2008-02-26 David Gilbert <dav...@ob...> Patch 1901599: Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java 2008-02-26 02:30:43 UTC (rev 747) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java 2008-03-19 20:30:39 UTC (rev 748) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------ * PiePlot.java * ------------ - * (C) Copyright 2000-2007, by Andrzej Porebski and Contributors. + * (C) Copyright 2000-2008, by Andrzej Porebski and Contributors. * * Original Author: Andrzej Porebski; * Contributor(s): David Gilbert (for Object Refinery Limited); @@ -147,6 +147,8 @@ * 18-Jul-2007 : Added simple label option (DG); * 21-Nov-2007 : Fixed labelling bugs, added debug code, restored default * white background (DG); + * 19-Mar-2008 : Fixed IllegalArgumentException when drawing with null + * dataset (DG); * */ @@ -1517,6 +1519,9 @@ * @return The percent. */ public double getMaximumExplodePercent() { + if (this.dataset == null) { + return 0.0; + } double result = 0.0; Iterator iterator = this.dataset.getKeys().iterator(); while (iterator.hasNext()) { @@ -2190,8 +2195,10 @@ PiePlotState state = new PiePlotState(info); state.setPassesRequired(2); - state.setTotal(DatasetUtilities.calculatePieDatasetTotal( - plot.getDataset())); + if (this.dataset != null) { + state.setTotal(DatasetUtilities.calculatePieDatasetTotal( + plot.getDataset())); + } state.setLatestAngle(plot.getStartAngle()); return state; Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/PiePlot3DTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/PiePlot3DTests.java 2008-02-26 02:30:43 UTC (rev 747) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/PiePlot3DTests.java 2008-03-19 20:30:39 UTC (rev 748) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------------- * Pie3DPlotTests.java * ------------------- - * (C) Copyright 2003-2007, by Object Refinery Limited and Contributors. + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -37,11 +37,15 @@ * 18-Mar-2003 : Version 1 (DG); * 22-Mar-2007 : Added testEquals() (DG); * 05-Oct-2007 : Modified testEquals() for new field (DG); + * 19-Mar-2008 : Added test for null dataset (DG); * */ package org.jfree.chart.plot.junit; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; @@ -53,6 +57,8 @@ import junit.framework.TestCase; import junit.framework.TestSuite; +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PiePlot3D; /** @@ -124,4 +130,25 @@ } + /** + * Draws a pie chart where the label generator returns null. + */ + public void testDrawWithNullDataset() { + JFreeChart chart = ChartFactory.createPieChart3D("Test", null, true, + false, false); + boolean success = false; + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); + g2.dispose(); + success = true; + } + catch (Exception e) { + success = false; + } + assertTrue(success); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |