From: <mu...@us...> - 2008-07-25 13:41:13
|
Revision: 1339 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1339&view=rev Author: mungady Date: 2008-07-25 13:41:10 +0000 (Fri, 25 Jul 2008) Log Message: ----------- 2008-07-25 David Gilbert <dav...@ob...> * source/org/jfree/chart/plot/XYPlot.java (drawQuadrants): Check for null axes, (render): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-07-22 15:18:46 UTC (rev 1338) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-07-25 13:41:10 UTC (rev 1339) @@ -1,3 +1,9 @@ +2008-07-25 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/plot/XYPlot.java + (drawQuadrants): Check for null axes, + (render): Likewise. + 2008-07-11 David Gilbert <dav...@ob...> Bug 1994355: Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java 2008-07-22 15:18:46 UTC (rev 1338) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java 2008-07-25 13:41:10 UTC (rev 1339) @@ -204,6 +204,7 @@ * for the domain axes (DG); * 09-Jul-2008 : Added renderer state notification when series pass begins * and ends - see patch 1997549 by Ulrich Voigt (DG); + * 25-Jul-2008 : Fixed NullPointerException for plots with no axes (DG); * */ @@ -3044,10 +3045,16 @@ boolean somethingToDraw = false; ValueAxis xAxis = getDomainAxis(); + if (xAxis == null) { // we can't draw quadrants without a valid x-axis + return; + } double x = xAxis.getRange().constrain(this.quadrantOrigin.getX()); double xx = xAxis.valueToJava2D(x, area, getDomainAxisEdge()); ValueAxis yAxis = getRangeAxis(); + if (yAxis == null) { // we can't draw quadrants without a valid y-axis + return; + } double y = yAxis.getRange().constrain(this.quadrantOrigin.getY()); double yy = yAxis.valueToJava2D(y, area, getRangeAxisEdge()); @@ -3069,8 +3076,7 @@ if (this.orientation == PlotOrientation.HORIZONTAL) { r[0] = new Rectangle2D.Double(Math.min(yymax, yy), Math.min(xxmin, xx), Math.abs(yy - yymax), - Math.abs(xx - xxmin) - ); + Math.abs(xx - xxmin)); } else { // PlotOrientation.VERTICAL r[0] = new Rectangle2D.Double(Math.min(xxmin, xx), @@ -3321,6 +3327,9 @@ foundData = true; ValueAxis xAxis = getDomainAxisForDataset(index); ValueAxis yAxis = getRangeAxisForDataset(index); + if (xAxis == null || yAxis == null) { + return foundData; // can't render anything without axes + } XYItemRenderer renderer = getRenderer(index); if (renderer == null) { renderer = getRenderer(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-08-11 15:22:12
|
Revision: 1341 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1341&view=rev Author: mungady Date: 2008-08-11 15:22:05 +0000 (Mon, 11 Aug 2008) Log Message: ----------- 2008-08-11 David Gilbert <dav...@ob...> * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java (totalWeight): Removed, (CombinedDomainCategoryPlot(CategoryAxis)): Updated for removed field, (add(CategoryPlot, int)): No longer need to track totalWeight, (remove): Likewise, (calculateAxisSpace): Compute totalWeight on-the-fly, * source/org/jfree/chart/plot/CombinedDomainXYPlot.java (totalWeight): Removed, (add(XYPlot, int)): No longer need to track totalWeight, (remove): Likewise, (calculateAxisSpace): Compute totalWeight on-the-fly, * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java (totalWeight): Removed, (add(CategoryPlot, int)): No longer need to track totalWeight, (remove): Likewise, (calculateAxisSpace): Compute totalWeight on-the-fly, * source/org/jfree/chart/plot/CombinedRangeXYPlot.java (totalWeight): Removed, (add(XYPlot, int)): No longer need to track totalWeight, (remove): Likewise, (calculateAxisSpace): Compute totalWeight on-the-fly. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedDomainXYPlot.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedRangeXYPlot.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-07-25 13:49:44 UTC (rev 1340) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-11 15:22:05 UTC (rev 1341) @@ -1,3 +1,27 @@ +2008-08-11 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java + (totalWeight): Removed, + (CombinedDomainCategoryPlot(CategoryAxis)): Updated for removed field, + (add(CategoryPlot, int)): No longer need to track totalWeight, + (remove): Likewise, + (calculateAxisSpace): Compute totalWeight on-the-fly, + * source/org/jfree/chart/plot/CombinedDomainXYPlot.java + (totalWeight): Removed, + (add(XYPlot, int)): No longer need to track totalWeight, + (remove): Likewise, + (calculateAxisSpace): Compute totalWeight on-the-fly, + * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java + (totalWeight): Removed, + (add(CategoryPlot, int)): No longer need to track totalWeight, + (remove): Likewise, + (calculateAxisSpace): Compute totalWeight on-the-fly, + * source/org/jfree/chart/plot/CombinedRangeXYPlot.java + (totalWeight): Removed, + (add(XYPlot, int)): No longer need to track totalWeight, + (remove): Likewise, + (calculateAxisSpace): Compute totalWeight on-the-fly. + 2008-07-25 David Gilbert <dav...@ob...> * source/org/jfree/chart/plot/XYPlot.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java 2008-07-25 13:49:44 UTC (rev 1340) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java 2008-08-11 15:22:05 UTC (rev 1341) @@ -58,6 +58,8 @@ * subplots, as suggested by Richard West (DG); * 28-Apr-2008 : Fixed zooming problem (see bug 1950037) (DG); * 26-Jun-2008 : Fixed crosshair support (DG); + * 11-Aug-2008 : Don't store totalWeight of subplots, calculate it as + * required (DG); * */ @@ -94,9 +96,6 @@ /** Storage for the subplot references. */ private List subplots; - /** Total weight of all charts. */ - private int totalWeight; - /** The gap between subplots. */ private double gap; @@ -120,7 +119,6 @@ public CombinedDomainCategoryPlot(CategoryAxis domainAxis) { super(null, domainAxis, null, null); this.subplots = new java.util.ArrayList(); - this.totalWeight = 0; this.gap = 5.0; } @@ -181,7 +179,6 @@ subplot.setOrientation(getOrientation()); subplot.addChangeListener(this); this.subplots.add(subplot); - this.totalWeight += weight; CategoryAxis axis = getDomainAxis(); if (axis != null) { axis.configure(); @@ -214,8 +211,6 @@ this.subplots.remove(position); subplot.setParent(null); subplot.removeChangeListener(this); - this.totalWeight -= subplot.getWeight(); - CategoryAxis domain = getDomainAxis(); if (domain != null) { domain.configure(); @@ -373,6 +368,11 @@ // work out the maximum height or width of the non-shared axes... int n = this.subplots.size(); + int totalWeight = 0; + for (int i = 0; i < n; i++) { + CategoryPlot sub = (CategoryPlot) this.subplots.get(i); + totalWeight += sub.getWeight(); + } this.subplotAreas = new Rectangle2D[n]; double x = adjustedPlotArea.getX(); double y = adjustedPlotArea.getY(); @@ -389,13 +389,13 @@ // calculate sub-plot area if (orientation == PlotOrientation.HORIZONTAL) { - double w = usableSize * plot.getWeight() / this.totalWeight; + double w = usableSize * plot.getWeight() / totalWeight; this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight()); x = x + w + this.gap; } else if (orientation == PlotOrientation.VERTICAL) { - double h = usableSize * plot.getWeight() / this.totalWeight; + double h = usableSize * plot.getWeight() / totalWeight; this.subplotAreas[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h); y = y + h + this.gap; @@ -639,20 +639,14 @@ if (!(obj instanceof CombinedDomainCategoryPlot)) { return false; } - if (!super.equals(obj)) { + CombinedDomainCategoryPlot that = (CombinedDomainCategoryPlot) obj; + if (this.gap != that.gap) { return false; } - CombinedDomainCategoryPlot plot = (CombinedDomainCategoryPlot) obj; - if (!ObjectUtilities.equal(this.subplots, plot.subplots)) { + if (!ObjectUtilities.equal(this.subplots, that.subplots)) { return false; } - if (this.totalWeight != plot.totalWeight) { - return false; - } - if (this.gap != plot.gap) { - return false; - } - return true; + return super.equals(obj); } /** Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedDomainXYPlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedDomainXYPlot.java 2008-07-25 13:49:44 UTC (rev 1340) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedDomainXYPlot.java 2008-08-11 15:22:05 UTC (rev 1341) @@ -89,6 +89,8 @@ * 31-Mar-2008 : Updated getSubplots() to return EMPTY_LIST for null * subplots, as suggested by Richard West (DG); * 28-Apr-2008 : Fixed zooming problem (see bug 1950037) (DG); + * 11-Aug-2008 : Don't store totalWeight of subplots, calculate it as + * required (DG); * */ @@ -127,9 +129,6 @@ /** Storage for the subplot references. */ private List subplots; - /** Total weight of all charts. */ - private int totalWeight = 0; - /** The gap between subplots. */ private double gap = 5.0; @@ -278,9 +277,6 @@ subplot.addChangeListener(this); this.subplots.add(subplot); - // keep track of total weights - this.totalWeight += weight; - ValueAxis axis = getDomainAxis(); if (axis != null) { axis.configure(); @@ -311,8 +307,6 @@ this.subplots.remove(position); subplot.setParent(null); subplot.removeChangeListener(this); - this.totalWeight -= subplot.getWeight(); - ValueAxis domain = getDomainAxis(); if (domain != null) { domain.configure(); @@ -375,6 +369,11 @@ // work out the maximum height or width of the non-shared axes... int n = this.subplots.size(); + int totalWeight = 0; + for (int i = 0; i < n; i++) { + XYPlot sub = (XYPlot) this.subplots.get(i); + totalWeight += sub.getWeight(); + } this.subplotAreas = new Rectangle2D[n]; double x = adjustedPlotArea.getX(); double y = adjustedPlotArea.getY(); @@ -391,13 +390,13 @@ // calculate sub-plot area if (orientation == PlotOrientation.HORIZONTAL) { - double w = usableSize * plot.getWeight() / this.totalWeight; + double w = usableSize * plot.getWeight() / totalWeight; this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight()); x = x + w + this.gap; } else if (orientation == PlotOrientation.VERTICAL) { - double h = usableSize * plot.getWeight() / this.totalWeight; + double h = usableSize * plot.getWeight() / totalWeight; this.subplotAreas[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h); y = y + h + this.gap; @@ -668,34 +667,20 @@ * @return <code>true</code> or <code>false</code>. */ public boolean equals(Object obj) { - - if (obj == null) { - return false; - } - if (obj == this) { return true; } - if (!(obj instanceof CombinedDomainXYPlot)) { return false; } - if (!super.equals(obj)) { + CombinedDomainXYPlot that = (CombinedDomainXYPlot) obj; + if (this.gap != that.gap) { return false; } - - CombinedDomainXYPlot p = (CombinedDomainXYPlot) obj; - if (this.totalWeight != p.totalWeight) { + if (!ObjectUtilities.equal(this.subplots, that.subplots)) { return false; } - if (this.gap != p.gap) { - return false; - } - if (!ObjectUtilities.equal(this.subplots, p.subplots)) { - return false; - } - - return true; + return super.equals(obj); } /** Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java 2008-07-25 13:49:44 UTC (rev 1340) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java 2008-08-11 15:22:05 UTC (rev 1341) @@ -54,6 +54,8 @@ * 31-Mar-2008 : Updated getSubplots() to return EMPTY_LIST for null * subplots, as suggested by Richard West (DG); * 26-Jun-2008 : Fixed crosshair support (DG); + * 11-Aug-2008 : Don't store totalWeight of subplots, calculate it as + * required (DG); * */ @@ -92,9 +94,6 @@ /** Storage for the subplot references. */ private List subplots; - /** Total weight of all charts. */ - private int totalWeight; - /** The gap between subplots. */ private double gap; @@ -116,7 +115,6 @@ public CombinedRangeCategoryPlot(ValueAxis rangeAxis) { super(null, null, rangeAxis, null); this.subplots = new java.util.ArrayList(); - this.totalWeight = 0; this.gap = 5.0; } @@ -179,8 +177,6 @@ subplot.setOrientation(getOrientation()); subplot.addChangeListener(this); this.subplots.add(subplot); - this.totalWeight += weight; - // configure the range axis... ValueAxis axis = getRangeAxis(); if (axis != null) { @@ -211,7 +207,6 @@ this.subplots.remove(position); subplot.setParent(null); subplot.removeChangeListener(this); - this.totalWeight -= subplot.getWeight(); ValueAxis range = getRangeAxis(); if (range != null) { @@ -280,7 +275,11 @@ Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); // work out the maximum height or width of the non-shared axes... int n = this.subplots.size(); - + int totalWeight = 0; + for (int i = 0; i < n; i++) { + CategoryPlot sub = (CategoryPlot) this.subplots.get(i); + totalWeight += sub.getWeight(); + } // calculate plotAreas of all sub-plots, maximum vertical/horizontal // axis width/height this.subplotArea = new Rectangle2D[n]; @@ -299,13 +298,13 @@ // calculate sub-plot area if (orientation == PlotOrientation.VERTICAL) { - double w = usableSize * plot.getWeight() / this.totalWeight; + double w = usableSize * plot.getWeight() / totalWeight; this.subplotArea[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight()); x = x + w + this.gap; } else if (orientation == PlotOrientation.HORIZONTAL) { - double h = usableSize * plot.getWeight() / this.totalWeight; + double h = usableSize * plot.getWeight() / totalWeight; this.subplotArea[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h); y = y + h + this.gap; @@ -508,20 +507,14 @@ if (!(obj instanceof CombinedRangeCategoryPlot)) { return false; } - if (!super.equals(obj)) { + CombinedRangeCategoryPlot that = (CombinedRangeCategoryPlot) obj; + if (this.gap != that.gap) { return false; } - CombinedRangeCategoryPlot that = (CombinedRangeCategoryPlot) obj; if (!ObjectUtilities.equal(this.subplots, that.subplots)) { return false; } - if (this.totalWeight != that.totalWeight) { - return false; - } - if (this.gap != that.gap) { - return false; - } - return true; + return super.equals(obj); } /** Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedRangeXYPlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedRangeXYPlot.java 2008-07-25 13:49:44 UTC (rev 1340) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CombinedRangeXYPlot.java 2008-08-11 15:22:05 UTC (rev 1341) @@ -91,6 +91,8 @@ * 31-Mar-2008 : Updated getSubplots() to return EMPTY_LIST for null * subplots, as suggested by Richard West (DG); * 28-Apr-2008 : Fixed zooming problem (see bug 1950037) (DG); + * 11-Aug-2008 : Don't store totalWeight of subplots, calculate it as + * required (DG); * */ @@ -129,9 +131,6 @@ /** Storage for the subplot references. */ private List subplots; - /** Total weight of all charts. */ - private int totalWeight = 0; - /** The gap between subplots. */ private double gap = 5.0; @@ -226,9 +225,6 @@ subplot.setRangeAxis(null); subplot.addChangeListener(this); this.subplots.add(subplot); - - // keep track of total weights - this.totalWeight += weight; configureRangeAxes(); fireChangeEvent(); @@ -256,7 +252,6 @@ this.subplots.remove(position); subplot.setParent(null); subplot.removeChangeListener(this); - this.totalWeight -= subplot.getWeight(); configureRangeAxes(); fireChangeEvent(); } @@ -317,6 +312,11 @@ Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); // work out the maximum height or width of the non-shared axes... int n = this.subplots.size(); + int totalWeight = 0; + for (int i = 0; i < n; i++) { + XYPlot sub = (XYPlot) this.subplots.get(i); + totalWeight += sub.getWeight(); + } // calculate plotAreas of all sub-plots, maximum vertical/horizontal // axis width/height @@ -336,13 +336,13 @@ // calculate sub-plot area if (orientation == PlotOrientation.VERTICAL) { - double w = usableSize * plot.getWeight() / this.totalWeight; + double w = usableSize * plot.getWeight() / totalWeight; this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, adjustedPlotArea.getHeight()); x = x + w + this.gap; } else if (orientation == PlotOrientation.HORIZONTAL) { - double h = usableSize * plot.getWeight() / this.totalWeight; + double h = usableSize * plot.getWeight() / totalWeight; this.subplotAreas[i] = new Rectangle2D.Double(x, y, adjustedPlotArea.getWidth(), h); y = y + h + this.gap; @@ -648,28 +648,20 @@ * @return <code>true</code> or <code>false</code>. */ public boolean equals(Object obj) { - if (obj == this) { return true; } - if (!(obj instanceof CombinedRangeXYPlot)) { return false; } - if (!super.equals(obj)) { + CombinedRangeXYPlot that = (CombinedRangeXYPlot) obj; + if (this.gap != that.gap) { return false; } - CombinedRangeXYPlot that = (CombinedRangeXYPlot) obj; if (!ObjectUtilities.equal(this.subplots, that.subplots)) { return false; } - if (this.totalWeight != that.totalWeight) { - return false; - } - if (this.gap != that.gap) { - return false; - } - return true; + return super.equals(obj); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-08-13 19:07:04
|
Revision: 1343 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1343&view=rev Author: mungady Date: 2008-08-13 19:06:54 +0000 (Wed, 13 Aug 2008) Log Message: ----------- 2008-08-11 David Gilbert <dav...@ob...> * source/org/jfree/chart/renderer/category/BarRenderer.java (shadowPaint): New field, (getShadowPaint): New method, (setShadowPaint): Likewise, (equals): Updated for new field, (writeObject): For serialization, (readObject): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/BarRenderer.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/category/junit/BarRendererTests.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/BarRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/BarRenderer.java 2008-08-11 15:26:45 UTC (rev 1342) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/BarRenderer.java 2008-08-13 19:06:54 UTC (rev 1343) @@ -85,6 +85,7 @@ * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); * 24-Jun-2008 : Added barPainter mechanism (DG); * 26-Jun-2008 : Added crosshair support (DG); + * 13-Aug-2008 : Added shadowPaint attribute (DG); * */ @@ -100,6 +101,9 @@ import java.awt.geom.Line2D; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; import java.io.Serializable; import org.jfree.chart.LegendItem; @@ -116,11 +120,13 @@ import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.general.DatasetUtilities; +import org.jfree.io.SerialUtilities; import org.jfree.text.TextUtilities; import org.jfree.ui.GradientPaintTransformer; import org.jfree.ui.RectangleEdge; import org.jfree.ui.StandardGradientPaintTransformer; import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; import org.jfree.util.PublicCloneable; /** @@ -235,6 +241,13 @@ private boolean shadowsVisible; /** + * The shadow paint. + * + * @since 1.0.11 + */ + private transient Paint shadowPaint; + + /** * The x-offset for the shadow effect. * * @since 1.0.11 @@ -266,6 +279,7 @@ setBaseLegendShape(new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0)); this.barPainter = getDefaultBarPainter(); this.shadowsVisible = true; + this.shadowPaint = Color.gray; this.shadowXOffset = 4.0; this.shadowYOffset = 4.0; } @@ -578,6 +592,36 @@ } /** + * Returns the shadow paint. + * + * @return The shadow paint. + * + * @see #setShadowPaint(Paint) + * + * @since 1.0.11 + */ + public Paint getShadowPaint() { + return this.shadowPaint; + } + + /** + * Sets the shadow paint and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getShadowPaint() + * + * @since 1.0.11 + */ + public void setShadowPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.shadowPaint = paint; + fireChangeEvent(); + } + /** * Returns the shadow x-offset. * * @return The shadow x-offset. @@ -1277,6 +1321,9 @@ if (this.shadowsVisible != that.shadowsVisible) { return false; } + if (!PaintUtilities.equal(this.shadowPaint, that.shadowPaint)) { + return false; + } if (this.shadowXOffset != that.shadowXOffset) { return false; } @@ -1286,4 +1333,30 @@ return super.equals(obj); } + /** + * Provides serialization support. + * + * @param stream the output stream. + * + * @throws IOException if there is an I/O error. + */ + private void writeObject(ObjectOutputStream stream) throws IOException { + stream.defaultWriteObject(); + SerialUtilities.writePaint(this.shadowPaint, stream); + } + + /** + * Provides serialization support. + * + * @param stream the input stream. + * + * @throws IOException if there is an I/O error. + * @throws ClassNotFoundException if there is a classpath problem. + */ + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + this.shadowPaint = SerialUtilities.readPaint(stream); + } + } Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/category/junit/BarRendererTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/category/junit/BarRendererTests.java 2008-08-11 15:26:45 UTC (rev 1342) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/category/junit/BarRendererTests.java 2008-08-13 19:06:54 UTC (rev 1343) @@ -173,6 +173,11 @@ r2.setShadowVisible(false); assertTrue(r1.equals(r2)); + r1.setShadowPaint(Color.red); + assertFalse(r1.equals(r2)); + r2.setShadowPaint(Color.red); + assertTrue(r1.equals(r2)); + // shadowXOffset r1.setShadowXOffset(3.3); assertFalse(r1.equals(r2)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-08-15 05:24:48
|
Revision: 1350 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1350&view=rev Author: mungady Date: 2008-08-15 05:24:46 +0000 (Fri, 15 Aug 2008) Log Message: ----------- 2008-08-15 David Gilbert <dav...@ob...> * source/org/jfree/chart/plot/Plot.java (setDrawingSupplier(DrawingSupplier, boolean)): New method. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/Plot.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 05:21:09 UTC (rev 1349) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 05:24:46 UTC (rev 1350) @@ -1,5 +1,20 @@ +2008-08-15 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/plot/Plot.java + (setDrawingSupplier(DrawingSupplier, boolean)): New method. + 2008-08-11 David Gilbert <dav...@ob...> + * source/org/jfree/chart/renderer/category/BarRenderer.java + (shadowPaint): New field, + (getShadowPaint): New method, + (setShadowPaint): Likewise, + (equals): Updated for new field, + (writeObject): For serialization, + (readObject): Likewise. + +2008-08-11 David Gilbert <dav...@ob...> + * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java (totalWeight): Removed, (CombinedDomainCategoryPlot(CategoryAxis)): Updated for removed field, Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/Plot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/Plot.java 2008-08-15 05:21:09 UTC (rev 1349) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/Plot.java 2008-08-15 05:24:46 UTC (rev 1350) @@ -121,6 +121,7 @@ * 07-Jun-2007 : Added new fillBackground() method to handle GradientPaint * taking into account orientation (DG); * 25-Mar-2008 : Added fireChangeEvent() method - see patch 1914411 (DG); + * 15-Aug-2008 : Added setDrawingSupplier() method with notify flag (DG); * */ @@ -609,10 +610,12 @@ } /** - * Sets the drawing supplier for the plot. The drawing supplier is - * responsible for supplying a limitless (possibly repeating) sequence of - * <code>Paint</code>, <code>Stroke</code> and <code>Shape</code> objects - * that the plot's renderer(s) can use to populate its (their) tables. + * Sets the drawing supplier for the plot and sends a + * {@link PlotChangeEvent} to all registered listeners. The drawing + * supplier is responsible for supplying a limitless (possibly repeating) + * sequence of <code>Paint</code>, <code>Stroke</code> and + * <code>Shape</code> objects that the plot's renderer(s) can use to + * populate its (their) tables. * * @param supplier the new supplier. * @@ -624,6 +627,28 @@ } /** + * Sets the drawing supplier for the plot and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. The drawing + * supplier is responsible for supplying a limitless (possibly repeating) + * sequence of <code>Paint</code>, <code>Stroke</code> and + * <code>Shape</code> objects that the plot's renderer(s) can use to + * populate its (their) tables. + * + * @param supplier the new supplier. + * @param notify notify listeners? + * + * @see #getDrawingSupplier() + * + * @since 1.0.11 + */ + public void setDrawingSupplier(DrawingSupplier supplier, boolean notify) { + this.drawingSupplier = supplier; + if (notify) { + fireChangeEvent(); + } + } + + /** * Returns the background image that is used to fill the plot's background * area. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-08-15 05:29:56
|
Revision: 1353 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1353&view=rev Author: mungady Date: 2008-08-15 05:29:54 +0000 (Fri, 15 Aug 2008) Log Message: ----------- 2008-08-15 David Gilbert <dav...@ob...> * source/org/jfree/chart/title/LegendTitle.java (getWrapper): New method. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/title/LegendTitle.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 05:27:48 UTC (rev 1352) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 05:29:54 UTC (rev 1353) @@ -1,5 +1,10 @@ 2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/title/LegendTitle.java + (getWrapper): New method. + +2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/plot/Plot.java (setDrawingSupplier(DrawingSupplier, boolean)): New method. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/title/LegendTitle.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/title/LegendTitle.java 2008-08-15 05:27:48 UTC (rev 1352) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/title/LegendTitle.java 2008-08-15 05:29:54 UTC (rev 1353) @@ -53,6 +53,7 @@ * 13-Dec-2006 : Added support for GradientPaint in legend items (DG); * 16-Mar-2007 : Updated border drawing for changes in AbstractBlock (DG); * 18-May-2007 : Pass seriesKey and dataset to legend item block (DG); + * 15-Aug-2008 : Added getWrapper() method (DG); * */ @@ -537,6 +538,17 @@ } /** + * Returns the wrapper container, if any. + * + * @return The wrapper container (possibly <code>null</code>). + * + * @since 1.0.11 + */ + public BlockContainer getWrapper() { + return this.wrapper; + } + + /** * Sets the wrapper container for the legend. * * @param wrapper the wrapper container. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-08-15 05:39:33
|
Revision: 1356 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1356&view=rev Author: mungady Date: 2008-08-15 05:39:27 +0000 (Fri, 15 Aug 2008) Log Message: ----------- 2008-08-15 David Gilbert <dav...@ob...> * source/org/jfree/chart/plot/CategoryPlot.java (getRendererCount): New method, * source/org/jfree/chart/plot/XYPlot.java (getRendererCount): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CategoryPlot.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 05:35:08 UTC (rev 1355) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 05:39:27 UTC (rev 1356) @@ -1,5 +1,12 @@ 2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/plot/CategoryPlot.java + (getRendererCount): New method, + * source/org/jfree/chart/plot/XYPlot.java + (getRendererCount): Likewise. + +2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/title/LegendTitle.java (getWrapper): New method. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CategoryPlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CategoryPlot.java 2008-08-15 05:35:08 UTC (rev 1355) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/CategoryPlot.java 2008-08-15 05:39:27 UTC (rev 1356) @@ -160,6 +160,7 @@ * 23-Apr-2008 : Fixed equals() and clone() methods (DG); * 26-Jun-2008 : Fixed crosshair support (DG); * 10-Jul-2008 : Fixed outline visibility for 3D renderers (DG); + * 12-Aug-2008 : Added rendererCount() method (DG); * */ @@ -1365,6 +1366,17 @@ } /** + * Returns the number of renderer slots for this plot. + * + * @return The number of renderer slots. + * + * @since 1.0.11 + */ + public int getRendererCount() { + return this.renderers.size(); + } + + /** * Returns a reference to the renderer for the plot. * * @return The renderer. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java 2008-08-15 05:35:08 UTC (rev 1355) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java 2008-08-15 05:39:27 UTC (rev 1356) @@ -205,6 +205,7 @@ * 09-Jul-2008 : Added renderer state notification when series pass begins * and ends - see patch 1997549 by Ulrich Voigt (DG); * 25-Jul-2008 : Fixed NullPointerException for plots with no axes (DG); + * 15-Aug-2008 : Added getRendererCount() method (DG); * */ @@ -1379,6 +1380,17 @@ } /** + * Returns the number of renderer slots for this plot. + * + * @return The number of renderer slots. + * + * @since 1.0.11 + */ + public int getRendererCount() { + return this.renderers.size(); + } + + /** * Returns the renderer for the primary dataset. * * @return The item renderer (possibly <code>null</code>). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-08-15 08:00:39
|
Revision: 1360 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1360&view=rev Author: mungady Date: 2008-08-15 08:00:37 +0000 (Fri, 15 Aug 2008) Log Message: ----------- 2008-08-15 David Gilbert <dav...@ob...> * source/org/jfree/chart/axis/SymbolAxis.java (drawGridBandsHorizontal): Use gridBandAlternatePaint, (drawGridBandsVertical): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/SymbolAxis.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 05:45:56 UTC (rev 1359) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 08:00:37 UTC (rev 1360) @@ -1,5 +1,11 @@ 2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/axis/SymbolAxis.java + (drawGridBandsHorizontal): Use gridBandAlternatePaint, + (drawGridBandsVertical): Likewise. + +2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/plot/CategoryPlot.java (getRendererCount): New method, * source/org/jfree/chart/plot/XYPlot.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 2008-08-15 05:45:56 UTC (rev 1359) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/SymbolAxis.java 2008-08-15 08:00:37 UTC (rev 1360) @@ -74,6 +74,7 @@ * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 28-Feb-2007 : Fixed bug 1669302 (tick label overlap) (DG); * 25-Jul-2007 : Added new field for alternate grid band paint (DG); + * 15-Aug-2008 : Use alternate grid band paint when drawing (DG); * */ @@ -385,7 +386,7 @@ g2.setPaint(this.gridBandPaint); } else { - g2.setPaint(Color.white); + g2.setPaint(this.gridBandAlternatePaint); } band = new Rectangle2D.Double(xx1, yy + outlineStrokeWidth, xx2 - xx1, dataArea.getMaxY() - yy - outlineStrokeWidth); @@ -442,7 +443,7 @@ g2.setPaint(this.gridBandPaint); } else { - g2.setPaint(Color.white); + g2.setPaint(this.gridBandAlternatePaint); } band = new Rectangle2D.Double(xx + outlineStrokeWidth, yy1, plotArea.getMaxX() - xx - outlineStrokeWidth, yy2 - yy1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-08-15 08:06:07
|
Revision: 1362 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1362&view=rev Author: mungady Date: 2008-08-15 08:06:01 +0000 (Fri, 15 Aug 2008) Log Message: ----------- 2008-08-15 David Gilbert <dav...@ob...> * source/org/jfree/chart/plot/PiePlot.java (clearSectionPaints): New method, (clearSectionOutlinePaints): Likewise, (clearSectionOutlineStrokes): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 08:02:22 UTC (rev 1361) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 08:06:01 UTC (rev 1362) @@ -1,5 +1,12 @@ 2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/plot/PiePlot.java + (clearSectionPaints): New method, + (clearSectionOutlinePaints): Likewise, + (clearSectionOutlineStrokes): Likewise. + +2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/axis/SymbolAxis.java (drawGridBandsHorizontal): Use gridBandAlternatePaint, (drawGridBandsVertical): Likewise. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java 2008-08-15 08:02:22 UTC (rev 1361) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java 2008-08-15 08:06:01 UTC (rev 1362) @@ -154,6 +154,7 @@ * 31-Mar-2008 : Added quad and cubic curve label link lines - see patch * 1891849 by Martin Hilpert (DG); * 02-Jul-2008 : Added autoPopulate flags (DG); + * 15-Aug-2008 : Added methods to clear section attributes (DG); * */ @@ -1004,6 +1005,25 @@ } /** + * Clears the section paint settings for this plot and, if requested, sends + * a {@link PlotChangeEvent} to all registered listeners. Be aware that + * if the <code>autoPopulateSectionPaint</code> flag is set, the section + * paints may be repopulated using the same colours as before. + * + * @param notify notify listeners? + * + * @since 1.0.11 + * + * @see #autoPopulateSectionPaint + */ + public void clearSectionPaints(boolean notify) { + this.sectionPaintMap.clear(); + if (notify) { + fireChangeEvent(); + } + } + + /** * Returns the base section paint. This is used when no other paint is * defined, which is rare. The default value is <code>Color.gray</code>. * @@ -1201,6 +1221,25 @@ } /** + * Clears the section outline paint settings for this plot and, if + * requested, sends a {@link PlotChangeEvent} to all registered listeners. + * Be aware that if the <code>autoPopulateSectionPaint</code> flag is set, + * the section paints may be repopulated using the same colours as before. + * + * @param notify notify listeners? + * + * @since 1.0.11 + * + * @see #autoPopulateSectionOutlinePaint + */ + public void clearSectionOutlinePaints(boolean notify) { + this.sectionOutlinePaintMap.clear(); + if (notify) { + fireChangeEvent(); + } + } + + /** * Returns the base section paint. This is used when no other paint is * available. * @@ -1371,6 +1410,25 @@ } /** + * Clears the section outline stroke settings for this plot and, if + * requested, sends a {@link PlotChangeEvent} to all registered listeners. + * Be aware that if the <code>autoPopulateSectionPaint</code> flag is set, + * the section paints may be repopulated using the same colours as before. + * + * @param notify notify listeners? + * + * @since 1.0.11 + * + * @see #autoPopulateSectionOutlineStroke + */ + public void clearSectionOutlineStrokes(boolean notify) { + this.sectionOutlineStrokeMap.clear(); + if (notify) { + fireChangeEvent(); + } + } + + /** * Returns the base section stroke. This is used when no other stroke is * available. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-08-15 08:20:31
|
Revision: 1365 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1365&view=rev Author: mungady Date: 2008-08-15 08:20:27 +0000 (Fri, 15 Aug 2008) Log Message: ----------- 2008-08-15 David Gilbert <dav...@ob...> * source/org/jfree/chart/renderer/AbstractRenderer.java (clearSeriesPaints): New method, (clearSeriesStrokes): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/AbstractRenderer.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 08:17:12 UTC (rev 1364) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 08:20:27 UTC (rev 1365) @@ -1,5 +1,11 @@ 2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/renderer/AbstractRenderer.java + (clearSeriesPaints): New method, + (clearSeriesStrokes): Likewise. + +2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/plot/PiePlot.java (clearSectionPaints): New method, (clearSectionOutlinePaints): Likewise, Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/AbstractRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/AbstractRenderer.java 2008-08-15 08:17:12 UTC (rev 1364) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/AbstractRenderer.java 2008-08-15 08:20:27 UTC (rev 1365) @@ -79,9 +79,9 @@ * methods (DG); * 04-Dec-2007 : Modified hashCode() implementation (DG); * 29-Apr-2008 : Minor API doc update (DG); - * 17-Jun-2008 : Added legendShape, legendTextFont and legendTextPaint + * 17-Jun-2008 : Added legendShape, legendTextFont and legendTextPaint * attributes (DG); - * + * 18-Aug-2008 : Added clearSeriesPaints() and clearSeriesStrokes() (DG); */ package org.jfree.chart.renderer; @@ -505,7 +505,7 @@ this.stroke = null; this.strokeList = new StrokeList(); this.baseStroke = DEFAULT_STROKE; - this.autoPopulateSeriesStroke = false; + this.autoPopulateSeriesStroke = true; this.outlineStroke = null; this.outlineStrokeList = new StrokeList(); @@ -1039,6 +1039,21 @@ } /** + * Clears the series paint settings for this renderer and, if requested, + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param notify notify listeners? + * + * @since 1.0.11 + */ + public void clearSeriesPaints(boolean notify) { + this.paintList.clear(); + if (notify) { + fireChangeEvent(); + } + } + + /** * Returns the base paint. * * @return The base paint (never <code>null</code>). @@ -1625,6 +1640,21 @@ } /** + * Clears the series stroke settings for this renderer and, if requested, + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param notify notify listeners? + * + * @since 1.0.11 + */ + public void clearSeriesStrokes(boolean notify) { + this.strokeList.clear(); + if (notify) { + fireChangeEvent(); + } + } + + /** * Returns the base stroke. * * @return The base stroke (never <code>null</code>). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-08-15 08:35:43
|
Revision: 1367 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1367&view=rev Author: mungady Date: 2008-08-15 08:35:40 +0000 (Fri, 15 Aug 2008) Log Message: ----------- 2008-08-15 David Gilbert <dav...@ob...> * source/org/jfree/chart/renderer/category/GradientBarPainter.java (paintBar): Use outline paint, (paintBarShadow): Use shadow paint, * source/org/jfree/chart/renderer/category/StandardBarPainter.java (paintBarShadow): Use shadow paint. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/GradientBarPainter.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/StandardBarPainter.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 08:26:10 UTC (rev 1366) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 08:35:40 UTC (rev 1367) @@ -1,5 +1,13 @@ 2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/renderer/category/GradientBarPainter.java + (paintBar): Use outline paint, + (paintBarShadow): Use shadow paint, + * source/org/jfree/chart/renderer/category/StandardBarPainter.java + (paintBarShadow): Use shadow paint. + +2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/renderer/AbstractRenderer.java (clearSeriesPaints): New method, (clearSeriesStrokes): Likewise. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/GradientBarPainter.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/GradientBarPainter.java 2008-08-15 08:26:10 UTC (rev 1366) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/GradientBarPainter.java 2008-08-15 08:35:40 UTC (rev 1367) @@ -35,6 +35,7 @@ * Changes: * -------- * 19-Jun-2008 : Version 1 (DG); + * 15-Aug-2008 : Use outline paint and shadow paint (DG); * */ @@ -179,8 +180,7 @@ if (renderer.isDrawBarOutline() /*&& state.getBarWidth() > renderer.BAR_OUTLINE_WIDTH_THRESHOLD*/) { Stroke stroke = renderer.getItemOutlineStroke(row, column); - - Paint paint = renderer.getItemPaint(row, column); + Paint paint = renderer.getItemOutlinePaint(row, column); if (stroke != null && paint != null) { g2.setStroke(stroke); g2.setPaint(paint); @@ -218,7 +218,7 @@ RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(), renderer.getShadowYOffset(), base, pegShadow); - g2.setPaint(Color.gray); + g2.setPaint(renderer.getShadowPaint()); g2.fill(shadow); } Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/StandardBarPainter.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/StandardBarPainter.java 2008-08-15 08:26:10 UTC (rev 1366) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/StandardBarPainter.java 2008-08-15 08:35:40 UTC (rev 1367) @@ -35,6 +35,7 @@ * Changes: * -------- * 19-Jun-2008 : Version 1 (DG); + * 15-Aug-2008 : Use renderer's shadow paint (DG); * */ @@ -133,7 +134,7 @@ RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(), renderer.getShadowYOffset(), base, pegShadow); - g2.setPaint(Color.gray); + g2.setPaint(renderer.getShadowPaint()); g2.fill(shadow); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-08-15 08:41:55
|
Revision: 1369 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1369&view=rev Author: mungady Date: 2008-08-15 08:41:52 +0000 (Fri, 15 Aug 2008) Log Message: ----------- 2008-08-15 David Gilbert <dav...@ob...> * source/org/jfree/chart/ChartPanel.java (DEFAULT_MAXIMUM_DRAW_WIDTH): Increased to 1024, (DEFAULT_MAXIMUM_DRAW_HEIGHT): Increased to 768. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartPanel.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 08:37:42 UTC (rev 1368) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 08:41:52 UTC (rev 1369) @@ -1,5 +1,11 @@ 2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/ChartPanel.java + (DEFAULT_MAXIMUM_DRAW_WIDTH): Increased to 1024, + (DEFAULT_MAXIMUM_DRAW_HEIGHT): Increased to 768. + +2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/renderer/category/GradientBarPainter.java (paintBar): Use outline paint, (paintBarShadow): Use shadow paint, Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartPanel.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartPanel.java 2008-08-15 08:37:42 UTC (rev 1368) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartPanel.java 2008-08-15 08:41:52 UTC (rev 1369) @@ -139,6 +139,7 @@ * 07-May-2008 : Fixed bug in zooming that triggered zoom for a rectangle * outside of the data area (DG); * 08-May-2008 : Fixed serialization bug (DG); + * 15-Aug-2008 : Increased default maxDrawWidth/Height (DG); * */ @@ -227,10 +228,10 @@ public static final int DEFAULT_MINIMUM_DRAW_HEIGHT = 200; /** The default limit below which chart scaling kicks in. */ - public static final int DEFAULT_MAXIMUM_DRAW_WIDTH = 800; + public static final int DEFAULT_MAXIMUM_DRAW_WIDTH = 1024; /** The default limit below which chart scaling kicks in. */ - public static final int DEFAULT_MAXIMUM_DRAW_HEIGHT = 600; + public static final int DEFAULT_MAXIMUM_DRAW_HEIGHT = 768; /** The minimum size required to perform a zoom on a rectangle */ public static final int DEFAULT_ZOOM_TRIGGER_DISTANCE = 10; @@ -2527,8 +2528,8 @@ } - /* (non-Javadoc) - * @see javax.swing.JPanel#updateUI() + /** + * Updates the UI for a LookAndFeel change. */ public void updateUI() { // here we need to update the UI for the popup menu, if the panel This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-08-15 08:55:56
|
Revision: 1371 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1371&view=rev Author: mungady Date: 2008-08-15 08:55:53 +0000 (Fri, 15 Aug 2008) Log Message: ----------- 2008-08-15 David Gilbert <dav...@ob...> * source/org/jfree/chart/ChartFactory.java: (currentTheme): New field, (getChartTheme): New method, (setChartTheme): Likewise, ...and applied current theme in all chart creation methods, * source/org/jfree/chart/ChartTheme.java: New file, * source/org/jfree/chart/ChartUtilities.java (applyCurrentTheme): New method, * source/org/jfree/chart/StandardChartTheme.java: New file. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartFactory.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartUtilities.java Added Paths: ----------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartTheme.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/StandardChartTheme.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 08:48:07 UTC (rev 1370) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 08:55:53 UTC (rev 1371) @@ -1,5 +1,17 @@ 2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/ChartFactory.java: + (currentTheme): New field, + (getChartTheme): New method, + (setChartTheme): Likewise, + ...and applied current theme in all chart creation methods, + * source/org/jfree/chart/ChartTheme.java: New file, + * source/org/jfree/chart/ChartUtilities.java + (applyCurrentTheme): New method, + * source/org/jfree/chart/StandardChartTheme.java: New file. + +2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/ChartPanel.java (DEFAULT_MAXIMUM_DRAW_WIDTH): Increased to 1024, (DEFAULT_MAXIMUM_DRAW_HEIGHT): Increased to 768. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartFactory.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartFactory.java 2008-08-15 08:48:07 UTC (rev 1370) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartFactory.java 2008-08-15 08:55:53 UTC (rev 1371) @@ -115,6 +115,7 @@ * submitted by Darren Jung (DG); * 10-Jul-2007 : Added new methods to create pie charts with locale for * section label and tool tip formatting (DG); + * 14-Aug-2008 : Added ChartTheme facility (DG); * */ @@ -217,6 +218,40 @@ */ public abstract class ChartFactory { + /** The chart theme. */ + private static ChartTheme currentTheme = new StandardChartTheme("JFree"); + + /** + * Returns the current chart theme used by the factory. + * + * @return The chart theme. + * + * @see #setChartTheme(ChartTheme) + * @see ChartUtilities#applyCurrentTheme(JFreeChart) + * + * @since 1.0.11 + */ + public static ChartTheme getChartTheme() { + return currentTheme; + } + + /** + * Sets the current chart theme. This will be applied to all new charts + * as they are created. + * + * @param theme the theme (<code>null</code> not permitted). + * + * @see #getChartTheme() + * + * @since 1.0.11 + */ + public static void setChartTheme(ChartTheme theme) { + if (theme == null) { + throw new IllegalArgumentException("Null 'theme' argument."); + } + currentTheme = theme; + } + /** * Creates a pie chart with default settings. * <P> @@ -242,8 +277,10 @@ if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); } - return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, - legend); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; } @@ -276,9 +313,10 @@ if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } - return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, - legend); - + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; } /** @@ -396,7 +434,7 @@ new Font("SansSerif", Font.PLAIN, 10)); chart.addSubtitle(subtitle); } - + currentTheme.apply(chart); return chart; } @@ -522,7 +560,7 @@ new Font("SansSerif", Font.PLAIN, 10)); chart.addSubtitle(subtitle); } - + currentTheme.apply(chart); return chart; } @@ -551,9 +589,10 @@ if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); } - return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, - legend); - + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; } /** @@ -585,8 +624,10 @@ if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } - return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, - legend); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; } @@ -635,7 +676,7 @@ JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -663,8 +704,10 @@ if (tooltips) { plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); } - return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, - legend); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; } @@ -695,8 +738,10 @@ if (urls) { plot.setURLGenerator(new StandardPieURLGenerator()); } - return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, - legend); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; } @@ -754,7 +799,7 @@ JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -825,7 +870,7 @@ plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -882,7 +927,7 @@ plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -945,7 +990,7 @@ JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -1010,7 +1055,7 @@ // create the chart... JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -1067,7 +1112,7 @@ plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -1123,7 +1168,7 @@ plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -1177,7 +1222,7 @@ plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -1231,7 +1276,7 @@ plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -1282,7 +1327,7 @@ plot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -1358,7 +1403,7 @@ plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -1393,6 +1438,7 @@ plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart( title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); + currentTheme.apply(chart); return chart; } @@ -1447,6 +1493,7 @@ JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); + currentTheme.apply(chart); return chart; } @@ -1516,7 +1563,7 @@ JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -1570,12 +1617,11 @@ urlGenerator = new StandardXYURLGenerator(); } - plot.setRenderer( - new XYAreaRenderer(XYAreaRenderer.AREA, tipGenerator, urlGenerator) - ); + plot.setRenderer(new XYAreaRenderer(XYAreaRenderer.AREA, tipGenerator, + urlGenerator)); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -1634,6 +1680,7 @@ JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); + currentTheme.apply(chart); return chart; } @@ -1681,7 +1728,7 @@ JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -1736,6 +1783,7 @@ plot.setRangeCrosshairVisible(false); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); + currentTheme.apply(chart); return chart; } @@ -1791,6 +1839,7 @@ plot.setRangeCrosshairVisible(false); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); + currentTheme.apply(chart); return chart; } @@ -1849,6 +1898,7 @@ JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); + currentTheme.apply(chart); return chart; } @@ -1878,6 +1928,7 @@ plot.setRenderer(new CandlestickRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); + currentTheme.apply(chart); return chart; } @@ -1908,6 +1959,7 @@ XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); + currentTheme.apply(chart); return chart; } @@ -1945,6 +1997,7 @@ XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); + currentTheme.apply(chart); return chart; } @@ -1999,7 +2052,7 @@ JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -2049,6 +2102,7 @@ plot.setOrientation(orientation); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); + currentTheme.apply(chart); return chart; } @@ -2082,8 +2136,10 @@ CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); - return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, - legend); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; } /** @@ -2110,8 +2166,10 @@ valueAxis.setAutoRangeIncludesZero(false); XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); - return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, - legend); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; } @@ -2151,7 +2209,7 @@ XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } @@ -2185,7 +2243,7 @@ JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); - + currentTheme.apply(chart); return chart; } Added: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartTheme.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartTheme.java (rev 0) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartTheme.java 2008-08-15 08:55:53 UTC (rev 1371) @@ -0,0 +1,63 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2008, 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * --------------- + * ChartTheme.java + * --------------- + * (C) Copyright 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 14-Aug-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import org.jfree.chart.JFreeChart; + +/** + * A {@link ChartTheme} a class that can apply a style or 'theme' to a chart. + * It can be implemented in an arbitrary manner, with the styling applied to + * the chart via the <code>apply(JFreeChart)</code> method. We provide one + * implementation ({@link StandardChartTheme}) that just mimics the manual + * process of calling methods to set various chart parameters. + * + * @since 1.0.11 + */ +public interface ChartTheme { + + /** + * Applies this theme to the supplied chart. + * + * @param chart the chart (<code>null</code> not permitted). + */ + public void apply(JFreeChart chart); + +} Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartUtilities.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartUtilities.java 2008-08-15 08:48:07 UTC (rev 1370) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartUtilities.java 2008-08-15 08:55:53 UTC (rev 1371) @@ -106,6 +106,19 @@ */ public abstract class ChartUtilities { + /** + * Applies the current theme to the specified chart. This method is + * provided for convenience, the theme itself is stored in the + * {@link ChartFactory} class. + * + * @param chart the chart (<code>null</code> not permitted). + * + * @since 1.0.11 + */ + public static void applyCurrentTheme(JFreeChart chart) { + ChartFactory.getChartTheme().apply(chart); + } + /** * Writes a chart to an output stream in PNG format. * Added: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/StandardChartTheme.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/StandardChartTheme.java (rev 0) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/StandardChartTheme.java 2008-08-15 08:55:53 UTC (rev 1371) @@ -0,0 +1,1735 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2008, 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * ----------------------- + * StandardChartTheme.java + * ----------------------- + * (C) Copyright 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 14-Aug-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.Paint; +import java.awt.Stroke; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.PeriodAxis; +import org.jfree.chart.axis.PeriodAxisLabelInfo; +import org.jfree.chart.axis.SymbolAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.block.Block; +import org.jfree.chart.block.BlockContainer; +import org.jfree.chart.block.LabelBlock; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.CombinedDomainCategoryPlot; +import org.jfree.chart.plot.CombinedDomainXYPlot; +import org.jfree.chart.plot.CombinedRangeCategoryPlot; +import org.jfree.chart.plot.CombinedRangeXYPlot; +import org.jfree.chart.plot.DefaultDrawingSupplier; +import org.jfree.chart.plot.DrawingSupplier; +import org.jfree.chart.plot.FastScatterPlot; +import org.jfree.chart.plot.MeterPlot; +import org.jfree.chart.plot.MultiplePiePlot; +import org.jfree.chart.plot.PieLabelLinkStyle; +import org.jfree.chart.plot.PiePlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PolarPlot; +import org.jfree.chart.plot.SpiderWebPlot; +import org.jfree.chart.plot.ThermometerPlot; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.AbstractRenderer; +import org.jfree.chart.renderer.category.BarPainter; +import org.jfree.chart.renderer.category.BarRenderer; +import org.jfree.chart.renderer.category.BarRenderer3D; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.renderer.category.GradientBarPainter; +import org.jfree.chart.renderer.category.LineRenderer3D; +import org.jfree.chart.renderer.category.MinMaxCategoryRenderer; +import org.jfree.chart.renderer.category.StatisticalBarRenderer; +import org.jfree.chart.renderer.xy.GradientXYBarPainter; +import org.jfree.chart.renderer.xy.XYBarPainter; +import org.jfree.chart.renderer.xy.XYBarRenderer; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.chart.title.CompositeTitle; +import org.jfree.chart.title.LegendTitle; +import org.jfree.chart.title.PaintScaleLegend; +import org.jfree.chart.title.TextTitle; +import org.jfree.chart.title.Title; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A default implementation of the {@link ChartTheme} interface. This + * implementation just collects a whole bunch of chart attributes and mimics + * the manual process of applying each attribute to the right sub-object + * within the JFreeChart instance. It's not elegant code, but it works. + * + * @since 1.0.11 + */ +public class StandardChartTheme implements ChartTheme, Cloneable, + PublicCloneable, Serializable { + + /** The name of this theme. */ + private String name; + + /** + * The largest font size. Use for the main chart title. + */ + private Font extraLargeFont; + + /** + * A large font. Used for subtitles. + */ + private Font largeFont; + + /** + * The regular font size. Used for axis tick labels, legend items etc. + */ + private Font regularFont; + + /** The paint used to display the main chart title. */ + private transient Paint titlePaint; + + /** The paint used to display subtitles. */ + private transient Paint subtitlePaint; + + /** The background paint for the chart. */ + private transient Paint chartBackgroundPaint; + + /** The legend background paint. */ + private transient Paint legendBackgroundPaint; + + /** The legend item paint. */ + private transient Paint legendItemPaint; + + /** The drawing supplier. */ + private DrawingSupplier drawingSupplier; + + /** The background paint for the plot. */ + private transient Paint plotBackgroundPaint; + + /** The plot outline paint. */ + private transient Paint plotOutlinePaint; + + /** The label link style for pie charts. */ + private PieLabelLinkStyle labelLinkStyle; + + /** The label link paint for pie charts. */ + private transient Paint labelLinkPaint; + + /** The domain grid line paint. */ + private transient Paint domainGridlinePaint; + + /** The range grid line paint. */ + private transient Paint rangeGridlinePaint; + + /** The axis offsets. */ + private RectangleInsets axisOffset; + + /** The axis label paint. */ + private transient Paint axisLabelPaint; + + /** The tick label paint. */ + private transient Paint tickLabelPaint; + + /** The item label paint. */ + private transient Paint itemLabelPaint; + + /** + * A flag that controls whether or not shadows are visible (for example, + * in a bar renderer). + */ + private boolean shadowVisible; + + /** The shadow paint. */ + private transient Paint shadowPaint; + + /** The bar painter. */ + private BarPainter barPainter; + + /** The XY bar painter. */ + private XYBarPainter xyBarPainter; + + /** The thermometer paint. */ + private transient Paint thermometerPaint; + + /** + * The paint used to fill the interior of the 'walls' in the background + * of a plot with a 3D effect. Applied to BarRenderer3D. + */ + private transient Paint wallPaint; + + /** The error indicator paint for the {@link StatisticalBarRenderer}. */ + private transient Paint errorIndicatorPaint; + + /** The grid band paint for a {@link SymbolAxis}. */ + private transient Paint gridBandPaint = SymbolAxis.DEFAULT_GRID_BAND_PAINT; + + /** The grid band alternate paint for a {@link SymbolAxis}. */ + private transient Paint gridBandAlternatePaint + = SymbolAxis.DEFAULT_GRID_BAND_ALTERNATE_PAINT; + + /** + * Creates and returns the default 'JFree' chart theme. + * + * @return A chart theme. + */ + public static ChartTheme createJFreeTheme() { + return new StandardChartTheme("JFree"); + } + + /** + * Creates and returns a theme called "Darkness". In this theme, the + * charts have a black background. + * + * @return The "Darkness" theme. + */ + public static ChartTheme createDarknessTheme() { + StandardChartTheme theme = new StandardChartTheme("Darkness"); + theme.titlePaint = Color.white; + theme.subtitlePaint = Color.white; + theme.legendBackgroundPaint = Color.black; + theme.legendItemPaint = Color.white; + theme.chartBackgroundPaint = Color.black; + theme.plotBackgroundPaint = Color.black; + theme.plotOutlinePaint = Color.yellow; + theme.labelLinkPaint = Color.lightGray; + theme.tickLabelPaint = Color.white; + theme.axisLabelPaint = Color.white; + theme.shadowPaint = Color.darkGray; + theme.itemLabelPaint = Color.white; + theme.drawingSupplier = new DefaultDrawingSupplier( + new Paint[] { Color.decode("0xFFFF00"), + Color.decode("0x0036CC"), Color.decode("0xFF0000"), + Color.decode("0xFFFF7F"), Color.decode("0x6681CC"), + Color.decode("0xFF7F7F"), Color.decode("0xFFFFBF"), + Color.decode("0x99A6CC"), Color.decode("0xFFBFBF"), + Color.decode("0xA9A938"), Color.decode("0x2D4587")}, + new Paint[] { Color.decode("0xFFFF00"), + Color.decode("0x0036CC")}, + new Stroke[] { new BasicStroke(2.0f)}, + new Stroke[] { new BasicStroke(0.5f)}, + DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); + theme.wallPaint = Color.darkGray; + theme.errorIndicatorPaint = Color.lightGray; + theme.gridBandPaint = new Color(255, 255, 255, 20); + theme.gridBandAlternatePaint = new Color(255, 255, 255, 40); + return theme; + } + /** + * Creates and returns a {@link ChartTheme} that doesn't apply any changes + * to the JFreeChart defaults. This produces the "legacy" look for + * JFreeChart. + * + * @return A legacy theme. + */ + public static ChartTheme createLegacyTheme() { + StandardChartTheme theme = new StandardChartTheme("Legacy") { + public void apply(JFreeChart chart) { + // do nothing at all + } + }; + return theme; + } + + /** + * Creates a new default instance. + * + * @param name the name of the theme (<code>null</code> not permitted). + */ + public StandardChartTheme(String name) { + if (name == null) { + throw new IllegalArgumentException("Null 'name' argument."); + } + this.name = name; + this.extraLargeFont = new Font("Tahoma", Font.BOLD, 20); + this.largeFont = new Font("Tahoma", Font.BOLD, 14); + this.regularFont = new Font("Tahoma", Font.PLAIN, 12); + + this.titlePaint = Color.black; + this.subtitlePaint = Color.black; + this.legendBackgroundPaint = Color.white; + this.legendItemPaint = Color.darkGray; + this.chartBackgroundPaint = Color.white; + this.drawingSupplier = new DefaultDrawingSupplier(); + this.plotBackgroundPaint = Color.lightGray; + this.plotOutlinePaint = Color.black; + this.labelLinkPaint = Color.black; + this.labelLinkStyle = PieLabelLinkStyle.CUBIC_CURVE; + this.axisOffset = new RectangleInsets(4, 4, 4, 4); + this.domainGridlinePaint = Color.white; + this.rangeGridlinePaint = Color.white; + this.axisLabelPaint = Color.darkGray; + this.tickLabelPaint = Color.darkGray; + this.barPainter = new GradientBarPainter(); + this.xyBarPainter = new GradientXYBarPainter(); + this.shadowVisible = true; + this.shadowPaint = Color.gray; + this.itemLabelPaint = Color.black; + this.thermometerPaint = Color.white; + this.wallPaint = BarRenderer3D.DEFAULT_WALL_PAINT; + this.errorIndicatorPaint = Color.black; + } + + /** + * Returns the largest font for this theme. + * + * @return The largest font for this theme. + * + * @see #setExtraLargeFont(Font) + */ + public Font getExtraLargeFont() { + return this.extraLargeFont; + } + + /** + * Sets the largest font for this theme. + * + * @param font the font (<code>null</code> not permitted). + * + * @see #getExtraLargeFont() + */ + public void setExtraLargeFont(Font font) { + if (font == null) { + throw new IllegalArgumentException("Null 'font' argument."); + } + this.extraLargeFont = font; + } + + /** + * Returns the large font for this theme. + * + * @return The large font (never <code>null</code>). + * + * @see #setLargeFont(Font) + */ + public Font getLargeFont() { + return this.largeFont; + } + + /** + * Sets the large font for this theme. + * + * @param font the font (<code>null</code> not permitted). + * + * @see #getLargeFont() + */ + public void setLargeFont(Font font) { + this.largeFont = font; + } + + /** + * Returns the regular font. + * + * @return The regular font (never <code>null</code>). + * + * @see #setRegularFont(Font) + */ + public Font getRegularFont() { + return this.regularFont; + } + + /** + * Sets the regular font for this theme. + * + * @param font the font (<code>null</code> not permitted). + * + * @see #getRegularFont() + */ + public void setRegularFont(Font font) { + this.regularFont = font; + } + + /** + * Returns the title paint. + * + * @return The title paint (never <code>null</code>). + * + * @see #setTitlePaint(Paint) + */ + public Paint getTitlePaint() { + return this.titlePaint; + } + + /** + * Sets the title paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getTitlePaint() + */ + public void setTitlePaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.titlePaint = paint; + } + + /** + * Returns the subtitle paint. + * + * @return The subtitle paint (never <code>null</code>). + * + * @see #setSubtitlePaint(Paint) + */ + public Paint getSubtitlePaint() { + return this.subtitlePaint; + } + + /** + * Sets the subtitle paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getSubtitlePaint() + */ + public void setSubtitlePaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.subtitlePaint = paint; + } + + /** + * Returns the chart background paint. + * + * @return The chart background paint (never <code>null</code>). + * + * @see #setChartBackgroundPaint(Paint) + */ + public Paint getChartBackgroundPaint() { + return this.chartBackgroundPaint; + } + + /** + * Sets the chart background paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getChartBackgroundPaint() + */ + public void setChartBackgroundPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.chartBackgroundPaint = paint; + } + + /** + * Returns the legend background paint. + * + * @return The legend background paint (never <code>null</code>). + * + * @see #setLegendBackgroundPaint(Paint) + */ + public Paint getLegendBackgroundPaint() { + return this.legendBackgroundPaint; + } + + /** + * Sets the legend background paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getLegendBackgroundPaint() + */ + public void setLegendBackgroundPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.legendBackgroundPaint = paint; + } + + /** + * Returns the legend item paint. + * + * @return The legend item paint (never <code>null</code>). + * + * @see #setLegendItemPaint(Paint) + */ + public Paint getLegendItemPaint() { + return this.legendItemPaint; + } + + /** + * Sets the legend item paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getLegendItemPaint() + */ + public void setLegendItemPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.legendItemPaint = paint; + } + + /** + * Returns the plot background paint. + * + * @return The plot background paint (never <code>null</code>). + * + * @see #setPlotBackgroundPaint(Paint) + */ + public Paint getPlotBackgroundPaint() { + return this.plotBackgroundPaint; + } + + /** + * Sets the plot background paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getPlotBackgroundPaint() + */ + public void setPlotBackgroundPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.plotBackgroundPaint = paint; + } + + /** + * Returns the plot outline paint. + * + * @return The plot outline paint (never <code>null</code>). + * + * @see #setPlotOutlinePaint(Paint) + */ + public Paint getPlotOutlinePaint() { + return this.plotOutlinePaint; + } + + /** + * Sets the plot outline paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getPlotOutlinePaint() + */ + public void setPlotOutlinePaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.plotOutlinePaint = paint; + } + + /** + * Returns the label link style for pie charts. + * + * @return The label link style (never <code>null</code>). + * + * @see #setLabelLinkStyle(PieLabelLinkStyle) + */ + public PieLabelLinkStyle getLabelLinkStyle() { + return this.labelLinkStyle; + } + + /** + * Sets the label link style for pie charts. + * + * @param style the style (<code>null</code> not permitted). + * + * @see #getLabelLinkStyle() + */ + public void setLabelLinkStyle(PieLabelLinkStyle style) { + if (style == null) { + throw new IllegalArgumentException("Null 'style' argument."); + } + this.labelLinkStyle = style; + } + + /** + * Returns the label link paint for pie charts. + * + * @return The label link paint (never <code>null</code>). + * + * @see #setLabelLinkPaint(Paint) + */ + public Paint getLabelLinkPaint() { + return this.labelLinkPaint; + } + + /** + * Sets the label link paint for pie charts. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getLabelLinkPaint() + */ + public void setLabelLinkPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.labelLinkPaint = paint; + } + + /** + * Returns the domain grid line paint. + * + * @return The domain grid line paint (never <code>null<code>). + * + * @see #setDomainGridlinePaint(Paint) + */ + public Paint getDomainGridlinePaint() { + return this.domainGridlinePaint; + } + + /** + * Sets the domain grid line paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getDomainGridlinePaint() + */ + public void setDomainGridlinePaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.domainGridlinePaint = paint; + } + + /** + * Returns the range grid line paint. + * + * @return The range grid line paint (never <code>null</code>). + * + * @see #setRangeGridlinePaint(Paint) + */ + public Paint getRangeGridlinePaint() { + return this.rangeGridlinePaint; + } + + /** + * Sets the range grid line paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getRangeGridlinePaint() + */ + public void setRangeGridlinePaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.rangeGridlinePaint = paint; + } + + /** + * Returns the axis offsets. + * + * @return The axis offsets (never <code>null</code>). + * + * @see #setAxisOffset(RectangleInsets) + */ + public RectangleInsets getAxisOffset() { + return this.axisOffset; + } + + /** + * Sets the axis offset. + * + * @param offset the offset (<code>null</code> not permitted). + * + * @see #getAxisOffset() + */ + public void setAxisOffset(RectangleInsets offset) { + if (offset == null) { + throw new IllegalArgumentException("Null 'offset' argument."); + } + this.axisOffset = offset; + } + + /** + * Returns the axis label paint. + * + * @return The axis label paint (never <code>null</code>). + * + * @see #setAxisLabelPaint(Paint) + */ + public Paint getAxisLabelPaint() { + return this.axisLabelPaint; + } + + /** + * Sets the axis label paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getAxisLabelPaint() + */ + public void setAxisLabelPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.axisLabelPaint = paint; + } + + /** + * Returns the tick label paint. + * + * @return The tick label paint (never <code>null</code>). + * + * @see #setTickLabelPaint(Paint) + */ + public Paint getTickLabelPaint() { + return this.tickLabelPaint; + } + + /** + * Sets the tick label paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getTickLabelPaint() + */ + public void setTickLabelPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.tickLabelPaint = paint; + } + + /** + * Returns the item label paint. + * + * @return The item label paint (never <code>null</code>). + * + * @see #setItemLabelPaint(Paint) + */ + public Paint getItemLabelPaint() { + return this.itemLabelPaint; + } + + /** + * Sets the item label paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getItemLabelPaint() + */ + public void setItemLabelPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.itemLabelPaint = paint; + } + + /** + * Returns the shadow visibility flag. + * + * @return The shadow visibility flag. + * + * @see #setShadowVisible(boolean) + */ + public boolean isShadowVisible() { + return this.shadowVisible; + } + + /** + * Sets the shadow visibility flag. + * + * @param visible the flag. + * + * @see #isShadowVisible() + */ + public void setShadowVisible(boolean visible) { + this.shadowVisible = visible; + } + + /** + * Returns the shadow paint. + * + * @return The shadow paint (never <code>null</code>). + * + * @see #setShadowPaint(Paint) + */ + public Paint getShadowPaint() { + return this.shadowPaint; + } + + /** + * Sets the shadow paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getShadowPaint() + */ + public void setShadowPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.shadowPaint = paint; + } + + /** + * Returns the bar painter. + * + * @return The bar painter (never <code>null</code>). + * + * @see #setBarPainter(BarPainter) + */ + public BarPainter getBarPainter() { + return this.barPainter; + } + + /** + * Sets the bar painter. + * + * @param painter the painter (<code>null</code> not permitted). + * + * @see #getBarPainter() + */ + public void setBarPainter(BarPainter painter) { + if (painter == null) { + throw new IllegalArgumentException("Null 'painter' argument."); + } + this.barPainter = painter; + } + + /** + * Returns the XY bar painter. + * + * @return The XY bar painter (never <code>null</code>). + * + * @see #setXYBarPainter(XYBarPainter) + */ + public XYBarPainter getXYBarPainter() { + return this.xyBarPainter; + } + + /** + * Sets the XY bar painter. + * + * @param painter the painter (<code>null</code> not permitted). + * + * @see #getXYBarPainter() + */ + public void setXYBarPainter(XYBarPainter painter) { + if (painter == null) { + throw new IllegalArgumentException("Null 'painter' argument."); + } + this.xyBarPainter = painter; + } + + /** + * Returns the thermometer paint. + * + * @return The thermometer paint (never <code>null</code>). + * + * @see #setThermometerPaint(Paint) + */ + public Paint getThermometerPaint() { + return this.thermometerPaint; + } + + /** + * Sets the thermometer paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getThermometerPaint() + */ + public void setThermometerPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.thermometerPaint = paint; + } + + /** + * Returns the wall paint for charts with a 3D effect. + * + * @return The wall paint (never <code>null</code>). + * + * @see #setWallPaint(Paint) + */ + public Paint getWallPaint() { + return this.wallPaint; + } + + /** + * Sets the wall paint for charts with a 3D effect. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getWallPaint() + */ + public void setWallPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.wallPaint = paint; + } + + /** + * Returns the error indicator paint. + * + * @return The error indicator paint (never <code>null</code>). + * + * @see #setErrorIndicatorPaint(Paint) + */ + public Paint getErrorIndicatorPaint() { + return this.errorIndicatorPaint; + } + + /** + * Sets the error indicator paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getErrorIndicatorPaint() + */ + public void setErrorIndicatorPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.errorIndicatorPaint = paint; + } + + /** + * Returns the grid band paint. + * + * @return The grid band paint (never <code>null</code>). + * + * @see #setGridBandPaint(Paint) + */ + public Paint getGridBandPaint() { + return this.gridBandPaint; + } + + /** + * Sets the grid band paint. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getGridBandPaint() + */ + public void setGridBandPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.gridBandPaint = paint; + } + + /** + * Returns the grid band alternate paint (used for a {@link SymbolAxis}). + * + * @return The paint (never <code>null</code>). + * + * @see #setGridBandAlternatePaint(Paint) + */ + public Paint getGridBandAlternatePaint() { + return this.gridBandAlternatePaint; + } + + /** + * Sets the grid band alternate paint (used for a {@link SymbolAxis}). + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getGridBandAlternatePaint() + */ + public void setGridBandAlternatePaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.gridBandAlternatePaint = paint; + } + + /** + * Returns the name of this theme. + * + * @return The name of this theme. + */ + public String getName() { + return this.name; + } + + /** + * Returns a clone of the drawing supplier for this theme. + * + * @return A clone of the drawing supplier. + */ + public DrawingSupplier getDrawingSupplier() { + DrawingSupplier result = null; + if (this.drawingSupplier instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.drawingSupplier; + try { + result = (DrawingSupplier) pc.clone(); + } + catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + } + return result; + } + + /** + * Sets the drawing supplier for this theme. + * + * @param supplier the supplier (<code>null</code> not permitted). + * + * @see #getDrawingSupplier() + */ + public void setDrawingSupplier(DrawingSupplier supplier) { + if (supplier == null) { + throw new IllegalArgumentException("Null 'supplier' argument."); + } + this.drawingSupplier = supplier; + } + + /** + * Applies this theme to the supplied chart. + * + * @param chart the chart (<code>null</code> not permitted). + */ + public void apply(JFreeChart chart) { + if (chart == null) { + throw new IllegalArgumentException("Null 'chart' argument."); + } + TextTitle title = chart.getTitle(); + if (title != null) { + title.setFont(this.extraLargeFont); + title.setPaint(this.titlePaint); + } + + int subtitleCount = chart.getSubtitleCount(); + for (int i = 0; i < subtitleCount; i++) { + applyToTitle(chart.getSubtitle(i)); + } + + chart.setBackgroundPaint(this.chartBackgroundPaint); + + // now process the plot if there is one + Plot plot = chart.getPlot(); + if (plot != null) { + applyToPlot(plot); + } + } + + /** + * Applies the attributes of this theme to the specified title. + * + * @param title the title. + */ + protected void applyToTitle(Title title) { + if (title instanceof TextTitle) { + TextTitle tt = (TextTitle) title; + tt.setFont(this.largeFont); + tt.setPaint(this.subtitlePaint); + } + else if (title instanceof LegendTitle) { + LegendTitle lt = (LegendTitle) title; + if (lt.getBackgroundPaint() != null) { + lt.setBackgroundPaint(this.legendBackgroundPaint); + } + lt.setItemFont(this.regularFont); + lt.setItemPaint(this.legendItemPaint); + if (lt.getWrapper() != null) { + applyToBlockContainer(lt.getWrapper()); + } + } + else if (title instanceof PaintScaleLegend) { + PaintScaleLegend psl = (PaintScaleLegend) title; + psl.setBackgroundPaint(this.legendBackgroundPaint); + ValueAxis axis = psl.getAxis(); + if (axis != null) { + applyToValueAxis(axis); + } + } + else if (title instanceof CompositeTitle) { + CompositeTitle ct = (CompositeTitle) title; + BlockContainer bc = ct.getContainer(); + List blocks = bc.getBlocks(); + Iterator iterator = blocks.iterator(); + while (iterator.hasNext()) { + Block b = (Block) iterator.next(); + if (b instanceof Title) { + applyToTitle((Title) b); + } + } + } + } + + /** + * Applies the attributes of this theme to the specified container. + * + * @param bc a block container (<code>null</code> not permitted). + */ + protected void applyToBlockContainer(BlockContainer bc) { + Iterator iterator = bc.getBlocks().iterator(); + while (iterator.hasNext()) { + Block b = (Block) iterator.next(); + applyToBlock(b); + } + } + + /** + * Applies the attributes of this theme to the specified block. + * + * @param b the block. + */ + protected void applyToBlock(Block b) { + if (b instanceof Title) { + applyToTitle((Title) b); + } + else if (b instanceof LabelBlock) { + LabelBlock lb = (LabelBlock) b; + lb.setFont(this.regularFont); + lb.setPaint(this.legendItemPaint); + } + } + + /** + * Applies the attributes of this theme to a plot. + * + * @param plot the plot (<code>null</code>). + */ + protected void applyToPlot(Plot plot) { + if (plot == null) { + throw new IllegalArgumentException("Null 'plot' argument."); + } + if (plot.getDrawingSupplier() != null) { + plot.setDrawingSupplier(getDrawingSupplier()); + } + if (plot.getBackgroundPaint() != null) { + plot.setBackgroundPaint(this.plotBackgroundPaint); + } + plot.setOutlinePaint(this.plotOutlinePaint); + + // now handle specific plot types (and yes, I know this is some + // really ugly code that has to be manually updated any time a new + // plot type is added - I should have written something much cooler, + // but I didn't and neither did anyone else). + if (plot instanceof PiePlot) { + applyToPiePlot((PiePlot) plot); + } + else if (plot instanceof MultiplePiePlot) { + applyToMultiplePiePlot((MultiplePiePlot) plot); + } + else if (plot instanceof CategoryPlot) { + applyToCategoryPlot((CategoryPlot) plot); + } + else if (plot instanceof XYPlot) { + applyToXYPlot((XYPlot) plot); + } + else if (plot instanceof FastScatterPlot) { + applyToFastScatterPlot((FastScatterPlot) plot); + } + else if (plot instanceof MeterPlot) { + applyToMeterPlot((MeterPlot) plot); + } + else if (plot instanceof ThermometerPlot) { + applyToThermometerPlot((ThermometerPlot) plot); + } + else if (plot instanceof SpiderWebPlot) { + applyToSpiderWebPlot((SpiderWebPlot) plot); + } + else if (plot instanceof PolarPlot) { + applyToPolarPlot((PolarPlot) plot); + } + } + + /** + * Applies the attributes of this theme to a {@link PiePlot} instance. + * This method also clears any set values for the section paint, outline + * etc, so that the theme's {@link DrawingSupplier} will be used. + * + * @param plot the plot (<code>null</code> not permitted). + */ + protected void applyToPiePlot(PiePlot plot) { + plot.setLabelLinkPaint(this.labelLinkPaint); + plot.setLabelLinkStyle(this.labelLinkStyle); + plot.setLabelFont(this.regularFont); + + // clear the section attributes so that the theme's DrawingSupplier + // will be used + if (plot.getAutoPopulateSectionPaint()) { + plot.clearSectionPaints(false); + } + if (plot.getAutoPopulateSectionOutlinePaint()) { + plot.clearSectionOutlinePaints(false); + } + if (plot.getAutoPopulateSectionOutlineStroke()) { + plot.clearSectionOutlineStrokes(false); + } + } + + /** + * Applies the attributes of this theme to a {@link MultiplePiePlot}. + * + * @param plot the plot (<code>null</code> not permitted). + */ + protected void applyToMultiplePiePlot(MultiplePiePlot plot) { + apply(plot.getPieChart()); + } + + /** + * Applies the attributes of this theme to a {@link CategoryPlot}. + * + * @param plot the plot (<code>null</code> not permitted). + */ + protected void applyToCategoryPlot(CategoryPlot plot) { + plot.setAxisOffset(this.axisOffset); + plot.setDomainGridlinePaint(this.domainGridlinePaint); + plot.setRangeGridlinePaint(this.rangeGridlinePaint); + + // process all domain axes + int domainAxisCount = plot.getDomainAxisCount(); + for (int i = 0; i < domainAxisCount; i++) { + CategoryAxis axis = (CategoryAxis) plot.getDomainAxis(i); + if (axis != null) { + applyToCategoryAxis(axis); + } + } + + // process all range axes + int rangeAxisCount = plot.getRangeAxisCount(); + for (int i = 0; i < rangeAxisCount; i++) { + ValueAxis axis = (ValueAxis) plot.getRangeAxis(i); + if (axis != null) { + applyToValueAxis(axis); + } + } + + // process all renderers + int rendererCount = plot.getRendererCount(); + for (int i = 0; i < rendererCount; i++) { + CategoryItemRenderer r = plot.getRenderer(i); + if (r != null) { + applyToCategoryItemRenderer(r); + } + } + + if (plot instanceof CombinedDomainCategoryPlot) { + CombinedDomainCategoryPlot cp = (CombinedDomainCategoryPlot) plot; + Iterator iterator = cp.getSubplots().iterator(); + while (iterator.hasNext()) { + CategoryPlot subplot = (CategoryPlot) iterator.next(); + if (subplot != null) { + applyToPlot(subplot); + } + } + } + if (plot instanceof CombinedRangeCategoryPlot) { + CombinedRangeCategoryPlot cp = (CombinedRangeCategoryPlot) plot; + Iterator iterator = cp.getSubplots().iterator(); + while (iterator.hasNext()) { + CategoryPlot subplot = (CategoryPlot) iterator.next(); + if (subplot != null) { + applyToPlot(subplot); + } + } + } + } + + /** + * Applies the attributes of this theme to a {@link XYPlot}. + * + * @param plot the plot (<code>null</code> not permitted). + */ + protected void applyToXYPlot(XYPlot plot) { + plot.setAxisOffset(this.axisOffset); + plot.setDomainGridlinePaint(this.domainGridlinePaint); + plot.setRangeGridlinePaint(this.rangeGridlinePaint); + + // process all domain axes + int domainAxisCount = plot.getDomainAxisCount(); + for (int i = 0; i < domainAxisCount; i++) { + ValueAxis axis = (ValueAxis) plot.getDomainAxis(i); + if (axis != null) { + applyToValueAxis(axis); + } + } + + // process all range axes + int rangeAxisCount = plot.getRangeAxisCount(); + for (int i = 0; i < rangeAxisCount; i++) { + ValueAxis axis = (ValueAxis) plot.getRangeAxis(i); + if (axis != null) { + applyToValueAxis(axis); + } + } + + // process all renderers + int rendererCount = plot.getRendererCount(); + for (int i = 0; i < rendererCount; i++) { + XYItemRenderer r = plot.getRenderer(i); + if (r != null) { + applyToXYItemRenderer(r); + } + } + if (plot instanceof CombinedDomainXYPlot) { + CombinedDomainXYPlot cp = (CombinedDomainXYPlot) plot; + Iterator iterator = cp.getSubplots().iterator(); + while (iterator.hasNext()) { + XYPlot subplot = (XYPlot) iterator.next(); + if (subplot != null) { + applyToPlot(subplot); + } + } + } + if (plot instanceof CombinedRangeXYPlot) { + CombinedRangeXYPlot cp = (CombinedRangeXYPlot) plot; + Iterator iterator = cp.getSubplots().iterator(); + while (iterator.hasNext()) { + XYPlot subplot = (XYPlot) iterator.next(); + if (subplot != null) { + applyToPlot(subplot); + } + } + } + } + + /** + * Applies the attributes of this theme to a {@link FastScatterPlot}. + * @param plot + */ + protected void applyToFastScatterPlot(FastScatterPlot plot) { + plot.setDomainGridlinePaint(this.domainGridlinePaint); + plot.setRangeGridlinePaint(this.rangeGridlinePaint); + ValueAxis xAxis = plot.getDomainAxis(); + if (xAxis != null) { + applyToValueAxis(xAxis); + } + ValueAxis yAxis = plot.getRangeAxis(); + if (yAxis != null) { + applyToValueAxis(yAxis); + } + + } + + /** + * Applies the attributes of this theme to a {@link PolarPlot}. This + * method is called from the {@link #applyToPlot(Plot)} method. + * + * @param plot the plot (<code>null</code> not permitted). + */ + protected void applyToPolarPlot(PolarPlot plot) { + plot.setAngleLabelFont(this.regularFont); + plot.setAngleLabelPaint(this.tickLabelPaint); + plot.setAngleGridlinePaint(this.domainGridlinePaint); + plot.setRadiusGridlinePaint(this.rangeGridlinePaint); + ValueAxis axis = plot.getAxis(); + if (axis != null) { + applyToValueAxis(axis); + } + } + + /** + * Applies the attributes of this theme to a {@link SpiderWebPlot}. + * + * @param plot the plot (<code>null</code> not permitted). + */ + protected void applyToSpiderWebPlot(SpiderWebPlot plot) { + plot.setLabelFont(this.regularFont); + plot.setLabelPaint(this.axisLabelPaint); + plot.setAxisLinePaint(this.axisLabelPaint); + } + + /** + * Applies the attributes of this theme to a {@link MeterPlot}. + * + * @param plot the plot (<code>null</code> not permitted). + */ + protected void applyToMeterPlot(MeterPlot plot) { + plot.setDialBackgroundPaint(this.plotBackgroundPaint); + plot.setValueFont(this.largeFont); + plot.setValuePaint(this.axisLabelPaint); + plot.setDialOutlinePaint(this.plotOutlinePaint); + plot.setNeedlePaint(this.thermometerPaint); + plot.setTickLabelFont(this.regularFont); + plot.setTickLabelPaint(this.tickLabelPaint); + } + + /** + * Applies the attributes for this theme to a {@link ThermometerPlot}. + * This method is called from the {@link #applyToPlot(Plot)} method. + * + * @param plot the plot. + */ + protected void applyToThermometerPlot(ThermometerPlot plot) { + plot.setValueFont(this.largeFont); + plot.setThermometerPaint(this.thermometerPaint); + ValueAxis axis = plot.getRangeAxis(); + if (axis != null) { + applyToValueAxis(axis); + } + } + + /** + * Applies the attributes for this theme to a {@link CategoryAxis}. + * + * @param axis the axis (<code>null</code> not permitted). + */ + protected void applyToCategoryAxis(CategoryAxis axis) { + axis.setLabelFont(this.largeFont); + axis.setLabelPaint(this.axisLabelPaint); + axis.setTickLabelFont(this.regularFont); + axis.setTickLabelPaint(this.tickLabelPaint); + } + + /** + * Applies the attributes for this theme to a {@link ValueAxis}. + * + * @param axis the axis (<code>null</code> not permitted). + */ + protected void applyToValueAxis(ValueAxis axis) { + axis.setLabelFont(this.largeFont); + axis.setLabelPaint(this.axisLabelPaint); + axis.setTickLabelFont(this.regularFont); + axis.setTickLabelPaint(this.tickLabelPaint); + if (axis instanceof SymbolAxis) { + applyToSymbolAxis((SymbolAxis) axis); + } + if (axis instanceof PeriodAxis) { + applyToPeriodAxis((PeriodAxis) axis); + } + } + + /** + * Applies the attributes for this theme to a {@link SymbolAxis}. + * + * @param axis the axis (<code>null</code> not permitted). + */ + protected void applyToSymbolAxis(SymbolAxis axis) { + axis.setGridBandPaint(this.gridBandPaint); + axis.setGridBandAlternatePaint(this.gridBandAlternatePaint); + } + + /** + * Applies the attributes for this theme to a {@link PeriodAxis}. + * + * @param axis the axis (<code>null</code> not permitted). + */ + protected void applyToPeriodAxis(PeriodAxis axis) { + PeriodAxisLabelInfo[] info = axis.getLabelInfo(); + for (int i = 0; i < info.length; i++) { + PeriodAxisLabelInfo e = info[i]; + PeriodAxisLabelInfo n = new PeriodAxisLabelInfo(e.getPeriodClass(), + e.getDateFormat(), e.getPadding(), this.regularFont, + this.tickLabelPaint, e.getDrawDividers(), + e.getDividerStroke(), e.getDividerPaint()); + info[i] = n; + } + axis.setLabelInfo(info); + } + + /** + * Applies the attributes for this theme to an {@link AbstractRenderer}. + * + * @param renderer the renderer (<code>null</code> not permitted). + */ + protected void applyToAbstractRenderer(AbstractRenderer renderer) { + if (renderer.getAutoPopulateSeriesPaint()) { + renderer.clearSeriesPaints(false); + } + if (renderer.getAutoPopulateSeriesStroke()) { + renderer.clearSeriesStrokes(false); + } + } + + /** + * Applies the settings of this theme to the specified renderer. + * + * @param renderer the renderer (<code>null</code> not permitted). + */ + protected void applyToCategoryItemRenderer(CategoryItemRenderer renderer) { + if (renderer == null) { + throw new IllegalArgumentException("Null 'renderer' argument."); + } + + if (renderer instanceof AbstractRenderer) { + applyToAbstractRenderer((AbstractRenderer) renderer); + } + + renderer.setBaseItemLabelFont(this.regularFont); + renderer.setBaseItemLabelPaint(this.itemLabelPaint); + + // now we handle some special cases - yes, UGLY code alert! + + // BarRenderer + if (renderer instanceof BarRenderer) { + BarRenderer br = (BarRenderer) renderer; + br.setBarPainter(this.barPainter); + br.setShadowVisible(this.shadowVisible); + br.setShadowPaint(this.shadowPaint); + } + + // BarRenderer3D + if (renderer instanceof BarRenderer3D) { + BarRenderer3D br3d = (BarRenderer3D) renderer; + br3d.setWallPaint(this.wallPaint); + } + + // LineRenderer3D + if (renderer instanceof LineRenderer3D) { + LineRenderer3D lr3d = (LineRenderer3D) renderer; + lr3d.setWallPaint(this.wallPaint); + } + + // StatisticalBarRenderer + if (renderer instanceof StatisticalBarRenderer) { + ... [truncated message content] |
From: <mu...@us...> - 2008-08-15 12:38:23
|
Revision: 1381 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1381&view=rev Author: mungady Date: 2008-08-15 12:38:19 +0000 (Fri, 15 Aug 2008) Log Message: ----------- 2008-08-15 David Gilbert <dav...@ob...> Bug 2051168: * source/org/jfree/chart/plot/PiePlot.java (getLegendItems): Populate with series key and index. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 12:31:01 UTC (rev 1380) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 12:38:19 UTC (rev 1381) @@ -1,5 +1,11 @@ 2008-08-15 David Gilbert <dav...@ob...> + Bug 2051168: + * source/org/jfree/chart/plot/PiePlot.java + (getLegendItems): Populate with series key and index. + +2008-08-15 David Gilbert <dav...@ob...> + * source/org/jfree/chart/ChartFactory.java: (currentTheme): New field, (getChartTheme): New method, Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java 2008-08-15 12:31:01 UTC (rev 1380) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java 2008-08-15 12:38:19 UTC (rev 1381) @@ -155,6 +155,8 @@ * 1891849 by Martin Hilpert (DG); * 02-Jul-2008 : Added autoPopulate flags (DG); * 15-Aug-2008 : Added methods to clear section attributes (DG); + * 15-Aug-2008 : Fixed bug 2051168 - problem with LegendItemEntity + * generation (DG); * */ @@ -2931,6 +2933,8 @@ false, // line not visible new Line2D.Float(), new BasicStroke(), Color.black); item.setDataset(getDataset()); + item.setSeriesIndex(this.dataset.getIndex(key)); + item.setSeriesKey(key); result.add(item); } section++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-08-15 13:43:28
|
Revision: 1384 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1384&view=rev Author: mungady Date: 2008-08-15 13:43:26 +0000 (Fri, 15 Aug 2008) Log Message: ----------- 2008-08-15 David Gilbert <dav...@ob...> Bug 2033721: * source/org/jfree/chart/renderer/WaferMapRenderer.java (getLegendCollection): Use lookupSeriesPaint. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/WaferMapRenderer.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 12:46:38 UTC (rev 1383) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 13:43:26 UTC (rev 1384) @@ -1,5 +1,11 @@ 2008-08-15 David Gilbert <dav...@ob...> + Bug 2033721: + * source/org/jfree/chart/renderer/WaferMapRenderer.java + (getLegendCollection): Use lookupSeriesPaint. + +2008-08-15 David Gilbert <dav...@ob...> + Bug 2051168: * source/org/jfree/chart/plot/PiePlot.java (getLegendItems): Populate with series key and index. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/WaferMapRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/WaferMapRenderer.java 2008-08-15 12:46:38 UTC (rev 1383) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/WaferMapRenderer.java 2008-08-15 13:43:26 UTC (rev 1384) @@ -300,9 +300,8 @@ String label = entry.getKey().toString(); String description = label; Shape shape = new Rectangle2D.Double(1d, 1d, 1d, 1d); - Paint paint = getSeriesPaint( - ((Integer) entry.getValue()).intValue() - ); + Paint paint = lookupSeriesPaint( + ((Integer) entry.getValue()).intValue()); Paint outlinePaint = Color.black; Stroke outlineStroke = DEFAULT_STROKE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-08-15 14:32:49
|
Revision: 1386 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1386&view=rev Author: mungady Date: 2008-08-15 14:32:46 +0000 (Fri, 15 Aug 2008) Log Message: ----------- 2008-08-15 David Gilbert <dav...@ob...> Bug 2031407: * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java (createStackedValueList): Encode series with negative values using -1 offset, (drawStackHorizontal): Account for -1 offset, (drawStackVertical): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 13:46:39 UTC (rev 1385) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-08-15 14:32:46 UTC (rev 1386) @@ -1,5 +1,14 @@ 2008-08-15 David Gilbert <dav...@ob...> + Bug 2031407: + * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java + (createStackedValueList): Encode series with negative values using -1 + offset, + (drawStackHorizontal): Account for -1 offset, + (drawStackVertical): Likewise. + +2008-08-15 David Gilbert <dav...@ob...> + Bug 2033721: * source/org/jfree/chart/renderer/WaferMapRenderer.java (getLegendCollection): Use lookupSeriesPaint. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java 2008-08-15 13:46:39 UTC (rev 1385) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java 2008-08-15 14:32:46 UTC (rev 1386) @@ -80,6 +80,7 @@ * see bug report 1599652 (DG); * 08-May-2007 : Fixed bugs 1713401 (drawBarOutlines flag) and 1713474 * (shading) (DG); + * 15-Aug-2008 : Fixed bug 2031407 - no negative zero for stack encoding (DG); * */ @@ -314,7 +315,7 @@ baseIndex = 0; } negBase = negBase + v; // '+' because v is negative - result.add(0, new Object[] {new Integer(-s), + result.add(0, new Object[] {new Integer(-s - 1), new Double(negBase)}); baseIndex++; } @@ -421,12 +422,12 @@ Object[] curr = (Object[]) values.get(index + 1); int series = 0; if (curr[0] == null) { - series = -((Integer) prev[0]).intValue(); + series = -((Integer) prev[0]).intValue() - 1; } else { series = ((Integer) curr[0]).intValue(); if (series < 0) { - series = -((Integer) prev[0]).intValue(); + series = -((Integer) prev[0]).intValue() - 1; } } double v0 = ((Double) prev[1]).doubleValue(); @@ -617,12 +618,12 @@ Object[] curr = (Object[]) values.get(index + 1); int series = 0; if (curr[0] == null) { - series = -((Integer) prev[0]).intValue(); + series = -((Integer) prev[0]).intValue() - 1; } else { series = ((Integer) curr[0]).intValue(); if (series < 0) { - series = -((Integer) prev[0]).intValue(); + series = -((Integer) prev[0]).intValue() - 1; } } double v0 = ((Double) prev[1]).doubleValue(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-01 08:56:03
|
Revision: 1391 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1391&view=rev Author: mungady Date: 2008-09-01 08:55:47 +0000 (Mon, 01 Sep 2008) Log Message: ----------- 2008-09-01 David Gilbert <dav...@ob...> * source/org/jfree/chart/renderer/xy/XYDotRenderer.java (drawItem): Check for item visibility. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYDotRenderer.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-01 07:26:30 UTC (rev 1390) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-01 08:55:47 UTC (rev 1391) @@ -1,3 +1,8 @@ +2008-09-01 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/renderer/xy/XYDotRenderer.java + (drawItem): Check for item visibility. + 2008-08-15 David Gilbert <dav...@ob...> Bug 2031407: Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYDotRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYDotRenderer.java 2008-09-01 07:26:30 UTC (rev 1390) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYDotRenderer.java 2008-09-01 08:55:47 UTC (rev 1391) @@ -79,10 +79,7 @@ * A renderer that draws a small dot at each data point for an {@link XYPlot}. */ public class XYDotRenderer extends AbstractXYItemRenderer - implements XYItemRenderer, - Cloneable, - PublicCloneable, - Serializable { + implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { /** For serialization. */ private static final long serialVersionUID = -2764344339073566425L; @@ -234,6 +231,11 @@ CrosshairState crosshairState, int pass) { + // do nothing if item is not visible + if (!getItemVisible(series, item)) { + return; + } + // get the data point... double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-01 10:11:44
|
Revision: 1396 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1396&view=rev Author: mungady Date: 2008-09-01 10:11:32 +0000 (Mon, 01 Sep 2008) Log Message: ----------- 2008-09-01 David Gilbert <dav...@ob...> * source/org/jfree/chart/util/RelativeDateFormat.java (hourFormatter): New field, (minuteFormatter): New field, (RelativeDateFormat(long)): Initialise new fields, (setDayFormatter): New method, (setHourFormatter): Likewise, (setMinuteFormatter): Likewise, (format): Use new fields for formatting, (equals): Updated for new fields. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/RelativeDateFormat.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-01 09:07:56 UTC (rev 1395) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-01 10:11:32 UTC (rev 1396) @@ -1,5 +1,17 @@ 2008-09-01 David Gilbert <dav...@ob...> + * source/org/jfree/chart/util/RelativeDateFormat.java + (hourFormatter): New field, + (minuteFormatter): New field, + (RelativeDateFormat(long)): Initialise new fields, + (setDayFormatter): New method, + (setHourFormatter): Likewise, + (setMinuteFormatter): Likewise, + (format): Use new fields for formatting, + (equals): Updated for new fields. + +2008-09-01 David Gilbert <dav...@ob...> + * source/org/jfree/chart/renderer/xy/XYDotRenderer.java (drawItem): Check for item visibility. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/RelativeDateFormat.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/RelativeDateFormat.java 2008-09-01 09:07:56 UTC (rev 1395) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/RelativeDateFormat.java 2008-09-01 10:11:32 UTC (rev 1396) @@ -39,6 +39,8 @@ * hashCode() (DG); * 15-Feb-2008 : Applied patch 1873328 by Michael Siemer, with minor * modifications (DG); + * 01-Sep-2008 : Added new fields for hour and minute formatting, based on + * patch 2033092 (DG); * */ @@ -96,11 +98,25 @@ private String daySuffix; /** + * A formatter for the hours. + * + * @since 1.0.11 + */ + private NumberFormat hourFormatter; + + /** * A string appended after the hours. */ private String hourSuffix; /** + * A formatter for the minutes. + * + * @since 1.0.11 + */ + private NumberFormat minuteFormatter; + + /** * A string appended after the minutes. */ private String minuteSuffix; @@ -126,7 +142,7 @@ private static long MILLISECONDS_IN_ONE_DAY = 24 * MILLISECONDS_IN_ONE_HOUR; /** - * Creates a new instance. + * Creates a new instance with base milliseconds set to zero. */ public RelativeDateFormat() { this(0L); @@ -152,9 +168,11 @@ this.showZeroDays = false; this.showZeroHours = true; this.positivePrefix = ""; - this.dayFormatter = NumberFormat.getInstance(); + this.dayFormatter = NumberFormat.getNumberInstance(); this.daySuffix = "d"; + this.hourFormatter = NumberFormat.getNumberInstance(); this.hourSuffix = "h"; + this.minuteFormatter = NumberFormat.getNumberInstance(); this.minuteSuffix = "m"; this.secondFormatter = NumberFormat.getNumberInstance(); this.secondFormatter.setMaximumFractionDigits(3); @@ -276,6 +294,20 @@ } /** + * Sets the formatter for the days. + * + * @param formatter the formatter (<code>null</code> not permitted). + * + * @since 1.0.11 + */ + public void setDayFormatter(NumberFormat formatter) { + if (formatter == null) { + throw new IllegalArgumentException("Null 'formatter' argument."); + } + this.dayFormatter = formatter; + } + + /** * Returns the string that is appended to the day count. * * @return The string. @@ -301,6 +333,20 @@ } /** + * Sets the formatter for the hours. + * + * @param formatter the formatter (<code>null</code> not permitted). + * + * @since 1.0.11 + */ + public void setHourFormatter(NumberFormat formatter) { + if (formatter == null) { + throw new IllegalArgumentException("Null 'formatter' argument."); + } + this.hourFormatter = formatter; + } + + /** * Returns the string that is appended to the hour count. * * @return The string. @@ -326,6 +372,20 @@ } /** + * Sets the formatter for the minutes. + * + * @param formatter the formatter (<code>null</code> not permitted). + * + * @since 1.0.11 + */ + public void setMinuteFormatter(NumberFormat formatter) { + if (formatter == null) { + throw new IllegalArgumentException("Null 'formatter' argument."); + } + this.minuteFormatter = formatter; + } + + /** * Returns the string that is appended to the minute count. * * @return The string. @@ -423,9 +483,11 @@ toAppendTo.append(this.dayFormatter.format(days) + getDaySuffix()); } if (hours != 0 || this.showZeroHours) { - toAppendTo.append(String.valueOf(hours) + getHourSuffix()); + toAppendTo.append(this.hourFormatter.format(hours) + + getHourSuffix()); } - toAppendTo.append(String.valueOf(minutes) + getMinuteSuffix()); + toAppendTo.append(this.minuteFormatter.format(minutes) + + getMinuteSuffix()); toAppendTo.append(this.secondFormatter.format(seconds) + getSecondSuffix()); return toAppendTo; @@ -485,6 +547,15 @@ if (!this.secondSuffix.equals(that.secondSuffix)) { return false; } + if (!this.dayFormatter.equals(that.dayFormatter)) { + return false; + } + if (!this.hourFormatter.equals(that.hourFormatter)) { + return false; + } + if (!this.minuteFormatter.equals(that.minuteFormatter)) { + return false; + } if (!this.secondFormatter.equals(that.secondFormatter)) { return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-01 13:18:22
|
Revision: 1402 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1402&view=rev Author: mungady Date: 2008-09-01 13:18:20 +0000 (Mon, 01 Sep 2008) Log Message: ----------- 2008-09-01 David Gilbert <dav...@ob...> * source/org/jfree/chart/axis/DateAxis.java (valueToJava2D): Use DateRange methods that return millis, (java2DToValue): Likewise, * source/org/jfree/data/time/DateRange.java (getLowerMillis): New method, (getUpperMillis): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateAxis.java branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/DateRange.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-01 12:54:42 UTC (rev 1401) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-01 13:18:20 UTC (rev 1402) @@ -1,5 +1,14 @@ 2008-09-01 David Gilbert <dav...@ob...> + * source/org/jfree/chart/axis/DateAxis.java + (valueToJava2D): Use DateRange methods that return millis, + (java2DToValue): Likewise, + * source/org/jfree/data/time/DateRange.java + (getLowerMillis): New method, + (getUpperMillis): Likewise. + +2008-09-01 David Gilbert <dav...@ob...> + * source/org/jfree/chart/util/RelativeDateFormat.java (hourFormatter): New field, (minuteFormatter): New field, 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 2008-09-01 12:54:42 UTC (rev 1401) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateAxis.java 2008-09-01 13:18:20 UTC (rev 1402) @@ -115,6 +115,7 @@ * 03-May-2007 : Fixed minor bugs in previousStandardDate(), with new JUnit * tests (DG); * 21-Nov-2007 : Fixed warnings from FindBugs (DG); + * 01-Sep-2008 : Use new methods from DateRange (DG); * */ @@ -701,8 +702,8 @@ value = this.timeline.toTimelineValue((long) value); DateRange range = (DateRange) getRange(); - double axisMin = this.timeline.toTimelineValue(range.getLowerDate()); - double axisMax = this.timeline.toTimelineValue(range.getUpperDate()); + double axisMin = this.timeline.toTimelineValue(range.getLowerMillis()); + double axisMax = this.timeline.toTimelineValue(range.getUpperMillis()); double result = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { double minX = area.getX(); @@ -765,8 +766,8 @@ RectangleEdge edge) { DateRange range = (DateRange) getRange(); - double axisMin = this.timeline.toTimelineValue(range.getLowerDate()); - double axisMax = this.timeline.toTimelineValue(range.getUpperDate()); + double axisMin = this.timeline.toTimelineValue(range.getLowerMillis()); + double axisMax = this.timeline.toTimelineValue(range.getUpperMillis()); double min = 0.0; double max = 0.0; @@ -1279,16 +1280,15 @@ * @param edge the axis location. */ protected void selectHorizontalAutoTickUnit(Graphics2D g2, - Rectangle2D dataArea, - RectangleEdge edge) { + Rectangle2D dataArea, RectangleEdge edge) { long shift = 0; if (this.timeline instanceof SegmentedTimeline) { shift = ((SegmentedTimeline) this.timeline).getStartTime(); } double zero = valueToJava2D(shift + 0.0, dataArea, edge); - double tickLabelWidth - = estimateMaximumTickLabelWidth(g2, getTickUnit()); + double tickLabelWidth = estimateMaximumTickLabelWidth(g2, + getTickUnit()); // start with the current tick unit... TickUnitSource tickUnits = getStandardTickUnits(); Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/DateRange.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/DateRange.java 2008-09-01 12:54:42 UTC (rev 1401) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/DateRange.java 2008-09-01 13:18:20 UTC (rev 1402) @@ -38,6 +38,7 @@ * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 23-Sep-2003 : Minor Javadoc update (DG); * 28-May-2008 : Fixed problem with immutability (DG); + * 01-Sep-2008 : Added getLowerMillis() and getUpperMillis() (DG); * */ @@ -112,21 +113,51 @@ * Returns the lower (earlier) date for the range. * * @return The lower date for the range. + * + * @see #getLowerMillis() */ public Date getLowerDate() { return new Date(this.lowerDate); } /** + * Returns the lower bound of the range in milliseconds. + * + * @return The lower bound. + * + * @see #getLowerDate() + * + * @since 1.0.11 + */ + public long getLowerMillis() { + return this.lowerDate; + } + + /** * Returns the upper (later) date for the range. * * @return The upper date for the range. + * + * @see #getUpperMillis() */ public Date getUpperDate() { return new Date(this.upperDate); } /** + * Returns the upper bound of the range in milliseconds. + * + * @return The upper bound. + * + * @see #getUpperDate() + * + * @since 1.0.11 + */ + public long getUpperMillis() { + return this.upperDate; + } + + /** * Returns a string representing the date range (useful for debugging). * * @return A string representing the date range. @@ -134,7 +165,7 @@ public String toString() { DateFormat df = DateFormat.getDateTimeInstance(); return "[" + df.format(getLowerDate()) + " --> " - + df.format(getUpperDate()) + "]"; + + df.format(getUpperDate()) + "]"; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-01 14:47:35
|
Revision: 1405 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1405&view=rev Author: mungady Date: 2008-09-01 14:47:33 +0000 (Mon, 01 Sep 2008) Log Message: ----------- 2008-09-01 David Gilbert <dav...@ob...> Bug 2078057: * source/org/jfree/chart/axis/DateAxis.java (previousStandardDate): For month option, peg in case of non-default time zone, * source/org/jfree/data/time/Month.java (previous): Added API doc comments, (next): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateAxis.java branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Month.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-01 13:25:14 UTC (rev 1404) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-01 14:47:33 UTC (rev 1405) @@ -1,6 +1,16 @@ 2008-09-01 David Gilbert <dav...@ob...> + Bug 2078057: * source/org/jfree/chart/axis/DateAxis.java + (previousStandardDate): For month option, peg in case of + non-default time zone, + * source/org/jfree/data/time/Month.java + (previous): Added API doc comments, + (next): Likewise. + +2008-09-01 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/axis/DateAxis.java (valueToJava2D): Use DateRange methods that return millis, (java2DToValue): Likewise, * source/org/jfree/data/time/DateRange.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 2008-09-01 13:25:14 UTC (rev 1404) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateAxis.java 2008-09-01 14:47:33 UTC (rev 1405) @@ -115,7 +115,8 @@ * 03-May-2007 : Fixed minor bugs in previousStandardDate(), with new JUnit * tests (DG); * 21-Nov-2007 : Fixed warnings from FindBugs (DG); - * 01-Sep-2008 : Use new methods from DateRange (DG); + * 01-Sep-2008 : Use new methods from DateRange, added fix for bug + * 2078057 (DG); * */ @@ -968,6 +969,9 @@ long millis = standardDate.getTime(); if (millis >= date.getTime()) { month = (Month) month.previous(); + // need to peg the month in case the time zone isn't the + // default - see bug 2078057 + month.peg(Calendar.getInstance(this.timeZone)); standardDate = calculateDateForPosition( month, this.tickMarkPosition); } Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Month.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Month.java 2008-09-01 13:25:14 UTC (rev 1404) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Month.java 2008-09-01 14:47:33 UTC (rev 1405) @@ -55,6 +55,7 @@ * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); * 04-Apr-2007 : Fixed bug in Month(Date, TimeZone) constructor (CB); + * 01-Sep-2008 : Added clarification for previous() and next() methods (DG); * */ @@ -221,7 +222,10 @@ } /** - * Returns the month preceding this one. + * Returns the month preceding this one. Note that the returned + * {@link Month} is "pegged" using the default time-zone, irrespective of + * the time-zone used to peg of the current month (which is not recorded + * anywhere). See the {@link #peg(Calendar)} method. * * @return The month preceding this one. */ @@ -242,7 +246,10 @@ } /** - * Returns the month following this one. + * Returns the month following this one. Note that the returned + * {@link Month} is "pegged" using the default time-zone, irrespective of + * the time-zone used to peg of the current month (which is not recorded + * anywhere). See the {@link #peg(Calendar)} method. * * @return The month following this one. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-03 09:32:43
|
Revision: 1477 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1477&view=rev Author: mungady Date: 2008-09-03 09:32:38 +0000 (Wed, 03 Sep 2008) Log Message: ----------- 2008-09-03 David Gilbert <dav...@ob...> * experimental/org/jfree/experimental/chart/annotations/XYTitleAnnotation.java: Moved to main, * experimental/org/jfree/experimental/chart/annotations/junit/XYTitleAnnotationTests.java Likewise, * experimental/org/jfree/experimental/chart/util/XYCoordinateType.java Likewise, * source/org/jfree/chart/annotation/XYTitleAnnotation.java: Transferred from experimental, * source/org/jfree/chart/util/XYCoordinateType.java: Likewise, * tests/org/jfree/chart/annotations/junit/AnnotationsPackageTests.java (suite): Added tests for XYTitleAnnotation, * tests/org/jfree/chart/annotations/junit/XYTitleAnnotationTests.java: New file. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/annotations/junit/AnnotationsPackageTests.java Added Paths: ----------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/annotations/XYTitleAnnotation.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/XYCoordinateType.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/annotations/junit/XYTitleAnnotationTests.java Removed Paths: ------------- branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/annotations/XYTitleAnnotation.java branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/annotations/junit/XYTitleAnnotationTests.java branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/demo/XYTitleAnnotationDemo1.java branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/util/XYCoordinateType.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-02 14:09:21 UTC (rev 1476) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-03 09:32:38 UTC (rev 1477) @@ -1,3 +1,19 @@ +2008-09-03 David Gilbert <dav...@ob...> + + * experimental/org/jfree/experimental/chart/annotations/XYTitleAnnotation.java: + Moved to main, + * experimental/org/jfree/experimental/chart/annotations/junit/XYTitleAnnotationTests.java + Likewise, + * experimental/org/jfree/experimental/chart/util/XYCoordinateType.java + Likewise, + * source/org/jfree/chart/annotation/XYTitleAnnotation.java: + Transferred from experimental, + * source/org/jfree/chart/util/XYCoordinateType.java: Likewise, + * tests/org/jfree/chart/annotations/junit/AnnotationsPackageTests.java + (suite): Added tests for XYTitleAnnotation, + * tests/org/jfree/chart/annotations/junit/XYTitleAnnotationTests.java: + New file. + 2008-09-01 David Gilbert <dav...@ob...> Bug 2078057: Deleted: branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/annotations/XYTitleAnnotation.java =================================================================== --- branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/annotations/XYTitleAnnotation.java 2008-09-02 14:09:21 UTC (rev 1476) +++ branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/annotations/XYTitleAnnotation.java 2008-09-03 09:32:38 UTC (rev 1477) @@ -1,392 +0,0 @@ -/* =========================================================== - * JFreeChart : a free chart library for the Java(tm) platform - * =========================================================== - * - * (C) Copyright 2000-2008, 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. - * - * [Java is a trademark or registered trademark of Sun Microsystems, Inc. - * in the United States and other countries.] - * - * ---------------------- - * XYTitleAnnotation.java - * ---------------------- - * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. - * - * Original Author: David Gilbert (for Object Refinery Limited); - * Contributor(s): Andrew Mickish; - * - * Changes: - * -------- - * 02-Feb-2007 : Version 1 (DG); - * 30-Apr-2007 : Fixed equals() method (DG); - * 26-Feb-2008 : Fixed NullPointerException when drawing chart with a null - * ChartRenderingInfo - see patch 1901599 by Andrew Mickish (DG); - * - */ - -package org.jfree.experimental.chart.annotations; - -import java.awt.Graphics2D; -import java.awt.geom.Point2D; -import java.awt.geom.Rectangle2D; -import java.io.Serializable; - -import org.jfree.chart.HashUtilities; -import org.jfree.chart.annotations.AbstractXYAnnotation; -import org.jfree.chart.axis.AxisLocation; -import org.jfree.chart.axis.ValueAxis; -import org.jfree.chart.block.BlockParams; -import org.jfree.chart.block.EntityBlockResult; -import org.jfree.chart.block.RectangleConstraint; -import org.jfree.chart.plot.Plot; -import org.jfree.chart.plot.PlotOrientation; -import org.jfree.chart.plot.PlotRenderingInfo; -import org.jfree.chart.plot.XYPlot; -import org.jfree.chart.title.Title; -import org.jfree.data.Range; -import org.jfree.experimental.chart.util.XYCoordinateType; -import org.jfree.ui.RectangleAnchor; -import org.jfree.ui.RectangleEdge; -import org.jfree.ui.Size2D; -import org.jfree.util.ObjectUtilities; -import org.jfree.util.PublicCloneable; - -/** - * An annotation that allows any {@link Title} to be placed at a location on - * an {@link XYPlot}. - */ -public class XYTitleAnnotation extends AbstractXYAnnotation - implements Cloneable, PublicCloneable, Serializable { - - /** For serialization. */ - private static final long serialVersionUID = -4364694501921559958L; - - /** The coordinate type. */ - private XYCoordinateType coordinateType; - - /** The x-coordinate (in data space). */ - private double x; - - /** The y-coordinate (in data space). */ - private double y; - - /** The maximum width. */ - private double maxWidth; - - /** The maximum height. */ - private double maxHeight; - - /** The title. */ - private Title title; - - /** - * The title anchor point. - */ - private RectangleAnchor anchor; - - /** - * Creates a new annotation to be displayed at the specified (x, y) - * location. - * - * @param x the x-coordinate (in data space). - * @param y the y-coordinate (in data space). - * @param title the title (<code>null</code> not permitted). - */ - public XYTitleAnnotation(double x, double y, Title title) { - this(x, y, title, RectangleAnchor.CENTER); - } - - /** - * Creates a new annotation to be displayed at the specified (x, y) - * location. - * - * @param x the x-coordinate (in data space). - * @param y the y-coordinate (in data space). - * @param title the title (<code>null</code> not permitted). - * @param anchor the title anchor (<code>null</code> not permitted). - */ - public XYTitleAnnotation(double x, double y, Title title, - RectangleAnchor anchor) { - if (title == null) { - throw new IllegalArgumentException("Null 'title' argument."); - } - if (anchor == null) { - throw new IllegalArgumentException("Null 'anchor' argument."); - } - this.coordinateType = XYCoordinateType.RELATIVE; - this.x = x; - this.y = y; - this.maxWidth = 0.0; - this.maxHeight = 0.0; - this.title = title; - this.anchor = anchor; - } - - /** - * Returns the coordinate type (set in the constructor). - * - * @return The coordinate type (never <code>null</code>). - */ - public XYCoordinateType getCoordinateType() { - return this.coordinateType; - } - - /** - * Returns the x-coordinate for the annotation. - * - * @return The x-coordinate. - */ - public double getX() { - return this.x; - } - - /** - * Returns the y-coordinate for the annotation. - * - * @return The y-coordinate. - */ - public double getY() { - return this.y; - } - - /** - * Returns the title for the annotation. - * - * @return The title. - */ - public Title getTitle() { - return this.title; - } - - /** - * Returns the title anchor for the annotation. - * - * @return The title anchor. - */ - public RectangleAnchor getTitleAnchor() { - return this.anchor; - } - - /** - * Returns the maximum width. - * - * @return The maximum width. - */ - public double getMaxWidth() { - return this.maxWidth; - } - - /** - * Sets the maximum width. - * - * @param max the maximum width (0.0 or less means no maximum). - */ - public void setMaxWidth(double max) { - this.maxWidth = max; - } - - /** - * Returns the maximum height. - * - * @return The maximum height. - */ - public double getMaxHeight() { - return this.maxHeight; - } - - /** - * Sets the maximum height. - * - * @param max the maximum height. - */ - public void setMaxHeight(double max) { - this.maxHeight = max; - } - - /** - * Draws the annotation. This method is called by the drawing code in the - * {@link XYPlot} class, you don't normally need to call this method - * directly. - * - * @param g2 the graphics device. - * @param plot the plot. - * @param dataArea the data area. - * @param domainAxis the domain axis. - * @param rangeAxis the range axis. - * @param rendererIndex the renderer index. - * @param info if supplied, this info object will be populated with - * entity information. - */ - public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, - ValueAxis domainAxis, ValueAxis rangeAxis, - int rendererIndex, - PlotRenderingInfo info) { - - PlotOrientation orientation = plot.getOrientation(); - AxisLocation domainAxisLocation = plot.getDomainAxisLocation(); - AxisLocation rangeAxisLocation = plot.getRangeAxisLocation(); - RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( - domainAxisLocation, orientation); - RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( - rangeAxisLocation, orientation); - Range xRange = domainAxis.getRange(); - Range yRange = rangeAxis.getRange(); - double anchorX = 0.0; - double anchorY = 0.0; - if (this.coordinateType == XYCoordinateType.RELATIVE) { - anchorX = xRange.getLowerBound() + (this.x * xRange.getLength()); - anchorY = yRange.getLowerBound() + (this.y * yRange.getLength()); - } - else { - anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge); - anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge); - } - - float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea, - domainEdge); - float j2DY = (float) rangeAxis.valueToJava2D(anchorY, dataArea, - rangeEdge); - float xx = 0.0f; - float yy = 0.0f; - if (orientation == PlotOrientation.HORIZONTAL) { - xx = j2DY; - yy = j2DX; - } - else if (orientation == PlotOrientation.VERTICAL) { - xx = j2DX; - yy = j2DY; - } - - double maxW = dataArea.getWidth(); - double maxH = dataArea.getHeight(); - if (this.coordinateType == XYCoordinateType.RELATIVE) { - if (this.maxWidth > 0.0) { - maxW = maxW * this.maxWidth; - } - if (this.maxHeight > 0.0) { - maxH = maxH * this.maxHeight; - } - } - if (this.coordinateType == XYCoordinateType.DATA) { - maxW = this.maxWidth; - maxH = this.maxHeight; - } - RectangleConstraint rc = new RectangleConstraint( - new Range(0, maxW), new Range(0, maxH)); - - Size2D size = this.title.arrange(g2, rc); - Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width, - size.height); - Point2D anchorPoint = RectangleAnchor.coordinates(titleRect, - this.anchor); - xx = xx - (float) anchorPoint.getX(); - yy = yy - (float) anchorPoint.getY(); - titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight()); - BlockParams p = new BlockParams(); - if (info != null) { - if (info.getOwner().getEntityCollection() != null) { - p.setGenerateEntities(true); - } - } - Object result = this.title.draw(g2, titleRect, p); - if (info != null) { - if (result instanceof EntityBlockResult) { - EntityBlockResult ebr = (EntityBlockResult) result; - info.getOwner().getEntityCollection().addAll( - ebr.getEntityCollection()); - } - String toolTip = getToolTipText(); - String url = getURL(); - if (toolTip != null || url != null) { - addEntity(info, new Rectangle2D.Float(xx, yy, - (float) size.width, (float) size.height), - rendererIndex, toolTip, url); - } - } - } - - /** - * Tests this object for equality with an arbitrary object. - * - * @param obj the object (<code>null</code> permitted). - * - * @return A boolean. - */ - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof XYTitleAnnotation)) { - return false; - } - XYTitleAnnotation that = (XYTitleAnnotation) obj; - if (this.coordinateType != that.coordinateType) { - return false; - } - if (this.x != that.x) { - return false; - } - if (this.y != that.y) { - return false; - } - if (this.maxWidth != that.maxWidth) { - return false; - } - if (this.maxHeight != that.maxHeight) { - return false; - } - if (!ObjectUtilities.equal(this.title, that.title)) { - return false; - } - if (!this.anchor.equals(that.anchor)) { - return false; - } - return super.equals(obj); - } - - /** - * Returns a hash code for this object. - * - * @return A hash code. - */ - public int hashCode() { - int result = 193; - result = HashUtilities.hashCode(result, this.anchor); - result = HashUtilities.hashCode(result, this.coordinateType); - result = HashUtilities.hashCode(result, this.x); - result = HashUtilities.hashCode(result, this.y); - result = HashUtilities.hashCode(result, this.maxWidth); - result = HashUtilities.hashCode(result, this.maxHeight); - result = HashUtilities.hashCode(result, this.title); - return result; - } - - /** - * Returns a clone of the annotation. - * - * @return A clone. - * - * @throws CloneNotSupportedException if the annotation can't be cloned. - */ - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - -} Deleted: branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/annotations/junit/XYTitleAnnotationTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/annotations/junit/XYTitleAnnotationTests.java 2008-09-02 14:09:21 UTC (rev 1476) +++ branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/annotations/junit/XYTitleAnnotationTests.java 2008-09-03 09:32:38 UTC (rev 1477) @@ -1,207 +0,0 @@ -/* =========================================================== - * JFreeChart : a free chart library for the Java(tm) platform - * =========================================================== - * - * (C) Copyright 2000-2008, 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. - * - * [Java is a trademark or registered trademark of Sun Microsystems, Inc. - * in the United States and other countries.] - * - * --------------------------- - * XYTitleAnnotationTests.java - * --------------------------- - * (C) Copyright 2007, 2008, by Object Refinery Limited. - * - * Original Author: David Gilbert (for Object Refinery Limited); - * Contributor(s): -; - * - * Changes - * ------- - * 30-Apr-2007 : Version 1 (DG); - * 26-Feb-2008 : Added testDrawWithNullInfo() (DG); - * - */ - -package org.jfree.experimental.chart.annotations.junit; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInput; -import java.io.ObjectInputStream; -import java.io.ObjectOutput; -import java.io.ObjectOutputStream; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import org.jfree.chart.JFreeChart; -import org.jfree.chart.axis.NumberAxis; -import org.jfree.chart.plot.XYPlot; -import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; -import org.jfree.chart.title.TextTitle; -import org.jfree.data.xy.DefaultTableXYDataset; -import org.jfree.data.xy.XYSeries; -import org.jfree.experimental.chart.annotations.XYTitleAnnotation; - -/** - * Tests for the {@link XYTitleAnnotation} class. - */ -public class XYTitleAnnotationTests extends TestCase { - - /** - * Returns the tests as a test suite. - * - * @return The test suite. - */ - public static Test suite() { - return new TestSuite(XYTitleAnnotationTests.class); - } - - /** - * Constructs a new set of tests. - * - * @param name the name of the tests. - */ - public XYTitleAnnotationTests(String name) { - super(name); - } - - /** - * Confirm that the equals method can distinguish all the required fields. - */ - public void testEquals() { - TextTitle t = new TextTitle("Title"); - XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); - XYTitleAnnotation a2 = new XYTitleAnnotation(1.0, 2.0, t); - assertTrue(a1.equals(a2)); - - a1 = new XYTitleAnnotation(1.1, 2.0, t); - assertFalse(a1.equals(a2)); - a2 = new XYTitleAnnotation(1.1, 2.0, t); - assertTrue(a1.equals(a2)); - - a1 = new XYTitleAnnotation(1.1, 2.2, t); - assertFalse(a1.equals(a2)); - a2 = new XYTitleAnnotation(1.1, 2.2, t); - assertTrue(a1.equals(a2)); - - TextTitle t2 = new TextTitle("Title 2"); - a1 = new XYTitleAnnotation(1.1, 2.2, t2); - assertFalse(a1.equals(a2)); - a2 = new XYTitleAnnotation(1.1, 2.2, t2); - assertTrue(a1.equals(a2)); - } - - /** - * Two objects that are equal are required to return the same hashCode. - */ - public void testHashCode() { - TextTitle t = new TextTitle("Title"); - XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); - XYTitleAnnotation a2 = new XYTitleAnnotation(1.0, 2.0, t); - assertTrue(a1.equals(a2)); - int h1 = a1.hashCode(); - int h2 = a2.hashCode(); - assertEquals(h1, h2); - } - - /** - * Confirm that cloning works. - */ - public void testCloning() { - TextTitle t = new TextTitle("Title"); - XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); - XYTitleAnnotation a2 = null; - try { - a2 = (XYTitleAnnotation) a1.clone(); - } - catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assertTrue(a1 != a2); - assertTrue(a1.getClass() == a2.getClass()); - assertTrue(a1.equals(a2)); - } - - /** - * Serialize an instance, restore it, and check for equality. - */ - public void testSerialization() { - TextTitle t = new TextTitle("Title"); - XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); - XYTitleAnnotation a2 = null; - try { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - ObjectOutput out = new ObjectOutputStream(buffer); - out.writeObject(a1); - out.close(); - - ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( - buffer.toByteArray())); - a2 = (XYTitleAnnotation) in.readObject(); - in.close(); - } - catch (Exception e) { - e.printStackTrace(); - } - assertEquals(a1, a2); - } - - /** - * Draws the chart with a <code>null</code> info object to make sure that - * no exceptions are thrown. - */ - public void testDrawWithNullInfo() { - boolean success = false; - try { - DefaultTableXYDataset dataset = new DefaultTableXYDataset(); - - XYSeries s1 = new XYSeries("Series 1", true, false); - s1.add(5.0, 5.0); - s1.add(10.0, 15.5); - s1.add(15.0, 9.5); - s1.add(20.0, 7.5); - dataset.addSeries(s1); - - XYSeries s2 = new XYSeries("Series 2", true, false); - s2.add(5.0, 5.0); - s2.add(10.0, 15.5); - s2.add(15.0, 9.5); - s2.add(20.0, 3.5); - dataset.addSeries(s2); - XYPlot plot = new XYPlot(dataset, - new NumberAxis("X"), new NumberAxis("Y"), - new XYLineAndShapeRenderer()); - plot.addAnnotation(new XYTitleAnnotation(5.0, 6.0, - new TextTitle("Hello World!"))); - JFreeChart chart = new JFreeChart(plot); - /* BufferedImage image = */ chart.createBufferedImage(300, 200, - null); - success = true; - } - catch (NullPointerException e) { - e.printStackTrace(); - success = false; - } - assertTrue(success); - } - -} Deleted: branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/demo/XYTitleAnnotationDemo1.java =================================================================== --- branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/demo/XYTitleAnnotationDemo1.java 2008-09-02 14:09:21 UTC (rev 1476) +++ branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/demo/XYTitleAnnotationDemo1.java 2008-09-03 09:32:38 UTC (rev 1477) @@ -1,227 +0,0 @@ -/* =========================================================== - * JFreeChart : a free chart library for the Java(tm) platform - * =========================================================== - * - * (C) Copyright 2000-2007, 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. - * - * [Java is a trademark or registered trademark of Sun Microsystems, Inc. - * in the United States and other countries.] - * - * --------------------------- - * XYTitleAnnotationDemo1.java - * --------------------------- - * (C) Copyright 2007, by Object Refinery Limited and Contributors. - * - * Original Author: David Gilbert (for Object Refinery Limited); - * Contributor(s): ; - * - * Changes - * ------- - * 02-Feb-2007 : Version 1 (DG); - * - */ - -package org.jfree.experimental.chart.demo; - -import java.awt.Color; -import java.awt.Font; -import java.text.SimpleDateFormat; - -import javax.swing.JPanel; - -import org.jfree.chart.ChartFactory; -import org.jfree.chart.ChartPanel; -import org.jfree.chart.JFreeChart; -import org.jfree.chart.axis.DateAxis; -import org.jfree.chart.axis.ValueAxis; -import org.jfree.chart.block.BlockBorder; -import org.jfree.chart.plot.XYPlot; -import org.jfree.chart.renderer.xy.XYItemRenderer; -import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; -import org.jfree.chart.title.LegendTitle; -import org.jfree.data.time.Month; -import org.jfree.data.time.TimeSeries; -import org.jfree.data.time.TimeSeriesCollection; -import org.jfree.data.xy.XYDataset; -import org.jfree.experimental.chart.annotations.XYTitleAnnotation; -import org.jfree.ui.ApplicationFrame; -import org.jfree.ui.RectangleAnchor; -import org.jfree.ui.RectangleEdge; -import org.jfree.ui.RectangleInsets; -import org.jfree.ui.RefineryUtilities; - -/** - * An example of a time series chart. For the most part, default settings are - * used, except that the renderer is modified to show filled shapes (as well as - * lines) at each data point. - */ -public class XYTitleAnnotationDemo1 extends ApplicationFrame { - - /** - * A demonstration application showing how to create a simple time series - * chart. This example uses monthly data. - * - * @param title the frame title. - */ - public XYTitleAnnotationDemo1(String title) { - super(title); - ChartPanel chartPanel = (ChartPanel) createDemoPanel(); - chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); - chartPanel.setMouseZoomable(true, false); - setContentPane(chartPanel); - } - - /** - * Creates a chart. - * - * @param dataset a dataset. - * - * @return A chart. - */ - private static JFreeChart createChart(XYDataset dataset) { - - JFreeChart chart = ChartFactory.createTimeSeriesChart( - "Legal & General Unit Trust Prices", // title - "Date", // x-axis label - "Price Per Unit", // y-axis label - dataset, // data - false, // create legend? - true, // generate tooltips? - false // generate URLs? - ); - - chart.setBackgroundPaint(Color.white); - - XYPlot plot = (XYPlot) chart.getPlot(); - plot.setBackgroundPaint(Color.lightGray); - plot.setDomainGridlinePaint(Color.white); - plot.setRangeGridlinePaint(Color.white); - plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); - plot.setDomainCrosshairVisible(true); - plot.setRangeCrosshairVisible(true); - - LegendTitle lt = new LegendTitle(plot); - lt.setItemFont(new Font("Dialog", Font.PLAIN, 9)); - lt.setBackgroundPaint(new Color(200, 200, 255, 100)); - lt.setFrame(new BlockBorder(Color.white)); - lt.setPosition(RectangleEdge.BOTTOM); - XYTitleAnnotation ta = new XYTitleAnnotation(0.98, 0.02, lt, - RectangleAnchor.BOTTOM_RIGHT); - - ta.setMaxWidth(0.48); - plot.addAnnotation(ta); - - XYItemRenderer r = plot.getRenderer(); - if (r instanceof XYLineAndShapeRenderer) { - XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; - renderer.setBaseShapesVisible(true); - renderer.setBaseShapesFilled(true); - } - - DateAxis axis = (DateAxis) plot.getDomainAxis(); - axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); - - ValueAxis yAxis = plot.getRangeAxis(); - yAxis.setLowerMargin(0.35); - return chart; - - } - - /** - * Creates a dataset, consisting of two series of monthly data. - * - * @return The dataset. - */ - private static XYDataset createDataset() { - - TimeSeries s1 = new TimeSeries("L&G European Index Trust", Month.class); - s1.add(new Month(2, 2001), 181.8); - s1.add(new Month(3, 2001), 167.3); - s1.add(new Month(4, 2001), 153.8); - s1.add(new Month(5, 2001), 167.6); - s1.add(new Month(6, 2001), 158.8); - s1.add(new Month(7, 2001), 148.3); - s1.add(new Month(8, 2001), 153.9); - s1.add(new Month(9, 2001), 142.7); - s1.add(new Month(10, 2001), 123.2); - s1.add(new Month(11, 2001), 131.8); - s1.add(new Month(12, 2001), 139.6); - s1.add(new Month(1, 2002), 142.9); - s1.add(new Month(2, 2002), 138.7); - s1.add(new Month(3, 2002), 137.3); - s1.add(new Month(4, 2002), 143.9); - s1.add(new Month(5, 2002), 139.8); - s1.add(new Month(6, 2002), 137.0); - s1.add(new Month(7, 2002), 132.8); - - TimeSeries s2 = new TimeSeries("L&G UK Index Trust", Month.class); - s2.add(new Month(2, 2001), 129.6); - s2.add(new Month(3, 2001), 123.2); - s2.add(new Month(4, 2001), 117.2); - s2.add(new Month(5, 2001), 124.1); - s2.add(new Month(6, 2001), 122.6); - s2.add(new Month(7, 2001), 119.2); - s2.add(new Month(8, 2001), 116.5); - s2.add(new Month(9, 2001), 112.7); - s2.add(new Month(10, 2001), 101.5); - s2.add(new Month(11, 2001), 106.1); - s2.add(new Month(12, 2001), 110.3); - s2.add(new Month(1, 2002), 111.7); - s2.add(new Month(2, 2002), 111.0); - s2.add(new Month(3, 2002), 109.6); - s2.add(new Month(4, 2002), 113.2); - s2.add(new Month(5, 2002), 111.6); - s2.add(new Month(6, 2002), 108.8); - s2.add(new Month(7, 2002), 101.6); - - TimeSeriesCollection dataset = new TimeSeriesCollection(); - dataset.addSeries(s1); - dataset.addSeries(s2); - - return dataset; - - } - - /** - * Creates a panel for the demo (used by SuperDemo.java). - * - * @return A panel. - */ - public static JPanel createDemoPanel() { - JFreeChart chart = createChart(createDataset()); - return new ChartPanel(chart); - } - - /** - * Starting point for the demonstration application. - * - * @param args ignored. - */ - public static void main(String[] args) { - - XYTitleAnnotationDemo1 demo = new XYTitleAnnotationDemo1( - "XYTitleAnnotationDemo1"); - demo.pack(); - RefineryUtilities.centerFrameOnScreen(demo); - demo.setVisible(true); - - } - -} Deleted: branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/util/XYCoordinateType.java =================================================================== --- branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/util/XYCoordinateType.java 2008-09-02 14:09:21 UTC (rev 1476) +++ branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/util/XYCoordinateType.java 2008-09-03 09:32:38 UTC (rev 1477) @@ -1,132 +0,0 @@ -/* =========================================================== - * JFreeChart : a free chart library for the Java(tm) platform - * =========================================================== - * - * (C) Copyright 2000-2007, 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. - * - * [Java is a trademark or registered trademark of Sun Microsystems, Inc. - * in the United States and other countries.] - * - * --------------------- - * XYCoordinateType.java - * --------------------- - * (C) Copyright 2007, by Object Refinery Limited and Contributors. - * - * Original Author: David Gilbert (for Object Refinery Limited); - * Contributor(s): -; - * - * Changes - * ------- - * 02-Feb-2007 : Version 1 (DG); - * - */ - -package org.jfree.experimental.chart.util; - -import java.io.ObjectStreamException; -import java.io.Serializable; - -/** - * Represents several possible interpretations for an (x, y) coordinate. - */ -public final class XYCoordinateType implements Serializable { - - /** The (x, y) coordinates represent a point in the data space. */ - public static final XYCoordinateType DATA - = new XYCoordinateType("XYCoordinateType.DATA"); - - /** - * The (x, y) coordinates represent a relative position in the data space. - * In this case, the values should be in the range (0.0 to 1.0). - */ - public static final XYCoordinateType RELATIVE - = new XYCoordinateType("XYCoordinateType.RELATIVE"); - - /** - * The (x, y) coordinates represent indices in a dataset. - * In this case, the values should be in the range (0.0 to 1.0). - */ - public static final XYCoordinateType INDEX - = new XYCoordinateType("XYCoordinateType.INDEX"); - - /** The name. */ - private String name; - - /** - * Private constructor. - * - * @param name the name. - */ - private XYCoordinateType(String name) { - this.name = name; - } - - /** - * Returns a string representing the object. - * - * @return The string. - */ - public String toString() { - return this.name; - } - - /** - * Returns <code>true</code> if this object is equal to the specified - * object, and <code>false</code> otherwise. - * - * @param obj the other object. - * - * @return A boolean. - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof XYCoordinateType)) { - return false; - } - XYCoordinateType order = (XYCoordinateType) obj; - if (!this.name.equals(order.toString())) { - return false; - } - return true; - } - - /** - * Ensures that serialization returns the unique instances. - * - * @return The object. - * - * @throws ObjectStreamException if there is a problem. - */ - private Object readResolve() throws ObjectStreamException { - if (this.equals(XYCoordinateType.DATA)) { - return XYCoordinateType.DATA; - } - else if (this.equals(XYCoordinateType.RELATIVE)) { - return XYCoordinateType.RELATIVE; - } - else if (this.equals(XYCoordinateType.INDEX)) { - return XYCoordinateType.INDEX; - } - return null; - } - -} Copied: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/annotations/XYTitleAnnotation.java (from rev 942, branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/annotations/XYTitleAnnotation.java) =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/annotations/XYTitleAnnotation.java (rev 0) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/annotations/XYTitleAnnotation.java 2008-09-03 09:32:38 UTC (rev 1477) @@ -0,0 +1,394 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2008, 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * ---------------------- + * XYTitleAnnotation.java + * ---------------------- + * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Andrew Mickish; + * + * Changes: + * -------- + * 02-Feb-2007 : Version 1 (DG); + * 30-Apr-2007 : Fixed equals() method (DG); + * 26-Feb-2008 : Fixed NullPointerException when drawing chart with a null + * ChartRenderingInfo - see patch 1901599 by Andrew Mickish (DG); + * 03-Sep-2008 : Moved from experimental to main (DG); + * + */ + +package org.jfree.chart.annotations; + +import java.awt.Graphics2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.axis.AxisLocation; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.block.BlockParams; +import org.jfree.chart.block.EntityBlockResult; +import org.jfree.chart.block.RectangleConstraint; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.title.Title; +import org.jfree.chart.util.XYCoordinateType; +import org.jfree.data.Range; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.Size2D; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * An annotation that allows any {@link Title} to be placed at a location on + * an {@link XYPlot}. + * + * @since 1.0.11 + */ +public class XYTitleAnnotation extends AbstractXYAnnotation + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -4364694501921559958L; + + /** The coordinate type. */ + private XYCoordinateType coordinateType; + + /** The x-coordinate (in data space). */ + private double x; + + /** The y-coordinate (in data space). */ + private double y; + + /** The maximum width. */ + private double maxWidth; + + /** The maximum height. */ + private double maxHeight; + + /** The title. */ + private Title title; + + /** + * The title anchor point. + */ + private RectangleAnchor anchor; + + /** + * Creates a new annotation to be displayed at the specified (x, y) + * location. + * + * @param x the x-coordinate (in data space). + * @param y the y-coordinate (in data space). + * @param title the title (<code>null</code> not permitted). + */ + public XYTitleAnnotation(double x, double y, Title title) { + this(x, y, title, RectangleAnchor.CENTER); + } + + /** + * Creates a new annotation to be displayed at the specified (x, y) + * location. + * + * @param x the x-coordinate (in data space). + * @param y the y-coordinate (in data space). + * @param title the title (<code>null</code> not permitted). + * @param anchor the title anchor (<code>null</code> not permitted). + */ + public XYTitleAnnotation(double x, double y, Title title, + RectangleAnchor anchor) { + if (title == null) { + throw new IllegalArgumentException("Null 'title' argument."); + } + if (anchor == null) { + throw new IllegalArgumentException("Null 'anchor' argument."); + } + this.coordinateType = XYCoordinateType.RELATIVE; + this.x = x; + this.y = y; + this.maxWidth = 0.0; + this.maxHeight = 0.0; + this.title = title; + this.anchor = anchor; + } + + /** + * Returns the coordinate type (set in the constructor). + * + * @return The coordinate type (never <code>null</code>). + */ + public XYCoordinateType getCoordinateType() { + return this.coordinateType; + } + + /** + * Returns the x-coordinate for the annotation. + * + * @return The x-coordinate. + */ + public double getX() { + return this.x; + } + + /** + * Returns the y-coordinate for the annotation. + * + * @return The y-coordinate. + */ + public double getY() { + return this.y; + } + + /** + * Returns the title for the annotation. + * + * @return The title. + */ + public Title getTitle() { + return this.title; + } + + /** + * Returns the title anchor for the annotation. + * + * @return The title anchor. + */ + public RectangleAnchor getTitleAnchor() { + return this.anchor; + } + + /** + * Returns the maximum width. + * + * @return The maximum width. + */ + public double getMaxWidth() { + return this.maxWidth; + } + + /** + * Sets the maximum width. + * + * @param max the maximum width (0.0 or less means no maximum). + */ + public void setMaxWidth(double max) { + this.maxWidth = max; + } + + /** + * Returns the maximum height. + * + * @return The maximum height. + */ + public double getMaxHeight() { + return this.maxHeight; + } + + /** + * Sets the maximum height. + * + * @param max the maximum height. + */ + public void setMaxHeight(double max) { + this.maxHeight = max; + } + + /** + * Draws the annotation. This method is called by the drawing code in the + * {@link XYPlot} class, you don't normally need to call this method + * directly. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param dataArea the data area. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param rendererIndex the renderer index. + * @param info if supplied, this info object will be populated with + * entity information. + */ + public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, + ValueAxis domainAxis, ValueAxis rangeAxis, + int rendererIndex, + PlotRenderingInfo info) { + + PlotOrientation orientation = plot.getOrientation(); + AxisLocation domainAxisLocation = plot.getDomainAxisLocation(); + AxisLocation rangeAxisLocation = plot.getRangeAxisLocation(); + RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( + domainAxisLocation, orientation); + RectangleEdge rangeEdge = Plot.resolveRangeAxisLocation( + rangeAxisLocation, orientation); + Range xRange = domainAxis.getRange(); + Range yRange = rangeAxis.getRange(); + double anchorX = 0.0; + double anchorY = 0.0; + if (this.coordinateType == XYCoordinateType.RELATIVE) { + anchorX = xRange.getLowerBound() + (this.x * xRange.getLength()); + anchorY = yRange.getLowerBound() + (this.y * yRange.getLength()); + } + else { + anchorX = domainAxis.valueToJava2D(this.x, dataArea, domainEdge); + anchorY = rangeAxis.valueToJava2D(this.y, dataArea, rangeEdge); + } + + float j2DX = (float) domainAxis.valueToJava2D(anchorX, dataArea, + domainEdge); + float j2DY = (float) rangeAxis.valueToJava2D(anchorY, dataArea, + rangeEdge); + float xx = 0.0f; + float yy = 0.0f; + if (orientation == PlotOrientation.HORIZONTAL) { + xx = j2DY; + yy = j2DX; + } + else if (orientation == PlotOrientation.VERTICAL) { + xx = j2DX; + yy = j2DY; + } + + double maxW = dataArea.getWidth(); + double maxH = dataArea.getHeight(); + if (this.coordinateType == XYCoordinateType.RELATIVE) { + if (this.maxWidth > 0.0) { + maxW = maxW * this.maxWidth; + } + if (this.maxHeight > 0.0) { + maxH = maxH * this.maxHeight; + } + } + if (this.coordinateType == XYCoordinateType.DATA) { + maxW = this.maxWidth; + maxH = this.maxHeight; + } + RectangleConstraint rc = new RectangleConstraint( + new Range(0, maxW), new Range(0, maxH)); + + Size2D size = this.title.arrange(g2, rc); + Rectangle2D titleRect = new Rectangle2D.Double(0, 0, size.width, + size.height); + Point2D anchorPoint = RectangleAnchor.coordinates(titleRect, + this.anchor); + xx = xx - (float) anchorPoint.getX(); + yy = yy - (float) anchorPoint.getY(); + titleRect.setRect(xx, yy, titleRect.getWidth(), titleRect.getHeight()); + BlockParams p = new BlockParams(); + if (info != null) { + if (info.getOwner().getEntityCollection() != null) { + p.setGenerateEntities(true); + } + } + Object result = this.title.draw(g2, titleRect, p); + if (info != null) { + if (result instanceof EntityBlockResult) { + EntityBlockResult ebr = (EntityBlockResult) result; + info.getOwner().getEntityCollection().addAll( + ebr.getEntityCollection()); + } + String toolTip = getToolTipText(); + String url = getURL(); + if (toolTip != null || url != null) { + addEntity(info, new Rectangle2D.Float(xx, yy, + (float) size.width, (float) size.height), + rendererIndex, toolTip, url); + } + } + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the object (<code>null</code> permitted). + * + * @return A boolean. + */ + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYTitleAnnotation)) { + return false; + } + XYTitleAnnotation that = (XYTitleAnnotation) obj; + if (this.coordinateType != that.coordinateType) { + return false; + } + if (this.x != that.x) { + return false; + } + if (this.y != that.y) { + return false; + } + if (this.maxWidth != that.maxWidth) { + return false; + } + if (this.maxHeight != that.maxHeight) { + return false; + } + if (!ObjectUtilities.equal(this.title, that.title)) { + return false; + } + if (!this.anchor.equals(that.anchor)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this object. + * + * @return A hash code. + */ + public int hashCode() { + int result = 193; + result = HashUtilities.hashCode(result, this.anchor); + result = HashUtilities.hashCode(result, this.coordinateType); + result = HashUtilities.hashCode(result, this.x); + result = HashUtilities.hashCode(result, this.y); + result = HashUtilities.hashCode(result, this.maxWidth); + result = HashUtilities.hashCode(result, this.maxHeight); + result = HashUtilities.hashCode(result, this.title); + return result; + } + + /** + * Returns a clone of the annotation. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the annotation can't be cloned. + */ + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} Property changes on: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/annotations/XYTitleAnnotation.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/XYCoordinateType.java (from rev 830, branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/util/XYCoordinateType.java) =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/XYCoordinateType.java (rev 0) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/XYCoordinateType.java 2008-09-03 09:32:38 UTC (rev 1477) @@ -0,0 +1,135 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2008, 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * --------------------- + * XYCoordinateType.java + * --------------------- + * (C) Copyright 2007, 2008 by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 02-Feb-2007 : Version 1 (DG); + * 03-Sep-2008 : Moved from experimental to main (DG); + * + */ + +package org.jfree.chart.util; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Represents several possible interpretations for an (x, y) coordinate. + * + * @since 1.0.11 + */ +public final class XYCoordinateType implements Serializable { + + /** The (x, y) coordinates represent a point in the data space. */ + public static final XYCoordinateType DATA + = new XYCoordinateType("XYCoordinateType.DATA"); + + /** + * The (x, y) coordinates represent a relative position in the data space. + * In this case, the values should be in the range (0.0 to 1.0). + */ + public static final XYCoordinateType RELATIVE + = new XYCoordinateType("XYCoordinateType.RELATIVE"); + + /** + * The (x, y) coordinates represent indices in a dataset. + * In this case, the values should be in the range (0.0 to 1.0). + */ + public static final XYCoordinateType INDEX + = new XYCoordinateType("XYCoordinateType.INDEX"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private XYCoordinateType(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + public String toString() { + return this.name; + } + + /** + * Returns <code>true</code> if this object is equal to the specified + * object, and <code>false</code> otherwise. + * + * @param obj the other object. + * + * @return A boolean. + */ + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof XYCoordinateType)) { + return false; + } + XYCoordinateType order = (XYCoordinateType) obj; + if (!this.name.equals(order.toString())) { + return false; + } + return true; + } + + /** + * Ensures that serialization returns the unique instances. + * + * @return The object. + * + * @throws ObjectStreamException if there is a problem. + */ + private Object readResolve() throws ObjectStreamException { + if (this.equals(XYCoordinateType.DATA)) { + return XYCoordinateType.DATA; + } + else if (this.equals(XYCoordinateType.RELATIVE)) { + return XYCoordinateType.RELATIVE; + } + else if (this.equals(XYCoordinateType.INDEX)) { + return XYCoordinateType.INDEX; + } + return null; + } + +} Property changes on: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/XYCoordinateType.java ___________________________________________________________________ Added: svn:mergeinfo + Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/annotations/junit/AnnotationsPackageTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/annotations/junit/AnnotationsPackageTests.java 2008-09-02 14:09:21 UTC (rev 1476) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/annotations/junit/AnnotationsPackageTests.java 2008-09-03 09:32:38 UTC (rev 1477) @@ -74,6 +74,7 @@ suite.addTestSuite(XYPolygonAnnotationTests.class); suite.addTestSuite(XYShapeAnnotationTests.class); suite.addTestSuite(XYTextAnnotationTests.class); + suite.addTestSuite(XYTitleAnnotationTests.class); return suite; } Copied: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/annotations/junit/XYTitleAnnotationTests.java (from rev 905, branches/jfreechart-1.0.x-branch/experimental/org/jfree/experimental/chart/annotations/junit/XYTitleAnnotationTests.java) =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/annotations/junit/XYTitleAnnotationTests.java (rev 0) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/annotations/junit/XYTitleAnnotationTests.java 2008-09-03 09:32:38 UTC (rev 1477) @@ -0,0 +1,207 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2008, 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * --------------------------- + * XYTitleAnnotationTests.java + * --------------------------- + * (C) Copyright 2007, 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Apr-2007 : Version 1 (DG); + * 26-Feb-2008 : Added testDrawWithNullInfo() (DG); + * + */ + +package org.jfree.chart.annotations.junit; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInput; +import java.io.ObjectInputStream; +import java.io.ObjectOutput; +import java.io.ObjectOutputStream; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.annotations.XYTitleAnnotation; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; +import org.jfree.chart.title.TextTitle; +import org.jfree.data.xy.DefaultTableXYDataset; +import org.jfree.data.xy.XYSeries; + +/** + * Tests for the {@link XYTitleAnnotation} class. + */ +public class XYTitleAnnotationTests extends TestCase { + + /** + * Returns the tests as a test suite. + * + * @return The test suite. + */ + public static Test suite() { + return new TestSuite(XYTitleAnnotationTests.class); + } + + /** + * Constructs a new set of tests. + * + * @param name the name of the tests. + */ + public XYTitleAnnotationTests(String name) { + super(name); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + public void testEquals() { + TextTitle t = new TextTitle("Title"); + XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); + XYTitleAnnotation a2 = new XYTitleAnnotation(1.0, 2.0, t... [truncated message content] |
From: <mu...@us...> - 2008-09-10 07:07:27
|
Revision: 1593 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1593&view=rev Author: mungady Date: 2008-09-10 07:07:25 +0000 (Wed, 10 Sep 2008) Log Message: ----------- 2008-09-10 David Gilbert <dav...@ob...> * source/org/jfree/chart/StandardChartTheme.java (applyToCategoryAxis): Check for SubCategoryAxis and set sublabel font and paint. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/StandardChartTheme.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-05 07:22:55 UTC (rev 1592) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-10 07:07:25 UTC (rev 1593) @@ -1,3 +1,9 @@ +2008-09-10 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/StandardChartTheme.java + (applyToCategoryAxis): Check for SubCategoryAxis and set sublabel font and + paint. + 2008-09-03 David Gilbert <dav...@ob...> * experimental/org/jfree/experimental/chart/annotations/XYTitleAnnotation.java: Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/StandardChartTheme.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/StandardChartTheme.java 2008-09-05 07:22:55 UTC (rev 1592) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/StandardChartTheme.java 2008-09-10 07:07:25 UTC (rev 1593) @@ -55,6 +55,7 @@ import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.PeriodAxis; import org.jfree.chart.axis.PeriodAxisLabelInfo; +import org.jfree.chart.axis.SubCategoryAxis; import org.jfree.chart.axis.SymbolAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.block.Block; @@ -1410,6 +1411,11 @@ axis.setLabelPaint(this.axisLabelPaint); axis.setTickLabelFont(this.regularFont); axis.setTickLabelPaint(this.tickLabelPaint); + if (axis instanceof SubCategoryAxis) { + SubCategoryAxis sca = (SubCategoryAxis) axis; + sca.setSubLabelFont(this.regularFont); + sca.setSubLabelPaint(this.tickLabelPaint); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-16 04:57:00
|
Revision: 1595 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1595&view=rev Author: mungady Date: 2008-09-16 11:56:55 +0000 (Tue, 16 Sep 2008) Log Message: ----------- 2008-09-16 David Gilbert <dav...@ob...> * source/org/jfree/data/time/Day.java (Day(Date)): Use TimeZone.getDefault(), * source/org/jfree/data/time/Hour.java (Hour(Date)): Likewise, * source/org/jfree/data/time/Millisecond.java (Millisecond(Date)): Likewise, * source/org/jfree/data/time/Minute.java (Minute(Date)): Likewise, * source/org/jfree/data/time/Month.java (Month(Date)): Likewise, (parseMonth): Updated for changes in Year range, * source/org/jfree/data/time/Quarter.java (Quarter(Date)): Use TimeZone.getDefault(), * source/org/jfree/data/time/RegularTimePeriod.java (DEFAULT_TIME_ZONE): Deprecated, * source/org/jfree/data/time/Second.java (Second(Date)): Use TimeZone.getDefault(), * source/org/jfree/data/time/Week.java (Week(Date)): Likewise, * source/org/jfree/data/time/Year.java (MINIMUM_YEAR): New field, (MAXIMUM_YEAR): Likewise, (Year(int)): Updated range check, (Year(Date)): Use TimeZone.getDefault(), (previous): Updated for new range bounds, (next): Likewise, (equals): Cleaned up, * tests/org/jfree/data/time/junit/YearTests.java (testEquals): Extended, (test1900Previous): Modified and enamed testMinus9999Previous, (testParseYear): Updated. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Day.java branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Hour.java branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Millisecond.java branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Minute.java branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Month.java branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Quarter.java branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/RegularTimePeriod.java branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Second.java branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Week.java branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Year.java branches/jfreechart-1.0.x-branch/tests/org/jfree/data/time/junit/YearTests.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-10 10:28:03 UTC (rev 1594) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-16 11:56:55 UTC (rev 1595) @@ -1,3 +1,37 @@ +2008-09-16 David Gilbert <dav...@ob...> + + * source/org/jfree/data/time/Day.java + (Day(Date)): Use TimeZone.getDefault(), + * source/org/jfree/data/time/Hour.java + (Hour(Date)): Likewise, + * source/org/jfree/data/time/Millisecond.java + (Millisecond(Date)): Likewise, + * source/org/jfree/data/time/Minute.java + (Minute(Date)): Likewise, + * source/org/jfree/data/time/Month.java + (Month(Date)): Likewise, + (parseMonth): Updated for changes in Year range, + * source/org/jfree/data/time/Quarter.java + (Quarter(Date)): Use TimeZone.getDefault(), + * source/org/jfree/data/time/RegularTimePeriod.java + (DEFAULT_TIME_ZONE): Deprecated, + * source/org/jfree/data/time/Second.java + (Second(Date)): Use TimeZone.getDefault(), + * source/org/jfree/data/time/Week.java + (Week(Date)): Likewise, + * source/org/jfree/data/time/Year.java + (MINIMUM_YEAR): New field, + (MAXIMUM_YEAR): Likewise, + (Year(int)): Updated range check, + (Year(Date)): Use TimeZone.getDefault(), + (previous): Updated for new range bounds, + (next): Likewise, + (equals): Cleaned up, + * tests/org/jfree/data/time/junit/YearTests.java + (testEquals): Extended, + (test1900Previous): Modified and enamed testMinus9999Previous, + (testParseYear): Updated. + 2008-09-10 David Gilbert <dav...@ob...> * source/org/jfree/chart/StandardChartTheme.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Day.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Day.java 2008-09-10 10:28:03 UTC (rev 1594) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Day.java 2008-09-16 11:56:55 UTC (rev 1595) @@ -56,6 +56,7 @@ * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * */ @@ -144,10 +145,12 @@ * default time zone. * * @param time the time (<code>null</code> not permitted). + * + * @see #Day(Date, TimeZone) */ public Day(Date time) { // defer argument checking... - this(time, RegularTimePeriod.DEFAULT_TIME_ZONE); + this(time, TimeZone.getDefault()); } /** Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Hour.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Hour.java 2008-09-10 10:28:03 UTC (rev 1594) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Hour.java 2008-09-16 11:56:55 UTC (rev 1595) @@ -57,6 +57,7 @@ * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); * 04-Apr-2007 : In Hour(Date, TimeZone), peg milliseconds using specified * time zone (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * */ @@ -129,24 +130,27 @@ } /** - * Constructs a new Hour, based on the supplied date/time. + * Constructs a new instance, based on the supplied date/time and + * the default time zone. * * @param time the date-time (<code>null</code> not permitted). + * + * @see #Hour(Date, TimeZone) */ public Hour(Date time) { // defer argument checking... - this(time, RegularTimePeriod.DEFAULT_TIME_ZONE); + this(time, TimeZone.getDefault()); } /** - * Constructs a new Hour, based on the supplied date/time evaluated in the - * specified time zone. + * Constructs a new instance, based on the supplied date/time evaluated + * in the specified time zone. * * @param time the date-time (<code>null</code> not permitted). * @param zone the time zone (<code>null</code> not permitted). */ public Hour(Date time, TimeZone zone) { - // FIXME: need a locale as well as a timezone + // FIXME: need a locale as well as a timezone if (time == null) { throw new IllegalArgumentException("Null 'time' argument."); } Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Millisecond.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Millisecond.java 2008-09-10 10:28:03 UTC (rev 1594) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Millisecond.java 2008-09-16 11:56:55 UTC (rev 1595) @@ -52,6 +52,7 @@ * 06-Jun-2008 : Added handling for general RegularTimePeriod in compareTo() * method: * see http://www.jfree.org/phpBB2/viewtopic.php?t=24805 (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * */ @@ -138,12 +139,14 @@ } /** - * Constructs a millisecond. + * Constructs a new millisecond using the default time zone. * * @param time the time. + * + * @see #Millisecond(Date, TimeZone) */ public Millisecond(Date time) { - this(time, RegularTimePeriod.DEFAULT_TIME_ZONE); + this(time, TimeZone.getDefault()); } /** @@ -153,7 +156,7 @@ * @param zone the time zone. */ public Millisecond(Date time, TimeZone zone) { - // FIXME: need a locale as well as a timezone + // FIXME: need a locale as well as a timezone Calendar calendar = Calendar.getInstance(zone); calendar.setTime(time); this.millisecond = calendar.get(Calendar.MILLISECOND); Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Minute.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Minute.java 2008-09-10 10:28:03 UTC (rev 1594) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Minute.java 2008-09-16 11:56:55 UTC (rev 1595) @@ -58,6 +58,7 @@ * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); * 11-Dec-2006 : Fix for previous() - bug 1611872 (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * */ @@ -122,13 +123,16 @@ } /** - * Constructs a new Minute, based on the supplied date/time. + * Constructs a new instance, based on the supplied date/time and + * the default time zone. * * @param time the time (<code>null</code> not permitted). + * + * @see #Minute(Date, TimeZone) */ public Minute(Date time) { // defer argument checking - this(time, RegularTimePeriod.DEFAULT_TIME_ZONE); + this(time, TimeZone.getDefault()); } /** @@ -138,7 +142,7 @@ * @param zone the time zone (<code>null</code> not permitted). */ public Minute(Date time, TimeZone zone) { - // FIXME: need a locale as well as a timezone + // FIXME: need a locale as well as a timezone if (time == null) { throw new IllegalArgumentException("Null 'time' argument."); } Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Month.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Month.java 2008-09-10 10:28:03 UTC (rev 1594) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Month.java 2008-09-16 11:56:55 UTC (rev 1595) @@ -56,6 +56,8 @@ * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); * 04-Apr-2007 : Fixed bug in Month(Date, TimeZone) constructor (CB); * 01-Sep-2008 : Added clarification for previous() and next() methods (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE, and updated parsing to handle + * extended range in Year (DG); * */ @@ -131,10 +133,12 @@ * Constructs a new <code>Month</code> instance, based on a date/time and * the default time zone. * - * @param time the date/time. + * @param time the date/time (<code>null</code> not permitted). + * + * @see #Month(Date, TimeZone) */ public Month(Date time) { - this(time, RegularTimePeriod.DEFAULT_TIME_ZONE); + this(time, TimeZone.getDefault()); } /** @@ -146,7 +150,7 @@ * @param zone the time zone (<code>null</code> not permitted). */ public Month(Date time, TimeZone zone) { - // FIXME: need a locale as well as a timezone + // FIXME: need a locale as well as a timezone Calendar calendar = Calendar.getInstance(zone); calendar.setTime(time); this.month = calendar.get(Calendar.MONTH) + 1; @@ -415,80 +419,80 @@ } /** - * Parses the string argument as a month. - * <P> - * This method is required to accept the format "YYYY-MM". It will also - * accept "MM-YYYY". Anything else, at the moment, is a bonus. + * Parses the string argument as a month. This method is required to + * accept the format "YYYY-MM". It will also accept "MM-YYYY". Anything + * else, at the moment, is a bonus. * - * @param s the string to parse. + * @param s the string to parse (<code>null</code> permitted). * * @return <code>null</code> if the string is not parseable, the month * otherwise. */ public static Month parseMonth(String s) { - Month result = null; - if (s != null) { - - // trim whitespace from either end of the string - s = s.trim(); - - int i = Month.findSeparator(s); - if (i != -1) { - String s1 = s.substring(0, i).trim(); - String s2 = s.substring(i + 1, s.length()).trim(); - - Year year = Month.evaluateAsYear(s1); - int month; - if (year != null) { - month = SerialDate.stringToMonthCode(s2); - if (month == -1) { - throw new TimePeriodFormatException( - "Can't evaluate the month." - ); - } - result = new Month(month, year); + if (s == null) { + return result; + } + // trim whitespace from either end of the string + s = s.trim(); + int i = Month.findSeparator(s); + String s1, s2; + boolean yearIsFirst; + // if there is no separator, we assume the first four characters + // are YYYY + if (i == -1) { + yearIsFirst = true; + s1 = s.substring(0, 5); + s2 = s.substring(5); + } + else { + s1 = s.substring(0, i).trim(); + s2 = s.substring(i + 1, s.length()).trim(); + // now it is trickier to determine if the month or year is first + Year y1 = Month.evaluateAsYear(s1); + if (y1 == null) { + yearIsFirst = false; + } + else { + Year y2 = Month.evaluateAsYear(s2); + if (y2 == null) { + yearIsFirst = true; } else { - year = Month.evaluateAsYear(s2); - if (year != null) { - month = SerialDate.stringToMonthCode(s1); - if (month == -1) { - throw new TimePeriodFormatException( - "Can't evaluate the month." - ); - } - result = new Month(month, year); - } - else { - throw new TimePeriodFormatException( - "Can't evaluate the year." - ); - } + yearIsFirst = (s1.length() > s2.length()); } - } - else { - throw new TimePeriodFormatException( - "Could not find separator." - ); - } - } + Year year; + int month; + if (yearIsFirst) { + year = Month.evaluateAsYear(s1); + month = SerialDate.stringToMonthCode(s2); + } + else { + year = Month.evaluateAsYear(s2); + month = SerialDate.stringToMonthCode(s1); + } + if (month == -1) { + throw new TimePeriodFormatException("Can't evaluate the month."); + } + if (year == null) { + throw new TimePeriodFormatException("Can't evaluate the year."); + } + result = new Month(month, year); return result; - } /** - * Finds the first occurrence of ' ', '-', ',' or '.' + * Finds the first occurrence of '-', or if that character is not found, + * the first occurrence of ',', or the first occurrence of ' ', , ',' or '.' * * @param s the string to parse. * - * @return <code>-1</code> if none of the characters where found, the - * position of the first occurence otherwise. + * @return The position of the separator character, or <code>-1</code> if + * none of the characters were found. */ private static int findSeparator(String s) { - int result = s.indexOf('-'); if (result == -1) { result = s.indexOf(','); @@ -503,8 +507,8 @@ } /** - * Creates a year from a string, or returns null (format exceptions - * suppressed). + * Creates a year from a string, or returns <code>null</code> (format + * exceptions suppressed). * * @param s the string to parse. * @@ -512,7 +516,6 @@ * otherwise. */ private static Year evaluateAsYear(String s) { - Year result = null; try { result = Year.parseYear(s); @@ -521,7 +524,6 @@ // suppress } return result; - } } Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Quarter.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Quarter.java 2008-09-10 10:28:03 UTC (rev 1594) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Quarter.java 2008-09-16 11:56:55 UTC (rev 1595) @@ -53,6 +53,7 @@ * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * */ @@ -144,12 +145,15 @@ } /** - * Constructs a new Quarter, based on a date/time and the default time zone. + * Constructs a new instance, based on a date/time and the default time + * zone. * - * @param time the date/time. + * @param time the date/time (<code>null</code> not permitted). + * + * @see #Quarter(Date, TimeZone) */ public Quarter(Date time) { - this(time, RegularTimePeriod.DEFAULT_TIME_ZONE); + this(time, TimeZone.getDefault()); } /** @@ -159,7 +163,7 @@ * @param zone the zone (<code>null</code> not permitted). */ public Quarter(Date time, TimeZone zone) { - // FIXME: need a locale as well as a timezone + // FIXME: need a locale as well as a timezone Calendar calendar = Calendar.getInstance(zone); calendar.setTime(time); int month = calendar.get(Calendar.MONTH) + 1; Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/RegularTimePeriod.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/RegularTimePeriod.java 2008-09-10 10:28:03 UTC (rev 1594) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/RegularTimePeriod.java 2008-09-16 11:56:55 UTC (rev 1595) @@ -47,6 +47,7 @@ * ------------- JFREECHART 1.0.x --------------------------------------------- * 06-Oct-2006 : Deprecated the WORKING_CALENDAR field and several methods, * added new peg() method (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * */ @@ -157,6 +158,9 @@ /** * The default time zone. + * + * @deprecated As of 1.0.11, we discourage the use of this field - use + * {@link TimeZone#getDefault()} instead. */ public static final TimeZone DEFAULT_TIME_ZONE = TimeZone.getDefault(); @@ -165,8 +169,8 @@ * * @deprecated This was a bad idea, don't use it! */ - public static final Calendar WORKING_CALENDAR - = Calendar.getInstance(DEFAULT_TIME_ZONE); + public static final Calendar WORKING_CALENDAR = Calendar.getInstance( + DEFAULT_TIME_ZONE); /** * Recalculates the start date/time and end date/time for this time period Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Second.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Second.java 2008-09-10 10:28:03 UTC (rev 1594) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Second.java 2008-09-16 11:56:55 UTC (rev 1595) @@ -53,6 +53,7 @@ * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * */ @@ -136,12 +137,15 @@ } /** - * Constructs a second. + * Constructs a new instance from the specified date/time and the default + * time zone.. * - * @param time the time. + * @param time the time (<code>null</code> not permitted). + * + * @see #Second(Date, TimeZone) */ public Second(Date time) { - this(time, RegularTimePeriod.DEFAULT_TIME_ZONE); + this(time, TimeZone.getDefault()); } /** @@ -150,8 +154,8 @@ * @param time the instant in time. * @param zone the time zone. */ - public Second(Date time, final TimeZone zone) { - // FIXME: need a locale as well as a time zone + public Second(Date time, TimeZone zone) { + // FIXME: need a locale as well as a time zone Calendar calendar = Calendar.getInstance(zone); calendar.setTime(time); this.second = (byte) calendar.get(Calendar.SECOND); Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Week.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Week.java 2008-09-10 10:28:03 UTC (rev 1594) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Week.java 2008-09-16 11:56:55 UTC (rev 1595) @@ -66,6 +66,7 @@ * 28-Aug-2007 : Added new constructor to avoid problem in creating new * instances (DG); * 19-Dec-2007 : Fixed bug in deprecated constructor (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); * */ @@ -152,13 +153,17 @@ /** * Creates a time period for the week in which the specified date/time - * falls. + * falls, using the default time zone and locale (the locale can affect the + * day-of-the-week that marks the beginning of the week, as well as the + * minimal number of days in the first week of the year). * * @param time the time (<code>null</code> not permitted). + * + * @see #Week(Date, TimeZone, Locale) */ public Week(Date time) { // defer argument checking... - this(time, RegularTimePeriod.DEFAULT_TIME_ZONE, Locale.getDefault()); + this(time, TimeZone.getDefault(), Locale.getDefault()); } /** Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Year.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Year.java 2008-09-10 10:28:03 UTC (rev 1594) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/time/Year.java 2008-09-16 11:56:55 UTC (rev 1595) @@ -53,6 +53,8 @@ * ------------- JFREECHART 1.0.x --------------------------------------------- * 05-Oct-2006 : Updated API docs (DG); * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); + * 16-Sep-2008 : Extended range of valid years, and deprecated + * DEFAULT_TIME_ZONE (DG); * */ @@ -63,14 +65,26 @@ import java.util.Date; import java.util.TimeZone; -import org.jfree.date.SerialDate; - /** - * Represents a year in the range 1900 to 9999. This class is immutable, which - * is a requirement for all {@link RegularTimePeriod} subclasses. + * Represents a year in the range -9999 to 9999. This class is immutable, + * which is a requirement for all {@link RegularTimePeriod} subclasses. */ public class Year extends RegularTimePeriod implements Serializable { + /** + * The minimum year value. + * + * @since 1.0.11 + */ + public static final int MINIMUM_YEAR = -9999; + + /** + * The maximum year value. + * + * @since 1.0.11 + */ + public static final int MAXIMUM_YEAR = 9999; + /** For serialization. */ private static final long serialVersionUID = -7659990929736074836L; @@ -96,9 +110,7 @@ * @param year the year. */ public Year(int year) { - if ((year < SerialDate.MINIMUM_YEAR_SUPPORTED) - || (year > SerialDate.MAXIMUM_YEAR_SUPPORTED)) { - + if ((year < Year.MINIMUM_YEAR) || (year > Year.MAXIMUM_YEAR)) { throw new IllegalArgumentException( "Year constructor: year (" + year + ") outside valid range."); } @@ -111,9 +123,11 @@ * using the default time zone. * * @param time the time (<code>null</code> not permitted). + * + * @see #Year(Date, TimeZone) */ public Year(Date time) { - this(time, RegularTimePeriod.DEFAULT_TIME_ZONE); + this(time, TimeZone.getDefault()); } /** @@ -123,7 +137,7 @@ * @param zone the time zone. */ public Year(Date time, TimeZone zone) { - // FIXME: needs a locale as well as a timezone + // FIXME: needs a locale as well as a timezone Calendar calendar = Calendar.getInstance(zone); calendar.setTime(time); this.year = (short) calendar.get(Calendar.YEAR); @@ -184,10 +198,10 @@ * Returns the year preceding this one. * * @return The year preceding this one (or <code>null</code> if the - * current year is 1900). + * current year is -9999). */ public RegularTimePeriod previous() { - if (this.year > SerialDate.MINIMUM_YEAR_SUPPORTED) { + if (this.year > Year.MINIMUM_YEAR) { return new Year(this.year - 1); } else { @@ -202,7 +216,7 @@ * year is 9999). */ public RegularTimePeriod next() { - if (this.year < SerialDate.MAXIMUM_YEAR_SUPPORTED) { + if (this.year < Year.MAXIMUM_YEAR) { return new Year(this.year + 1); } else { @@ -265,24 +279,20 @@ * instance representing the same year as this object. In all other cases, * returns <code>false</code>. * - * @param object the object (<code>null</code> permitted). + * @param obj the object (<code>null</code> permitted). * * @return <code>true</code> if the year of this and the object are the * same. */ - public boolean equals(Object object) { - if (object != null) { - if (object instanceof Year) { - Year target = (Year) object; - return (this.year == target.getYear()); - } - else { - return false; - } + public boolean equals(Object obj) { + if (obj == this) { + return true; } - else { + if (!(obj instanceof Year)) { return false; } + Year that = (Year) obj; + return (this.year == that.year); } /** Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/data/time/junit/YearTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/data/time/junit/YearTests.java 2008-09-10 10:28:03 UTC (rev 1594) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/data/time/junit/YearTests.java 2008-09-16 11:56:55 UTC (rev 1595) @@ -113,6 +113,11 @@ Year year1 = new Year(2002); Year year2 = new Year(2002); assertTrue(year1.equals(year2)); + + year1 = new Year(1999); + assertFalse(year1.equals(year2)); + year2 = new Year(1999); + assertTrue(year1.equals(year2)); } /** @@ -157,8 +162,8 @@ * Set up a year equal to 1900. Request the previous year, it should be * null. */ - public void test1900Previous() { - Year current = new Year(1900); + public void testMinuss9999Previous() { + Year current = new Year(-9999); Year previous = (Year) current.previous(); assertNull(previous); } @@ -223,7 +228,7 @@ catch (TimePeriodFormatException e) { year = new Year(1900); } - assertEquals(1900, year.getYear()); + assertEquals(99, year.getYear()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-17 01:46:38
|
Revision: 1598 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1598&view=rev Author: mungady Date: 2008-09-17 08:46:33 +0000 (Wed, 17 Sep 2008) Log Message: ----------- 2008-09-17 David Gilbert <dav...@ob...> * source/org/jfree/data/gantt/XYTaskDataset.java: New class, * tests/org/jfree/data/gantt/junit/DataGanttPackageTests.java (suite): Added XYTaskDatasetTests, * tests/org/jfree/data/gantt/junit/XYTaskDatasetTests.java: New file. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/tests/org/jfree/data/gantt/junit/DataGanttPackageTests.java Added Paths: ----------- branches/jfreechart-1.0.x-branch/source/org/jfree/data/gantt/XYTaskDataset.java branches/jfreechart-1.0.x-branch/tests/org/jfree/data/gantt/junit/XYTaskDatasetTests.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-16 13:34:15 UTC (rev 1597) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-17 08:46:33 UTC (rev 1598) @@ -1,3 +1,10 @@ +2008-09-17 David Gilbert <dav...@ob...> + + * source/org/jfree/data/gantt/XYTaskDataset.java: New class, + * tests/org/jfree/data/gantt/junit/DataGanttPackageTests.java + (suite): Added XYTaskDatasetTests, + * tests/org/jfree/data/gantt/junit/XYTaskDatasetTests.java: New file. + 2008-09-16 David Gilbert <dav...@ob...> * source/org/jfree/data/time/Day.java Added: branches/jfreechart-1.0.x-branch/source/org/jfree/data/gantt/XYTaskDataset.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/gantt/XYTaskDataset.java (rev 0) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/gantt/XYTaskDataset.java 2008-09-17 08:46:33 UTC (rev 1598) @@ -0,0 +1,461 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2008, 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * ------------------ + * XYTaskDataset.java + * ------------------ + * (C) Copyright 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 17-Sep-2008 : Version 1 (DG); + * + */ + +package org.jfree.data.gantt; + +import java.util.Date; + +import org.jfree.chart.axis.SymbolAxis; +import org.jfree.chart.renderer.xy.XYBarRenderer; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetChangeListener; +import org.jfree.data.time.TimePeriod; +import org.jfree.data.xy.AbstractXYDataset; +import org.jfree.data.xy.IntervalXYDataset; + +/** + * A dataset implementation that wraps a {@link TaskSeriesCollection} and + * presents it as an {@link IntervalXYDataset}, allowing a set of tasks to + * be displayed using an {@link XYBarRenderer} (and usually a + * {@link SymbolAxis}. This is a very specialised dataset implementation + * ---before using it, you should take some time to understand the use-cases + * that it is designed for. + * + * @since 1.0.11 + */ +public class XYTaskDataset extends AbstractXYDataset + implements IntervalXYDataset, DatasetChangeListener { + + /** The underlying tasks. */ + private TaskSeriesCollection underlying; + + /** The series interval width (typically 0.0 < w <= 1.0). */ + private double seriesWidth; + + /** A flag that controls whether or not the data values are transposed. */ + private boolean transposed; + + /** + * Creates a new dataset based on the supplied collection of tasks. + * + * @param tasks the underlying dataset (<code>null</code> not permitted). + */ + public XYTaskDataset(TaskSeriesCollection tasks) { + if (tasks == null) { + throw new IllegalArgumentException("Null 'tasks' argument."); + } + this.underlying = tasks; + this.seriesWidth = 0.8; + this.underlying.addChangeListener(this); + } + + /** + * Returns the underlying task series collection that was supplied to the + * constructor. + * + * @return The underlying collection (never <code>null</code>). + */ + public TaskSeriesCollection getTasks() { + return this.underlying; + } + + /** + * Returns the width of the interval for each series this dataset. + * + * @return The width of the series interval. + * + * @see #setSeriesWidth(double) + */ + public double getSeriesWidth() { + return this.seriesWidth; + } + + /** + * Sets the series interval width and sends a {@link DatasetChangeEvent} to + * all registered listeners. + * + * @param w the width. + * + * @see #getSeriesWidth() + */ + public void setSeriesWidth(double w) { + if (w <= 0.0) { + throw new IllegalArgumentException("Requires 'w' > 0.0."); + } + this.seriesWidth = w; + fireDatasetChanged(); + } + + /** + * Returns a flag that indicates whether or not the dataset is transposed. + * The default is <code>false</code> which means the x-values are integers + * corresponding to the series indices, and the y-values are millisecond + * values corresponding to the task date/time intervals. If the flag + * is set to <code>true</code>, the x and y-values are reversed. + * + * @return The flag. + * + * @see #setTransposed(boolean) + */ + public boolean isTransposed() { + return this.transposed; + } + + /** + * Sets the flag that controls whether or not the dataset is transposed + * and sends a {@link DatasetChangeEvent} to all registered listeners. + * + * @param transposed the new flag value. + * + * @see #isTransposed() + */ + public void setTransposed(boolean transposed) { + this.transposed = transposed; + fireDatasetChanged(); + } + + /** + * Returns the number of series in the dataset. + * + * @return The series count. + */ + public int getSeriesCount() { + return this.underlying.getSeriesCount(); + } + + /** + * Returns the name of a series. + * + * @param series the series index (zero-based). + * + * @return The name of a series. + */ + public Comparable getSeriesKey(int series) { + return this.underlying.getSeriesKey(series); + } + + /** + * Returns the number of items (tasks) in the specified series. + * + * @param series the series index (zero-based). + * + * @return The item count. + */ + public int getItemCount(int series) { + return this.underlying.getSeries(series).getItemCount(); + } + + /** + * Returns the x-value (as a double primitive) for an item within a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + public double getXValue(int series, int item) { + if (!this.transposed) { + return getSeriesValue(series); + } + else { + return getItemValue(series, item); + } + } + + /** + * Returns the starting date/time for the specified item (task) in the + * given series, measured in milliseconds since 1-Jan-1970 (as in + * java.util.Date). + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The start date/time. + */ + public double getStartXValue(int series, int item) { + if (!this.transposed) { + return getSeriesStartValue(series); + } + else { + return getItemStartValue(series, item); + } + } + + /** + * Returns the ending date/time for the specified item (task) in the + * given series, measured in milliseconds since 1-Jan-1970 (as in + * java.util.Date). + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The end date/time. + */ + public double getEndXValue(int series, int item) { + if (!this.transposed) { + return getSeriesEndValue(series); + } + else { + return getItemEndValue(series, item); + } + } + + /** + * Returns the x-value for the specified series. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value (in milliseconds). + */ + public Number getX(int series, int item) { + return new Double(getXValue(series, item)); + } + + /** + * Returns the starting date/time for the specified item (task) in the + * given series, measured in milliseconds since 1-Jan-1970 (as in + * java.util.Date). + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The start date/time. + */ + public Number getStartX(int series, int item) { + return new Double(getStartXValue(series, item)); + } + + /** + * Returns the ending date/time for the specified item (task) in the + * given series, measured in milliseconds since 1-Jan-1970 (as in + * java.util.Date). + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The end date/time. + */ + public Number getEndX(int series, int item) { + return new Double(getEndXValue(series, item)); + } + + /** + * Returns the y-value (as a double primitive) for an item within a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + public double getYValue(int series, int item) { + if (!this.transposed) { + return getItemValue(series, item); + } + else { + return getSeriesValue(series); + } + } + + /** + * Returns the starting value of the y-interval for an item in the + * given series. + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The y-interval start. + */ + public double getStartYValue(int series, int item) { + if (!this.transposed) { + return getItemStartValue(series, item); + } + else { + return getSeriesStartValue(series); + } + } + + /** + * Returns the ending value of the y-interval for an item in the + * given series. + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The y-interval end. + */ + public double getEndYValue(int series, int item) { + if (!this.transposed) { + return getItemEndValue(series, item); + } + else { + return getSeriesEndValue(series); + } + } + + /** + * Returns the y-value for the specified series/item. In this + * implementation, we return the series index as the y-value (this means + * that every item in the series has a constant integer value). + * + * @param series the series index. + * @param item the item index. + * + * @return The y-value. + */ + public Number getY(int series, int item) { + return new Double(getYValue(series, item)); + } + + /** + * Returns the starting value of the y-interval for an item in the + * given series. + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The y-interval start. + */ + public Number getStartY(int series, int item) { + return new Double(getStartYValue(series, item)); + } + + /** + * Returns the ending value of the y-interval for an item in the + * given series. + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The y-interval end. + */ + public Number getEndY(int series, int item) { + return new Double(getEndYValue(series, item)); + } + + private double getSeriesValue(int series) { + return series; + } + + private double getSeriesStartValue(int series) { + return series - this.seriesWidth / 2.0; + } + + private double getSeriesEndValue(int series) { + return series + this.seriesWidth / 2.0; + } + + private double getItemValue(int series, int item) { + TaskSeries s = this.underlying.getSeries(series); + Task t = s.get(item); + TimePeriod duration = t.getDuration(); + Date start = duration.getStart(); + Date end = duration.getEnd(); + return (start.getTime() + end.getTime()) / 2.0; + } + + private double getItemStartValue(int series, int item) { + TaskSeries s = this.underlying.getSeries(series); + Task t = s.get(item); + TimePeriod duration = t.getDuration(); + Date start = duration.getStart(); + return start.getTime(); + } + + private double getItemEndValue(int series, int item) { + TaskSeries s = this.underlying.getSeries(series); + Task t = s.get(item); + TimePeriod duration = t.getDuration(); + Date end = duration.getEnd(); + return end.getTime(); + } + + + /** + * Receives a change event from the underlying dataset and responds by + * firing a change event for this dataset. + * + * @param event the event. + */ + public void datasetChanged(DatasetChangeEvent event) { + fireDatasetChanged(); + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object (<code>null</code> permitted). + * + * @return A boolean. + */ + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYTaskDataset)) { + return false; + } + XYTaskDataset that = (XYTaskDataset) obj; + if (this.seriesWidth != that.seriesWidth) { + return false; + } + if (this.transposed != that.transposed) { + return false; + } + if (!this.underlying.equals(that.underlying)) { + return false; + } + return true; + } + + /** + * Returns a clone of this dataset. + * + * @return A clone of this dataset. + * + * @throws CloneNotSupportedException if there is a problem cloning. + */ + public Object clone() throws CloneNotSupportedException { + XYTaskDataset clone = (XYTaskDataset) super.clone(); + clone.underlying = (TaskSeriesCollection) this.underlying.clone(); + return clone; + } + +} Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/data/gantt/junit/DataGanttPackageTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/data/gantt/junit/DataGanttPackageTests.java 2008-09-16 13:34:15 UTC (rev 1597) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/data/gantt/junit/DataGanttPackageTests.java 2008-09-17 08:46:33 UTC (rev 1598) @@ -66,6 +66,7 @@ suite.addTestSuite(TaskTests.class); suite.addTestSuite(TaskSeriesTests.class); suite.addTestSuite(TaskSeriesCollectionTests.class); + suite.addTestSuite(XYTaskDatasetTests.class); return suite; } Added: branches/jfreechart-1.0.x-branch/tests/org/jfree/data/gantt/junit/XYTaskDatasetTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/data/gantt/junit/XYTaskDatasetTests.java (rev 0) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/data/gantt/junit/XYTaskDatasetTests.java 2008-09-17 08:46:33 UTC (rev 1598) @@ -0,0 +1,183 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2008, 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * ----------------------- + * XYTaskDatasetTests.java + * ----------------------- + * (C) Copyright 2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Sep-2008 : Version 1 (DG); + * + */ + +package org.jfree.data.gantt.junit; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInput; +import java.io.ObjectInputStream; +import java.io.ObjectOutput; +import java.io.ObjectOutputStream; +import java.util.Date; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.jfree.data.gantt.Task; +import org.jfree.data.gantt.TaskSeries; +import org.jfree.data.gantt.TaskSeriesCollection; +import org.jfree.data.gantt.XYTaskDataset; + +/** + * Tests for the {@link XYTaskDataset} class. + */ +public class XYTaskDatasetTests extends TestCase { + + /** + * Returns the tests as a test suite. + * + * @return The test suite. + */ + public static Test suite() { + return new TestSuite(XYTaskDatasetTests.class); + } + + /** + * Constructs a new set of tests. + * + * @param name the name of the tests. + */ + public XYTaskDatasetTests(String name) { + super(name); + } + + /** + * Some checks for the equals() method. + */ + public void testEquals() { + TaskSeries s1 = new TaskSeries("Series"); + s1.add(new Task("Task 1", new Date(0L), new Date(1L))); + s1.add(new Task("Task 2", new Date(10L), new Date(11L))); + s1.add(new Task("Task 3", new Date(20L), new Date(21L))); + TaskSeriesCollection u1 = new TaskSeriesCollection(); + u1.add(s1); + XYTaskDataset d1 = new XYTaskDataset(u1); + TaskSeries s2 = new TaskSeries("Series"); + s2.add(new Task("Task 1", new Date(0L), new Date(1L))); + s2.add(new Task("Task 2", new Date(10L), new Date(11L))); + s2.add(new Task("Task 3", new Date(20L), new Date(21L))); + TaskSeriesCollection u2 = new TaskSeriesCollection(); + u2.add(s2); + XYTaskDataset d2 = new XYTaskDataset(u2); + assertTrue(d1.equals(d2)); + + d1.setSeriesWidth(0.123); + assertFalse(d1.equals(d2)); + d2.setSeriesWidth(0.123); + assertTrue(d1.equals(d2)); + + d1.setTransposed(true); + assertFalse(d1.equals(d2)); + d2.setTransposed(true); + assertTrue(d1.equals(d2)); + + s1.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertFalse(d1.equals(d2)); + s2.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + public void testCloning() { + TaskSeries s1 = new TaskSeries("Series"); + s1.add(new Task("Task 1", new Date(0L), new Date(1L))); + TaskSeriesCollection u1 = new TaskSeriesCollection(); + u1.add(s1); + XYTaskDataset d1 = new XYTaskDataset(u1); + XYTaskDataset d2 = null; + try { + d2 = (XYTaskDataset) d1.clone(); + } + catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // basic check for independence + s1.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertFalse(d1.equals(d2)); + TaskSeriesCollection u2 = d2.getTasks(); + TaskSeries s2 = u2.getSeries("Series"); + s2.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + public void testSerialization() { + TaskSeries s1 = new TaskSeries("Series"); + s1.add(new Task("Task 1", new Date(0L), new Date(1L))); + TaskSeriesCollection u1 = new TaskSeriesCollection(); + u1.add(s1); + XYTaskDataset d1 = new XYTaskDataset(u1); + XYTaskDataset d2 = null; + try { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + ObjectOutput out = new ObjectOutputStream(buffer); + out.writeObject(d1); + out.close(); + + ObjectInput in = new ObjectInputStream( + new ByteArrayInputStream(buffer.toByteArray())); + d2 = (XYTaskDataset) in.readObject(); + in.close(); + } + catch (Exception e) { + e.printStackTrace(); + } + assertEquals(d1, d2); + + // basic check for independence + s1.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertFalse(d1.equals(d2)); + TaskSeriesCollection u2 = d2.getTasks(); + TaskSeries s2 = u2.getSeries("Series"); + s2.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertTrue(d1.equals(d2)); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-17 05:53:52
|
Revision: 1600 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1600&view=rev Author: mungady Date: 2008-09-17 12:53:50 +0000 (Wed, 17 Sep 2008) Log Message: ----------- 2008-09-17 David Gilbert <dav...@ob...> * source/org/jfree/chart/title/PaintScaleLegend.java (PaintScaleLegend(PaintScale, ValueAxis)): Change axis range to reflect scale bounds. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/title/PaintScaleLegend.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-17 09:24:41 UTC (rev 1599) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-17 12:53:50 UTC (rev 1600) @@ -1,5 +1,11 @@ 2008-09-17 David Gilbert <dav...@ob...> + * source/org/jfree/chart/title/PaintScaleLegend.java + (PaintScaleLegend(PaintScale, ValueAxis)): Change axis range to reflect + scale bounds. + +2008-09-17 David Gilbert <dav...@ob...> + * source/org/jfree/data/gantt/XYTaskDataset.java: New class, * tests/org/jfree/data/gantt/junit/DataGanttPackageTests.java (suite): Added XYTaskDatasetTests, Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/title/PaintScaleLegend.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/title/PaintScaleLegend.java 2008-09-17 09:24:41 UTC (rev 1599) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/title/PaintScaleLegend.java 2008-09-17 12:53:50 UTC (rev 1600) @@ -132,6 +132,7 @@ this.axis = axis; this.axisLocation = AxisLocation.BOTTOM_OR_LEFT; this.axisOffset = 0.0; + this.axis.setRange(scale.getLowerBound(), scale.getUpperBound()); this.stripWidth = 15.0; this.stripOutlineVisible = false; this.stripOutlinePaint = Color.gray; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-17 06:07:51
|
Revision: 1602 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1602&view=rev Author: mungady Date: 2008-09-17 13:07:46 +0000 (Wed, 17 Sep 2008) Log Message: ----------- 2008-09-17 David Gilbert <dav...@ob...> * source/org/jfree/chart/annotations/XYDataImageAnnotation.java: New class. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog Added Paths: ----------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/annotations/XYDataImageAnnotation.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-17 12:59:32 UTC (rev 1601) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-17 13:07:46 UTC (rev 1602) @@ -1,5 +1,10 @@ 2008-09-17 David Gilbert <dav...@ob...> + * source/org/jfree/chart/annotations/XYDataImageAnnotation.java: + New class. + +2008-09-17 David Gilbert <dav...@ob...> + * source/org/jfree/chart/title/PaintScaleLegend.java (PaintScaleLegend(PaintScale, ValueAxis)): Change axis range to reflect scale bounds. Added: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/annotations/XYDataImageAnnotation.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/annotations/XYDataImageAnnotation.java (rev 0) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/annotations/XYDataImageAnnotation.java 2008-09-17 13:07:46 UTC (rev 1602) @@ -0,0 +1,306 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2008, 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. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * -------------------------- + * XYDataImageAnnotation.java + * -------------------------- + * (C) Copyright 2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 17-Sep-2008 : Version 1, based on XYImageAnnotation (DG); + */ + +package org.jfree.chart.annotations; + +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import org.jfree.chart.axis.AxisLocation; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * An annotation that allows an image to be placed within a rectangle specified + * in data coordinates on an {@link XYPlot}. Note that this annotation + * is not currently serializable, so don't use it if you plan on serializing + * your chart(s). + * + * @since 1.0.11 + */ +public class XYDataImageAnnotation extends AbstractXYAnnotation + implements Cloneable, PublicCloneable { + + /** The image. */ + private transient Image image; + + /** + * The x-coordinate (in data space). + */ + private double x; + + /** + * The y-coordinate (in data space). + */ + private double y; + + /** + * The image display area width in data coordinates. + */ + private double w; + + /** + * The image display area height in data coordinates. + */ + private double h; + + /** + * Creates a new annotation to be displayed within the specified rectangle. + * + * @param image the image (<code>null</code> not permitted). + * @param x the x-coordinate (in data space). + * @param y the y-coordinate (in data space). + * @param w the image display area width. + * @param h the image display area height. + */ + public XYDataImageAnnotation(Image image, double x, double y, double w, + double h) { + if (image == null) { + throw new IllegalArgumentException("Null 'image' argument."); + } + this.image = image; + this.x = x; + this.y = y; + this.w = w; + this.h = h; + } + + /** + * Returns the image for the annotation. + * + * @return The image. + */ + public Image getImage() { + return this.image; + } + + /** + * Returns the x-coordinate (in data space) for the annotation. + * + * @return The x-coordinate. + */ + public double getX() { + return this.x; + } + + /** + * Returns the y-coordinate (in data space) for the annotation. + * + * @return The y-coordinate. + */ + public double getY() { + return this.y; + } + + /** + * Returns the width (in data space) of the data rectangle into which the + * image will be drawn. + * + * @return The width. + */ + public double getWidth() { + return this.w; + } + + /** + * Returns the height (in data space) of the data rectangle into which the + * image will be drawn. + * + * @return The height. + */ + public double getHeight() { + return this.h; + } + + /** + * Draws the annotation. This method is called by the drawing code in the + * {@link XYPlot} class, you don't normally need to call this method + * directly. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param dataArea the data area. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param rendererIndex the renderer index. + * @param info if supplied, this info object will be populated with + * entity information. + */ + public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, + ValueAxis domainAxis, ValueAxis rangeAxis, + int rendererIndex, + PlotRenderingInfo info) { + + PlotOrientation orientation = plot.getOrientation(); + AxisLocation xAxisLocation = plot.getDomainAxisLocation(); + AxisLocation yAxisLocation = plot.getRangeAxisLocation(); + RectangleEdge xEdge = Plot.resolveDomainAxisLocation(xAxisLocation, + orientation); + RectangleEdge yEdge = Plot.resolveRangeAxisLocation(yAxisLocation, + orientation); + float j2DX0 = (float) domainAxis.valueToJava2D(this.x, dataArea, xEdge); + float j2DY0 = (float) rangeAxis.valueToJava2D(this.y, dataArea, yEdge); + float j2DX1 = (float) domainAxis.valueToJava2D(this.x + this.w, + dataArea, xEdge); + float j2DY1 = (float) rangeAxis.valueToJava2D(this.y + this.h, + dataArea, yEdge); + float xx0 = 0.0f; + float yy0 = 0.0f; + float xx1 = 0.0f; + float yy1 = 0.0f; + if (orientation == PlotOrientation.HORIZONTAL) { + xx0 = j2DY0; + xx1 = j2DY1; + yy0 = j2DX0; + yy1 = j2DX1; + } + else if (orientation == PlotOrientation.VERTICAL) { + xx0 = j2DX0; + xx1 = j2DX1; + yy0 = j2DY0; + yy1 = j2DY1; + } + // TODO: rotate the image when drawn with horizontal orientation? + g2.drawImage(this.image, (int) xx0, (int) Math.min(yy0, yy1), + (int) (xx1 - xx0), (int) Math.abs(yy1 - yy0), null); + String toolTip = getToolTipText(); + String url = getURL(); + if (toolTip != null || url != null) { + addEntity(info, new Rectangle2D.Float(xx0, yy0, (xx1 - xx0), + (yy1 - yy0)), rendererIndex, toolTip, url); + } + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the object (<code>null</code> permitted). + * + * @return A boolean. + */ + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + // now try to reject equality... + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof XYDataImageAnnotation)) { + return false; + } + XYDataImageAnnotation that = (XYDataImageAnnotation) obj; + if (this.x != that.x) { + return false; + } + if (this.y != that.y) { + return false; + } + if (this.w != that.w) { + return false; + } + if (this.h != that.h) { + return false; + } + if (!ObjectUtilities.equal(this.image, that.image)) { + return false; + } + // seems to be the same... + return true; + } + + /** + * Returns a hash code for this object. + * + * @return A hash code. + */ + public int hashCode() { + return this.image.hashCode(); + } + + /** + * Returns a clone of the annotation. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the annotation can't be cloned. + */ + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Provides serialization support. + * + * @param stream the output stream. + * + * @throws IOException if there is an I/O error. + */ + private void writeObject(ObjectOutputStream stream) throws IOException { + stream.defaultWriteObject(); + // FIXME + //SerialUtilities.writeImage(this.image, stream); + } + + /** + * Provides serialization support. + * + * @param stream the input stream. + * + * @throws IOException if there is an I/O error. + * @throws ClassNotFoundException if there is a classpath problem. + */ + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + // FIXME + //this.image = SerialUtilities.readImage(stream); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |