From: <mu...@us...> - 2012-01-08 21:02:44
|
Revision: 2463 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=2463&view=rev Author: mungady Date: 2012-01-08 21:02:37 +0000 (Sun, 08 Jan 2012) Log Message: ----------- 2012-01-08 David Gilbert <dav...@ob...> * source/org/jfree/chart/plot/dial/StandardDialScale.java (angleToValue): Implemented and removed FIXME. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/StandardDialScale.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/StandardDialScaleTests.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2012-01-08 20:17:33 UTC (rev 2462) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2012-01-08 21:02:37 UTC (rev 2463) @@ -1,5 +1,10 @@ 2012-01-08 David Gilbert <dav...@ob...> + * source/org/jfree/chart/plot/dial/StandardDialScale.java + (angleToValue): Implemented and removed FIXME. + +2012-01-08 David Gilbert <dav...@ob...> + Bug 3445507: * source/org/jfree/data/time/TimeSeriesCollection.java (getRangeBounds(boolean)): New method, Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/StandardDialScale.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/StandardDialScale.java 2012-01-08 20:17:33 UTC (rev 2462) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/StandardDialScale.java 2012-01-08 21:02:37 UTC (rev 2463) @@ -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 @@ * ---------------------- * StandardDialScale.java * ---------------------- - * (C) Copyright 2006-2010, by Object Refinery Limited. + * (C) Copyright 2006-2012, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -40,6 +40,7 @@ * 19-Nov-2007 : Added some missing accessor methods (DG); * 27-Feb-2009 : Fixed bug 2617557: tickLabelPaint ignored (DG); * 09-Feb-2010 : Fixed bug 2946521 (DG); + * 08-Jan-2012 : Added missing angleToValue() implementation (DG); * */ @@ -860,14 +861,16 @@ /** * Converts the given angle to a data value, based on this scale. * - * @param angle the angle. + * @param angle the angle (in degrees). * * @return The data value. * * @see #valueToAngle(double) */ public double angleToValue(double angle) { - return Double.NaN; // FIXME + double range = this.upperBound - this.lowerBound; + double unit = range / this.extent; + return (angle - this.startAngle) * unit; } /** Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/StandardDialScaleTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/StandardDialScaleTests.java 2012-01-08 20:17:33 UTC (rev 2462) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/StandardDialScaleTests.java 2012-01-08 21:02:37 UTC (rev 2463) @@ -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 @@ * ------------------------- * SimpleDialScaleTests.java * ------------------------- - * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. + * (C) Copyright 2006-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -36,6 +36,7 @@ * ------- * 03-Nov-2006 : Version 1 (DG); * 24-Oct-2007 : Updated for API changes (DG); + * 08-Jan-2012 : Added tests for valueToAngle() and angleToValue(); * */ @@ -291,4 +292,39 @@ assertEquals(s1, s2); } + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the valueToAngle() method. + */ + public void testValueToAngle() { + StandardDialScale s = new StandardDialScale(); + assertEquals(175.0, s.valueToAngle(0.0), EPSILON); + assertEquals(90.0, s.valueToAngle(50.0), EPSILON); + assertEquals(5.0, s.valueToAngle(100.0), EPSILON); + assertEquals(192.0, s.valueToAngle(-10.0), EPSILON); + assertEquals(-12.0, s.valueToAngle(110.0), EPSILON); + + s = new StandardDialScale(0, 20, 180, -180.0, 10, 3); + assertEquals(180.0, s.valueToAngle(0.0), EPSILON); + assertEquals(90.0, s.valueToAngle(10.0), EPSILON); + assertEquals(0.0, s.valueToAngle(20.0), EPSILON); + } + + /** + * Some checks for the angleToValue() method. + */ + public void testAngleToValue() { + StandardDialScale s = new StandardDialScale(); + assertEquals(0.0, s.angleToValue(175.0), EPSILON); + assertEquals(50.0, s.angleToValue(90.0), EPSILON); + assertEquals(100.0, s.angleToValue(5.0), EPSILON); + assertEquals(-10.0, s.angleToValue(192.0), EPSILON); + assertEquals(110.0, s.angleToValue(-12.0), EPSILON); + + s = new StandardDialScale(0, 20, 180, -180.0, 10, 3); + assertEquals(0.0, s.angleToValue(180.0), EPSILON); + assertEquals(10.0, s.angleToValue(90.0), EPSILON); + assertEquals(20.0, s.angleToValue(0.0), EPSILON); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |