From: <mu...@us...> - 2008-04-07 14:10:23
|
Revision: 810 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=810&view=rev Author: mungady Date: 2008-04-07 06:55:20 -0700 (Mon, 07 Apr 2008) Log Message: ----------- 2008-04-07 David Gilbert <dav...@ob...> * source/org/jfree/chart/plot/CategoryPlot.java (removeDomainMarker): Check for null collection, (removeRangeMarker): Likewise, * source/org/jfree/chart/plot/XYPlot.java (removeDomainMarker): Check for null collection, (removeRangeMarker): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CategoryPlot.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/CategoryPlotTests.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/XYPlotTests.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-04-07 13:20:17 UTC (rev 809) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-04-07 13:55:20 UTC (rev 810) @@ -1,5 +1,14 @@ 2008-04-07 David Gilbert <dav...@ob...> + * source/org/jfree/chart/plot/CategoryPlot.java + (removeDomainMarker): Check for null collection, + (removeRangeMarker): Likewise, + * source/org/jfree/chart/plot/XYPlot.java + (removeDomainMarker): Check for null collection, + (removeRangeMarker): Likewise. + +2008-04-07 David Gilbert <dav...@ob...> + * source/org/jfree/data/DefaultKeyedValue.java (equals): Simplified to reflect that this.key is never null. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CategoryPlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CategoryPlot.java 2008-04-07 13:20:17 UTC (rev 809) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CategoryPlot.java 2008-04-07 13:55:20 UTC (rev 810) @@ -155,6 +155,8 @@ * 14-Nov-2007 : Added missing event notifications (DG); * 25-Mar-2008 : Added new methods with optional notification - see patch * 1913751 (DG); + * 07-Apr-2008 : Fixed NPE in removeDomainMarker() and + * removeRangeMarker() (DG); * * */ @@ -2159,6 +2161,9 @@ markers = (ArrayList) this.backgroundDomainMarkers.get(new Integer( index)); } + if (markers == null) { + return false; + } boolean removed = markers.remove(marker); if (removed && notify) { fireChangeEvent(); @@ -2435,13 +2440,15 @@ ArrayList markers; if (layer == Layer.FOREGROUND) { markers = (ArrayList) this.foregroundRangeMarkers.get(new Integer( - index)); + index)); } else { markers = (ArrayList) this.backgroundRangeMarkers.get(new Integer( index)); } - + if (markers == null) { + return false; + } boolean removed = markers.remove(marker); if (removed && notify) { fireChangeEvent(); Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java 2008-04-07 13:20:17 UTC (rev 809) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java 2008-04-07 13:55:20 UTC (rev 810) @@ -196,6 +196,8 @@ * 04-Jan-2008 : Fix for quadrant painting error - see patch 1849564 (DG); * 25-Mar-2008 : Added new methods with optional notification - see patch * 1913751 (DG); + * 07-Apr-2008 : Fixed NPE in removeDomainMarker() and + * removeRangeMarker() (DG); * */ @@ -2279,13 +2281,16 @@ boolean notify) { ArrayList markers; if (layer == Layer.FOREGROUND) { - markers = (ArrayList) this.foregroundDomainMarkers.get(new Integer( - index)); + markers = (ArrayList) this.foregroundDomainMarkers.get( + new Integer(index)); } else { - markers = (ArrayList) this.backgroundDomainMarkers.get(new Integer( - index)); + markers = (ArrayList) this.backgroundDomainMarkers.get( + new Integer(index)); } + if (markers == null) { + return false; + } boolean removed = markers.remove(marker); if (removed && notify) { fireChangeEvent(); @@ -2515,14 +2520,16 @@ } ArrayList markers; if (layer == Layer.FOREGROUND) { - markers = (ArrayList) this.foregroundRangeMarkers.get(new Integer( - index)); + markers = (ArrayList) this.foregroundRangeMarkers.get( + new Integer(index)); } else { - markers = (ArrayList) this.backgroundRangeMarkers.get(new Integer( - index)); + markers = (ArrayList) this.backgroundRangeMarkers.get( + new Integer(index)); } - + if (markers == null) { + return false; + } boolean removed = markers.remove(marker); if (removed && notify) { fireChangeEvent(); Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/CategoryPlotTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/CategoryPlotTests.java 2008-04-07 13:20:17 UTC (rev 809) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/CategoryPlotTests.java 2008-04-07 13:55:20 UTC (rev 810) @@ -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 @@ * ---------------------- * CategoryPlotTests.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): -; @@ -39,6 +39,8 @@ * fixed) (DG); * 05-Feb-2007 : Added testAddDomainMarker() and testAddRangeMarker() (DG); * 07-Feb-2007 : Added test1654215() (DG); + * 07-Apr-2008 : Added testRemoveDomainMarker() and + * testRemoveRangeMarker() (DG); * */ @@ -757,4 +759,23 @@ } assertTrue(pass); } + + /** + * Check that removing a marker that isn't assigned to the plot returns + * false. + */ + public void testRemoveDomainMarker() { + CategoryPlot plot = new CategoryPlot(); + assertFalse(plot.removeDomainMarker(new CategoryMarker("Category 1"))); + } + + /** + * Check that removing a marker that isn't assigned to the plot returns + * false. + */ + public void testRemoveRangeMarker() { + CategoryPlot plot = new CategoryPlot(); + assertFalse(plot.removeRangeMarker(new ValueMarker(0.5))); + } + } Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/XYPlotTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/XYPlotTests.java 2008-04-07 13:20:17 UTC (rev 809) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/XYPlotTests.java 2008-04-07 13:55:20 UTC (rev 810) @@ -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 @@ * ---------------- * XYPlotTests.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): -; @@ -42,6 +42,8 @@ * 05-Feb-2007 : Added testAddDomainMarker() and testAddRangeMarker() (DG); * 07-Feb-2007 : Added test1654215() (DG); * 24-May-2007 : Added testDrawSeriesWithZeroItems() (DG); + * 07-Apr-2008 : Added testRemoveDomainMarker() and + * testRemoveRangeMarker() (DG); * */ @@ -1017,5 +1019,23 @@ } assertTrue(success); } + + /** + * Check that removing a marker that isn't assigned to the plot returns + * false. + */ + public void testRemoveDomainMarker() { + XYPlot plot = new XYPlot(); + assertFalse(plot.removeDomainMarker(new ValueMarker(0.5))); + } + /** + * Check that removing a marker that isn't assigned to the plot returns + * false. + */ + public void testRemoveRangeMarker() { + XYPlot plot = new XYPlot(); + assertFalse(plot.removeRangeMarker(new ValueMarker(0.5))); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |