From: <mu...@us...> - 2009-12-08 20:39:15
|
Revision: 2257 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=2257&view=rev Author: mungady Date: 2009-12-08 20:39:06 +0000 (Tue, 08 Dec 2009) Log Message: ----------- New file. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/data/statistics/HistogramDataset.java branches/jfreechart-1.0.x-branch/tests/org/jfree/data/statistics/junit/HistogramDatasetTests.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2009-11-27 07:20:13 UTC (rev 2256) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2009-12-08 20:39:06 UTC (rev 2257) @@ -1,3 +1,8 @@ +2009-08-12 David Gilbert <dav...@ob...> + + * source/org/jfree/data/statistics/HistogramDataset.java + (addSeries): Fire dataset change event. + 2009-11-27 David Gilbert <dav...@ob...> * source/org/jfree/chart/plot/PolarPlot.java @@ -52,7 +57,8 @@ (drawAxis): Likewise, * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java (drawSeries): Fetch appropriate axis, - (drawAngularGridLines): Update for deprecated method. + (drawAngularGridLines): Update for deprecated method, + * source/org/jfree/chart/plot/PolarAxisLocation.java: New file. 2009-11-04 David Gilbert <dav...@ob...> Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/data/statistics/HistogramDataset.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/statistics/HistogramDataset.java 2009-11-27 07:20:13 UTC (rev 2256) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/statistics/HistogramDataset.java 2009-12-08 20:39:06 UTC (rev 2257) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,12 +27,13 @@ * --------------------- * HistogramDataset.java * --------------------- - * (C) Copyright 2003-2008, by Jelai Wang and Contributors. + * (C) Copyright 2003-2009, by Jelai Wang and Contributors. * * Original Author: Jelai Wang (jelaiw AT mindspring.com); * Contributor(s): David Gilbert (for Object Refinery Limited); * Cameron Hayne; * Rikard Bj?rklind; + * Thomas A Caswell (patch 2902842); * * Changes * ------- @@ -53,6 +54,8 @@ * 03-Aug-2006 : Improved precision of bin boundary calculation (DG); * 07-Sep-2006 : Fixed bug 1553088 (DG); * 22-May-2008 : Implemented clone() method override (DG); + * 08-Dec-2009 : Fire change event in addSeries() - see patch 2902842 + * contributed by Thomas A Caswell (DG); * */ @@ -117,11 +120,12 @@ throw new IllegalArgumentException("Null 'type' argument"); } this.type = type; - notifyListeners(new DatasetChangeEvent(this, this)); + fireDatasetChanged(); } /** - * Adds a series to the dataset, using the specified number of bins. + * Adds a series to the dataset, using the specified number of bins, + * and sends a {@link DatasetChangeEvent} to all registered listeners. * * @param key the series key (<code>null</code> not permitted). * @param values the values (<code>null</code> not permitted). @@ -146,11 +150,8 @@ * @param minimum the lower bound of the bin range. * @param maximum the upper bound of the bin range. */ - public void addSeries(Comparable key, - double[] values, - int bins, - double minimum, - double maximum) { + public void addSeries(Comparable key, double[] values, int bins, + double minimum, double maximum) { if (key == null) { throw new IllegalArgumentException("Null 'key' argument."); @@ -208,6 +209,7 @@ map.put("values.length", new Integer(values.length)); map.put("bin width", new Double(binWidth)); this.list.add(map); + fireDatasetChanged(); } /** Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/data/statistics/junit/HistogramDatasetTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/data/statistics/junit/HistogramDatasetTests.java 2009-11-27 07:20:13 UTC (rev 2256) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/data/statistics/junit/HistogramDatasetTests.java 2009-12-08 20:39:06 UTC (rev 2257) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * -------------------------- * HistogramDatasetTests.java * -------------------------- - * (C) Copyright 2004-2008, by Object Refinery Limited. + * (C) Copyright 2004-2009, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -38,6 +38,7 @@ * 08-Jun-2005 : Added test for getSeriesKey(int) bug (DG); * 03-Aug-2006 : Added testAddSeries() and testBinBoundaries() method (DG); * 22-May-2008 : Added testAddSeries2() and enhanced testCloning() (DG); + * 08-Dec-2009 : Added test2902842() for patch at SourceForge (DG); * */ @@ -54,12 +55,15 @@ import junit.framework.TestCase; import junit.framework.TestSuite; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetChangeListener; import org.jfree.data.statistics.HistogramDataset; /** * Tests for the {@link HistogramDataset} class. */ -public class HistogramDatasetTests extends TestCase { +public class HistogramDatasetTests extends TestCase + implements DatasetChangeListener { /** * Returns the tests as a test suite. @@ -256,4 +260,30 @@ assertEquals(3.0, d.getYValue(0, 1), EPSILON); } + /** + * A test to show the limitation addressed by patch 2902842. + */ + public void test2902842() { + this.lastEvent = null; + double[] values = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + HistogramDataset hd = new HistogramDataset(); + hd.addChangeListener(this); + hd.addSeries("S1", values, 5); + assertNotNull(this.lastEvent); + } + + /** + * A reference to the last event received by the datasetChanged() method. + */ + private DatasetChangeEvent lastEvent; + + /** + * Receives event notification. + * + * @param event the event. + */ + public void datasetChanged(DatasetChangeEvent event) { + this.lastEvent = event; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |