You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(165) |
Nov
(296) |
Dec
(92) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(84) |
Feb
(20) |
Mar
(20) |
Apr
(42) |
May
(26) |
Jun
(30) |
Jul
(77) |
Aug
(151) |
Sep
(61) |
Oct
(259) |
Nov
(160) |
Dec
(76) |
2007 |
Jan
(159) |
Feb
(155) |
Mar
(183) |
Apr
(113) |
May
(110) |
Jun
(178) |
Jul
(56) |
Aug
(21) |
Sep
(50) |
Oct
(251) |
Nov
(218) |
Dec
(42) |
2008 |
Jan
(14) |
Feb
(37) |
Mar
(60) |
Apr
(77) |
May
(146) |
Jun
(256) |
Jul
(72) |
Aug
(51) |
Sep
(283) |
Oct
(22) |
Nov
(55) |
Dec
(53) |
2009 |
Jan
(56) |
Feb
(45) |
Mar
(56) |
Apr
(98) |
May
(84) |
Jun
(87) |
Jul
(32) |
Aug
(6) |
Sep
(19) |
Oct
|
Nov
(10) |
Dec
(6) |
2010 |
Jan
(2) |
Feb
(6) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(158) |
Nov
(17) |
Dec
(15) |
2012 |
Jan
(9) |
Feb
(3) |
Mar
(1) |
Apr
|
May
(1) |
Jun
(1) |
Jul
(22) |
Aug
(1) |
Sep
(29) |
Oct
(1) |
Nov
|
Dec
|
2013 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(259) |
Aug
(125) |
Sep
(24) |
Oct
(8) |
Nov
(132) |
Dec
(3) |
2014 |
Jan
(3) |
Feb
(26) |
Mar
(17) |
Apr
(8) |
May
|
Jun
(31) |
Jul
(126) |
Aug
(22) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(21) |
Oct
|
Nov
(1) |
Dec
|
2016 |
Jan
(19) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <mu...@us...> - 2014-04-09 08:52:32
|
Revision: 3122 http://sourceforge.net/p/jfreechart/code/3122 Author: mungady Date: 2014-04-09 08:52:25 +0000 (Wed, 09 Apr 2014) Log Message: ----------- Test updates. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/CategoryPlotTest.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/XYPlotTest.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/AbstractRendererTest.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/category/AbstractCategoryItemRendererTest.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/AbstractXYItemRendererTest.java branches/jfreechart-1.0.x-branch/tests/org/jfree/data/time/TimeSeriesCollectionTest.java Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/CategoryPlotTest.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/CategoryPlotTest.java 2014-04-08 14:31:46 UTC (rev 3121) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/CategoryPlotTest.java 2014-04-09 08:52:25 UTC (rev 3122) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * --------------------- * CategoryPlotTest.java * --------------------- - * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2003-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -55,7 +55,10 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.junit.Assert.assertNotEquals; +import org.junit.Test; + import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; @@ -92,7 +95,6 @@ import org.jfree.ui.Layer; import org.jfree.ui.RectangleInsets; import org.jfree.util.SortOrder; -import org.junit.Test; /** * Tests for the {@link CategoryPlot} class. @@ -130,7 +132,6 @@ */ @Test public void testEquals() { - CategoryPlot plot1 = new CategoryPlot(); CategoryPlot plot2 = new CategoryPlot(); assertTrue(plot1.equals(plot2)); @@ -483,6 +484,76 @@ } /** + * This test covers a flaw in the ObjectList equals() method. + */ + @Test + public void testEquals_ObjectList() { + CategoryPlot p1 = new CategoryPlot(); + p1.setDomainAxis(new CategoryAxis("A")); + CategoryPlot p2 = new CategoryPlot(); + p2.setDomainAxis(new CategoryAxis("A")); + assertEquals(p1, p2); + p2.setDomainAxis(1, new CategoryAxis("B")); + assertNotEquals(p1, p2); + } + + /** + * This test covers a flaw in the ObjectList equals() method. + */ + @Test + public void testEquals_ObjectList2() { + CategoryPlot p1 = new CategoryPlot(); + p1.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); + CategoryPlot p2 = new CategoryPlot(); + p2.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); + assertEquals(p1, p2); + p2.setDomainAxisLocation(1, AxisLocation.TOP_OR_LEFT); + assertNotEquals(p1, p2); + } + + /** + * This test covers a flaw in the ObjectList equals() method. + */ + @Test + public void testEquals_ObjectList3() { + CategoryPlot p1 = new CategoryPlot(); + p1.setRangeAxis(new NumberAxis("A")); + CategoryPlot p2 = new CategoryPlot(); + p2.setRangeAxis(new NumberAxis("A")); + assertEquals(p1, p2); + p2.setRangeAxis(1, new NumberAxis("B")); + assertNotEquals(p1, p2); + } + + /** + * This test covers a flaw in the ObjectList equals() method. + */ + @Test + public void testEquals_ObjectList4() { + CategoryPlot p1 = new CategoryPlot(); + p1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); + CategoryPlot p2 = new CategoryPlot(); + p2.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); + assertEquals(p1, p2); + p2.setRangeAxisLocation(1, AxisLocation.TOP_OR_LEFT); + assertNotEquals(p1, p2); + } + + /** + * This test covers a flaw in the ObjectList equals() method. + */ + @Test + public void testEquals_ObjectList5() { + CategoryPlot p1 = new CategoryPlot(); + p1.setRenderer(new BarRenderer()); + CategoryPlot p2 = new CategoryPlot(); + p2.setRenderer(new BarRenderer()); + assertEquals(p1, p2); + p2.setRenderer(1, new LineAndShapeRenderer()); + assertNotEquals(p1, p2); + } + + /** * Confirm that cloning works. */ @Test @@ -494,7 +565,7 @@ 4.0f, 5.0f, Color.red)); p1.setRangeZeroBaselinePaint(new GradientPaint(3.0f, 4.0f, Color.red, 5.0f, 6.0f, Color.white)); - CategoryPlot p2 = null; + CategoryPlot p2; try { p2 = (CategoryPlot) p1.clone(); } @@ -545,7 +616,7 @@ CategoryPlot p1 = new CategoryPlot(); p1.setFixedDomainAxisSpace(da1); p1.setFixedRangeAxisSpace(ra1); - CategoryPlot p2 = null; + CategoryPlot p2; try { p2 = (CategoryPlot) p1.clone(); } @@ -611,7 +682,7 @@ CategoryPlot p1 = new CategoryPlot(); LineAndShapeRenderer r1 = new LineAndShapeRenderer(); p1.setRenderer(r1); - CategoryPlot p2 = null; + CategoryPlot p2; try { p2 = (CategoryPlot) p1.clone(); } Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/XYPlotTest.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/XYPlotTest.java 2014-04-08 14:31:46 UTC (rev 3121) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/XYPlotTest.java 2014-04-09 08:52:25 UTC (rev 3122) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * --------------- * XYPlotTest.java * --------------- - * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2003-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -55,7 +55,10 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.junit.Assert.assertNotEquals; +import org.junit.Test; + import java.awt.BasicStroke; import java.awt.Color; import java.awt.GradientPaint; @@ -95,7 +98,6 @@ import org.jfree.date.MonthConstants; import org.jfree.ui.Layer; import org.jfree.ui.RectangleInsets; -import org.junit.Test; /** * Tests for the {@link XYPlot} class. @@ -437,6 +439,76 @@ } /** + * This test covers a flaw in the ObjectList equals() method. + */ + @Test + public void testEquals_ObjectList() { + XYPlot p1 = new XYPlot(); + p1.setDomainAxis(new NumberAxis("A")); + XYPlot p2 = new XYPlot(); + p2.setDomainAxis(new NumberAxis("A")); + assertEquals(p1, p2); + p2.setDomainAxis(1, new NumberAxis("B")); + assertNotEquals(p1, p2); + } + + /** + * This test covers a flaw in the ObjectList equals() method. + */ + @Test + public void testEquals_ObjectList2() { + XYPlot p1 = new XYPlot(); + p1.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); + XYPlot p2 = new XYPlot(); + p2.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); + assertEquals(p1, p2); + p2.setDomainAxisLocation(1, AxisLocation.TOP_OR_LEFT); + assertNotEquals(p1, p2); + } + + /** + * This test covers a flaw in the ObjectList equals() method. + */ + @Test + public void testEquals_ObjectList3() { + XYPlot p1 = new XYPlot(); + p1.setRangeAxis(new NumberAxis("A")); + XYPlot p2 = new XYPlot(); + p2.setRangeAxis(new NumberAxis("A")); + assertEquals(p1, p2); + p2.setRangeAxis(1, new NumberAxis("B")); + assertNotEquals(p1, p2); + } + + /** + * This test covers a flaw in the ObjectList equals() method. + */ + @Test + public void testEquals_ObjectList4() { + XYPlot p1 = new XYPlot(); + p1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); + XYPlot p2 = new XYPlot(); + p2.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); + assertEquals(p1, p2); + p2.setRangeAxisLocation(1, AxisLocation.TOP_OR_LEFT); + assertNotEquals(p1, p2); + } + + /** + * This test covers a flaw in the ObjectList equals() method. + */ + @Test + public void testEquals_ObjectList5() { + XYPlot p1 = new XYPlot(); + p1.setRenderer(new XYBarRenderer()); + XYPlot p2 = new XYPlot(); + p2.setRenderer(new XYBarRenderer()); + assertEquals(p1, p2); + p2.setRenderer(1, new XYLineAndShapeRenderer()); + assertNotEquals(p1, p2); + } + + /** * Confirm that basic cloning works. */ @Test Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/AbstractRendererTest.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/AbstractRendererTest.java 2014-04-08 14:31:46 UTC (rev 3121) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/AbstractRendererTest.java 2014-04-09 08:52:25 UTC (rev 3122) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------------------- * AbstractRendererTest.java * ------------------------- - * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2003-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -47,12 +47,15 @@ package org.jfree.chart.renderer; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import org.junit.Test; + import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; @@ -65,7 +68,6 @@ import java.awt.geom.Rectangle2D; import org.jfree.chart.TestUtilities; - import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.event.RendererChangeEvent; @@ -78,7 +80,6 @@ import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.ui.TextAnchor; -import org.junit.Test; /** * Tests for the {@link AbstractRenderer} class. @@ -426,9 +427,52 @@ r2.setBaseLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, 4.0f, Color.red)); assertTrue(r1.equals(r2)); + } + @Test + public void testEquals_ObjectList() { + BarRenderer r1 = new BarRenderer(); + r1.setSeriesItemLabelFont(0, new Font(Font.DIALOG, Font.BOLD, 10)); + BarRenderer r2 = new BarRenderer(); + r2.setSeriesItemLabelFont(0, new Font(Font.DIALOG, Font.BOLD, 10)); + assertEquals(r1, r2); + r2.setSeriesItemLabelFont(1, new Font(Font.DIALOG, Font.PLAIN, 5)); + assertNotEquals(r1, r2); } + + @Test + public void testEquals_ObjectList2() { + BarRenderer r1 = new BarRenderer(); + r1.setLegendTextFont(0, new Font(Font.DIALOG, Font.BOLD, 10)); + BarRenderer r2 = new BarRenderer(); + r2.setLegendTextFont(0, new Font(Font.DIALOG, Font.BOLD, 10)); + assertEquals(r1, r2); + r2.setLegendTextFont(1, new Font(Font.DIALOG, Font.PLAIN, 5)); + assertNotEquals(r1, r2); + } + @Test + public void testEquals_ObjectList3() { + BarRenderer r1 = new BarRenderer(); + r1.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); + BarRenderer r2 = new BarRenderer(); + r2.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); + assertEquals(r1, r2); + r2.setSeriesPositiveItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.INSIDE1, TextAnchor.CENTER)); + assertNotEquals(r1, r2); + } + + @Test + public void testEquals_ObjectList4() { + BarRenderer r1 = new BarRenderer(); + r1.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); + BarRenderer r2 = new BarRenderer(); + r2.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); + assertEquals(r1, r2); + r2.setSeriesNegativeItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.INSIDE1, TextAnchor.CENTER)); + assertNotEquals(r1, r2); + } + private static class TestRenderer extends XYLineAndShapeRenderer { @Override public void setTreatLegendShapeAsLine(boolean flag) { Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/category/AbstractCategoryItemRendererTest.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/category/AbstractCategoryItemRendererTest.java 2014-04-08 14:31:46 UTC (rev 3121) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/category/AbstractCategoryItemRendererTest.java 2014-04-09 08:52:25 UTC (rev 3122) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------------------------------- * AbstractCategoryItemRendererTest.java * ------------------------------------- - * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2004-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -45,11 +45,15 @@ package org.jfree.chart.renderer.category; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNotNull; +import org.junit.Test; + +import java.text.DecimalFormat; import java.text.NumberFormat; import org.jfree.chart.LegendItemCollection; @@ -61,7 +65,6 @@ import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.data.Range; import org.jfree.data.category.DefaultCategoryDataset; -import org.junit.Test; /** * Tests for the {@link AbstractCategoryItemRenderer} class. @@ -166,6 +169,39 @@ assertTrue(r1.equals(r2)); } + @Test + public void testEquals_ObjectList() { + BarRenderer r1 = new BarRenderer(); + r1.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator()); + BarRenderer r2 = new BarRenderer(); + r2.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator()); + assertEquals(r1, r2); + r2.setSeriesItemLabelGenerator(1, new StandardCategoryItemLabelGenerator("X", new DecimalFormat("0.0"))); + assertNotEquals(r1, r2); + } + + @Test + public void testEquals_ObjectList2() { + BarRenderer r1 = new BarRenderer(); + r1.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); + BarRenderer r2 = new BarRenderer(); + r2.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); + assertEquals(r1, r2); + r2.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator("X", new DecimalFormat("0.0"))); + assertNotEquals(r1, r2); + } + + @Test + public void testEquals_ObjectList3() { + BarRenderer r1 = new BarRenderer(); + r1.setSeriesItemURLGenerator(0, new StandardCategoryURLGenerator()); + BarRenderer r2 = new BarRenderer(); + r2.setSeriesItemURLGenerator(0, new StandardCategoryURLGenerator()); + assertEquals(r1, r2); + r2.setSeriesItemURLGenerator(1, new StandardCategoryURLGenerator()); + assertNotEquals(r1, r2); + } + /** * Confirm that cloning works. */ Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/AbstractXYItemRendererTest.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/AbstractXYItemRendererTest.java 2014-04-08 14:31:46 UTC (rev 3121) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/AbstractXYItemRendererTest.java 2014-04-09 08:52:25 UTC (rev 3122) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------------------------- * AbstractXYItemRendererTest.java * ------------------------------- - * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2004-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -42,14 +42,18 @@ package org.jfree.chart.renderer.xy; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; +import org.junit.Test; + import org.jfree.chart.labels.StandardXYSeriesLabelGenerator; +import org.jfree.chart.labels.StandardXYToolTipGenerator; +import org.jfree.chart.labels.StandardXYItemLabelGenerator; import org.jfree.data.Range; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; -import org.junit.Test; /** * Tests for the {@link AbstractXYItemRenderer} class. @@ -159,5 +163,27 @@ assertTrue(r1.getLegendItemURLGenerator() != r2.getLegendItemURLGenerator()); } + + @Test + public void testEquals_ObjectList() { + XYBarRenderer r1 = new XYBarRenderer(); + r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); + XYBarRenderer r2 = new XYBarRenderer(); + r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); + assertEquals(r1, r2); + r2.setSeriesItemLabelGenerator(1, new StandardXYItemLabelGenerator("X")); + assertNotEquals(r1, r2); + } + @Test + public void testEquals_ObjectList2() { + XYBarRenderer r1 = new XYBarRenderer(); + r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); + XYBarRenderer r2 = new XYBarRenderer(); + r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); + assertEquals(r1, r2); + r2.setSeriesToolTipGenerator(1, new StandardXYToolTipGenerator()); + assertNotEquals(r1, r2); + } + } Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/data/time/TimeSeriesCollectionTest.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/data/time/TimeSeriesCollectionTest.java 2014-04-08 14:31:46 UTC (rev 3121) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/data/time/TimeSeriesCollectionTest.java 2014-04-09 08:52:25 UTC (rev 3122) @@ -474,7 +474,6 @@ assertEquals(new Range(10.0, 10.0), collection.getRangeBounds( Arrays.asList("S1"), range, true)); collection.setXPosition(TimePeriodAnchor.END); - assertTrue(collection.getRangeBounds( - Arrays.asList("S1"), range, true).isNaNRange()); + assertNull(collection.getRangeBounds(Arrays.asList("S1"), range, true)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-04-08 14:31:49
|
Revision: 3121 http://sourceforge.net/p/jfreechart/code/3121 Author: mungady Date: 2014-04-08 14:31:46 +0000 (Tue, 08 Apr 2014) Log Message: ----------- 2013-04-07 David Gilbert <dav...@ob...> * org/jfree/chart/labels/StandardPieSectionLabelGenerator.java (attributedLabels): Change from ObjectList to Map, (StandardPieSectionLabelGenerator): Modify initialisation of storage, (setAttributedLabel): Storage changed to map, (equals): Simplification, (clone): Clone the attributed labels, * org/jfree/chart/StrokeMap.java (clone): Clone the storage, * org/jfree/chart/PaintMap.java (clone): Likewise, * org/jfree/chart/plot/PiePlot.java (clone): Clone required fields. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/PaintMap.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/StrokeMap.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/PaintMap.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/PaintMap.java 2014-04-08 14:31:12 UTC (rev 3120) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/PaintMap.java 2014-04-08 14:31:46 UTC (rev 3121) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------- * PaintMap.java * ------------- - * (C) Copyright 2006-2013, by Object Refinery Limited. + * (C) Copyright 2006-2014, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -174,9 +174,12 @@ */ @Override public Object clone() throws CloneNotSupportedException { + PaintMap clone = (PaintMap) super.clone(); + clone.store = new HashMap(); + clone.store.putAll(this.store); // TODO: I think we need to make sure the keys are actually cloned, // whereas the paint instances are always immutable so they're OK - return super.clone(); + return clone; } /** Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/StrokeMap.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/StrokeMap.java 2014-04-08 14:31:12 UTC (rev 3120) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/StrokeMap.java 2014-04-08 14:31:46 UTC (rev 3121) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * -------------- * StrokeMap.java * -------------- - * (C) Copyright 2006-2013, by Object Refinery Limited. + * (C) Copyright 2006-2014, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -169,9 +169,12 @@ */ @Override public Object clone() throws CloneNotSupportedException { + StrokeMap clone = (StrokeMap) super.clone(); + clone.store = new TreeMap(); + clone.store.putAll(this.store); // TODO: I think we need to make sure the keys are actually cloned, // whereas the stroke instances are always immutable so they're OK - return super.clone(); + return clone; } /** Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java 2014-04-08 14:31:12 UTC (rev 3120) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java 2014-04-08 14:31:46 UTC (rev 3121) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------------------------------- * StandardPieSectionLabelGenerator.java * ------------------------------------- - * (C) Copyright 2004-2008, by Object Refinery Limited. + * (C) Copyright 2004-2014, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -41,6 +41,7 @@ * 10-Jan-2007 : Include attributedLabels in equals() test (DG); * 10-Jul-2007 : Added constructors with locale parameter (DG); * 23-Apr-2008 : Implemented PublicCloneable (DG); + * 07-Apr-2014 : Fix cloning issue (DG); * */ @@ -52,10 +53,11 @@ import java.io.Serializable; import java.text.AttributedString; import java.text.NumberFormat; +import java.util.HashMap; import java.util.Locale; +import java.util.Map; import org.jfree.data.general.PieDataset; -import org.jfree.util.ObjectList; import org.jfree.util.PublicCloneable; /** @@ -79,9 +81,10 @@ public static final String DEFAULT_SECTION_LABEL_FORMAT = "{0}"; /** - * An optional list of attributed labels (instances of AttributedString). + * An optional map between item indices (Integer) and attributed labels + * (instances of AttributedString). */ - private ObjectList attributedLabels; + private Map attributedLabels; /** * Creates a new section label generator using @@ -141,7 +144,7 @@ public StandardPieSectionLabelGenerator(String labelFormat, NumberFormat numberFormat, NumberFormat percentFormat) { super(labelFormat, numberFormat, percentFormat); - this.attributedLabels = new ObjectList(); + this.attributedLabels = new HashMap(); } /** @@ -163,7 +166,7 @@ * @param label the label (<code>null</code> permitted). */ public void setAttributedLabel(int section, AttributedString label) { - this.attributedLabels.set(section, label); + this.attributedLabels.put(section, label); } /** @@ -208,7 +211,7 @@ */ @Override public AttributedString generateAttributedSectionLabel(PieDataset dataset, - Comparable key) { + Comparable key) { return getAttributedLabel(dataset.getIndex(key)); } @@ -232,10 +235,7 @@ if (!this.attributedLabels.equals(that.attributedLabels)) { return false; } - if (!super.equals(obj)) { - return false; - } - return true; + return super.equals(obj); } /** @@ -247,7 +247,11 @@ */ @Override public Object clone() throws CloneNotSupportedException { - return super.clone(); + StandardPieSectionLabelGenerator clone + = (StandardPieSectionLabelGenerator) super.clone(); + clone.attributedLabels = new HashMap(); + clone.attributedLabels.putAll(this.attributedLabels); + return clone; } } 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 2014-04-08 14:31:12 UTC (rev 3120) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java 2014-04-08 14:31:46 UTC (rev 3121) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------ * PiePlot.java * ------------ - * (C) Copyright 2000-2013, by Andrzej Porebski and Contributors. + * (C) Copyright 2000-2014, by Andrzej Porebski and Contributors. * * Original Author: Andrzej Porebski; * Contributor(s): David Gilbert (for Object Refinery Limited); @@ -3473,6 +3473,17 @@ @Override public Object clone() throws CloneNotSupportedException { PiePlot clone = (PiePlot) super.clone(); + clone.sectionPaintMap = (PaintMap) this.sectionPaintMap.clone(); + clone.sectionOutlinePaintMap + = (PaintMap) this.sectionOutlinePaintMap.clone(); + clone.sectionOutlineStrokeMap + = (StrokeMap) this.sectionOutlineStrokeMap.clone(); + clone.explodePercentages + = new TreeMap<Comparable<?>, Number>(this.explodePercentages); + if (this.labelGenerator != null) { + clone.labelGenerator = (PieSectionLabelGenerator) + ObjectUtilities.clone(this.labelGenerator); + } if (clone.dataset != null) { clone.dataset.addChangeListener(clone); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-04-08 14:31:15
|
Revision: 3120 http://sourceforge.net/p/jfreechart/code/3120 Author: mungady Date: 2014-04-08 14:31:12 +0000 (Tue, 08 Apr 2014) Log Message: ----------- Added tests for cloning. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/PiePlotTest.java Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/PiePlotTest.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/PiePlotTest.java 2014-03-19 06:53:45 UTC (rev 3119) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/PiePlotTest.java 2014-04-08 14:31:12 UTC (rev 3120) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ---------------- * PiePlotTest.java * ---------------- - * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2003-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -41,6 +41,7 @@ * 17-Apr-2007 : Added check for label generator that returns a null label (DG); * 31-Mar-2008 : Updated testEquals() (DG); * 10-Jul-2009 : Updated testEquals() (DG); + * 07-Apr-2014 : Add cloning tests (DG); * */ @@ -75,6 +76,8 @@ import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; import org.jfree.util.Rotation; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import org.junit.Test; /** @@ -633,5 +636,79 @@ } assertTrue(success); } + + @Test + public void testBug1126() throws CloneNotSupportedException { + DefaultPieDataset dataset1 = new DefaultPieDataset(); + PiePlot plot1 = new PiePlot(dataset1); + plot1.setSectionPaint("A", Color.RED); + plot1.setSectionPaint("B", Color.GREEN); + PiePlot plot2 = (PiePlot) plot1.clone(); + plot2.setSectionPaint("A", Color.BLUE); + plot2.setSectionPaint("B", Color.YELLOW); + assertEquals(Color.RED, plot1.getSectionPaint("A")); + assertEquals(Color.GREEN, plot1.getSectionPaint("B")); + assertEquals(Color.BLUE, plot2.getSectionPaint("A")); + assertEquals(Color.YELLOW, plot2.getSectionPaint("B")); + } + + @Test + public void testBug1126_b() throws CloneNotSupportedException { + DefaultPieDataset dataset1 = new DefaultPieDataset(); + PiePlot plot1 = new PiePlot(dataset1); + plot1.setSectionOutlinePaint("A", Color.RED); + plot1.setSectionOutlinePaint("B", Color.GREEN); + PiePlot plot2 = (PiePlot) plot1.clone(); + plot2.setSectionOutlinePaint("A", Color.BLUE); + plot2.setSectionOutlinePaint("B", Color.YELLOW); + assertEquals(Color.RED, plot1.getSectionOutlinePaint("A")); + assertEquals(Color.GREEN, plot1.getSectionOutlinePaint("B")); + assertEquals(Color.BLUE, plot2.getSectionOutlinePaint("A")); + assertEquals(Color.YELLOW, plot2.getSectionOutlinePaint("B")); + } + + @Test + public void testBug1126_c() throws CloneNotSupportedException { + DefaultPieDataset dataset1 = new DefaultPieDataset(); + PiePlot plot1 = new PiePlot(dataset1); + plot1.setSectionOutlineStroke("A", new BasicStroke(5.0f)); + plot1.setSectionOutlineStroke("B", new BasicStroke(6.0f)); + PiePlot plot2 = (PiePlot) plot1.clone(); + plot2.setSectionOutlineStroke("A", new BasicStroke(7.0f)); + plot2.setSectionOutlineStroke("B", new BasicStroke(8.0f)); + assertEquals(new BasicStroke(5.0f), plot1.getSectionOutlineStroke("A")); + assertEquals(new BasicStroke(6.0f), plot1.getSectionOutlineStroke("B")); + assertEquals(new BasicStroke(7.0f), plot2.getSectionOutlineStroke("A")); + assertEquals(new BasicStroke(8.0f), plot2.getSectionOutlineStroke("B")); + } + + @Test + public void testBug1126_d() throws CloneNotSupportedException { + DefaultPieDataset dataset1 = new DefaultPieDataset(); + PiePlot plot1 = new PiePlot(dataset1); + plot1.setExplodePercent("A", 0.1); + plot1.setExplodePercent("B", 0.2); + PiePlot plot2 = (PiePlot) plot1.clone(); + plot2.setExplodePercent("A", 0.3); + plot2.setExplodePercent("B", 0.4); + assertEquals(0.1, plot1.getExplodePercent("A"), EPSILON); + assertEquals(0.2, plot1.getExplodePercent("B"), EPSILON); + assertEquals(0.3, plot2.getExplodePercent("A"), EPSILON); + assertEquals(0.4, plot2.getExplodePercent("B"), EPSILON); + } + + private static final double EPSILON = 0.000000001; + @Test + public void testBug1126_e() throws CloneNotSupportedException { + DefaultPieDataset dataset1 = new DefaultPieDataset(); + PiePlot plot1 = new PiePlot(dataset1); + plot1.setLabelGenerator(new StandardPieSectionLabelGenerator()); + PiePlot plot2 = (PiePlot) plot1.clone(); + StandardPieSectionLabelGenerator g2 + = (StandardPieSectionLabelGenerator) plot2.getLabelGenerator(); + g2.setAttributedLabel(1, new AttributedString("TESTING")); + assertNotEquals(plot1, plot2); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-19 06:53:48
|
Revision: 3119 http://sourceforge.net/p/jfreechart/code/3119 Author: mungady Date: 2014-03-19 06:53:45 +0000 (Wed, 19 Mar 2014) Log Message: ----------- 2013-03-19 David Gilbert <dav...@ob...> * org/jfree/chart/axis/SymbolAxis.java (drawGridBandsHorizontal): Take into account inverted axis, (drawGridBandsVertical): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2014-03-19 06:53:36 UTC (rev 3118) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2014-03-19 06:53:45 UTC (rev 3119) @@ -1,3 +1,39 @@ +2013-03-19 David Gilbert <dav...@ob...> + + * org/jfree/chart/axis/SymbolAxis.java + (drawGridBandsHorizontal): Take into account inverted axis, + (drawGridBandsVertical): Likewise. + +2013-03-18 David Gilbert <dav...@ob...> + + * org/jfree/chart/utils/AttrStringUtils.java + (getTextBounds): New method, + (deriveTextBoundsAnchorOffsets): Workaround for top anchor, + * org/jfree/chart/axis/LogAxis.java + (baseSymbol): New field, + (baseFormatter): New field, + (LogAxis(String)): Instantiate new tick unit source, + (getBaseSymbol): New method, + (setBaseSymbol): New method, + (getBaseFormatter): New method, + (setBaseFormatter): New method, + (calculateValueNoINF): New private method, + (refreshTicksHorizontal): Reimplement using attributed strings, + (refreshTicksVertical): Likewise, + (selectHorizontalAutoTickUnit): Reimplemented, + (selectVerticalAutoTickUnit): Likewise, + (createTickLabel): New method, + (estimateMaximumTickLabelWidth): Updated for attributed strings, + (resizeRange): New method override, + (resizeRange2): Likewise, + (equals): Updated for new fields, + * org/jfree/chart/axis/LogTick.java: New file, + * org/jfree/chart/axis/NumberTickUnitSource.java: New file, + * org/jfree/chart/axis/ValueAxis.java + (drawTickMarksAndLabels): Updated to draw attributed string labels, + (findMaximumTickLabelHeight): Updated to handle LogTick, + (findMaximumTickLabelWidth): Likewise. + 2014-03-11 David Gilbert <dav...@ob...> * org/jfree/chart/renderer/BarRenderer3D.java This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-19 06:53:40
|
Revision: 3118 http://sourceforge.net/p/jfreechart/code/3118 Author: mungady Date: 2014-03-19 06:53:36 +0000 (Wed, 19 Mar 2014) Log Message: ----------- 2013-03-19 David Gilbert <dav...@ob...> * org/jfree/chart/axis/SymbolAxis.java (drawGridBandsHorizontal): Take into account inverted axis, (drawGridBandsVertical): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/SymbolAxis.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/SymbolAxis.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/SymbolAxis.java 2014-03-18 19:53:15 UTC (rev 3117) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/SymbolAxis.java 2014-03-19 06:53:36 UTC (rev 3118) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * --------------- * SymbolAxis.java * --------------- - * (C) Copyright 2002-2013, by Anthony Boulestreau and Contributors. + * (C) Copyright 2002-2014, by Anthony Boulestreau and Contributors. * * Original Author: Anthony Boulestreau; * Contributor(s): David Gilbert (for Object Refinery Limited); @@ -76,6 +76,7 @@ * 25-Jul-2007 : Added new field for alternate grid band paint (DG); * 15-Aug-2008 : Use alternate grid band paint when drawing (DG); * 02-Jul-2013 : Use ParamChecks (DG); + * 19-Mar-2014 : Fix gridbands (bug #1056) (DG); * */ @@ -198,10 +199,8 @@ * @see #isGridBandsVisible() */ public void setGridBandsVisible(boolean flag) { - if (this.gridBandsVisible != flag) { - this.gridBandsVisible = flag; - fireChangeEvent(); - } + this.gridBandsVisible = flag; + fireChangeEvent(); } /** @@ -311,41 +310,40 @@ * <CODE>gridBandPaint</CODE> (<CODE>DEFAULT_GRID_BAND_PAINT</CODE> by * default). * - * @param g2 the graphics device. - * @param plotArea the area within which the chart should be drawn. - * @param dataArea the area within which the plot should be drawn (a - * subset of the drawArea). - * @param edge the axis location. - * @param ticks the ticks. + * @param g2 the graphics target (<code>null</code> not permitted). + * @param plotArea the area within which the plot is drawn + * (<code>null</code> not permitted). + * @param dataArea the data area to which the axes are aligned + * (<code>null</code> not permitted). + * @param edge the edge to which the axis is aligned (<code>null</code> not + * permitted). + * @param ticks the ticks (<code>null</code> not permitted). */ protected void drawGridBands(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, List ticks) { - Shape savedClip = g2.getClip(); g2.clip(dataArea); if (RectangleEdge.isTopOrBottom(edge)) { drawGridBandsHorizontal(g2, plotArea, dataArea, true, ticks); - } - else if (RectangleEdge.isLeftOrRight(edge)) { + } else if (RectangleEdge.isLeftOrRight(edge)) { drawGridBandsVertical(g2, plotArea, dataArea, true, ticks); } g2.setClip(savedClip); - } /** * Draws the grid bands for the axis when it is at the top or bottom of * the plot. * - * @param g2 the graphics device. - * @param plotArea the area within which the chart should be drawn. - * @param dataArea the area within which the plot should be drawn - * (a subset of the drawArea). + * @param g2 the graphics target (<code>null</code> not permitted). + * @param plotArea the area within which the plot is drawn (not used here). + * @param dataArea the area for the data (to which the axes are aligned, + * <code>null</code> not permitted). * @param firstGridBandIsDark True: the first grid band takes the * color of <CODE>gridBandPaint</CODE>. * False: the second grid band takes the * color of <CODE>gridBandPaint</CODE>. - * @param ticks the ticks. + * @param ticks a list of ticks (<code>null</code> not permitted). */ protected void drawGridBandsHorizontal(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, @@ -356,14 +354,11 @@ double xx1, xx2; //gets the outline stroke width of the plot - double outlineStrokeWidth; - if (getPlot().getOutlineStroke() != null) { - outlineStrokeWidth - = ((BasicStroke) getPlot().getOutlineStroke()).getLineWidth(); + double outlineStrokeWidth = 1.0; + Stroke outlineStroke = getPlot().getOutlineStroke(); + if (outlineStroke != null && outlineStroke instanceof BasicStroke) { + outlineStrokeWidth = ((BasicStroke) outlineStroke).getLineWidth(); } - else { - outlineStrokeWidth = 1d; - } Iterator iterator = ticks.iterator(); ValueTick tick; @@ -380,53 +375,51 @@ else { g2.setPaint(this.gridBandAlternatePaint); } - band = new Rectangle2D.Double(xx1, yy + outlineStrokeWidth, - xx2 - xx1, dataArea.getMaxY() - yy - outlineStrokeWidth); + band = new Rectangle2D.Double(Math.min(xx1, xx2), + yy + outlineStrokeWidth, Math.abs(xx2 - xx1), + dataArea.getMaxY() - yy - outlineStrokeWidth); g2.fill(band); currentGridBandIsDark = !currentGridBandIsDark; } - g2.setPaintMode(); } /** - * Draws the grid bands for the axis when it is at the top or bottom of - * the plot. + * Draws the grid bands for an axis that is aligned to the left or + * right of the data area (that is, a vertical axis). * - * @param g2 the graphics device. - * @param drawArea the area within which the chart should be drawn. - * @param plotArea the area within which the plot should be drawn (a - * subset of the drawArea). + * @param g2 the graphics target (<code>null</code> not permitted). + * @param plotArea the area within which the plot is drawn (not used here). + * @param dataArea the area for the data (to which the axes are aligned, + * <code>null</code> not permitted). * @param firstGridBandIsDark True: the first grid band takes the * color of <CODE>gridBandPaint</CODE>. * False: the second grid band takes the * color of <CODE>gridBandPaint</CODE>. - * @param ticks a list of ticks. + * @param ticks a list of ticks (<code>null</code> not permitted). */ - protected void drawGridBandsVertical(Graphics2D g2, Rectangle2D drawArea, - Rectangle2D plotArea, boolean firstGridBandIsDark, List ticks) { + protected void drawGridBandsVertical(Graphics2D g2, Rectangle2D plotArea, + Rectangle2D dataArea, boolean firstGridBandIsDark, + List ticks) { boolean currentGridBandIsDark = firstGridBandIsDark; - double xx = plotArea.getX(); + double xx = dataArea.getX(); double yy1, yy2; //gets the outline stroke width of the plot - double outlineStrokeWidth; + double outlineStrokeWidth = 1.0; Stroke outlineStroke = getPlot().getOutlineStroke(); if (outlineStroke != null && outlineStroke instanceof BasicStroke) { outlineStrokeWidth = ((BasicStroke) outlineStroke).getLineWidth(); } - else { - outlineStrokeWidth = 1d; - } Iterator iterator = ticks.iterator(); ValueTick tick; Rectangle2D band; while (iterator.hasNext()) { tick = (ValueTick) iterator.next(); - yy1 = valueToJava2D(tick.getValue() + 0.5d, plotArea, + yy1 = valueToJava2D(tick.getValue() + 0.5d, dataArea, RectangleEdge.LEFT); - yy2 = valueToJava2D(tick.getValue() - 0.5d, plotArea, + yy2 = valueToJava2D(tick.getValue() - 0.5d, dataArea, RectangleEdge.LEFT); if (currentGridBandIsDark) { g2.setPaint(this.gridBandPaint); @@ -434,12 +427,12 @@ else { g2.setPaint(this.gridBandAlternatePaint); } - band = new Rectangle2D.Double(xx + outlineStrokeWidth, yy1, - plotArea.getMaxX() - xx - outlineStrokeWidth, yy2 - yy1); + band = new Rectangle2D.Double(xx + outlineStrokeWidth, + Math.min(yy1, yy2), dataArea.getMaxX() - xx + - outlineStrokeWidth, Math.abs(yy2 - yy1)); g2.fill(band); currentGridBandIsDark = !currentGridBandIsDark; } - g2.setPaintMode(); } /** @@ -447,7 +440,6 @@ */ @Override protected void autoAdjustRange() { - Plot plot = getPlot(); if (plot == null) { return; // no plot, no data @@ -475,47 +467,37 @@ if (getAutoRangeStickyZero()) { if (upper <= 0.0) { upper = 0.0; - } - else { + } else { upper = upper + upperMargin; } if (lower >= 0.0) { lower = 0.0; - } - else { + } else { lower = lower - lowerMargin; } - } - else { + } else { upper = Math.max(0.0, upper + upperMargin); lower = Math.min(0.0, lower - lowerMargin); } - } - else { + } else { if (getAutoRangeStickyZero()) { if (upper <= 0.0) { upper = Math.min(0.0, upper + upperMargin); - } - else { + } else { upper = upper + upperMargin * range; } if (lower >= 0.0) { lower = Math.max(0.0, lower - lowerMargin); - } - else { + } else { lower = lower - lowerMargin; } - } - else { + } else { upper = upper + upperMargin; lower = lower - lowerMargin; } } - setRange(new Range(lower, upper), false, false); - } - } /** @@ -535,8 +517,7 @@ List ticks = null; if (RectangleEdge.isTopOrBottom(edge)) { ticks = refreshTicksHorizontal(g2, dataArea, edge); - } - else if (RectangleEdge.isLeftOrRight(edge)) { + } else if (RectangleEdge.isLeftOrRight(edge)) { ticks = refreshTicksVertical(g2, dataArea, edge); } return ticks; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-18 19:53:19
|
Revision: 3117 http://sourceforge.net/p/jfreechart/code/3117 Author: mungady Date: 2014-03-18 19:53:15 +0000 (Tue, 18 Mar 2014) Log Message: ----------- 2013-03-18 David Gilbert <dav...@ob...> * org/jfree/chart/utils/AttrStringUtils.java (getTextBounds): New method, (deriveTextBoundsAnchorOffsets): Workaround for top anchor, * org/jfree/chart/axis/LogAxis.java (baseSymbol): New field, (baseFormatter): New field, (LogAxis(String)): Instantiate new tick unit source, (getBaseSymbol): New method, (setBaseSymbol): New method, (getBaseFormatter): New method, (setBaseFormatter): New method, (calculateValueNoINF): New private method, (refreshTicksHorizontal): Reimplement using attributed strings, (refreshTicksVertical): Likewise, (selectHorizontalAutoTickUnit): Reimplemented, (selectVerticalAutoTickUnit): Likewise, (createTickLabel): New method, (estimateMaximumTickLabelWidth): Updated for attributed strings, (resizeRange): New method override, (resizeRange2): Likewise, (equals): Updated for new fields, * org/jfree/chart/axis/LogTick.java: New file, * org/jfree/chart/axis/NumberTickUnitSource.java: New file, * org/jfree/chart/axis/ValueAxis.java (drawTickMarksAndLabels): Updated to draw attributed string labels, (findMaximumTickLabelHeight): Updated to handle LogTick, (findMaximumTickLabelWidth): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/LogAxis.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueAxis.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/AttrStringUtils.java Added Paths: ----------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/LogTick.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/NumberTickUnitSource.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/LogAxis.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/LogAxis.java 2014-03-18 19:49:00 UTC (rev 3116) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/LogAxis.java 2014-03-18 19:53:15 UTC (rev 3117) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------ * LogAxis.java * ------------ - * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2006-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Andrew Mickish (patch 1868745); @@ -57,32 +57,38 @@ * 28-Oct-2011 : Fixed endless loop for 0 TickUnit, # 3429707 (MH); * 02-Jul-2013 : Use ParamChecks (DG); * 01-Aug-2013 : Added attributedLabel override to support superscripts, - * subscripts and more (DG); */ + * subscripts and more (DG); + * 18-Mar-2014 : Add support for super-scripted tick labels (DG); + * + */ package org.jfree.chart.axis; import java.awt.Font; -import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.font.FontRenderContext; import java.awt.font.LineMetrics; +import java.awt.font.TextAttribute; import java.awt.geom.Rectangle2D; +import java.text.AttributedString; import java.text.DecimalFormat; +import java.text.Format; import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; import java.util.Locale; -import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.ValueAxisPlot; +import org.jfree.chart.util.AttrStringUtils; import org.jfree.chart.util.LogFormat; import org.jfree.chart.util.ParamChecks; import org.jfree.data.Range; import org.jfree.ui.RectangleEdge; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; +import org.jfree.util.ObjectUtilities; /** * A numerical axis that uses a logarithmic scale. The class is an @@ -98,6 +104,18 @@ /** The logarithm of the base value - cached for performance. */ private double baseLog = Math.log(10.0); + /** + * The base symbol to display (if <code>null</code> then the numerical + * value of the base is displayed). + */ + private String baseSymbol = null; + + /** + * The formatter to use for the base value when the base is displayed + * as a numerical value. + */ + private Format baseFormatter = new DecimalFormat("0"); + /** The smallest value permitted on the axis. */ private double smallestValue = 1E-100; @@ -120,13 +138,14 @@ * @param label the axis label (<code>null</code> permitted). */ public LogAxis(String label) { - super(label, createLogTickUnits(Locale.getDefault())); + super(label, new NumberTickUnitSource()); setDefaultAutoRange(new Range(0.01, 1.0)); - this.tickUnit = new NumberTickUnit(1.0, new DecimalFormat("0.#"), 9); + this.tickUnit = new NumberTickUnit(1.0, new DecimalFormat("0.#"), 10); } /** - * Returns the base for the logarithm calculation. + * Returns the base for the logarithm calculation. The default value is + * <code>10.0</code>. * * @return The base for the logarithm calculation. * @@ -137,8 +156,8 @@ } /** - * Sets the base for the logarithm calculation and sends an - * {@link AxisChangeEvent} to all registered listeners. + * Sets the base for the logarithm calculation and sends a change event to + * all registered listeners. * * @param base the base value (must be > 1.0). * @@ -154,6 +173,60 @@ } /** + * Returns the symbol used to represent the base of the logarithmic scale + * for the axis. If this is <code>null</code> (the default) then the + * numerical value of the base is displayed. + * + * @return The base symbol (possibly <code>null</code>). + * + * @since 1.0.18 + */ + public String getBaseSymbol() { + return this.baseSymbol; + } + + /** + * Sets the symbol used to represent the base value of the logarithmic + * scale and sends a change event to all registered listeners. + * + * @param symbol the symbol (<code>null</code> permitted). + * + * @since 1.0.18 + */ + public void setBaseSymbol(String symbol) { + this.baseSymbol = symbol; + fireChangeEvent(); + } + + /** + * Returns the formatter used to format the base value of the logarithmic + * scale when it is displayed numerically. The default value is + * <code>new DecimalFormat("0")</code>. + * + * @return The base formatter (never <code>null</code>). + * + * @since 1.0.18 + */ + public Format getBaseFormatter() { + return this.baseFormatter; + } + + /** + * Sets the formatter used to format the base value of the logarithmic + * scale when it is displayed numerically and sends a change event to all + * registered listeners. + * + * @param formatter the formatter (<code>null</code> not permitted). + * + * @since 1.0.18 + */ + public void setBaseFormatter(Format formatter) { + ParamChecks.nullNotPermitted(formatter, "formatter"); + this.baseFormatter = formatter; + fireChangeEvent(); + } + + /** * Returns the smallest value represented by the axis. * * @return The smallest value represented by the axis. @@ -165,8 +238,8 @@ } /** - * Sets the smallest value represented by the axis and sends an - * {@link AxisChangeEvent} to all registered listeners. + * Sets the smallest value represented by the axis and sends a change event + * to all registered listeners. * * @param value the value. * @@ -222,7 +295,6 @@ */ public void setTickUnit(NumberTickUnit unit, boolean notify, boolean turnOffAutoSelect) { - ParamChecks.nullNotPermitted(unit, "unit"); this.tickUnit = unit; if (turnOffAutoSelect) { @@ -231,12 +303,11 @@ if (notify) { fireChangeEvent(); } - } /** - * Returns the number format override. If this is non-null, then it will - * be used to format the numbers on the axis. + * Returns the number format override. If this is non-<code>null</code>, + * then it will be used to format the numbers on the axis. * * @return The number formatter (possibly <code>null</code>). * @@ -247,7 +318,8 @@ } /** - * Sets the number format override. If this is non-null, then it will be + * Sets the number format override and sends a change event to all + * registered listeners. If this is non-<code>null</code>, then it will be * used to format the numbers on the axis. * * @param formatter the number formatter (<code>null</code> permitted). @@ -286,14 +358,28 @@ public double calculateValue(double log) { return Math.pow(this.base, log); } + + private double calculateValueNoINF(double log) { + double result = calculateValue(log); + if (Double.isInfinite(result)) { + result = Double.MAX_VALUE; + } + if (result <= 0.0) { + result = Double.MIN_VALUE; + } + return result; + } /** * Converts a Java2D coordinate to an axis value, assuming that the - * axis covers the specified <code>edge</code> of the <code>area</code>. + * axis is aligned to the specified <code>edge</code> of the + * <code>area</code>. * * @param java2DValue the Java2D coordinate. - * @param area the area. - * @param edge the edge that the axis belongs to. + * @param area the area for plotting data (<code>null</code> not + * permitted). + * @param edge the edge that the axis is aligned to (<code>null</code> not + * permitted). * * @return A value along the axis scale. */ @@ -310,8 +396,7 @@ if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getMaxX(); - } - else if (RectangleEdge.isLeftOrRight(edge)) { + } else if (RectangleEdge.isLeftOrRight(edge)) { min = area.getMaxY(); max = area.getY(); } @@ -319,8 +404,7 @@ if (isInverted()) { log = axisMax - (java2DValue - min) / (max - min) * (axisMax - axisMin); - } - else { + } else { log = axisMin + (java2DValue - min) / (max - min) * (axisMax - axisMin); } @@ -333,8 +417,8 @@ * specified <code>edge</code>. * * @param value the data value. - * @param area the area. - * @param edge the edge. + * @param area the area (<code>null</code> not permitted). + * @param edge the edge (<code>null</code> not permitted). * * @return The Java2D coordinate corresponding to <code>value</code>. */ @@ -352,16 +436,14 @@ if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getMaxX(); - } - else if (RectangleEdge.isLeftOrRight(edge)) { + } else if (RectangleEdge.isLeftOrRight(edge)) { max = area.getMinY(); min = area.getMaxY(); } if (isInverted()) { return max - ((value - axisMin) / (axisMax - axisMin)) * (max - min); - } - else { + } else { return min + ((value - axisMin) / (axisMax - axisMin)) * (max - min); } @@ -421,10 +503,9 @@ double logRange = logUpper - logLower; logUpper = logUpper + getUpperMargin() * logRange; logLower = logLower - getLowerMargin() * logRange; - upper = calculateValue(logUpper); - lower = calculateValue(logLower); + upper = calculateValueNoINF(logUpper); + lower = calculateValueNoINF(logLower); } - setRange(new Range(lower, upper), false, false); } @@ -481,7 +562,6 @@ * @param edge the location of the axis. * * @return A list of ticks. - * */ @Override public List refreshTicks(Graphics2D g2, AxisState state, @@ -495,13 +575,13 @@ } return result; } - + /** * Returns a list of ticks for an axis at the top or bottom of the chart. * - * @param g2 the graphics device. - * @param dataArea the data area. - * @param edge the edge. + * @param g2 the graphics device (<code>null</code> not permitted). + * @param dataArea the data area (<code>null</code> not permitted). + * @param edge the edge (<code>null</code> not permitted). * * @return A list of ticks. */ @@ -524,16 +604,19 @@ selectAutoTickUnit(g2, dataArea, edge); } int minorTickCount = this.tickUnit.getMinorTickCount(); - double start = Math.floor(calculateLog(getLowerBound())); - double end = Math.ceil(calculateLog(getUpperBound())); + double unit = getTickUnit().getSize(); + double index = Math.ceil(calculateLog(getRange().getLowerBound()) + / unit); + double start = index * unit; + double end = calculateLog(getUpperBound()); double current = start; boolean hasTicks = (this.tickUnit.getSize() > 0.0) && !Double.isInfinite(start); while (hasTicks && current <= end) { - double v = calculateValue(current); + double v = calculateValueNoINF(current); if (range.contains(v)) { - ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v), - textAnchor, TextAnchor.CENTER, 0.0)); + ticks.add(new LogTick(TickType.MAJOR, v, createTickLabel(v), + textAnchor)); } // add minor ticks (for gridlines) double next = Math.pow(this.base, current @@ -541,8 +624,8 @@ for (int i = 1; i < minorTickCount; i++) { double minorV = v + i * ((next - v) / minorTickCount); if (range.contains(minorV)) { - ticks.add(new NumberTick(TickType.MINOR, minorV, "", - textAnchor, TextAnchor.CENTER, 0.0)); + ticks.add(new LogTick(TickType.MINOR, minorV, null, + textAnchor)); } } current = current + this.tickUnit.getSize(); @@ -553,9 +636,10 @@ /** * Returns a list of ticks for an axis at the left or right of the chart. * - * @param g2 the graphics device. - * @param dataArea the data area. - * @param edge the edge. + * @param g2 the graphics device (<code>null</code> not permitted). + * @param dataArea the data area (<code>null</code> not permitted). + * @param edge the edge that the axis is aligned to (<code>null</code> + * not permitted). * * @return A list of ticks. */ @@ -578,16 +662,19 @@ selectAutoTickUnit(g2, dataArea, edge); } int minorTickCount = this.tickUnit.getMinorTickCount(); - double start = Math.floor(calculateLog(getLowerBound())); - double end = Math.ceil(calculateLog(getUpperBound())); + double unit = getTickUnit().getSize(); + double index = Math.ceil(calculateLog(getRange().getLowerBound()) + / unit); + double start = index * unit; + double end = calculateLog(getUpperBound()); double current = start; boolean hasTicks = (this.tickUnit.getSize() > 0.0) && !Double.isInfinite(start); while (hasTicks && current <= end) { - double v = calculateValue(current); + double v = calculateValueNoINF(current); if (range.contains(v)) { - ticks.add(new NumberTick(TickType.MAJOR, v, createTickLabel(v), - textAnchor, TextAnchor.CENTER, 0.0)); + ticks.add(new LogTick(TickType.MAJOR, v, createTickLabel(v), + textAnchor)); } // add minor ticks (for gridlines) double next = Math.pow(this.base, current @@ -595,8 +682,8 @@ for (int i = 1; i < minorTickCount; i++) { double minorV = v + i * ((next - v) / minorTickCount); if (range.contains(minorV)) { - ticks.add(new NumberTick(TickType.MINOR, minorV, "", - textAnchor, TextAnchor.CENTER, 0.0)); + ticks.add(new LogTick(TickType.MINOR, minorV, null, + textAnchor)); } } current = current + this.tickUnit.getSize(); @@ -609,22 +696,21 @@ * display as many ticks as possible (selected from an array of 'standard' * tick units) without the labels overlapping. * - * @param g2 the graphics device. - * @param dataArea the area defined by the axes. - * @param edge the axis location. + * @param g2 the graphics device (<code>null</code> not permitted). + * @param dataArea the area defined by the axes (<code>null</code> not + * permitted). + * @param edge the axis location (<code>null</code> not permitted). * * @since 1.0.7 */ protected void selectAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { - if (RectangleEdge.isTopOrBottom(edge)) { selectHorizontalAutoTickUnit(g2, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { selectVerticalAutoTickUnit(g2, dataArea, edge); } - } /** @@ -638,33 +724,42 @@ * * @since 1.0.7 */ - protected void selectHorizontalAutoTickUnit(Graphics2D g2, - Rectangle2D dataArea, RectangleEdge edge) { + protected void selectHorizontalAutoTickUnit(Graphics2D g2, + Rectangle2D dataArea, RectangleEdge edge) { - double tickLabelWidth = estimateMaximumTickLabelWidth(g2, - getTickUnit()); - - // start with the current tick unit... + // select a tick unit that is the next one bigger than the current + // (log) range divided by 50 + Range range = getRange(); + double logAxisMin = calculateLog(range.getLowerBound()); + double logAxisMax = calculateLog(range.getUpperBound()); + double size = (logAxisMax - logAxisMin) / 50; TickUnitSource tickUnits = getStandardTickUnits(); - TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); - double unit1Width = exponentLengthToJava2D(unit1.getSize(), dataArea, - edge); - - // then extrapolate... - double guess = (tickLabelWidth / unit1Width) * unit1.getSize(); - - NumberTickUnit unit2 = (NumberTickUnit) - tickUnits.getCeilingTickUnit(guess); - double unit2Width = exponentLengthToJava2D(unit2.getSize(), dataArea, - edge); - - tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2); - if (tickLabelWidth > unit2Width) { - unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2); - } - - setTickUnit(unit2, false, false); - + TickUnit candidate = tickUnits.getCeilingTickUnit(size); + TickUnit prevCandidate = candidate; + boolean found = false; + while (!found) { + // while the tick labels overlap and there are more tick sizes available, + // choose the next bigger label + this.tickUnit = (NumberTickUnit) candidate; + double tickLabelWidth = estimateMaximumTickLabelWidth(g2, + candidate); + // what is the available space for one unit? + double candidateWidth = exponentLengthToJava2D(candidate.getSize(), + dataArea, edge); + if (tickLabelWidth < candidateWidth) { + found = true; + } else if (Double.isNaN(candidateWidth)) { + candidate = prevCandidate; + found = true; + } else { + prevCandidate = candidate; + candidate = tickUnits.getLargerTickUnit(prevCandidate); + if (candidate.equals(prevCandidate)) { + found = true; // there are no more candidates + } + } + } + setTickUnit((NumberTickUnit) candidate, false, false); } /** @@ -681,8 +776,8 @@ */ public double exponentLengthToJava2D(double length, Rectangle2D area, RectangleEdge edge) { - double one = valueToJava2D(calculateValue(1.0), area, edge); - double l = valueToJava2D(calculateValue(length + 1.0), area, edge); + double one = valueToJava2D(calculateValueNoINF(1.0), area, edge); + double l = valueToJava2D(calculateValueNoINF(length + 1.0), area, edge); return Math.abs(l - one); } @@ -699,30 +794,69 @@ */ protected void selectVerticalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { - - double tickLabelHeight = estimateMaximumTickLabelHeight(g2); - - // start with the current tick unit... + // select a tick unit that is the next one bigger than the current + // (log) range divided by 50 + Range range = getRange(); + double logAxisMin = calculateLog(range.getLowerBound()); + double logAxisMax = calculateLog(range.getUpperBound()); + double size = (logAxisMax - logAxisMin) / 50; TickUnitSource tickUnits = getStandardTickUnits(); - TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); - double unitHeight = exponentLengthToJava2D(unit1.getSize(), dataArea, - edge); + TickUnit candidate = tickUnits.getCeilingTickUnit(size); + TickUnit prevCandidate = candidate; + boolean found = false; + while (!found) { + // while the tick labels overlap and there are more tick sizes available, + // choose the next bigger label + this.tickUnit = (NumberTickUnit) candidate; + double tickLabelHeight = estimateMaximumTickLabelHeight(g2); + // what is the available space for one unit? + double candidateHeight = exponentLengthToJava2D(candidate.getSize(), + dataArea, edge); + if (tickLabelHeight < candidateHeight) { + found = true; + } else if (Double.isNaN(candidateHeight)) { + candidate = prevCandidate; + found = true; + } else { + prevCandidate = candidate; + candidate = tickUnits.getLargerTickUnit(prevCandidate); + if (candidate.equals(prevCandidate)) { + found = true; // there are no more candidates + } + } + } + setTickUnit((NumberTickUnit) candidate, false, false); + } - // then extrapolate... - double guess = (tickLabelHeight / unitHeight) * unit1.getSize(); - - NumberTickUnit unit2 = (NumberTickUnit) - tickUnits.getCeilingTickUnit(guess); - double unit2Height = exponentLengthToJava2D(unit2.getSize(), dataArea, - edge); - - tickLabelHeight = estimateMaximumTickLabelHeight(g2); - if (tickLabelHeight > unit2Height) { - unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2); + /** + * Creates a tick label for the specified value based on the current + * tick unit (used for formatting the exponent). + * + * @param value the value. + * + * @return The label. + * + * @since 1.0.18 + */ + protected AttributedString createTickLabel(double value) { + if (this.numberFormatOverride != null) { + return new AttributedString( + this.numberFormatOverride.format(value)); + } else { + String baseStr = this.baseSymbol; + if (baseStr == null) { + baseStr = this.baseFormatter.format(this.base); + } + double logy = calculateLog(value); + String exponentStr = getTickUnit().valueToString(logy); + AttributedString as = new AttributedString(baseStr + exponentStr); + as.addAttributes(getTickLabelFont().getAttributes(), 0, (baseStr + + exponentStr).length()); + as.addAttribute(TextAttribute.SUPERSCRIPT, + TextAttribute.SUPERSCRIPT_SUPER, baseStr.length(), + baseStr.length() + exponentStr.length()); + return as; } - - setTickUnit(unit2, false, false); - } /** @@ -735,7 +869,6 @@ * @since 1.0.7 */ protected double estimateMaximumTickLabelHeight(Graphics2D g2) { - RectangleInsets tickLabelInsets = getTickLabelInsets(); double result = tickLabelInsets.getTop() + tickLabelInsets.getBottom(); @@ -743,7 +876,6 @@ FontRenderContext frc = g2.getFontRenderContext(); result += tickLabelFont.getLineMetrics("123", frc).getHeight(); return result; - } /** @@ -776,27 +908,16 @@ } else { // look at lower and upper bounds... - FontMetrics fm = g2.getFontMetrics(getTickLabelFont()); Range range = getRange(); double lower = range.getLowerBound(); double upper = range.getUpperBound(); - String lowerStr, upperStr; - NumberFormat formatter = getNumberFormatOverride(); - if (formatter != null) { - lowerStr = formatter.format(lower); - upperStr = formatter.format(upper); - } - else { - lowerStr = unit.valueToString(lower); - upperStr = unit.valueToString(upper); - } - double w1 = fm.stringWidth(lowerStr); - double w2 = fm.stringWidth(upperStr); + AttributedString lowerStr = createTickLabel(lower); + AttributedString upperStr = createTickLabel(upper); + double w1 = AttrStringUtils.getTextBounds(lowerStr, g2).getWidth(); + double w2 = AttrStringUtils.getTextBounds(upperStr, g2).getWidth(); result += Math.max(w1, w2); } - return result; - } /** @@ -817,12 +938,14 @@ if (isInverted()) { double logA = log1 + length * (1 - upperPercent); double logB = log1 + length * (1 - lowerPercent); - adjusted = new Range(calculateValue(logA), calculateValue(logB)); + adjusted = new Range(calculateValueNoINF(logA), + calculateValueNoINF(logB)); } else { double logA = log1 + length * lowerPercent; double logB = log1 + length * upperPercent; - adjusted = new Range(calculateValue(logA), calculateValue(logB)); + adjusted = new Range(calculateValueNoINF(logA), + calculateValueNoINF(logB)); } setRange(adjusted); } @@ -845,25 +968,69 @@ double adj = length * percent; log1 = log1 + adj; log2 = log2 + adj; - setRange(calculateValue(log1), calculateValue(log2)); + setRange(calculateValueNoINF(log1), calculateValueNoINF(log2)); } - + /** - * Creates a tick label for the specified value. Note that this method - * was 'private' prior to version 1.0.10. + * Increases or decreases the axis range by the specified percentage about + * the central value and sends an {@link AxisChangeEvent} to all registered + * listeners. + * <P> + * To double the length of the axis range, use 200% (2.0). + * To halve the length of the axis range, use 50% (0.5). * - * @param value the value. + * @param percent the resize factor. * - * @return The label. - * - * @since 1.0.10 + * @see #resizeRange(double, double) */ - protected String createTickLabel(double value) { - if (this.numberFormatOverride != null) { - return this.numberFormatOverride.format(value); + @Override + public void resizeRange(double percent) { + Range range = getRange(); + double logMin = calculateLog(range.getLowerBound()); + double logMax = calculateLog(range.getUpperBound()); + double centralValue = calculateValueNoINF((logMin + logMax) / 2.0); + resizeRange(percent, centralValue); + } + + @Override + public void resizeRange(double percent, double anchorValue) { + resizeRange2(percent, anchorValue); + } + + /** + * Resizes the axis length to the specified percentage of the current + * range and sends a change event to all registered listeners. If + * <code>percent</code> is greater than 1.0 (100 percent) then the axis + * range is increased (which has the effect of zooming out), while if the + * <code>percent</code> is less than 1.0 the axis range is decreased + * (which has the effect of zooming in). The resize occurs around an + * anchor value (which may not be in the center of the axis). This is used + * to support mouse wheel zooming around an arbitrary point on the plot. + * <br><br> + * This method is overridden to perform the percentage calculations on the + * log values (which are linear for this axis). + * + * @param percent the percentage (must be greater than zero). + * @param anchorValue the anchor value. + */ + @Override + public void resizeRange2(double percent, double anchorValue) { + if (percent > 0.0) { + double logAnchorValue = calculateLog(anchorValue); + Range range = getRange(); + double logAxisMin = calculateLog(range.getLowerBound()); + double logAxisMax = calculateLog(range.getUpperBound()); + + double left = percent * (logAnchorValue - logAxisMin); + double right = percent * (logAxisMax - logAnchorValue); + + double upperBound = calculateValueNoINF(logAnchorValue + right); + Range adjusted = new Range(calculateValueNoINF( + logAnchorValue - left), upperBound); + setRange(adjusted); } else { - return this.tickUnit.valueToString(value); + setAutoRange(true); } } @@ -886,9 +1053,19 @@ if (this.base != that.base) { return false; } + if (!ObjectUtilities.equal(this.baseSymbol, that.baseSymbol)) { + return false; + } + if (!this.baseFormatter.equals(that.baseFormatter)) { + return false; + } if (this.smallestValue != that.smallestValue) { return false; } + if (!ObjectUtilities.equal(this.numberFormatOverride, + that.numberFormatOverride)) { + return false; + } return super.equals(obj); } @@ -920,6 +1097,10 @@ * @return A collection of tick units for integer values. * * @since 1.0.7 + * + * @deprecated This method is no longer used internally and will be removed + * from a future version. If you need this method, copy the source + * code into your project. */ public static TickUnitSource createLogTickUnits(Locale locale) { TickUnits units = new TickUnits(); @@ -940,5 +1121,4 @@ units.add(new NumberTickUnit(10, numberFormat)); return units; } - } Added: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/LogTick.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/LogTick.java (rev 0) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/LogTick.java 2014-03-18 19:53:15 UTC (rev 3117) @@ -0,0 +1,78 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. + * + * Project Info: http://www.jfree.org/jfreechart/index.html + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------ + * LogTick.java + * ------------ + * (C) Copyright 2014, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Mar-2014 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import java.text.AttributedString; +import org.jfree.ui.TextAnchor; + +/** + * A tick from a {@link LogAxis}. + */ +public class LogTick extends ValueTick { + + /** The attributed string for the tick label. */ + AttributedString attributedLabel; + + /** + * Creates a new instance. + * + * @param type the type (major or minor tick, <code>null</code> not + * permitted). + * @param value the value. + * @param label the label (<code>null</code> permitted). + * @param textAnchor the text anchor. + */ + public LogTick(TickType type, double value, AttributedString label, + TextAnchor textAnchor) { + super(type, value, null, textAnchor, textAnchor, 0.0); + this.attributedLabel = label; + } + + /** + * Returns the attributed string for the tick label, or <code>null</code> + * if there is no label. + * + * @return The attributed string or <code>null</code>. + */ + public AttributedString getAttributedLabel() { + return this.attributedLabel; + } +} Added: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/NumberTickUnitSource.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/NumberTickUnitSource.java (rev 0) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/NumberTickUnitSource.java 2014-03-18 19:53:15 UTC (rev 3117) @@ -0,0 +1,159 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. + * + * Project Info: http://www.jfree.org/jfreechart/index.html + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * NumberTickUnitSource.java + * ------------------------- + * (C) Copyright 2014, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Mar-2014 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.Serializable; +import java.text.DecimalFormat; +import java.text.NumberFormat; + +/** + * A tick unit source implementation that returns NumberTickUnit instances + * that are multiples of 1 or 5 times some power of 10. + * + * @since 1.0.18 + */ +public class NumberTickUnitSource implements TickUnitSource, Serializable { + + private int power = 0; + + private int factor = 1; + + /** + * Creates a new instance. + */ + public NumberTickUnitSource() { + this.power = 0; + this.factor = 1; + } + + @Override + public TickUnit getLargerTickUnit(TickUnit unit) { + TickUnit t = getCeilingTickUnit(unit); + if (t.equals(unit)) { + next(); + t = new NumberTickUnit(getTickSize(), getTickLabelFormat(), + getMinorTickCount()); + } + return t; + } + + @Override + public TickUnit getCeilingTickUnit(TickUnit unit) { + return getCeilingTickUnit(unit.getSize()); + } + + @Override + public TickUnit getCeilingTickUnit(double size) { + this.power = (int) Math.ceil(Math.log10(size)); + this.factor = 1; + return new NumberTickUnit(getTickSize(), getTickLabelFormat(), + getMinorTickCount()); + } + + private boolean next() { + if (factor == 1) { + factor = 5; + return true; + } + if (factor == 5) { + power++; + factor = 1; + return true; + } + throw new IllegalStateException("We should never get here."); + } + + private boolean previous() { + if (factor == 1) { + factor = 5; + power--; + return true; + } + if (factor == 5) { + factor = 1; + return true; + } + throw new IllegalStateException("We should never get here."); + } + + private double getTickSize() { + return this.factor * Math.pow(10.0, this.power); + } + + private DecimalFormat dfNeg4 = new DecimalFormat("0.0000"); + private DecimalFormat dfNeg3 = new DecimalFormat("0.000"); + private DecimalFormat dfNeg2 = new DecimalFormat("0.00"); + private DecimalFormat dfNeg1 = new DecimalFormat("0.0"); + private DecimalFormat df0 = new DecimalFormat("#,##0"); + + private NumberFormat getTickLabelFormat() { + if (power == -4) { + return dfNeg4; + } + if (power == -3) { + return dfNeg3; + } + if (power == -2) { + return dfNeg2; + } + if (power == -1) { + return dfNeg1; + } + if (power >= 0 && power <= 6) { + return df0; + } + return new DecimalFormat("0.#E0"); + } + + private int getMinorTickCount() { + if (factor == 1) { + return 10; + } else if (factor == 5) { + return 5; + } + return 0; + } + + @Override + public boolean equals(Object obj) { + return (obj instanceof NumberTickUnitSource); + } +} Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueAxis.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueAxis.java 2014-03-18 19:49:00 UTC (rev 3116) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueAxis.java 2014-03-18 19:53:15 UTC (rev 3117) @@ -107,7 +107,7 @@ * 30-Mar-2009 : Added pan(double) method (DG); * 03-Sep-2012 : Fix reserveSpace() method, bug 3555275 (DG); * 02-Jul-2013 : Use ParamChecks (DG); - * 10-Mar-2014 : Added setRange() check for issue #1121 (DG); + * 18-Mar-2014 : Updates to support attributed tick labels for LogAxis (DG); * */ @@ -131,6 +131,7 @@ import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.plot.Plot; +import org.jfree.chart.util.AttrStringUtils; import org.jfree.chart.util.ParamChecks; import org.jfree.data.Range; import org.jfree.io.SerialUtilities; @@ -669,11 +670,12 @@ /** * Draws the axis line, tick marks and tick mark labels. * - * @param g2 the graphics device. + * @param g2 the graphics device (<code>null</code> not permitted). * @param cursor the cursor. - * @param plotArea the plot area. - * @param dataArea the data area. - * @param edge the edge that the axis is aligned with. + * @param plotArea the plot area (<code>null</code> not permitted). + * @param dataArea the data area (<code>null</code> not permitted). + * @param edge the edge that the axis is aligned with (<code>null</code> + * not permitted). * * @return The width or height used to draw the axis. */ @@ -682,11 +684,9 @@ RectangleEdge edge) { AxisState state = new AxisState(cursor); - if (isAxisLineVisible()) { drawAxisLine(g2, cursor, dataArea, edge); } - List ticks = refreshTicks(g2, state, dataArea, edge); state.setTicks(ticks); g2.setFont(getTickLabelFont()); @@ -697,9 +697,24 @@ g2.setPaint(getTickLabelPaint()); float[] anchorPoint = calculateAnchorPoint(tick, cursor, dataArea, edge); - TextUtilities.drawRotatedString(tick.getText(), g2, - anchorPoint[0], anchorPoint[1], tick.getTextAnchor(), - tick.getAngle(), tick.getRotationAnchor()); + if (tick instanceof LogTick) { + LogTick lt = (LogTick) tick; + if (lt.getAttributedLabel() == null) { + continue; + } + AttrStringUtils.drawRotatedString(lt.getAttributedLabel(), + g2, anchorPoint[0], anchorPoint[1], + tick.getTextAnchor(), tick.getAngle(), + tick.getRotationAnchor()); + } else { + if (tick.getText() == null) { + continue; + } + TextUtilities.drawRotatedString(tick.getText(), g2, + anchorPoint[0], anchorPoint[1], + tick.getTextAnchor(), tick.getAngle(), + tick.getRotationAnchor()); + } } if ((isTickMarksVisible() && tick.getTickType().equals( @@ -844,22 +859,31 @@ RectangleInsets insets = getTickLabelInsets(); Font font = getTickLabelFont(); + g2.setFont(font); double maxHeight = 0.0; if (vertical) { FontMetrics fm = g2.getFontMetrics(font); Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { Tick tick = (Tick) iterator.next(); - Rectangle2D labelBounds = TextUtilities.getTextBounds( - tick.getText(), g2, fm); - if (labelBounds.getWidth() + insets.getTop() - + insets.getBottom() > maxHeight) { + Rectangle2D labelBounds = null; + if (tick instanceof LogTick) { + LogTick lt = (LogTick) tick; + if (lt.getAttributedLabel() != null) { + labelBounds = AttrStringUtils.getTextBounds( + lt.getAttributedLabel(), g2); + } + } else if (tick.getText() != null) { + labelBounds = TextUtilities.getTextBounds( + tick.getText(), g2, fm); + } + if (labelBounds != null && labelBounds.getWidth() + + insets.getTop() + insets.getBottom() > maxHeight) { maxHeight = labelBounds.getWidth() + insets.getTop() + insets.getBottom(); } } - } - else { + } else { LineMetrics metrics = font.getLineMetrics("ABCxyz", g2.getFontRenderContext()); maxHeight = metrics.getHeight() @@ -891,16 +915,25 @@ Iterator iterator = ticks.iterator(); while (iterator.hasNext()) { Tick tick = (Tick) iterator.next(); - Rectangle2D labelBounds = TextUtilities.getTextBounds( - tick.getText(), g2, fm); - if (labelBounds.getWidth() + insets.getLeft() + Rectangle2D labelBounds = null; + if (tick instanceof LogTick) { + LogTick lt = (LogTick) tick; + if (lt.getAttributedLabel() != null) { + labelBounds = AttrStringUtils.getTextBounds( + lt.getAttributedLabel(), g2); + } + } else if (tick.getText() != null) { + labelBounds = TextUtilities.getTextBounds(tick.getText(), + g2, fm); + } + if (labelBounds != null + && labelBounds.getWidth() + insets.getLeft() + insets.getRight() > maxWidth) { maxWidth = labelBounds.getWidth() + insets.getLeft() + insets.getRight(); } } - } - else { + } else { LineMetrics metrics = font.getLineMetrics("ABCxyz", g2.getFontRenderContext()); maxWidth = metrics.getHeight() Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/AttrStringUtils.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/AttrStringUtils.java 2014-03-18 19:49:00 UTC (rev 3116) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/AttrStringUtils.java 2014-03-18 19:53:15 UTC (rev 3117) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * -------------------- * AttrStringUtils.java * -------------------- - * (C) Copyright 2013 by Object Refinery Limited and Contributors. + * (C) Copyright 2013, 2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -35,7 +35,8 @@ * Changes: * -------- * 01-Aug-2013 : Version 1, backported from JFreeChart-FSE (DG); - * + * 18-Mar-2014 : Added getTextBounds() method (DG); + * */ package org.jfree.chart.util; @@ -59,6 +60,23 @@ } /** + * Returns the bounds for the attributed string. + * + * @param text the attributed string (<code>null</code> not permitted). + * @param g2 the graphics target (<code>null</code> not permitted). + * + * @return The bounds (never <code>null</code>). + * + * @since 1.0.18 + */ + public static Rectangle2D getTextBounds(AttributedString text, + Graphics2D g2) { + TextLayout tl = new TextLayout(text.getIterator(), + g2.getFontRenderContext()); + return tl.getBounds(); + } + + /** * Draws the attributed string at <code>(x, y)</code>, rotated by the * specified angle about <code>(x, y)</code>. * @@ -179,7 +197,8 @@ } if (isTop(anchor)) { - yAdj = -descent - leading + (float) bounds.getHeight(); + //yAdj = -descent - leading + (float) bounds.getHeight(); + yAdj = (float) bounds.getHeight(); } else if (isHalfAscent(anchor)) { yAdj = halfAscent; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-18 19:49:03
|
Revision: 3116 http://sourceforge.net/p/jfreechart/code/3116 Author: mungady Date: 2014-03-18 19:49:00 +0000 (Tue, 18 Mar 2014) Log Message: ----------- Minor Javadoc updates. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/TickUnitSource.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/TickUnitSource.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/TickUnitSource.java 2014-03-18 17:42:40 UTC (rev 3115) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/TickUnitSource.java 2014-03-18 19:49:00 UTC (rev 3116) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------------- * TickUnitSource.java * ------------------- - * (C) Copyright 2003-2008, by Object Refinery Limited. + * (C) Copyright 2003-2014, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -47,9 +47,11 @@ public interface TickUnitSource { /** - * Returns a tick unit that is larger than the supplied unit. + * Returns the smallest tick unit available in the source that is larger + * than <code>unit</code> or, if there is no larger unit, returns + * <code>unit</code>. * - * @param unit the unit. + * @param unit the unit (<code>null</code> not permitted). * * @return A tick unit that is larger than the supplied unit. */ @@ -66,12 +68,13 @@ public TickUnit getCeilingTickUnit(TickUnit unit); /** - * Returns the tick unit in the collection that is greater than or equal - * to the specified size. + * Returns the smallest tick unit available in the source that is greater + * than or equal to the specified size. If there is no such tick unit, + * the method should return the largest available tick in the source. * * @param size the size. * - * @return A unit from the collection. + * @return A unit from the collection (never <code>null</code>). */ public TickUnit getCeilingTickUnit(double size); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-18 17:42:42
|
Revision: 3115 http://sourceforge.net/p/jfreechart/code/3115 Author: mungady Date: 2014-03-18 17:42:40 +0000 (Tue, 18 Mar 2014) Log Message: ----------- Minor Javadoc correction. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/Tick.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/Tick.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/Tick.java 2014-03-18 17:32:46 UTC (rev 3114) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/Tick.java 2014-03-18 17:42:40 UTC (rev 3115) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * --------- * Tick.java * --------- - * (C) Copyright 2000-2013, by Object Refinery Limited. + * (C) Copyright 2000-2014, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Nicolas Brodu; @@ -94,7 +94,7 @@ /** * Returns the text version of the tick value. * - * @return A string (possibly <code>null</code>; + * @return A string (possibly <code>null</code>); */ public String getText() { return this.text; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-18 17:32:49
|
Revision: 3114 http://sourceforge.net/p/jfreechart/code/3114 Author: mungady Date: 2014-03-18 17:32:46 +0000 (Tue, 18 Mar 2014) Log Message: ----------- Minor Javadoc edit. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateTick.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateTick.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateTick.java 2014-03-18 17:30:16 UTC (rev 3113) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateTick.java 2014-03-18 17:32:46 UTC (rev 3114) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------- * DateTick.java * ------------- - * (C) Copyright 2003-2009, by Object Refinery Limited. + * (C) Copyright 2003-2014, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Peter Kolb (patch 1934255); @@ -45,6 +45,7 @@ import java.util.Date; +import org.jfree.chart.util.ParamChecks; import org.jfree.ui.TextAnchor; import org.jfree.util.ObjectUtilities; @@ -69,15 +70,13 @@ public DateTick(Date date, String label, TextAnchor textAnchor, TextAnchor rotationAnchor, double angle) { - this(TickType.MAJOR, date, label, textAnchor, rotationAnchor, angle); - } /** * Creates a new date tick. * - * @param tickType the tick type. + * @param tickType the tick type (<code>null</code> not permitted). * @param date the date. * @param label the label. * @param textAnchor the part of the label that is aligned to the anchor @@ -90,11 +89,10 @@ public DateTick(TickType tickType, Date date, String label, TextAnchor textAnchor, TextAnchor rotationAnchor, double angle) { - super(tickType, date.getTime(), label, textAnchor, rotationAnchor, angle); + ParamChecks.nullNotPermitted(tickType, "tickType"); this.date = date; - } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-18 17:30:19
|
Revision: 3113 http://sourceforge.net/p/jfreechart/code/3113 Author: mungady Date: 2014-03-18 17:30:16 +0000 (Tue, 18 Mar 2014) Log Message: ----------- Minor Javadoc edit. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueTick.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueTick.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueTick.java 2014-03-18 17:27:06 UTC (rev 3112) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueTick.java 2014-03-18 17:30:16 UTC (rev 3113) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * -------------- * ValueTick.java * -------------- - * (C) Copyright 2003-2008, by Object Refinery Limited. + * (C) Copyright 2003-2014, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -80,7 +80,8 @@ /** * Creates a new value tick. * - * @param tickType the tick type (major or minor). + * @param tickType the tick type (major or minor, <code>null</code> not + * permitted). * @param value the value. * @param label the label. * @param textAnchor the part of the label that is aligned to the anchor This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-18 17:27:09
|
Revision: 3112 http://sourceforge.net/p/jfreechart/code/3112 Author: mungady Date: 2014-03-18 17:27:06 +0000 (Tue, 18 Mar 2014) Log Message: ----------- Minor Javadoc edit. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/MouseWheelHandler.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/MouseWheelHandler.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/MouseWheelHandler.java 2014-03-11 06:48:36 UTC (rev 3111) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/MouseWheelHandler.java 2014-03-18 17:27:06 UTC (rev 3112) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ---------------------- * MouseWheelHandler.java * ---------------------- - * (C) Copyright 2009-2013 by Object Refinery Limited and Contributors. + * (C) Copyright 2009-2014 by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Ulrich Voigt - patch 2686040; @@ -48,8 +48,8 @@ import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; import java.awt.geom.Point2D; +import java.io.Serializable; -import java.io.Serializable; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.plot.Plot; import org.jfree.chart.plot.PlotRenderingInfo; @@ -57,8 +57,6 @@ /** * A class that handles mouse wheel events for the {@link ChartPanel} class. - * Mouse wheel event support was added in JDK 1.4, so this class will be omitted - * from JFreeChart if you build it using JDK 1.3. * * @since 1.0.13 */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-11 06:48:39
|
Revision: 3111 http://sourceforge.net/p/jfreechart/code/3111 Author: mungady Date: 2014-03-11 06:48:36 +0000 (Tue, 11 Mar 2014) Log Message: ----------- Clean up. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/demo/BarChartDemo1.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/demo/BarChartDemo1.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/demo/BarChartDemo1.java 2014-03-11 06:44:53 UTC (rev 3110) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/demo/BarChartDemo1.java 2014-03-11 06:48:36 UTC (rev 3111) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------------ * BarChartDemo1.java * ------------------ - * (C) Copyright 2003-2011, by Object Refinery Limited and Contributors. + * (C) Copyright 2003-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): ; @@ -35,7 +35,8 @@ * Changes * ------- * 09-Mar-2005 : Version 1 (DG); - * + * 11-Mar-2014 : Use new ChartFactory method (DG); + * */ package org.jfree.chart.demo; @@ -52,7 +53,6 @@ import org.jfree.chart.axis.CategoryLabelPositions; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; -import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; @@ -147,16 +147,9 @@ "Bar Chart Demo 1", // chart title "Category", // domain axis label "Value", // range axis label - dataset, // data - PlotOrientation.VERTICAL, // orientation - true, // include legend - true, // tooltips? - false // URLs? - ); + dataset); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... - - // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-11 06:44:55
|
Revision: 3110 http://sourceforge.net/p/jfreechart/code/3110 Author: mungady Date: 2014-03-11 06:44:53 +0000 (Tue, 11 Mar 2014) Log Message: ----------- Update Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2014-03-11 06:44:38 UTC (rev 3109) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2014-03-11 06:44:53 UTC (rev 3110) @@ -1,3 +1,8 @@ +2014-03-11 David Gilbert <dav...@ob...> + + * org/jfree/chart/renderer/BarRenderer3D.java + (drawItem): Check visible series. + 2014-03-10 David Gilbert <dav...@ob...> * org/jfree/chart/axis/DateAxis.java This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-11 06:44:41
|
Revision: 3109 http://sourceforge.net/p/jfreechart/code/3109 Author: mungady Date: 2014-03-11 06:44:38 +0000 (Tue, 11 Mar 2014) Log Message: ----------- 2014-03-10 David Gilbert <dav...@ob...> * org/jfree/chart/renderer/BarRenderer3D.java (drawItem): Check visible series. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/BarRenderer3D.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/BarRenderer3D.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/BarRenderer3D.java 2014-03-10 13:20:46 UTC (rev 3108) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/BarRenderer3D.java 2014-03-11 06:44:38 UTC (rev 3109) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------------ * BarRenderer3D.java * ------------------ - * (C) Copyright 2001-2013, by Serge V. Grachov and Contributors. + * (C) Copyright 2001-2014, by Serge V. Grachov and Contributors. * * Original Author: Serge V. Grachov; * Contributor(s): David Gilbert (for Object Refinery Limited); @@ -95,6 +95,7 @@ * 19-Mar-2009 : Override for drawRangeLine() method (DG); * 11-Jun-2012 : Utilise new PaintAlpha class - patch 3204823 from DaveLaw (DG); * 03-Jul-2013 : Use ParamChecks (DG); + * 11-Mar-2014 : Check visible series (DG); * */ @@ -667,6 +668,13 @@ ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { + // nothing is drawn if the row index is not included in the list with + // the indices of the visible rows... + int visibleRow = state.getVisibleSeriesIndex(row); + if (visibleRow < 0) { + return; + } + // check the value we are plotting... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { @@ -683,7 +691,7 @@ PlotOrientation orientation = plot.getOrientation(); double barW0 = calculateBarW0(plot, orientation, adjusted, domainAxis, - state, row, column); + state, visibleRow, column); double[] barL0L1 = calculateBarL0L1(value); if (barL0L1 == null) { return; // the bar is not visible This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-10 13:20:49
|
Revision: 3108 http://sourceforge.net/p/jfreechart/code/3108 Author: mungady Date: 2014-03-10 13:20:46 +0000 (Mon, 10 Mar 2014) Log Message: ----------- Update equals() test. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/DateAxisTest.java Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/DateAxisTest.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/DateAxisTest.java 2014-03-10 13:20:21 UTC (rev 3107) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/DateAxisTest.java 2014-03-10 13:20:46 UTC (rev 3108) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ----------------- * DateAxisTest.java * ----------------- - * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2003-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -53,6 +53,8 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import org.junit.Test; + import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; @@ -75,7 +77,6 @@ import org.jfree.data.time.Second; import org.jfree.data.time.Year; import org.jfree.ui.RectangleEdge; -import org.junit.Test; /** * Tests for the {@link DateAxis} class. @@ -111,6 +112,16 @@ assertFalse(a1.equals(null)); assertFalse(a1.equals("Some non-DateAxis object")); + a1 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.US); + assertFalse(a1.equals(a2)); + a2 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.US); + assertTrue(a1.equals(a2)); + + a1 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.FRANCE); + assertFalse(a1.equals(a2)); + a2 = new DateAxis("Test", TimeZone.getTimeZone("PST"), Locale.FRANCE); + assertTrue(a1.equals(a2)); + // tickUnit a1.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7)); assertFalse(a1.equals(a2)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-10 13:20:24
|
Revision: 3107 http://sourceforge.net/p/jfreechart/code/3107 Author: mungady Date: 2014-03-10 13:20:21 +0000 (Mon, 10 Mar 2014) Log Message: ----------- 2014-03-10 David Gilbert <dav...@ob...> * org/jfree/chart/axis/DateAxis.java (get/setLocale): New methods, (equals): Check locale and timezone fields explicitly. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2014-03-10 13:20:10 UTC (rev 3106) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2014-03-10 13:20:21 UTC (rev 3107) @@ -1,5 +1,11 @@ 2014-03-10 David Gilbert <dav...@ob...> + * org/jfree/chart/axis/DateAxis.java + (get/setLocale): New methods, + (equals): Check locale and timezone fields explicitly. + +2014-03-10 David Gilbert <dav...@ob...> + * org/jfree/chart/axis/ValueAxis.java (setRange): Check range length is positive. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-10 13:20:13
|
Revision: 3106 http://sourceforge.net/p/jfreechart/code/3106 Author: mungady Date: 2014-03-10 13:20:10 +0000 (Mon, 10 Mar 2014) Log Message: ----------- 2014-03-10 David Gilbert <dav...@ob...> * org/jfree/chart/axis/DateAxis.java (get/setLocale): New methods, (equals): Check locale and timezone fields explicitly. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateAxis.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateAxis.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateAxis.java 2014-03-10 12:56:34 UTC (rev 3105) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateAxis.java 2014-03-10 13:20:10 UTC (rev 3106) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------- * DateAxis.java * ------------- - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert; * Contributor(s): Jonathan Nash; @@ -131,6 +131,7 @@ * subscripts and more (DG); * 12-Sep-2013 : Prevent exception when zooming in below 1 millisecond (DG); * 23-Nov-2013 : Deprecated DEFAULT_DATE_TICK_UNIT to fix bug #977 (DG); + * 10-Mar-2014 : Add get/setLocale() methods (DG); * */ @@ -435,13 +436,35 @@ */ public void setTimeZone(TimeZone zone) { ParamChecks.nullNotPermitted(zone, "zone"); - if (!this.timeZone.equals(zone)) { - this.timeZone = zone; - setStandardTickUnits(createStandardDateTickUnits(zone, - this.locale)); - fireChangeEvent(); - } + this.timeZone = zone; + setStandardTickUnits(createStandardDateTickUnits(zone, this.locale)); + fireChangeEvent(); } + + /** + * Returns the locale for this axis. + * + * @return The locale (never <code>null</code>). + * + * @since 1.0.18 + */ + public Locale getLocale() { + return this.locale; + } + + /** + * Sets the locale for the axis and sends a change event to all registered + * listeners. + * + * @param locale the new locale (<code>null</code> not permitted). + */ + public void setLocale(Locale locale) { + ParamChecks.nullNotPermitted(locale, "locale"); + this.locale = locale; + setStandardTickUnits(createStandardDateTickUnits(this.timeZone, + this.locale)); + fireChangeEvent(); + } /** * Returns the underlying timeline used by this axis. @@ -1907,6 +1930,12 @@ return false; } DateAxis that = (DateAxis) obj; + if (!ObjectUtilities.equal(this.timeZone, that.timeZone)) { + return false; + } + if (!ObjectUtilities.equal(this.locale, that.locale)) { + return false; + } if (!ObjectUtilities.equal(this.tickUnit, that.tickUnit)) { return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-10 12:56:36
|
Revision: 3105 http://sourceforge.net/p/jfreechart/code/3105 Author: mungady Date: 2014-03-10 12:56:34 +0000 (Mon, 10 Mar 2014) Log Message: ----------- Added setRange() check for issue #1121. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2014-03-10 12:55:29 UTC (rev 3104) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2014-03-10 12:56:34 UTC (rev 3105) @@ -1,3 +1,8 @@ +2014-03-10 David Gilbert <dav...@ob...> + + * org/jfree/chart/axis/ValueAxis.java + (setRange): Check range length is positive. + 2014-02-28 David Gilbert <dav...@ob...> * org/jfree/chart/util/LineUtils.java: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-10 12:55:32
|
Revision: 3104 http://sourceforge.net/p/jfreechart/code/3104 Author: mungady Date: 2014-03-10 12:55:29 +0000 (Mon, 10 Mar 2014) Log Message: ----------- Added setRange() check for issue #1121. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueAxis.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueAxis.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueAxis.java 2014-03-10 11:21:44 UTC (rev 3103) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueAxis.java 2014-03-10 12:55:29 UTC (rev 3104) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * -------------- * ValueAxis.java * -------------- - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Jonathan Nash; @@ -107,6 +107,7 @@ * 30-Mar-2009 : Added pan(double) method (DG); * 03-Sep-2012 : Fix reserveSpace() method, bug 3555275 (DG); * 02-Jul-2013 : Use ParamChecks (DG); + * 10-Mar-2014 : Added setRange() check for issue #1121 (DG); * */ @@ -1225,8 +1226,8 @@ } /** - * Sets the range attribute and sends an {@link AxisChangeEvent} to all - * registered listeners. As a side-effect, the auto-range flag is set to + * Sets the range for the axis and sends a change event to all registered + * listeners. As a side-effect, the auto-range flag is set to * <code>false</code>. * * @param range the range (<code>null</code> not permitted). @@ -1239,9 +1240,11 @@ } /** - * Sets the range for the axis, if requested, sends an - * {@link AxisChangeEvent} to all registered listeners. As a side-effect, - * the auto-range flag is set to <code>false</code> (optional). + * Sets the range for the axis and, if requested, sends a change event to + * all registered listeners. Furthermore, if <code>turnOffAutoRange</code> + * is <code>true</code>, the auto-range flag is set to <code>false</code> + * (normally when setting the axis range manually the caller expects that + * range to remain in force). * * @param range the range (<code>null</code> not permitted). * @param turnOffAutoRange a flag that controls whether or not the auto @@ -1254,6 +1257,10 @@ public void setRange(Range range, boolean turnOffAutoRange, boolean notify) { ParamChecks.nullNotPermitted(range, "range"); + if (range.getLength() <= 0.0) { + throw new IllegalArgumentException( + "A positive range length is required: " + range); + } if (turnOffAutoRange) { this.autoRange = false; } @@ -1264,8 +1271,8 @@ } /** - * Sets the axis range and sends an {@link AxisChangeEvent} to all - * registered listeners. As a side-effect, the auto-range flag is set to + * Sets the range for the axis and sends a change event to all registered + * listeners. As a side-effect, the auto-range flag is set to * <code>false</code>. * * @param lower the lower axis limit. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-03-10 11:21:47
|
Revision: 3103 http://sourceforge.net/p/jfreechart/code/3103 Author: mungady Date: 2014-03-10 11:21:44 +0000 (Mon, 10 Mar 2014) Log Message: ----------- Updated Javadocs for issue #1123. Modified Paths: -------------- 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 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 2014-02-28 13:23:10 UTC (rev 3102) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CategoryPlot.java 2014-03-10 11:21:44 UTC (rev 3103) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ----------------- * CategoryPlot.java * ----------------- - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Jeremy Bowman; @@ -180,7 +180,8 @@ * 20-Nov-2011 : Initialise shadow generator as null (DG); * 02-Jul-2013 : Use ParamChecks (DG); * 12-Sep-2013 : Check for KEY_SUPPRESS_SHADOW_GENERATION rendering hint (DG); - * + * 10-Mar-2014 : Updated Javadocs for issue #1123 (DG); + * */ package org.jfree.chart.plot; @@ -1581,8 +1582,7 @@ /** * Sets the renderer at index 0 (sometimes referred to as the "primary" - * renderer) and sends a {@link PlotChangeEvent} to all registered - * listeners. + * renderer) and sends a change event to all registered listeners. * * @param renderer the renderer (<code>null</code> permitted. * @@ -1594,8 +1594,8 @@ /** * Sets the renderer at index 0 (sometimes referred to as the "primary" - * renderer) and, if requested, sends a {@link PlotChangeEvent} to all - * registered listeners. + * renderer) and, if requested, sends a change event to all registered + * listeners. * <p> * You can set the renderer to <code>null</code>, but this is not * recommended because: @@ -1614,8 +1614,10 @@ } /** - * Sets the renderer at the specified index and sends a - * {@link PlotChangeEvent} to all registered listeners. + * Sets the renderer to use for the dataset with the specified index and + * sends a change event to all registered listeners. Note that each + * dataset should have its own renderer, you should not use one renderer + * for multiple datasets. * * @param index the index. * @param renderer the renderer (<code>null</code> permitted). @@ -1628,8 +1630,10 @@ } /** - * Sets a renderer. A {@link PlotChangeEvent} is sent to all registered - * listeners. + * Sets the renderer to use for the dataset with the specified index and, + * if requested, sends a change event to all registered listeners. Note + * that each dataset should have its own renderer, you should not use one + * renderer for multiple datasets. * * @param index the index. * @param renderer the renderer (<code>null</code> permitted). 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 2014-02-28 13:23:10 UTC (rev 3102) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java 2014-03-10 11:21:44 UTC (rev 3103) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ----------- * XYPlot.java * ----------- - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Craig MacFarlane; @@ -228,7 +228,8 @@ * 10-Jul-2009 : Added optional drop shadow generator (DG); * 18-Oct-2011 : Fix tooltip offset with shadow renderer (DG); * 12-Sep-2013 : Check for KEY_SUPPRESS_SHADOW_GENERATION rendering hint (DG); - * + * 10-Mar-2014 : Updated Javadocs for issue #1123 (DG); + * */ package org.jfree.chart.plot; @@ -1592,9 +1593,9 @@ } /** - * Sets the renderer for the primary dataset and sends a - * {@link PlotChangeEvent} to all registered listeners. If the renderer - * is set to <code>null</code>, no data will be displayed. + * Sets the renderer for the primary dataset and sends a change event to + * all registered listeners. If the renderer is set to <code>null</code>, + * no data will be displayed. * * @param renderer the renderer (<code>null</code> permitted). * @@ -1605,8 +1606,10 @@ } /** - * Sets a renderer and sends a {@link PlotChangeEvent} to all - * registered listeners. + * Sets the renderer for the dataset with the specified index and sends a + * change event to all registered listeners. Note that each dataset should + * have its own renderer, you should not use one renderer for multiple + * datasets. * * @param index the index. * @param renderer the renderer. @@ -1618,8 +1621,10 @@ } /** - * Sets a renderer and sends a {@link PlotChangeEvent} to all - * registered listeners. + * Sets the renderer for the dataset with the specified index and, if + * requested, sends a change event to all registered listeners. Note that + * each dataset should have its own renderer, you should not use one + * renderer for multiple datasets. * * @param index the index. * @param renderer the renderer. @@ -5654,7 +5659,7 @@ } clone.quadrantOrigin = (Point2D) ObjectUtilities.clone( this.quadrantOrigin); - clone.quadrantPaint = (Paint[]) this.quadrantPaint.clone(); + clone.quadrantPaint = this.quadrantPaint.clone(); return clone; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-02-28 13:23:15
|
Revision: 3102 http://sourceforge.net/p/jfreechart/code/3102 Author: mungady Date: 2014-02-28 13:23:10 +0000 (Fri, 28 Feb 2014) Log Message: ----------- Fix Javadoc warnings. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/RingPlot.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/RingPlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/RingPlot.java 2014-02-28 13:16:44 UTC (rev 3101) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/RingPlot.java 2014-02-28 13:23:10 UTC (rev 3102) @@ -73,7 +73,6 @@ import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.PieSectionEntity; -import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.labels.PieToolTipGenerator; import org.jfree.chart.urls.PieURLGenerator; import org.jfree.chart.util.LineUtilities; @@ -323,8 +322,8 @@ /** * Sets the flag that controls whether or not separators are drawn between - * the sections in the chart, and sends a {@link PlotChangeEvent} to all - * registered listeners. + * the sections in the chart, and sends a change event to all registered + * listeners. * * @param visible the flag. * @@ -348,7 +347,7 @@ /** * Sets the stroke used to draw the separator between sections and sends - * a {@link PlotChangeEvent} to all registered listeners. + * a change event to all registered listeners. * * @param stroke the stroke (<code>null</code> not permitted). * @@ -373,7 +372,7 @@ /** * Sets the paint used to draw the separator between sections and sends a - * {@link PlotChangeEvent} to all registered listeners. + * change event to all registered listeners. * * @param paint the paint (<code>null</code> not permitted). * @@ -401,8 +400,7 @@ /** * Sets the length of the inner extension of the separator line that is * drawn between sections, as a percentage of the depth of the - * sections, and sends a {@link PlotChangeEvent} to all registered - * listeners. + * sections, and sends a change event to all registered listeners. * * @param percent the percentage. * @@ -430,8 +428,7 @@ /** * Sets the length of the outer extension of the separator line that is * drawn between sections, as a percentage of the depth of the - * sections, and sends a {@link PlotChangeEvent} to all registered - * listeners. + * sections, and sends a change event to all registered listeners. * * @param percent the percentage. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-02-28 13:16:47
|
Revision: 3101 http://sourceforge.net/p/jfreechart/code/3101 Author: mungady Date: 2014-02-28 13:16:44 +0000 (Fri, 28 Feb 2014) Log Message: ----------- Move extendLine() method to LineUtilities. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/RingPlot.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/RingPlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/RingPlot.java 2014-02-28 13:14:45 UTC (rev 3100) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/RingPlot.java 2014-02-28 13:16:44 UTC (rev 3101) @@ -73,8 +73,10 @@ import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.entity.PieSectionEntity; +import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.labels.PieToolTipGenerator; import org.jfree.chart.urls.PieURLGenerator; +import org.jfree.chart.util.LineUtilities; import org.jfree.chart.util.ParamChecks; import org.jfree.data.general.PieDataset; import org.jfree.io.SerialUtilities; @@ -626,9 +628,9 @@ } else if (currentPass == 2) { if (this.separatorsVisible) { - Line2D extendedSeparator = extendLine(separator, - this.innerSeparatorExtension, - this.outerSeparatorExtension); + Line2D extendedSeparator = LineUtilities.extendLine( + separator, this.innerSeparatorExtension, + this.outerSeparatorExtension); g2.setStroke(this.separatorStroke); g2.setPaint(this.separatorPaint); g2.draw(extendedSeparator); @@ -703,32 +705,6 @@ } /** - * Creates a new line by extending an existing line. - * - * @param line the line (<code>null</code> not permitted). - * @param startPercent the amount to extend the line at the start point - * end. - * @param endPercent the amount to extend the line at the end point end. - * - * @return A new line. - */ - private Line2D extendLine(Line2D line, double startPercent, - double endPercent) { - ParamChecks.nullNotPermitted(line, "line"); - double x1 = line.getX1(); - double x2 = line.getX2(); - double deltaX = x2 - x1; - double y1 = line.getY1(); - double y2 = line.getY2(); - double deltaY = y2 - y1; - x1 = x1 - (startPercent * deltaX); - y1 = y1 - (startPercent * deltaY); - x2 = x2 + (endPercent * deltaX); - y2 = y2 + (endPercent * deltaY); - return new Line2D.Double(x1, y1, x2, y2); - } - - /** * Provides serialization support. * * @param stream the output stream. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-02-28 13:14:47
|
Revision: 3100 http://sourceforge.net/p/jfreechart/code/3100 Author: mungady Date: 2014-02-28 13:14:45 +0000 (Fri, 28 Feb 2014) Log Message: ----------- 2014-02-28 David Gilbert <dav...@ob...> * org/jfree/chart/util/LineUtils.java: (extendLine): New method. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2014-02-28 13:14:27 UTC (rev 3099) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2014-02-28 13:14:45 UTC (rev 3100) @@ -1,5 +1,10 @@ 2014-02-28 David Gilbert <dav...@ob...> + * org/jfree/chart/util/LineUtils.java: + (extendLine): New method. + +2014-02-28 David Gilbert <dav...@ob...> + * org/jfree/chart/plot/CenterTextMode.java: New file, * org/jfree/chart/plot/RingPlot.java (centerTextMode): New field, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-02-28 13:14:31
|
Revision: 3099 http://sourceforge.net/p/jfreechart/code/3099 Author: mungady Date: 2014-02-28 13:14:27 +0000 (Fri, 28 Feb 2014) Log Message: ----------- 2014-02-28 David Gilbert <dav...@ob...> * org/jfree/chart/util/LineUtils.java: (extendLine): New method. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/LineUtilities.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/LineUtilities.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/LineUtilities.java 2014-02-28 12:51:40 UTC (rev 3098) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/LineUtilities.java 2014-02-28 13:14:27 UTC (rev 3099) @@ -2,7 +2,7 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2014, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * @@ -27,7 +27,7 @@ * ------------------ * LineUtilities.java * ------------------ - * (C) Copyright 2008, by Object Refinery Limited and Contributors. + * (C) Copyright 2008, 2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; @@ -35,6 +35,7 @@ * Changes * ------- * 05-Nov-2008 : Version 1 (DG); + * 28-Feb-2014 : Added extendLine() (DG); * */ @@ -139,4 +140,33 @@ // returned false from within the while loop above } + + /** + * Creates a new line by extending an existing line. + * + * @param line the line (<code>null</code> not permitted). + * @param startPercent the amount to extend the line at the start point + * end. + * @param endPercent the amount to extend the line at the end point end. + * + * @return A new line. + * + * @since 1.0.18 + */ + public static Line2D extendLine(Line2D line, double startPercent, + double endPercent) { + ParamChecks.nullNotPermitted(line, "line"); + double x1 = line.getX1(); + double x2 = line.getX2(); + double deltaX = x2 - x1; + double y1 = line.getY1(); + double y2 = line.getY2(); + double deltaY = y2 - y1; + x1 = x1 - (startPercent * deltaX); + y1 = y1 - (startPercent * deltaY); + x2 = x2 + (endPercent * deltaX); + y2 = y2 + (endPercent * deltaY); + return new Line2D.Double(x1, y1, x2, y2); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2014-02-28 12:51:42
|
Revision: 3098 http://sourceforge.net/p/jfreechart/code/3098 Author: mungady Date: 2014-02-28 12:51:40 +0000 (Fri, 28 Feb 2014) Log Message: ----------- Update version numbers. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ant/build-swt.xml Modified: branches/jfreechart-1.0.x-branch/ant/build-swt.xml =================================================================== --- branches/jfreechart-1.0.x-branch/ant/build-swt.xml 2014-02-28 12:51:06 UTC (rev 3097) +++ branches/jfreechart-1.0.x-branch/ant/build-swt.xml 2014-02-28 12:51:40 UTC (rev 3098) @@ -4,7 +4,7 @@ <target name="initialise" description="Initialise required settings."> <tstamp /> <property name="jfreechart.name" value="jfreechart" /> - <property name="jfreechart.version" value="1.0.17" /> + <property name="jfreechart.version" value="1.0.18-pre" /> <property name="jcommon.name" value="jcommon" /> <property name="jcommon.version" value="1.0.21" /> <property name="builddir" value="${basedir}/build" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |