From: <mu...@us...> - 2008-09-18 01:21:39
|
Revision: 1603 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1603&view=rev Author: mungady Date: 2008-09-18 08:21:35 +0000 (Thu, 18 Sep 2008) Log Message: ----------- 2008-09-18 David Gilbert <dav...@ob...> * source/org/jfree/chart/renderer/xy/XYShapeRenderer.java: New class, * tests/org/jfree/chart/renderer/xy/junit/XYShapeRendererTests.java: New tests, * tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java (suite): Added XYShapeRendererTests. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java Added Paths: ----------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYShapeRenderer.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/junit/XYShapeRendererTests.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-17 13:07:46 UTC (rev 1602) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-18 08:21:35 UTC (rev 1603) @@ -1,3 +1,11 @@ +2008-09-18 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/renderer/xy/XYShapeRenderer.java: New class, + * tests/org/jfree/chart/renderer/xy/junit/XYShapeRendererTests.java: + New tests, + * tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java + (suite): Added XYShapeRendererTests. + 2008-09-17 David Gilbert <dav...@ob...> * source/org/jfree/chart/annotations/XYDataImageAnnotation.java: Added: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYShapeRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYShapeRenderer.java (rev 0) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYShapeRenderer.java 2008-09-18 08:21:35 UTC (rev 1603) @@ -0,0 +1,595 @@ +/* =========================================================== + * 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.] + * + * -------------------- + * XYShapeRenderer.java + * -------------------- + * (C) Copyright 2008, by Andreas Haumer, xS+S and Contributors. + * + * Original Author: Martin Hoeller (x Software + Systeme xS+S - Andreas + * Haumer); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 17-Sep-2008 : Version 1, based on a contribution from Martin Hoeller with + * amendments by David Gilbert (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Line2D; +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.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.LookupPaintScale; +import org.jfree.chart.renderer.PaintScale; +import org.jfree.data.Range; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYZDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A renderer that draws shapes at (x, y) coordinates and, if the dataset + * is an instance of {@link XYZDataset}, fills the shapes with a paint that + * is based on the z-value (the paint is obtained from a lookup table). The + * renderer also allows for optional guidelines, horizontal and vertical lines + * connecting the shape to the edges of the plot. + * <p> + * This renderer has similarities to, but also differences from, the + * {@link XYLineAndShapeRenderer}. + * + * @since 1.0.11 + */ +public class XYShapeRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, Cloneable, Serializable { + + /** Auto generated serial version id. */ + private static final long serialVersionUID = 8320552104211173221L; + + /** The paint scale. */ + private PaintScale paintScale; + + /** A flag that controls whether or not the shape outlines are drawn. */ + private boolean drawOutlines; + + /** + * A flag that controls whether or not the outline paint is used (if not, + * the regular paint is used). + */ + private boolean useOutlinePaint; + + /** + * A flag that controls whether or not the fill paint is used (if not, + * the fill paint is used). + */ + private boolean useFillPaint; + + /** Flag indicating if guide lines should be drawn for every item. */ + private boolean guideLinesVisible; + + /** The paint used for drawing the guide lines. */ + private transient Paint guideLinePaint; + + /** The stroke used for drawing the guide lines. */ + private transient Stroke guideLineStroke; + + /** + * Creates a new <code>XYShapeRenderer</code> instance with default + * attributes. + */ + public XYShapeRenderer() { + this.paintScale = new LookupPaintScale(); + this.useFillPaint = false; + this.drawOutlines = false; + this.useOutlinePaint = true; + this.guideLinesVisible = false; + this.guideLinePaint = Color.darkGray; + this.guideLineStroke = new BasicStroke(); + setBaseShape(new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0)); + setAutoPopulateSeriesShape(false); + } + + /** + * Returns the paint scale used by the renderer. + * + * @return The paint scale (never <code>null</code>). + * + * @see #setPaintScale(PaintScale) + */ + public PaintScale getPaintScale() { + return this.paintScale; + } + + /** + * Sets the paint scale used by the renderer and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param scale the scale (<code>null</code> not permitted). + * + * @see #getPaintScale() + */ + public void setPaintScale(PaintScale scale) { + if (scale == null) { + throw new IllegalArgumentException("Null 'scale' argument."); + } + this.paintScale = scale; + notifyListeners(new RendererChangeEvent(this)); + } + + /** + * Returns <code>true</code> if outlines should be drawn for shapes, and + * <code>false</code> otherwise. + * + * @return A boolean. + * + * @see #setDrawOutlines(boolean) + */ + public boolean getDrawOutlines() { + return this.drawOutlines; + } + + /** + * Sets the flag that controls whether outlines are drawn for + * shapes, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * <P> + * In some cases, shapes look better if they do NOT have an outline, but + * this flag allows you to set your own preference. + * + * @param flag the flag. + * + * @see #getDrawOutlines() + */ + public void setDrawOutlines(boolean flag) { + this.drawOutlines = flag; + fireChangeEvent(); + } + + /** + * Returns <code>true</code> if the renderer should use the fill paint + * setting to fill shapes, and <code>false</code> if it should just + * use the regular paint. + * <p> + * Refer to <code>XYLineAndShapeRendererDemo2.java</code> to see the + * effect of this flag. + * + * @return A boolean. + * + * @see #setUseFillPaint(boolean) + * @see #getUseOutlinePaint() + */ + public boolean getUseFillPaint() { + return this.useFillPaint; + } + + /** + * Sets the flag that controls whether the fill paint is used to fill + * shapes, and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param flag the flag. + * + * @see #getUseFillPaint() + */ + public void setUseFillPaint(boolean flag) { + this.useFillPaint = flag; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether the outline paint is used for + * shape outlines. If not, the regular series paint is used. + * + * @return A boolean. + * + * @see #setUseOutlinePaint(boolean) + */ + public boolean getUseOutlinePaint() { + return this.useOutlinePaint; + } + + /** + * Sets the flag that controls whether the outline paint is used for shape + * outlines, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param use the flag. + * + * @see #getUseOutlinePaint() + */ + public void setUseOutlinePaint(boolean use) { + this.useOutlinePaint = use; + fireChangeEvent(); + } + + /** + * Returns a flag that controls whether or not guide lines are drawn for + * each data item (the lines are horizontal and vertical "crosshairs" + * linking the data point to the axes). + * + * @return A boolean. + * + * @see #setGuideLinesVisible(boolean) + */ + public boolean isGuideLinesVisible() { + return this.guideLinesVisible; + } + + /** + * Sets the flag that controls whether or not guide lines are drawn for + * each data item and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param visible the new flag value. + * + * @see #isGuideLinesVisible() + */ + public void setGuideLinesVisible(boolean visible) { + this.guideLinesVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw the guide lines. + * + * @return The paint (never <code>null</code>). + * + * @see #setGuideLinePaint(Paint) + */ + public Paint getGuideLinePaint() { + return this.guideLinePaint; + } + + /** + * Sets the paint used to draw the guide lines and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getGuideLinePaint() + */ + public void setGuideLinePaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.guideLinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the stroke used to draw the guide lines. + * + * @return The stroke. + * + * @see #setGuideLineStroke(Stroke) + */ + public Stroke getGuideLineStroke() { + return this.guideLineStroke; + } + + /** + * Sets the stroke used to draw the guide lines and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param stroke the stroke (<code>null</code> not permitted). + * + * @see #getGuideLineStroke() + */ + public void setGuideLineStroke(Stroke stroke) { + if (stroke == null) { + throw new IllegalArgumentException("Null 'stroke' argument."); + } + this.guideLineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the lower and upper bounds (range) of the x-values in the + * specified dataset. + * + * @param dataset the dataset (<code>null</code> permitted). + * + * @return The range (<code>null</code> if the dataset is <code>null</code> + * or empty). + */ + public Range findDomainBounds(XYDataset dataset) { + if (dataset != null) { + Range r = DatasetUtilities.findDomainBounds(dataset, false); + double offset = 0; // TODO getSeriesShape(n).getBounds().width / 2; + return new Range(r.getLowerBound() + offset, + r.getUpperBound() + offset); + } + else { + return null; + } + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (<code>null</code> permitted). + * + * @return The range (<code>null</code> if the dataset is <code>null</code> + * or empty). + */ + public Range findRangeBounds(XYDataset dataset) { + if (dataset != null) { + Range r = DatasetUtilities.findRangeBounds(dataset, false); + double offset = 0; // TODO getSeriesShape(n).getBounds().height / 2; + return new Range(r.getLowerBound() + offset, r.getUpperBound() + + offset); + } + else { + return null; + } + } + + /** + * Returns the number of passes required by this renderer. + * + * @return <code>2</code>. + */ + public int getPassCount() { + return 2; + } + + /** + * Draws the block representing the specified item. + * + * @param g2 the graphics device. + * @param state the state. + * @param dataArea the data area. + * @param info the plot rendering info. + * @param plot the plot. + * @param domainAxis the x-axis. + * @param rangeAxis the y-axis. + * @param dataset the dataset. + * @param series the series index. + * @param item the item index. + * @param crosshairState the crosshair state. + * @param pass the pass index. + */ + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + Shape hotspot = null; + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + } + + double x = dataset.getXValue(series, item); + double y = dataset.getYValue(series, item); + if (Double.isNaN(x) || Double.isNaN(y)) { + // can't draw anything + return; + } + + double transX = domainAxis.valueToJava2D(x, dataArea, + plot.getDomainAxisEdge()); + double transY = rangeAxis.valueToJava2D(y, dataArea, + plot.getRangeAxisEdge()); + + PlotOrientation orientation = plot.getOrientation(); + + // draw optional guide lines + if ((pass == 0) && this.guideLinesVisible) { + g2.setStroke(this.guideLineStroke); + g2.setPaint(this.guideLinePaint); + if (orientation == PlotOrientation.HORIZONTAL) { + g2.draw(new Line2D.Double(transY, dataArea.getMinY(), transY, + dataArea.getMaxY())); + g2.draw(new Line2D.Double(dataArea.getMinX(), transX, + dataArea.getMaxX(), transX)); + } + else { + g2.draw(new Line2D.Double(transX, dataArea.getMinY(), transX, + dataArea.getMaxY())); + g2.draw(new Line2D.Double(dataArea.getMinX(), transY, + dataArea.getMaxX(), transY)); + } + } + else if (pass == 1) { + Shape shape = getItemShape(series, item); + if (orientation == PlotOrientation.HORIZONTAL) { + shape = ShapeUtilities.createTranslatedShape(shape, transY, + transX); + } + else if (orientation == PlotOrientation.VERTICAL) { + shape = ShapeUtilities.createTranslatedShape(shape, transX, + transY); + } + hotspot = shape; + if (shape.intersects(dataArea)) { + //if (getItemShapeFilled(series, item)) { + g2.setPaint(getPaint(dataset, series, item)); + g2.fill(shape); + //} + if (this.drawOutlines) { + if (getUseOutlinePaint()) { + g2.setPaint(getItemOutlinePaint(series, item)); + } + else { + g2.setPaint(getItemPaint(series, item)); + } + g2.setStroke(getItemOutlineStroke(series, item)); + g2.draw(shape); + } + } + + // add an entity for the item... + if (entities != null) { + addEntity(entities, hotspot, dataset, series, item, transX, + transY); + } + } + } + + /** + * Get the paint for a given series and item from a dataset. + * + * @param dataset the dataset.. + * @param series the series index. + * @param item the item index. + * + * @return The paint. + */ + protected Paint getPaint(XYDataset dataset, int series, int item) { + Paint p = null; + if (dataset instanceof XYZDataset) { + double z = ((XYZDataset) dataset).getZValue(series, item); + p = this.paintScale.getPaint(z); + } + else { + if (this.useFillPaint) { + p = getItemFillPaint(series, item); + } + else { + p = getItemPaint(series, item); + } + } + return p; + } + + /** + * Tests this instance for equality with an arbitrary object. This method + * returns <code>true</code> if and only if: + * <ul> + * <li><code>obj</code> is an instance of <code>XYShapeRenderer</code> (not + * <code>null</code>);</li> + * <li><code>obj</code> has the same field values as this + * <code>XYShapeRenderer</code>;</li> + * </ul> + * + * @param obj the object (<code>null</code> permitted). + * + * @return A boolean. + */ + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYShapeRenderer)) { + return false; + } + XYShapeRenderer that = (XYShapeRenderer) obj; + if ((this.paintScale == null && that.paintScale != null) + || (!this.paintScale.equals(that.paintScale))) { + return false; + } + if (this.drawOutlines != that.drawOutlines) { + return false; + } + if (this.useOutlinePaint != that.useOutlinePaint) { + return false; + } + if (this.useFillPaint != that.useFillPaint) { + return false; + } + if (this.guideLinesVisible != that.guideLinesVisible) { + return false; + } + if ((this.guideLinePaint == null && that.guideLinePaint != null) + || (!this.guideLinePaint.equals(that.guideLinePaint))) + return false; + if ((this.guideLineStroke == null && that.guideLineStroke != null) + || (!this.guideLineStroke.equals(that.guideLineStroke))) + return false; + + return super.equals(obj); + } + + /** + * Returns a clone of this renderer. + * + * @return A clone of this renderer. + * + * @throws CloneNotSupportedException if there is a problem creating the + * clone. + */ + public Object clone() throws CloneNotSupportedException { + XYShapeRenderer clone = (XYShapeRenderer) super.clone(); + if (this.paintScale instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.paintScale; + clone.paintScale = (PaintScale) pc.clone(); + } + return clone; + } + + /** + * 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.guideLinePaint = SerialUtilities.readPaint(stream); + this.guideLineStroke = SerialUtilities.readStroke(stream); + } + + /** + * 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.guideLinePaint, stream); + SerialUtilities.writeStroke(this.guideLineStroke, stream); + } + +} Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java 2008-09-17 13:07:46 UTC (rev 1602) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java 2008-09-18 08:21:35 UTC (rev 1603) @@ -96,6 +96,7 @@ suite.addTestSuite(XYErrorRendererTests.class); suite.addTestSuite(XYLineAndShapeRendererTests.class); suite.addTestSuite(XYLine3DRendererTests.class); + suite.addTestSuite(XYShapeRendererTests.class); suite.addTestSuite(XYSplineRendererTests.class); suite.addTestSuite(XYStepRendererTests.class); suite.addTestSuite(XYStepAreaRendererTests.class); Added: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/junit/XYShapeRendererTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/junit/XYShapeRendererTests.java (rev 0) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/renderer/xy/junit/XYShapeRendererTests.java 2008-09-18 08:21:35 UTC (rev 1603) @@ -0,0 +1,162 @@ +/* =========================================================== + * 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.] + * + * ------------------------- + * XYShapeRendererTests.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.chart.renderer.xy.junit; + +import java.awt.Color; +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.renderer.LookupPaintScale; +import org.jfree.chart.renderer.xy.XYShapeRenderer; + +/** + * Tests for the {@link XYShapeRenderer} class. + */ +public class XYShapeRendererTests extends TestCase { + + /** + * Returns the tests as a test suite. + * + * @return The test suite. + */ + public static Test suite() { + return new TestSuite(XYShapeRendererTests.class); + } + + /** + * Constructs a new set of tests. + * + * @param name the name of the tests. + */ + public XYShapeRendererTests(String name) { + super(name); + } + + /** + * Some checks for the equals() method. + */ + public void testEquals() { + XYShapeRenderer r1 = new XYShapeRenderer(); + XYShapeRenderer r2 = new XYShapeRenderer(); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + r1.setPaintScale(new LookupPaintScale(1.0, 2.0, Color.white)); + assertFalse(r1.equals(r2)); + r2.setPaintScale(new LookupPaintScale(1.0, 2.0, Color.white)); + assertTrue(r1.equals(r2)); + + r1.setDrawOutlines(true); + assertFalse(r1.equals(r2)); + r2.setDrawOutlines(true); + assertTrue(r1.equals(r2)); + + r1.setUseOutlinePaint(false); + assertFalse(r1.equals(r2)); + r2.setUseOutlinePaint(false); + assertTrue(r1.equals(r2)); + + r1.setUseFillPaint(true); + assertFalse(r1.equals(r2)); + r2.setUseFillPaint(true); + assertTrue(r1.equals(r2)); + + r1.setGuideLinesVisible(true); + assertFalse(r1.equals(r2)); + r2.setGuideLinesVisible(true); + assertTrue(r1.equals(r2)); + + r1.setGuideLinePaint(Color.red); + assertFalse(r1.equals(r2)); + r2.setGuideLinePaint(Color.red); + assertTrue(r1.equals(r2)); + + } + + /** + * Confirm that cloning works. + */ + public void testCloning() { + XYShapeRenderer r1 = new XYShapeRenderer(); + XYShapeRenderer r2 = null; + try { + r2 = (XYShapeRenderer) r1.clone(); + } + catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + public void testSerialization() { + XYShapeRenderer r1 = new XYShapeRenderer(); + XYShapeRenderer r2 = null; + try { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + ObjectOutput out = new ObjectOutputStream(buffer); + out.writeObject(r1); + out.close(); + + ObjectInput in = new ObjectInputStream( + new ByteArrayInputStream(buffer.toByteArray())); + r2 = (XYShapeRenderer) in.readObject(); + in.close(); + } + catch (Exception e) { + e.printStackTrace(); + } + assertEquals(r1, r2); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-18 01:31:42
|
Revision: 1606 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1606&view=rev Author: mungady Date: 2008-09-18 08:31:39 +0000 (Thu, 18 Sep 2008) Log Message: ----------- 2008-09-18 David Gilbert <dav...@ob...> * source/org/jfree/chart/ChartPanel.java (paintComponent): Modified chart buffer creation. 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-09-18 08:25:52 UTC (rev 1605) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-18 08:31:39 UTC (rev 1606) @@ -1,5 +1,10 @@ 2008-09-18 David Gilbert <dav...@ob...> + * source/org/jfree/chart/ChartPanel.java + (paintComponent): Modified chart buffer creation. + +2008-09-18 David Gilbert <dav...@ob...> + * source/org/jfree/chart/renderer/xy/XYShapeRenderer.java: New class, * tests/org/jfree/chart/renderer/xy/junit/XYShapeRendererTests.java: New tests, 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-09-18 08:25:52 UTC (rev 1605) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartPanel.java 2008-09-18 08:31:39 UTC (rev 1606) @@ -140,6 +140,7 @@ * outside of the data area (DG); * 08-May-2008 : Fixed serialization bug (DG); * 15-Aug-2008 : Increased default maxDrawWidth/Height (DG); + * 18-Sep-2008 : Modified creation of chart buffer (DG); * */ @@ -150,9 +151,11 @@ import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; import java.awt.Image; import java.awt.Insets; import java.awt.Point; +import java.awt.Transparency; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; @@ -1302,12 +1305,10 @@ || (this.chartBufferHeight != available.getHeight())) { this.chartBufferWidth = (int) available.getWidth(); this.chartBufferHeight = (int) available.getHeight(); - this.chartBuffer = createImage(this.chartBufferWidth, - this.chartBufferHeight); -// GraphicsConfiguration gc = g2.getDeviceConfiguration(); -// this.chartBuffer = gc.createCompatibleImage( -// this.chartBufferWidth, this.chartBufferHeight, -// Transparency.TRANSLUCENT); + GraphicsConfiguration gc = g2.getDeviceConfiguration(); + this.chartBuffer = gc.createCompatibleImage( + this.chartBufferWidth, this.chartBufferHeight, + Transparency.TRANSLUCENT); this.refreshBuffer = true; clearBuffer = false; // buffer is new, no clearing required } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-18 06:12:08
|
Revision: 1617 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1617&view=rev Author: mungady Date: 2008-09-18 13:12:05 +0000 (Thu, 18 Sep 2008) Log Message: ----------- Updates for imminent release. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/NEWS branches/jfreechart-1.0.x-branch/README.txt Modified: branches/jfreechart-1.0.x-branch/NEWS =================================================================== --- branches/jfreechart-1.0.x-branch/NEWS 2008-09-18 13:11:34 UTC (rev 1616) +++ branches/jfreechart-1.0.x-branch/NEWS 2008-09-18 13:12:05 UTC (rev 1617) @@ -3,14 +3,16 @@ 18 September 2008 This release features a new chart theming mechanism to allow charts to be -restyled easily, a new BarPainter mechanism to enhance the appearance of bar -charts, a new XYShapeRenderer class, a scaling facility for the +restyled conveniently, a new BarPainter mechanism to enhance the appearance of +bar charts, a new XYShapeRenderer class, a scaling facility for the XYDrawableAnnotation for drawing images within specific data coordinates, some new classes (XYTaskDataset, XYDataImageAnnotation and XYTitleAnnotation), a modification to the Year class to support an extended range, and various bug fixes and API improvements. There is an important bug fix for the StackedBarRenderer3D class (see bug 2031407). +This release passes 1,961 JUnit tests (0 failures) on JRE 1.6.0_07. + API Adjustments: - AbstractRenderer - added clearSeriesPaints() and clearSeriesStrokes() methods; Modified: branches/jfreechart-1.0.x-branch/README.txt =================================================================== --- branches/jfreechart-1.0.x-branch/README.txt 2008-09-18 13:11:34 UTC (rev 1616) +++ branches/jfreechart-1.0.x-branch/README.txt 2008-09-18 13:12:05 UTC (rev 1617) @@ -1,8 +1,8 @@ ******************************** -* JFREECHART: Version 1.0.10 * +* JFREECHART: Version 1.0.11 * ******************************** -9 June 2008 +18 September 2008 (C)opyright 2000-2008, by Object Refinery Limited and Contributors. @@ -35,7 +35,7 @@ 3. DOCUMENTATION ----------------- You can download installation instructions -(jfreechart-1.0.10-install.pdf) from the JFreeChart home +(jfreechart-1.0.11-install.pdf) from the JFreeChart home page or the project page on SourceForge. Further documentation for JFreeChart (the JFreeChart Developer Guide) is @@ -67,7 +67,7 @@ plug-in installed. Most other browsers (e.g. Firefox, Mozilla, Netscape, Konqueror) support JRE 1.4, 1.5 or 1.6. -(b) JCommon - version 1.0.0 or later. The runtime jar file (version 1.0.13) +(b) JCommon - version 1.0.0 or later. The runtime jar file (version 1.0.14) is included in the JFreeChart distribution. You can obtain the complete source code for JCommon from: @@ -141,7 +141,7 @@ generated is included in the JFreeChart distribution. To run the demo (using JDK 1.3.1 or later), use the following command: - java -jar jfreechart-1.0.10-demo.jar + java -jar jfreechart-1.0.11-demo.jar The complete source code for the demo application is available for download when you purchase the JFreeChart Developer Guide. @@ -193,7 +193,12 @@ --------------- A list of changes in recent versions: -1.0.10 : (5-May-2008) +1.0.11 : (18-Sep-2008) + - this release includes a new chart theming mechanism, and numerous + other feature enhancements and bug fixes - see the NEWS and ChangeLog + files for details. + +1.0.10 : (8-Jun-2008) - another general maintenance release - see the NEWS and ChangeLog files for more details. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-18 23:23:30
|
Revision: 1618 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1618&view=rev Author: mungady Date: 2008-09-19 06:23:21 +0000 (Fri, 19 Sep 2008) Log Message: ----------- 2008-09-19 David Gilbert <dav...@ob...> * source/org/jfree/chart/JFreeChart.java (draw): Check title visibility, * source/org/jfree/chart/title/Title.java (visible): New field, (isVisible): New method, (setVisible): Likewise, (equals): Check visible flag. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/JFreeChart.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/title/Title.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/title/junit/TitleTests.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-18 13:12:05 UTC (rev 1617) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-19 06:23:21 UTC (rev 1618) @@ -1,5 +1,15 @@ ---------- JFREECHART 1.0.11 RELEASED ------------------------ +2008-09-19 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/JFreeChart.java + (draw): Check title visibility, + * source/org/jfree/chart/title/Title.java + (visible): New field, + (isVisible): New method, + (setVisible): Likewise, + (equals): Check visible flag. + 2008-08-18 David Gilbert <dav...@ob...> * source/org/jfree/chart/axis/DateAxis.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/JFreeChart.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/JFreeChart.java 2008-09-18 13:12:05 UTC (rev 1617) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/JFreeChart.java 2008-09-19 06:23:21 UTC (rev 1618) @@ -141,6 +141,7 @@ * TextTitle) (DG); * 23-Apr-2008 : Added new contributor (Diego Pierangeli) (DG); * 16-May-2008 : Added new contributor (Michael Siemer) (DG); + * 19-Sep-2008 : Check for title visibility (DG); * */ @@ -1207,10 +1208,12 @@ Iterator iterator = this.subtitles.iterator(); while (iterator.hasNext()) { Title currentTitle = (Title) iterator.next(); - EntityCollection e = drawTitle(currentTitle, g2, nonTitleArea, - (entities != null)); - if (e != null) { - entities.addAll(e); + if (currentTitle.isVisible()) { + EntityCollection e = drawTitle(currentTitle, g2, nonTitleArea, + (entities != null)); + if (e != null) { + entities.addAll(e); + } } } Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/title/Title.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/title/Title.java 2008-09-18 13:12:05 UTC (rev 1617) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/title/Title.java 2008-09-19 06:23:21 UTC (rev 1618) @@ -54,6 +54,7 @@ * release (DG); * 02-Feb-2005 : Changed Spacer --> RectangleInsets for padding (DG); * 03-May-2005 : Fixed problem in equals() method (DG); + * 19-Sep-2008 : Added visibility flag (DG); * */ @@ -106,6 +107,13 @@ public static final RectangleInsets DEFAULT_PADDING = new RectangleInsets( 1, 1, 1, 1); + /** + * A flag that controls whether or not the title is visible. + * + * @since 1.0.11 + */ + public boolean visible; + /** The title position. */ private RectangleEdge position; @@ -187,6 +195,7 @@ throw new IllegalArgumentException("Null 'spacer' argument."); } + this.visible = true; this.position = position; this.horizontalAlignment = horizontalAlignment; this.verticalAlignment = verticalAlignment; @@ -197,6 +206,34 @@ } /** + * Returns a flag that controls whether or not the title should be + * drawn. The default value is <code>true</code>. + * + * @return A boolean. + * + * @see #setVisible(boolean) + * + * @since 1.0.11 + */ + public boolean isVisible() { + return this.visible; + } + + /** + * Sets a flag that controls whether or not the title should be drawn, and + * sends a {@link TitleChangeEvent} to all registered listeners. + * + * @param visible the new flag value. + * + * @see #isVisible() + * + * @since 1.0.11 + */ + public void setVisible(boolean visible) { + this.visible = visible; + notifyListeners(new TitleChangeEvent(this)); + } + /** * Returns the position of the title. * * @return The title position (never <code>null</code>). @@ -377,10 +414,10 @@ if (!(obj instanceof Title)) { return false; } - if (!super.equals(obj)) { + Title that = (Title) obj; + if (this.visible != that.visible) { return false; } - Title that = (Title) obj; if (this.position != that.position) { return false; } @@ -393,7 +430,7 @@ if (this.notify != that.notify) { return false; } - return true; + return super.equals(obj); } /** Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/title/junit/TitleTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/title/junit/TitleTests.java 2008-09-18 13:12:05 UTC (rev 1617) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/title/junit/TitleTests.java 2008-09-19 06:23:21 UTC (rev 1618) @@ -35,6 +35,7 @@ * Changes * ------- * 17-Feb-2004 : Version 1 (DG); + * 18-Sep-2008 : Updated testEquals() (DG); * */ @@ -98,6 +99,11 @@ t2.setVerticalAlignment(VerticalAlignment.BOTTOM); assertTrue(t1.equals(t2)); + t1.setVisible(false); + assertFalse(t1.equals(t2)); + t2.setVisible(false); + assertTrue(t1.equals(t2)); + } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-18 23:51:17
|
Revision: 1623 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1623&view=rev Author: mungady Date: 2008-09-19 06:51:15 +0000 (Fri, 19 Sep 2008) Log Message: ----------- 2008-09-19 David Gilbert <dav...@ob...> * source/org/jfree/chart/StandardChartTheme.java (smallFont): New field, (crosshairPaint): New field, (createDarknessTheme): Initilise crosshairPaint, (StandardChartTheme): Initialise new fields, (getCrosshairPaint): New method, (setCrosshairPaint): Likewise, (applyToXYPlot): Apply crosshair paint and process annotations, (applyToXYAnnotation): New method, (equals): Check new fields, (writeObject): Handle crosshairPaint, (readObject): Likewise. 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-19 06:32:52 UTC (rev 1622) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-19 06:51:15 UTC (rev 1623) @@ -2,6 +2,21 @@ 2008-09-19 David Gilbert <dav...@ob...> + * source/org/jfree/chart/StandardChartTheme.java + (smallFont): New field, + (crosshairPaint): New field, + (createDarknessTheme): Initilise crosshairPaint, + (StandardChartTheme): Initialise new fields, + (getCrosshairPaint): New method, + (setCrosshairPaint): Likewise, + (applyToXYPlot): Apply crosshair paint and process annotations, + (applyToXYAnnotation): New method, + (equals): Check new fields, + (writeObject): Handle crosshairPaint, + (readObject): Likewise. + +2008-09-19 David Gilbert <dav...@ob...> + * source/org/jfree/chart/JFreeChart.java (draw): Check title visibility, * source/org/jfree/chart/title/Title.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-19 06:32:52 UTC (rev 1622) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/StandardChartTheme.java 2008-09-19 06:51:15 UTC (rev 1623) @@ -52,6 +52,8 @@ import java.util.Iterator; import java.util.List; +import org.jfree.chart.annotations.XYAnnotation; +import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.PeriodAxis; import org.jfree.chart.axis.PeriodAxisLabelInfo; @@ -130,6 +132,11 @@ */ private Font regularFont; + /** + * The small font size. + */ + private Font smallFont; + /** The paint used to display the main chart title. */ private transient Paint titlePaint; @@ -166,6 +173,9 @@ /** The range grid line paint. */ private transient Paint rangeGridlinePaint; + /** The crosshair paint. */ + private transient Paint crosshairPaint; + /** The axis offsets. */ private RectangleInsets axisOffset; @@ -236,6 +246,7 @@ theme.chartBackgroundPaint = Color.black; theme.plotBackgroundPaint = Color.black; theme.plotOutlinePaint = Color.yellow; + theme.crosshairPaint = Color.red; theme.labelLinkPaint = Color.lightGray; theme.tickLabelPaint = Color.white; theme.axisLabelPaint = Color.white; @@ -288,7 +299,7 @@ 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.smallFont = new Font("Tahoma", Font.PLAIN, 10); this.titlePaint = Color.black; this.subtitlePaint = Color.black; this.legendBackgroundPaint = Color.white; @@ -302,6 +313,7 @@ this.axisOffset = new RectangleInsets(4, 4, 4, 4); this.domainGridlinePaint = Color.white; this.rangeGridlinePaint = Color.white; + this.crosshairPaint = Color.blue; this.axisLabelPaint = Color.darkGray; this.tickLabelPaint = Color.darkGray; this.barPainter = new GradientBarPainter(); @@ -659,6 +671,27 @@ } /** + * Returns the crosshair paint. + * + * @return The crosshair paint. + */ + public Paint getCrosshairPaint() { + return this.crosshairPaint; + } + + /** + * Sets the crosshair paint. + * + * @param paint the paint (<code>null</code> not permitted). + */ + public void setCrosshairPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.crosshairPaint = paint; + } + + /** * Returns the axis offsets. * * @return The axis offsets (never <code>null</code>). @@ -1276,7 +1309,8 @@ plot.setAxisOffset(this.axisOffset); plot.setDomainGridlinePaint(this.domainGridlinePaint); plot.setRangeGridlinePaint(this.rangeGridlinePaint); - + plot.setDomainCrosshairPaint(this.crosshairPaint); + plot.setRangeCrosshairPaint(this.crosshairPaint); // process all domain axes int domainAxisCount = plot.getDomainAxisCount(); for (int i = 0; i < domainAxisCount; i++) { @@ -1303,6 +1337,14 @@ applyToXYItemRenderer(r); } } + + // process all annotations + Iterator iter = plot.getAnnotations().iterator(); + while (iter.hasNext()) { + XYAnnotation a = (XYAnnotation) iter.next(); + applyToXYAnnotation(a); + } + if (plot instanceof CombinedDomainXYPlot) { CombinedDomainXYPlot cp = (CombinedDomainXYPlot) plot; Iterator iterator = cp.getSubplots().iterator(); @@ -1552,6 +1594,22 @@ } /** + * Applies the settings of this theme to the specified annotation. + * + * @param annotation the annotation. + */ + protected void applyToXYAnnotation(XYAnnotation annotation) { + if (annotation == null) { + throw new IllegalArgumentException("Null 'annotation' argument."); + } + if (annotation instanceof XYTextAnnotation) { + XYTextAnnotation xyta = (XYTextAnnotation) annotation; + xyta.setFont(this.smallFont); + xyta.setPaint(this.itemLabelPaint); + } + } + + /** * Tests this theme for equality with an arbitrary object. * * @param obj the object (<code>null</code> permitted). @@ -1578,6 +1636,9 @@ if (!this.regularFont.equals(that.regularFont)) { return false; } + if (!this.smallFont.equals(that.smallFont)) { + return false; + } if (!PaintUtilities.equal(this.titlePaint, that.titlePaint)) { return false; } @@ -1620,6 +1681,9 @@ that.rangeGridlinePaint)) { return false; } + if (!PaintUtilities.equal(this.crosshairPaint, that.crosshairPaint)) { + return false; + } if (!this.axisOffset.equals(that.axisOffset)) { return false; } @@ -1695,6 +1759,7 @@ SerialUtilities.writePaint(this.labelLinkPaint, stream); SerialUtilities.writePaint(this.domainGridlinePaint, stream); SerialUtilities.writePaint(this.rangeGridlinePaint, stream); + SerialUtilities.writePaint(this.crosshairPaint, stream); SerialUtilities.writePaint(this.axisLabelPaint, stream); SerialUtilities.writePaint(this.tickLabelPaint, stream); SerialUtilities.writePaint(this.itemLabelPaint, stream); @@ -1727,6 +1792,7 @@ this.labelLinkPaint = SerialUtilities.readPaint(stream); this.domainGridlinePaint = SerialUtilities.readPaint(stream); this.rangeGridlinePaint = SerialUtilities.readPaint(stream); + this.crosshairPaint = SerialUtilities.readPaint(stream); this.axisLabelPaint = SerialUtilities.readPaint(stream); this.tickLabelPaint = SerialUtilities.readPaint(stream); this.itemLabelPaint = SerialUtilities.readPaint(stream); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-19 00:30:47
|
Revision: 1625 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1625&view=rev Author: mungady Date: 2008-09-19 07:30:45 +0000 (Fri, 19 Sep 2008) Log Message: ----------- 2008-09-19 David Gilbert <dav...@ob...> Patch from Greg Darke, slightly modified: * source/org/jfree/chart/renderer/xy/XYItemRendererState.java (firstItemIndex): New field, (lastItemIndex): Likewise, (getFirstItemIndex): New method, (getLastItemIndex): New method, (startSeriesPass): Record first and last item indices, * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java (State.startSeriesPass): Reset series state, (drawItem): Removed code that is handled in State now, (drawPrimaryLineAsPath): Fix check for last item. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/demo/TimeSeriesChartDemo1.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYItemRendererState.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-19 06:59:06 UTC (rev 1624) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-19 07:30:45 UTC (rev 1625) @@ -2,6 +2,20 @@ 2008-09-19 David Gilbert <dav...@ob...> + Patch from Greg Darke, slightly modified: + * source/org/jfree/chart/renderer/xy/XYItemRendererState.java + (firstItemIndex): New field, + (lastItemIndex): Likewise, + (getFirstItemIndex): New method, + (getLastItemIndex): New method, + (startSeriesPass): Record first and last item indices, + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (State.startSeriesPass): Reset series state, + (drawItem): Removed code that is handled in State now, + (drawPrimaryLineAsPath): Fix check for last item. + +2008-09-19 David Gilbert <dav...@ob...> + * source/org/jfree/chart/StandardChartTheme.java (smallFont): New field, (crosshairPaint): New field, Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/demo/TimeSeriesChartDemo1.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/demo/TimeSeriesChartDemo1.java 2008-09-19 06:59:06 UTC (rev 1624) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/demo/TimeSeriesChartDemo1.java 2008-09-19 07:30:45 UTC (rev 1625) @@ -116,6 +116,7 @@ XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); + renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYItemRendererState.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYItemRendererState.java 2008-09-19 06:59:06 UTC (rev 1624) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYItemRendererState.java 2008-09-19 07:30:45 UTC (rev 1625) @@ -31,6 +31,7 @@ * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Ulrich Voigt; + * Greg Darke; * * Changes: * -------- @@ -40,6 +41,8 @@ * 04-May-2007 : Added processVisibleItemsOnly flag (DG); * 09-Jul-2008 : Added start/endSeriesPass() methods - see patch 1997549 by * Ulrich Voigt (DG); + * 19-Sep-2008 : Added first and last item indices, based on patch by Greg + * Darke (DG); * */ @@ -58,6 +61,20 @@ public class XYItemRendererState extends RendererState { /** + * The first item in the series that will be displayed. + * + * @since 1.0.11 + */ + private int firstItemIndex; + + /** + * The last item in the current series that will be displayed. + * + * @since 1.0.11 + */ + private int lastItemIndex; + + /** * A line object that the renderer can reuse to save instantiating a lot * of objects. */ @@ -110,10 +127,34 @@ } /** + * Returns the first item index (this is updated with each call to + * {@link #startSeriesPass(XYDataset, int, int, int, int, int)}. + * + * @return The first item index. + * + * @since 1.0.11 + */ + public int getFirstItemIndex() { + return this.firstItemIndex; + } + + /** + * Returns the last item index (this is updated with each call to + * {@link #startSeriesPass(XYDataset, int, int, int, int, int)}. + * + * @return The last item index. + * + * @since 1.0.11 + */ + public int getLastItemIndex() { + return this.lastItemIndex; + } + + /** * This method is called by the {@link XYPlot} when it starts a pass * through the (visible) items in a series. The default implementation - * does nothing, but you can override this method to implement specialised - * behaviour. + * records the first and last item indices - override this method to + * implement additional specialised behaviour. * * @param dataset the dataset. * @param series the series index. @@ -128,7 +169,8 @@ */ public void startSeriesPass(XYDataset dataset, int series, int firstItem, int lastItem, int pass, int passCount) { - // do nothing...this is just a hook for subclasses + this.firstItemIndex = firstItem; + this.lastItemIndex = lastItem; } /** Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java 2008-09-19 06:59:06 UTC (rev 1624) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java 2008-09-19 07:30:45 UTC (rev 1625) @@ -63,6 +63,7 @@ * 26-Oct-2007 : Deprecated override attributes (DG); * 02-Jun-2008 : Fixed tooltips at lower edges of data area (DG); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * 19-Sep-2008 : Fixed bug with drawSeriesLineAsPath - patch by Greg Darke (DG); * */ @@ -807,6 +808,26 @@ public void setLastPointGood(boolean good) { this.lastPointGood = good; } + + /** + * This method is called by the {@link XYPlot} at the start of each + * series pass. We reset the state for the current series. + * + * @param dataset the dataset. + * @param series the series index. + * @param firstItem the first item index for this pass. + * @param lastItem the last item index for this pass. + * @param pass the current pass index. + * @param passCount the number of passes. + */ + public void startSeriesPass(XYDataset dataset, int series, + int firstItem, int lastItem, int pass, int passCount) { + this.seriesPath.reset(); + this.lastPointGood = false; + super.startSeriesPass(dataset, series, firstItem, lastItem, pass, + passCount); + } + } /** @@ -875,14 +896,6 @@ // first pass draws the background (lines, for instance) if (isLinePass(pass)) { - if (item == 0) { - if (this.drawSeriesLineAsPath) { - State s = (State) state; - s.seriesPath.reset(); - s.lastPointGood = false; - } - } - if (getItemLineVisible(series, item)) { if (this.drawSeriesLineAsPath) { drawPrimaryLineAsPath(state, g2, plot, dataset, pass, @@ -1080,7 +1093,7 @@ s.setLastPointGood(false); } // if this is the last item, draw the path ... - if (item == dataset.getItemCount(series) - 1) { + if (item == s.getLastItemIndex()) { // draw path drawFirstPassShape(g2, pass, series, item, s.seriesPath); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-19 00:52:12
|
Revision: 1628 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1628&view=rev Author: mungady Date: 2008-09-19 07:52:10 +0000 (Fri, 19 Sep 2008) Log Message: ----------- Update for release. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/NEWS branches/jfreechart-1.0.x-branch/README.txt Modified: branches/jfreechart-1.0.x-branch/NEWS =================================================================== --- branches/jfreechart-1.0.x-branch/NEWS 2008-09-19 07:51:47 UTC (rev 1627) +++ branches/jfreechart-1.0.x-branch/NEWS 2008-09-19 07:52:10 UTC (rev 1628) @@ -1,6 +1,6 @@ JFreeChart 1.0.11 ----------------- -18 September 2008 +19 September 2008 This release features a new chart theming mechanism to allow charts to be restyled conveniently, a new BarPainter mechanism to enhance the appearance of Modified: branches/jfreechart-1.0.x-branch/README.txt =================================================================== --- branches/jfreechart-1.0.x-branch/README.txt 2008-09-19 07:51:47 UTC (rev 1627) +++ branches/jfreechart-1.0.x-branch/README.txt 2008-09-19 07:52:10 UTC (rev 1628) @@ -2,7 +2,7 @@ * JFREECHART: Version 1.0.11 * ******************************** -18 September 2008 +19 September 2008 (C)opyright 2000-2008, by Object Refinery Limited and Contributors. @@ -730,6 +730,7 @@ - Pascal Collet - Martin Cordova - Paolo Cova + - Greg Darke - Mike Duffy - Don Elliott - Rune Fauske This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-19 01:31:11
|
Revision: 1629 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1629&view=rev Author: mungady Date: 2008-09-19 08:31:08 +0000 (Fri, 19 Sep 2008) Log Message: ----------- Sample files for inclusion in Javadocs. Added Paths: ----------- branches/jfreechart-1.0.x-branch/docfiles/ branches/jfreechart-1.0.x-branch/docfiles/BarRendererSample.png branches/jfreechart-1.0.x-branch/docfiles/DeviationRendererSample.png branches/jfreechart-1.0.x-branch/docfiles/DialPlotSample.png branches/jfreechart-1.0.x-branch/docfiles/LineAndShapeRendererSample.png branches/jfreechart-1.0.x-branch/docfiles/PiePlotSample.png Property changes on: branches/jfreechart-1.0.x-branch/docfiles/BarRendererSample.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: branches/jfreechart-1.0.x-branch/docfiles/DeviationRendererSample.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: branches/jfreechart-1.0.x-branch/docfiles/DialPlotSample.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: branches/jfreechart-1.0.x-branch/docfiles/LineAndShapeRendererSample.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Property changes on: branches/jfreechart-1.0.x-branch/docfiles/PiePlotSample.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-23 07:02:12
|
Revision: 1634 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1634&view=rev Author: mungady Date: 2008-09-23 07:02:00 +0000 (Tue, 23 Sep 2008) Log Message: ----------- 2008-09-23 David Gilbert <dav...@ob...> * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java (drawItem): Check shadow visibility before drawing shadow. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/NEWS branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-19 09:59:05 UTC (rev 1633) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-23 07:02:00 UTC (rev 1634) @@ -1,3 +1,8 @@ +2008-09-23 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java + (drawItem): Check shadow visibility before drawing shadow. + ---------- JFREECHART 1.0.11 RELEASED ------------------------ 2008-09-19 David Gilbert <dav...@ob...> Modified: branches/jfreechart-1.0.x-branch/NEWS =================================================================== --- branches/jfreechart-1.0.x-branch/NEWS 2008-09-19 09:59:05 UTC (rev 1633) +++ branches/jfreechart-1.0.x-branch/NEWS 2008-09-23 07:02:00 UTC (rev 1634) @@ -1,3 +1,10 @@ +JFreeChart 1.0.12 +----------------- +?? ??? 2008 + +Also fixed StackedXYBarRenderer which was ignoring the shadowsVisible attribute. + + JFreeChart 1.0.11 ----------------- 19 September 2008 Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java 2008-09-19 09:59:05 UTC (rev 1633) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java 2008-09-23 07:02:00 UTC (rev 1634) @@ -48,6 +48,7 @@ * 06-Dec-2006 : Added support for GradientPaint (DG); * 15-Mar-2007 : Added renderAsPercentages option (DG); * 24-Jun-2008 : Added new barPainter mechanism (DG); + * 23-Sep-2008 : Check shadow visibility before drawing shadow (DG); * */ @@ -365,8 +366,10 @@ } if (pass == 0) { - getBarPainter().paintBarShadow(g2, this, series, item, bar, barBase, - false); + if (getShadowsVisible()) { + getBarPainter().paintBarShadow(g2, this, series, item, bar, + barBase, false); + } } else if (pass == 1) { getBarPainter().paintBar(g2, this, series, item, bar, barBase); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-23 07:59:50
|
Revision: 1636 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1636&view=rev Author: mungady Date: 2008-09-23 07:59:39 +0000 (Tue, 23 Sep 2008) Log Message: ----------- 2008-09-23 David Gilbert <dav...@ob...> Bug 2121818 (fix by Christoph Beck): * source/org/jfree/chart/plot/PiePlot.java (getLabelLinkDepth): New method, (drawLeftLabels): Use getLabelLinkDepth(), (drawRightLabels): Likewise, * source/org/jfree/chart/plot/RingPlot.java (getLabelLinkDepth): New method. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/NEWS branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/RingPlot.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-23 07:12:53 UTC (rev 1635) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-23 07:59:39 UTC (rev 1636) @@ -1,5 +1,15 @@ 2008-09-23 David Gilbert <dav...@ob...> + Bug 2121818 (fix by Christoph Beck): + * source/org/jfree/chart/plot/PiePlot.java + (getLabelLinkDepth): New method, + (drawLeftLabels): Use getLabelLinkDepth(), + (drawRightLabels): Likewise, + * source/org/jfree/chart/plot/RingPlot.java + (getLabelLinkDepth): New method. + +2008-09-23 David Gilbert <dav...@ob...> + * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java (drawItem): Check shadow visibility before drawing shadow. Modified: branches/jfreechart-1.0.x-branch/NEWS =================================================================== --- branches/jfreechart-1.0.x-branch/NEWS 2008-09-23 07:12:53 UTC (rev 1635) +++ branches/jfreechart-1.0.x-branch/NEWS 2008-09-23 07:59:39 UTC (rev 1636) @@ -2,6 +2,9 @@ ----------------- ?? ??? 2008 +Bug Fixes: +2121818 : Label link lines for very thin RingPlot; + Also fixed StackedXYBarRenderer which was ignoring the shadowsVisible attribute. 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-09-23 07:12:53 UTC (rev 1635) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/PiePlot.java 2008-09-23 07:59:39 UTC (rev 1636) @@ -37,6 +37,7 @@ * Arnaud Lelievre; * Martin Hilpert (patch 1891849); * Andreas Schroeder (very minor); + * Christoph Beck (bug 2121818); * * Changes * ------- @@ -157,6 +158,8 @@ * 15-Aug-2008 : Added methods to clear section attributes (DG); * 15-Aug-2008 : Fixed bug 2051168 - problem with LegendItemEntity * generation (DG); + * 23-Sep-2008 : Added getLabelLinkDepth() method - see bug 2121818 reported + * by Christoph Beck (DG); * */ @@ -1846,6 +1849,21 @@ } /** + * Returns the distance that the end of the label link is embedded into + * the plot, expressed as a percentage of the plot's radius. + * <br><br> + * This method is overridden in the {@link RingPlot} class to resolve + * bug 2121818. + * + * @return <code>0.10</code>. + * + * @since 1.0.12 + */ + protected double getLabelLinkDepth() { + return 0.1; + } + + /** * Returns the section label font. * * @return The font (never <code>null</code>). @@ -2815,7 +2833,8 @@ this.labelDistributor.addPieLabelRecord(new PieLabelRecord( leftKeys.getKey(i), theta, baseY, labelBox, hh, - lGap / 2.0 + lGap / 2.0 * -Math.cos(theta), 0.9 + lGap / 2.0 + lGap / 2.0 * -Math.cos(theta), 1.0 + - getLabelLinkDepth() + getExplodePercent(leftKeys.getKey(i)))); } } @@ -2869,7 +2888,8 @@ this.labelDistributor.addPieLabelRecord(new PieLabelRecord( keys.getKey(i), theta, baseY, labelBox, hh, lGap / 2.0 + lGap / 2.0 * Math.cos(theta), - 0.9 + getExplodePercent(keys.getKey(i)))); + 1.0 - getLabelLinkDepth() + + getExplodePercent(keys.getKey(i)))); } } double hh = plotArea.getHeight(); Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/RingPlot.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/RingPlot.java 2008-09-23 07:12:53 UTC (rev 1635) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/RingPlot.java 2008-09-23 07:59:39 UTC (rev 1636) @@ -30,7 +30,7 @@ * (C) Copyright 2004-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limtied); - * Contributor(s): -; + * Contributor(s): Christoph Beck (bug 2121818); * * Changes * ------- @@ -43,6 +43,7 @@ * 27-Sep-2006 : Updated drawItem() method for new lookup methods (DG); * 12-Oct-2006 : Added configurable section depth (DG); * 14-Feb-2007 : Added notification in setSectionDepth() method (DG); + * 23-Sep-2008 : Fix for bug 2121818 by Christoph Beck (DG); * */ @@ -457,6 +458,16 @@ } /** + * This method overrides the default value for cases where the ring plot + * is very thin. This fixes bug 2121818. + * + * @return The label link depth, as a percentage of the plot's radius. + */ + protected double getLabelLinkDepth() { + return Math.min(super.getLabelLinkDepth(), getSectionDepth() / 2); + } + + /** * Tests this plot for equality with an arbitrary object. * * @param obj the object to test against (<code>null</code> permitted). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-24 07:51:27
|
Revision: 1638 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1638&view=rev Author: mungady Date: 2008-09-24 07:51:17 +0000 (Wed, 24 Sep 2008) Log Message: ----------- 2008-09-24 David Gilbert <dav...@ob...> Bug 2113627 * source/org/jfree/chart/renderer/XYStepRenderer.java (drawItem): Draw item labels in second pass only, add chart entity info in first pass only. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYStepRenderer.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-23 08:08:23 UTC (rev 1637) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-24 07:51:17 UTC (rev 1638) @@ -1,3 +1,10 @@ +2008-09-24 David Gilbert <dav...@ob...> + + Bug 2113627 + * source/org/jfree/chart/renderer/XYStepRenderer.java + (drawItem): Draw item labels in second pass only, add chart + entity info in first pass only. + 2008-09-23 David Gilbert <dav...@ob...> Bug 2121818 (fix by Christoph Beck): @@ -34,7 +41,7 @@ * source/org/jfree/chart/StandardChartTheme.java (smallFont): New field, (crosshairPaint): New field, - (createDarknessTheme): Initilise crosshairPaint, + (createDarknessTheme): Initialise crosshairPaint, (StandardChartTheme): Initialise new fields, (getCrosshairPaint): New method, (setCrosshairPaint): Likewise, Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYStepRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYStepRenderer.java 2008-09-23 08:08:23 UTC (rev 1637) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/XYStepRenderer.java 2008-09-24 07:51:17 UTC (rev 1638) @@ -63,6 +63,8 @@ * 14-Feb-2008 : Applied patch 1874890 by Ulrich Voigt (with contribution from * Martin Hoeller) (DG); * 14-May-2008 : Call addEntity() in drawItem() (DG); + * 24-Sep-2008 : Fixed bug 2113627 by utilising second pass to draw item + * labels (DG); * */ @@ -182,7 +184,7 @@ * @param item the item index (zero-based). * @param crosshairState crosshair information for the plot * (<code>null</code> permitted). - * @param pass the pass index (ignored here). + * @param pass the pass index. */ public void drawItem(Graphics2D g2, XYItemRendererState state, @@ -219,7 +221,7 @@ double transY1 = (Double.isNaN(y1) ? Double.NaN : rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation)); - if (item > 0) { + if (pass== 0 && item > 0) { // get the previous data point... double x0 = dataset.getXValue(series, item - 1); double y0 = dataset.getYValue(series, item - 1); @@ -267,32 +269,34 @@ } } - } + // submit this data item as a candidate for the crosshair point + int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); + int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); + updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, + rangeAxisIndex, transX1, transY1, orientation); - // draw the item label if there is one... - if (isItemLabelVisible(series, item)) { - double xx = transX1; - double yy = transY1; - if (orientation == PlotOrientation.HORIZONTAL) { - xx = transY1; - yy = transX1; + // collect entity and tool tip information... + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addEntity(entities, null, dataset, series, item, transX1, + transY1); } - drawItemLabel(g2, orientation, dataset, series, item, xx, yy, - (y1 < 0.0)); + } - // submit this data item as a candidate for the crosshair point - int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); - int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); - updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, - rangeAxisIndex, transX1, transY1, orientation); - - // collect entity and tool tip information... - EntityCollection entities = state.getEntityCollection(); - if (entities != null) { - addEntity(entities, null, dataset, series, item, transX1, transY1); + if (pass == 1) { + // draw the item label if there is one... + if (isItemLabelVisible(series, item)) { + double xx = transX1; + double yy = transY1; + if (orientation == PlotOrientation.HORIZONTAL) { + xx = transY1; + yy = transX1; + } + drawItemLabel(g2, orientation, dataset, series, item, xx, yy, + (y1 < 0.0)); + } } - } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-25 09:47:58
|
Revision: 1640 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1640&view=rev Author: mungady Date: 2008-09-25 09:47:55 +0000 (Thu, 25 Sep 2008) Log Message: ----------- 2008-09-25 David Gilbert <dav...@ob...> * source/org/jfree/chart/renderer/xy/HighLowRenderer.java (drawItem): Check for non-null entity collection. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/HighLowRenderer.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-24 07:57:25 UTC (rev 1639) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-25 09:47:55 UTC (rev 1640) @@ -1,7 +1,12 @@ +2008-09-25 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/renderer/xy/HighLowRenderer.java + (drawItem): Check for non-null entity collection. + 2008-09-24 David Gilbert <dav...@ob...> Bug 2113627 - * source/org/jfree/chart/renderer/XYStepRenderer.java + * source/org/jfree/chart/renderer/xy/XYStepRenderer.java (drawItem): Draw item labels in second pass only, add chart entity info in first pass only. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/HighLowRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/HighLowRenderer.java 2008-09-24 07:57:25 UTC (rev 1639) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/HighLowRenderer.java 2008-09-25 09:47:55 UTC (rev 1640) @@ -62,6 +62,7 @@ * 06-Jul-2006 : Replace dataset methods getX() --> getXValue() (DG); * 08-Apr-2008 : Added findRangeBounds() override (DG); * 29-Apr-2008 : Added tickLength field (DG); + * 25-Sep-2008 : Check for non-null entity collection (DG); * */ @@ -438,7 +439,9 @@ } } - addEntity(entities, entityArea, dataset, series, item, 0.0, 0.0); + if (entities != null) { + addEntity(entities, entityArea, dataset, series, item, 0.0, 0.0); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-25 15:34:15
|
Revision: 1642 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1642&view=rev Author: mungady Date: 2008-09-25 15:34:01 +0000 (Thu, 25 Sep 2008) Log Message: ----------- 2008-09-25 David Gilbert <dav...@ob...> Patch 1934255 (incorporating 1870189): * source/org/jfree/chart/axis/Axis.java (minorTickMarksVisible): New field, (minorTickMarkInsideLength): New field, (minorTickMarkOutsideLength): New field, (Axis(String)): Initialise new fields, (isMinorTickMarksVisible): New method, (setMinorTickMarksVisible): Likewise, (getMinorTickMarkInsideLength): Likewise, (setMinorTickMarkInsideLength): Likewise, (getMinorTickMarkOutsideLength): Likewise, (setMinorTickMarkOutsideLength): Likewise, * source/org/jfree/chart/axis/DateAxis.java (refreshTicksHorizontal): Add minor ticks, (refreshTicksVertical): Likewise, * source/org/jfree/chart/axis/DateTick.java (DateTick): New constructor, (equals): Clean up, * source/org/jfree/chart/axis/LogAxis.java (minorTickCount): Removed (now in superclass), (LogAxis(String)): Updated for removed field, (getMinorTickCount): Removed (now in superclass), (setMinorTickCount): Likewise, (refreshTicksHorizontal): Updated for removed field, (refreshTicksVertical): Likewise, (equals): Likewise, (hashCode): Likewise, * source/org/jfree/chart/axis/NumberAxis.java (refreshTicksHorizontal): Add minor ticks, (refreshTicksVertical): Likewise, * source/org/jfree/chart/axis/ValueAxis.java (minorTickCount): New field, (drawTickMarksAndLabels): Draw minor ticks, (getMinorTickCount): New method, (setMinorTickCount): Likewise, (equals): Updated for new field, * source/org/jfree/chart/plot/XYPlot.java (domainMinorGridlinesVisible): New field, (domainMinorGridlineStroke): Likewise, (domainMinorGridlinePaint): Likewise, (rangeMinorGridlinesVisible): Likewise, (rangeMinorGridlineStroke): Likewise, (rangeMinorGridlinePaint): Likewise, (XYPlot): Initialise new fields, (isDomainMinorGridlinesVisible): New method, (setDomainMinorGridlinesVisible): Likewise, (getDomainMinorGridlineStroke): Likewise, (setDomainMinorGridlineStroke): Likewise, (getDomainMinorGridlinePaint): Likewise, (setDomainMinorGridlinePaint): Likewise, (isRangeMinorGridlinesVisible): Likewise, (setRangeMinorGridlinesVisible): Likewise, (getRangeMinorGridlineStroke): Likewise, (setRangeMinorGridlineStroke): Likewise, (getRangeMinorGridlinePaint): Likewise, (setRangeMinorGridlinePaint): Likewise, (drawDomainGridlines): Draw minor gridlines too, (drawRangeGridlines): Likewise, (equals): Updated for new attributes, (writeObject): Likewise, (readObject): Likewise, * tests/org/jfree/chart/axis/junit/AxisTests.java (testEquals): Updated for new field, * tests/org/jfree/chart/axis/junit/DateTickTests.java (testEquals): Updated for new field, * tests/org/jfree/chart/plot/junit/XYPlotTests.java (testEquals): Updated for new fields. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/Axis.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateAxis.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateTick.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/LogAxis.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/NumberAxis.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueAxis.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/junit/AxisTests.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/junit/DateTickTests.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/XYPlotTests.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-25 10:02:23 UTC (rev 1641) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-25 15:34:01 UTC (rev 1642) @@ -1,5 +1,75 @@ 2008-09-25 David Gilbert <dav...@ob...> + Patch 1934255 (incorporating 1870189): + * source/org/jfree/chart/axis/Axis.java + (minorTickMarksVisible): New field, + (minorTickMarkInsideLength): New field, + (minorTickMarkOutsideLength): New field, + (Axis(String)): Initialise new fields, + (isMinorTickMarksVisible): New method, + (setMinorTickMarksVisible): Likewise, + (getMinorTickMarkInsideLength): Likewise, + (setMinorTickMarkInsideLength): Likewise, + (getMinorTickMarkOutsideLength): Likewise, + (setMinorTickMarkOutsideLength): Likewise, + * source/org/jfree/chart/axis/DateAxis.java + (refreshTicksHorizontal): Add minor ticks, + (refreshTicksVertical): Likewise, + * source/org/jfree/chart/axis/DateTick.java + (DateTick): New constructor, + (equals): Clean up, + * source/org/jfree/chart/axis/LogAxis.java + (minorTickCount): Removed (now in superclass), + (LogAxis(String)): Updated for removed field, + (getMinorTickCount): Removed (now in superclass), + (setMinorTickCount): Likewise, + (refreshTicksHorizontal): Updated for removed field, + (refreshTicksVertical): Likewise, + (equals): Likewise, + (hashCode): Likewise, + * source/org/jfree/chart/axis/NumberAxis.java + (refreshTicksHorizontal): Add minor ticks, + (refreshTicksVertical): Likewise, + * source/org/jfree/chart/axis/ValueAxis.java + (minorTickCount): New field, + (drawTickMarksAndLabels): Draw minor ticks, + (getMinorTickCount): New method, + (setMinorTickCount): Likewise, + (equals): Updated for new field, + * source/org/jfree/chart/plot/XYPlot.java + (domainMinorGridlinesVisible): New field, + (domainMinorGridlineStroke): Likewise, + (domainMinorGridlinePaint): Likewise, + (rangeMinorGridlinesVisible): Likewise, + (rangeMinorGridlineStroke): Likewise, + (rangeMinorGridlinePaint): Likewise, + (XYPlot): Initialise new fields, + (isDomainMinorGridlinesVisible): New method, + (setDomainMinorGridlinesVisible): Likewise, + (getDomainMinorGridlineStroke): Likewise, + (setDomainMinorGridlineStroke): Likewise, + (getDomainMinorGridlinePaint): Likewise, + (setDomainMinorGridlinePaint): Likewise, + (isRangeMinorGridlinesVisible): Likewise, + (setRangeMinorGridlinesVisible): Likewise, + (getRangeMinorGridlineStroke): Likewise, + (setRangeMinorGridlineStroke): Likewise, + (getRangeMinorGridlinePaint): Likewise, + (setRangeMinorGridlinePaint): Likewise, + (drawDomainGridlines): Draw minor gridlines too, + (drawRangeGridlines): Likewise, + (equals): Updated for new attributes, + (writeObject): Likewise, + (readObject): Likewise, + * tests/org/jfree/chart/axis/junit/AxisTests.java + (testEquals): Updated for new field, + * tests/org/jfree/chart/axis/junit/DateTickTests.java + (testEquals): Updated for new field, + * tests/org/jfree/chart/plot/junit/XYPlotTests.java + (testEquals): Updated for new fields. + +2008-09-25 David Gilbert <dav...@ob...> + * source/org/jfree/chart/renderer/xy/HighLowRenderer.java (drawItem): Check for non-null entity collection. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/Axis.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/Axis.java 2008-09-25 10:02:23 UTC (rev 1641) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/Axis.java 2008-09-25 15:34:01 UTC (rev 1642) @@ -31,7 +31,9 @@ * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Bill Kelemen; - * Nicolas Brodu. + * Nicolas Brodu; + * Peter Kolb (patch 1934255); + * Andrew Mickish (patch 1870189); * * Changes * ------- @@ -77,6 +79,7 @@ * ------------- JFREECHART 1.0.x --------------------------------------------- * 22-Aug-2006 : API doc updates (DG); * 06-Jun-2008 : Added setTickLabelInsets(RectangleInsets, boolean) (DG); + * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); * */ @@ -217,17 +220,45 @@ private RectangleInsets tickLabelInsets; /** - * A flag that indicates whether or not tick marks are visible for the - * axis. + * A flag that indicates whether or not major tick marks are visible for + * the axis. */ private boolean tickMarksVisible; - /** The length of the tick mark inside the data area (zero permitted). */ + /** + * The length of the major tick mark inside the data area (zero + * permitted). + */ private float tickMarkInsideLength; - /** The length of the tick mark outside the data area (zero permitted). */ + /** + * The length of the major tick mark outside the data area (zero + * permitted). + */ private float tickMarkOutsideLength; + /** + * A flag that indicates whether or not minor tick marks are visible for the + * axis. + * + * @since 1.0.12 + */ + private boolean minorTickMarksVisible; + + /** + * The length of the minor tick mark inside the data area (zero permitted). + * + * @since 1.0.12 + */ + private float minorTickMarkInsideLength; + + /** + * The length of the minor tick mark outside the data area (zero permitted). + * + * @since 1.0.12 + */ + private float minorTickMarkOutsideLength; + /** The stroke used to draw tick marks. */ private transient Stroke tickMarkStroke; @@ -275,6 +306,10 @@ this.tickMarkInsideLength = DEFAULT_TICK_MARK_INSIDE_LENGTH; this.tickMarkOutsideLength = DEFAULT_TICK_MARK_OUTSIDE_LENGTH; + this.minorTickMarksVisible = false; + this.minorTickMarkInsideLength = 0.0f; + this.minorTickMarkOutsideLength = 2.0f; + this.plot = null; this.listenerList = new EventListenerList(); @@ -590,6 +625,38 @@ } /** + * Returns the flag that indicates whether or not the minor tick marks are + * showing. + * + * @return The flag that indicates whether or not the minor tick marks are + * showing. + * + * @see #setMinorTickMarksVisible(boolean) + * + * @since 1.0.12 + */ + public boolean isMinorTickMarksVisible() { + return this.minorTickMarksVisible; + } + + /** + * Sets the flag that indicates whether or not the minor tick marks are showing + * and sends an {@link AxisChangeEvent} to all registered listeners. + * + * @param flag the flag. + * + * @see #isMinorTickMarksVisible() + * + * @since 1.0.12 + */ + public void setMinorTickMarksVisible(boolean flag) { + if (flag != this.minorTickMarksVisible) { + this.minorTickMarksVisible = flag; + notifyListeners(new AxisChangeEvent(this)); + } + } + + /** * Returns the font used for the tick labels (if showing). * * @return The font (never <code>null</code>). @@ -812,6 +879,64 @@ } /** + * Returns the inside length of the minor tick marks. + * + * @return The length. + * + * @see #getMinorTickMarkOutsideLength() + * @see #setMinorTickMarkInsideLength(float) + * + * @since 1.0.12 + */ + public float getMinorTickMarkInsideLength() { + return this.minorTickMarkInsideLength; + } + + /** + * Sets the inside length of the minor tick marks and sends + * an {@link AxisChangeEvent} to all registered listeners. + * + * @param length the new length. + * + * @see #getMinorTickMarkInsideLength() + * + * @since 1.0.12 + */ + public void setMinorTickMarkInsideLength(float length) { + this.minorTickMarkInsideLength = length; + notifyListeners(new AxisChangeEvent(this)); + } + + /** + * Returns the outside length of the minor tick marks. + * + * @return The length. + * + * @see #getMinorTickMarkInsideLength() + * @see #setMinorTickMarkOutsideLength(float) + * + * @since 1.0.12 + */ + public float getMinorTickMarkOutsideLength() { + return this.minorTickMarkOutsideLength; + } + + /** + * Sets the outside length of the minor tick marks and sends + * an {@link AxisChangeEvent} to all registered listeners. + * + * @param length the new length. + * + * @see #getMinorTickMarkInsideLength() + * + * @since 1.0.12 + */ + public void setMinorTickMarkOutsideLength(float length) { + this.minorTickMarkOutsideLength = length; + notifyListeners(new AxisChangeEvent(this)); + } + + /** * Returns the plot that the axis is assigned to. This method will return * <code>null</code> if the axis is not currently assigned to a plot. * @@ -1239,6 +1364,15 @@ if (!ObjectUtilities.equal(this.tickMarkStroke, that.tickMarkStroke)) { return false; } + if (this.minorTickMarksVisible != that.minorTickMarksVisible) { + return false; + } + if (this.minorTickMarkInsideLength != that.minorTickMarkInsideLength) { + return false; + } + if (this.minorTickMarkOutsideLength != that.minorTickMarkOutsideLength) { + return false; + } if (this.fixedDimension != that.fixedDimension) { return false; } 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-25 10:02:23 UTC (rev 1641) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateAxis.java 2008-09-25 15:34:01 UTC (rev 1642) @@ -36,6 +36,8 @@ * Bill Kelemen; * Pawel Pabis; * Chris Boek; + * Peter Kolb (patch 1934255); + * Andrew Mickish (patch 1870189); * * Changes (from 23-Jun-2001) * -------------------------- @@ -118,6 +120,7 @@ * 01-Sep-2008 : Use new methods from DateRange, added fix for bug * 2078057 (DG); * 18-Sep-2008 : Added locale to go with timezone (DG); + * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); * */ @@ -1565,8 +1568,7 @@ * @return A list of ticks. */ protected List refreshTicksHorizontal(Graphics2D g2, - Rectangle2D dataArea, - RectangleEdge edge) { + Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); @@ -1582,6 +1584,20 @@ Date upperDate = getMaximumDate(); while (tickDate.before(upperDate)) { + long lowestTickTime = tickDate.getTime(); + long distance = unit.addToDate(tickDate, this.timeZone).getTime() + - lowestTickTime; + for(int minorTick = 1; minorTick < getMinorTickCount(); + minorTick++) { + long minorTickTime = lowestTickTime - distance + * minorTick / getMinorTickCount(); + if (minorTickTime > 0 && getRange().contains(minorTickTime) + && (!isHiddenValue(minorTickTime))) { + result.add(new DateTick(TickType.MINOR, + new Date(minorTickTime), "", TextAnchor.TOP_CENTER, + TextAnchor.CENTER, 0.0)); + } + } if (!isHiddenValue(tickDate.getTime())) { // work out the value, label and position @@ -1620,7 +1636,24 @@ Tick tick = new DateTick(tickDate, tickLabel, anchor, rotationAnchor, angle); result.add(tick); + + long currentTickTime = tickDate.getTime(); tickDate = unit.addToDate(tickDate, this.timeZone); + long nextTickTime = tickDate.getTime(); + for (int minorTick = 1; minorTick < getMinorTickCount(); + minorTick++){ + long minorTickTime = currentTickTime + + (nextTickTime - currentTickTime) + * minorTick / getMinorTickCount(); + if (getRange().contains(minorTickTime) + && (!isHiddenValue(minorTickTime))) { + result.add(new DateTick(TickType.MINOR, + new Date(minorTickTime), "", + TextAnchor.TOP_CENTER, TextAnchor.CENTER, + 0.0)); + } + } + } else { tickDate = unit.rollDate(tickDate, this.timeZone); @@ -1666,8 +1699,7 @@ * @return A list of ticks. */ protected List refreshTicksVertical(Graphics2D g2, - Rectangle2D dataArea, - RectangleEdge edge) { + Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); @@ -1683,6 +1715,20 @@ Date upperDate = getMaximumDate(); while (tickDate.before(upperDate)) { + long lowestTickTime = tickDate.getTime(); + long distance = unit.addToDate(tickDate, this.timeZone).getTime() + - lowestTickTime; + for(int minorTick = 1; minorTick < getMinorTickCount(); + minorTick++) { + long minorTickTime = lowestTickTime - distance + * minorTick / getMinorTickCount(); + if (minorTickTime > 0 && getRange().contains(minorTickTime) + && (!isHiddenValue(minorTickTime))) { + result.add(new DateTick(TickType.MINOR, + new Date(minorTickTime), "", TextAnchor.TOP_CENTER, + TextAnchor.CENTER, 0.0)); + } + } if (!isHiddenValue(tickDate.getTime())) { // work out the value, label and position String tickLabel; @@ -1720,7 +1766,22 @@ Tick tick = new DateTick(tickDate, tickLabel, anchor, rotationAnchor, angle); result.add(tick); + long currentTickTime = tickDate.getTime(); tickDate = unit.addToDate(tickDate, this.timeZone); + long nextTickTime = tickDate.getTime(); + for(int minorTick = 1; minorTick < getMinorTickCount(); + minorTick++){ + long minorTickTime = currentTickTime + + (nextTickTime - currentTickTime) + * minorTick / getMinorTickCount(); + if (getRange().contains(minorTickTime) + && (!isHiddenValue(minorTickTime))) { + result.add(new DateTick(TickType.MINOR, + new Date(minorTickTime), "", + TextAnchor.TOP_CENTER, TextAnchor.CENTER, + 0.0)); + } + } } else { tickDate = unit.rollDate(tickDate, this.timeZone); @@ -1833,10 +1894,7 @@ if (!ObjectUtilities.equal(this.timeline, that.timeline)) { return false; } - if (!super.equals(obj)) { - return false; - } - return true; + return super.equals(obj); } /** Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateTick.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateTick.java 2008-09-25 10:02:23 UTC (rev 1641) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/DateTick.java 2008-09-25 15:34:01 UTC (rev 1642) @@ -30,12 +30,14 @@ * (C) Copyright 2003-2008, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); - * Contributor(s): -; + * Contributor(s): Peter Kolb (patch 1934255); + * Andrew Mickish (patch 1870189); * * Changes * ------- * 07-Nov-2003 : Version 1 (DG); * 13-May-2004 : Added equals() method (DG); + * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); * */ @@ -68,7 +70,28 @@ TextAnchor textAnchor, TextAnchor rotationAnchor, double angle) { - super(date.getTime(), label, textAnchor, rotationAnchor, angle); + this(TickType.MAJOR, date, label, textAnchor, rotationAnchor, angle); + + } + + /** + * Creates a new date tick. + * + * @param tickType the tick type. + * @param date the date. + * @param label the label. + * @param textAnchor the part of the label that is aligned to the anchor + * point. + * @param rotationAnchor defines the rotation point relative to the text. + * @param angle the rotation angle (in radians). + * + * @since 1.0.12 + */ + public DateTick(TickType tickType, Date date, String label, + TextAnchor textAnchor, TextAnchor rotationAnchor, + double angle) { + + super(tickType, date.getTime(), label, textAnchor, rotationAnchor, angle); this.date = date; } @@ -93,14 +116,14 @@ if (obj == this) { return true; } - if (obj instanceof DateTick && super.equals(obj)) { - DateTick dt = (DateTick) obj; - if (!ObjectUtilities.equal(this.date, dt.date)) { - return false; - } - return true; + if (!(obj instanceof DateTick)) { + return false; } - return false; + DateTick that = (DateTick) obj; + if (!ObjectUtilities.equal(this.date, that.date)) { + return false; + } + return super.equals(obj); } /** Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/LogAxis.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/LogAxis.java 2008-09-25 10:02:23 UTC (rev 1641) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/LogAxis.java 2008-09-25 15:34:01 UTC (rev 1642) @@ -31,6 +31,7 @@ * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Andrew Mickish (patch 1868745); + * Peter Kolb (patch 1934255); * * Changes * ------- @@ -46,6 +47,8 @@ * labels for vertical axis (DG); * 26-Mar-2008 : Changed createTickLabel() method from private to protected - * see patch 1918209 by Andrew Mickish (DG); + * 25-Sep-2008 : Moved minor tick fields up to superclass, see patch 1934255 + * by Peter Kolb (DG); * */ @@ -95,9 +98,6 @@ /** The override number format. */ private NumberFormat numberFormatOverride; - /** The number of minor ticks per major tick unit. */ - private int minorTickCount; - /** * Creates a new <code>LogAxis</code> with no label. */ @@ -114,7 +114,7 @@ super(label, createLogTickUnits(Locale.getDefault())); setDefaultAutoRange(new Range(0.01, 1.0)); this.tickUnit = new NumberTickUnit(1.0, new DecimalFormat("0.#")); - this.minorTickCount = 9; + setMinorTickCount(9); } /** @@ -254,33 +254,6 @@ } /** - * Returns the number of minor tick marks to display. - * - * @return The number of minor tick marks to display. - * - * @see #setMinorTickCount(int) - */ - public int getMinorTickCount() { - return this.minorTickCount; - } - - /** - * Sets the number of minor tick marks to display, and sends an - * {@link AxisChangeEvent} to all registered listeners. - * - * @param count the count. - * - * @see #getMinorTickCount() - */ - public void setMinorTickCount(int count) { - if (count <= 0) { - throw new IllegalArgumentException("Requires 'count' > 0."); - } - this.minorTickCount = count; - notifyListeners(new AxisChangeEvent(this)); - } - - /** * Calculates the log of the given value, using the current base. * * @param value the value. @@ -545,8 +518,8 @@ // add minor ticks (for gridlines) double next = Math.pow(this.base, current + this.tickUnit.getSize()); - for (int i = 1; i < this.minorTickCount; i++) { - double minorV = v + i * ((next - v) / this.minorTickCount); + for (int i = 1; i < getMinorTickCount(); i++) { + double minorV = v + i * ((next - v) / getMinorTickCount()); if (range.contains(minorV)) { ticks.add(new NumberTick(TickType.MINOR, minorV, "", textAnchor, TextAnchor.CENTER, 0.0)); @@ -596,8 +569,8 @@ // add minor ticks (for gridlines) double next = Math.pow(this.base, current + this.tickUnit.getSize()); - for (int i = 1; i < this.minorTickCount; i++) { - double minorV = v + i * ((next - v) / this.minorTickCount); + for (int i = 1; i < getMinorTickCount(); i++) { + double minorV = v + i * ((next - v) / getMinorTickCount()); if (range.contains(minorV)) { ticks.add(new NumberTick(TickType.MINOR, minorV, "", textAnchor, TextAnchor.CENTER, 0.0)); @@ -872,9 +845,6 @@ if (this.smallestValue != that.smallestValue) { return false; } - if (this.minorTickCount != that.minorTickCount) { - return false; - } return super.equals(obj); } @@ -887,7 +857,6 @@ int result = 193; long temp = Double.doubleToLongBits(this.base); result = 37 * result + (int) (temp ^ (temp >>> 32)); - result = 37 * result + this.minorTickCount; temp = Double.doubleToLongBits(this.smallestValue); result = 37 * result + (int) (temp ^ (temp >>> 32)); if (this.numberFormatOverride != null) { Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/NumberAxis.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/NumberAxis.java 2008-09-25 10:02:23 UTC (rev 1641) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/NumberAxis.java 2008-09-25 15:34:01 UTC (rev 1642) @@ -31,6 +31,7 @@ * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Laurence Vanhelsuwe; + * Peter Kolb (patch 1934255); * * Changes * ------- @@ -90,6 +91,7 @@ * 11-Dec-2006 : Fix bug in auto-tick unit selection with tick format override, * see bug 1608371 (DG); * 22-Mar-2007 : Use new defaultAutoRange attribute (DG); + * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); * */ @@ -1163,8 +1165,7 @@ * @return A list of ticks. */ protected List refreshTicksHorizontal(Graphics2D g2, - Rectangle2D dataArea, - RectangleEdge edge) { + Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); @@ -1180,6 +1181,17 @@ double lowestTickValue = calculateLowestVisibleTickValue(); if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { + for(int minorTick = 1; minorTick < getMinorTickCount(); + minorTick++) { + double minorTickValue = lowestTickValue + - getTickUnit().getSize() + * minorTick / getMinorTickCount(); + if (getRange().contains(minorTickValue)){ + result.add(new NumberTick(TickType.MINOR, minorTickValue, + "", TextAnchor.TOP_CENTER, TextAnchor.CENTER, + 0.0)); + } + } for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); String tickLabel; @@ -1217,6 +1229,18 @@ Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); result.add(tick); + double nextTickValue = lowestTickValue + ((i + 1)* size); + for (int minorTick = 1; minorTick < getMinorTickCount(); + minorTick++){ + double minorTickValue = currentTickValue + + (nextTickValue - currentTickValue) + * minorTick / getMinorTickCount(); + if (getRange().contains(minorTickValue)){ + result.add(new NumberTick(TickType.MINOR, + minorTickValue, "", TextAnchor.TOP_CENTER, + TextAnchor.CENTER, 0.0)); + } + } } } return result; @@ -1234,8 +1258,7 @@ * @return A list of ticks. */ protected List refreshTicksVertical(Graphics2D g2, - Rectangle2D dataArea, - RectangleEdge edge) { + Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); result.clear(); @@ -1251,6 +1274,18 @@ double lowestTickValue = calculateLowestVisibleTickValue(); if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { + for (int minorTick = 1; minorTick < getMinorTickCount(); + minorTick++){ + double minorTickValue = lowestTickValue + - getTickUnit().getSize() + * minorTick / getMinorTickCount() ; + if (getRange().contains(minorTickValue)){ + result.add(new NumberTick(TickType.MINOR, minorTickValue, + "", TextAnchor.TOP_CENTER, TextAnchor.CENTER, + 0.0)); + } + } + for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); String tickLabel; @@ -1291,6 +1326,19 @@ Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); result.add(tick); + + double nextTickValue = lowestTickValue + ((i + 1)* size); + for (int minorTick = 1; minorTick < getMinorTickCount(); + minorTick++){ + double minorTickValue = currentTickValue + + (nextTickValue - currentTickValue) + * minorTick / getMinorTickCount(); + if (getRange().contains(minorTickValue)){ + result.add(new NumberTick(TickType.MINOR, + minorTickValue, "", TextAnchor.TOP_CENTER, + TextAnchor.CENTER, 0.0)); + } + } } } return result; @@ -1328,9 +1376,6 @@ if (!(obj instanceof NumberAxis)) { return false; } - if (!super.equals(obj)) { - return false; - } NumberAxis that = (NumberAxis) obj; if (this.autoRangeIncludesZero != that.autoRangeIncludesZero) { return false; @@ -1348,7 +1393,7 @@ if (!this.rangeType.equals(that.rangeType)) { return false; } - return true; + return super.equals(obj); } /** Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueAxis.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueAxis.java 2008-09-25 10:02:23 UTC (rev 1641) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/ValueAxis.java 2008-09-25 15:34:01 UTC (rev 1642) @@ -33,6 +33,8 @@ * Contributor(s): Jonathan Nash; * Nicolas Brodu (for Astrium and EADS Corporate Research * Center); + * Peter Kolb (patch 1934255); + * Andrew Mickish (patch 1870189); * * Changes * ------- @@ -96,6 +98,7 @@ * 10-Oct-2006 : Source reformatting (DG); * 22-Mar-2007 : Added new defaultAutoRange attribute (DG); * 02-Aug-2007 : Check for major tick when drawing label (DG); + * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); * */ @@ -257,6 +260,9 @@ /** An index into an array of standard tick values. */ private int autoTickIndex; + + /** The number of minor ticks per major tick unit. */ + private int minorTickCount; /** A flag indicating whether or not tick labels are rotated to vertical. */ private boolean verticalTickLabels; @@ -319,6 +325,7 @@ this.leftArrow = p4; this.verticalTickLabels = false; + this.minorTickCount = 1; } @@ -666,10 +673,8 @@ * @return The width or height used to draw the axis. */ protected AxisState drawTickMarksAndLabels(Graphics2D g2, - double cursor, - Rectangle2D plotArea, - Rectangle2D dataArea, - RectangleEdge edge) { + double cursor, Rectangle2D plotArea, Rectangle2D dataArea, + RectangleEdge edge) { AxisState state = new AxisState(cursor); @@ -677,9 +682,6 @@ drawAxisLine(g2, cursor, dataArea, edge); } - double ol = getTickMarkOutsideLength(); - double il = getTickMarkInsideLength(); - List ticks = refreshTicks(g2, state, dataArea, edge); state.setTicks(ticks); g2.setFont(getTickLabelFont()); @@ -695,8 +697,16 @@ tick.getAngle(), tick.getRotationAnchor()); } - if (isTickMarksVisible() && tick.getTickType().equals( - TickType.MAJOR)) { + if ((isTickMarksVisible() && tick.getTickType().equals( + TickType.MAJOR)) || (isMinorTickMarksVisible() + && tick.getTickType().equals(TickType.MINOR))) { + + double ol = (tick.getTickType().equals(TickType.MINOR)) ? + getMinorTickMarkOutsideLength() : getTickMarkOutsideLength(); + + double il = (tick.getTickType().equals(TickType.MINOR)) ? + getMinorTickMarkInsideLength() : getTickMarkInsideLength(); + float xx = (float) valueToJava2D(tick.getValue(), dataArea, edge); Line2D mark = null; @@ -1403,6 +1413,37 @@ } /** + * Returns the number of minor tick marks to display. + * + * @return The number of minor tick marks to display. + * + * @see #setMinorTickCount(int) + * + * @since 1.0.12 + */ + public int getMinorTickCount() { + return this.minorTickCount; + } + + /** + * Sets the number of minor tick marks to display, and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param count the count. + * + * @see #getMinorTickCount() + * + * @since 1.0.12 + */ + public void setMinorTickCount(int count) { + if (count <= 0) { + throw new IllegalArgumentException("Requires 'count' > 0."); + } + this.minorTickCount = count; + notifyListeners(new AxisChangeEvent(this)); + } + + /** * Converts a data value to a coordinate in Java2D space, assuming that the * axis runs along one edge of the specified dataArea. * <p> @@ -1567,16 +1608,13 @@ * @return <code>true</code> or <code>false</code>. */ public boolean equals(Object obj) { - if (obj == this) { return true; } if (!(obj instanceof ValueAxis)) { return false; } - ValueAxis that = (ValueAxis) obj; - if (this.positiveArrowVisible != that.positiveArrowVisible) { return false; } @@ -1617,9 +1655,10 @@ if (this.verticalTickLabels != that.verticalTickLabels) { return false; } - + if (this.minorTickCount != that.minorTickCount) { + return false; + } return super.equals(obj); - } /** 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-09-25 10:02:23 UTC (rev 1641) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/XYPlot.java 2008-09-25 15:34:01 UTC (rev 1642) @@ -43,6 +43,7 @@ * Sergei Ivanov; * Richard West, Advanced Micro Devices, Inc.; * Ulrich Voigt - patch 1997549; + * Peter Kolb - patch 1934255; * * Changes (from 21-Jun-2001) * -------------------------- @@ -206,6 +207,7 @@ * 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); + * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); * */ @@ -247,6 +249,7 @@ import org.jfree.chart.axis.AxisState; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.axis.ValueTick; +import org.jfree.chart.axis.TickType; import org.jfree.chart.event.ChartChangeEventType; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.RendererChangeEvent; @@ -373,6 +376,48 @@ private transient Paint rangeGridlinePaint; /** + * A flag that controls whether the domain minor grid-lines are visible. + * + * @since 1.0.12 + */ + private boolean domainMinorGridlinesVisible; + + /** + * The stroke used to draw the domain minor grid-lines. + * + * @since 1.0.12 + */ + private transient Stroke domainMinorGridlineStroke; + + /** + * The paint used to draw the domain minor grid-lines. + * + * @since 1.0.12 + */ + private transient Paint domainMinorGridlinePaint; + + /** + * A flag that controls whether the range minor grid-lines are visible. + * + * @since 1.0.12 + */ + private boolean rangeMinorGridlinesVisible; + + /** + * The stroke used to draw the range minor grid-lines. + * + * @since 1.0.12 + */ + private transient Stroke rangeMinorGridlineStroke; + + /** + * The paint used to draw the range minor grid-lines. + * + * @since 1.0.12 + */ + private transient Paint rangeMinorGridlinePaint; + + /** * A flag that controls whether or not the zero baseline against the domain * axis is visible. * @@ -580,6 +625,10 @@ this.domainGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.domainGridlinePaint = DEFAULT_GRIDLINE_PAINT; + this.domainMinorGridlinesVisible = false; + this.domainMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; + this.domainMinorGridlinePaint = Color.white; + this.domainZeroBaselineVisible = false; this.domainZeroBaselinePaint = Color.black; this.domainZeroBaselineStroke = new BasicStroke(0.5f); @@ -588,6 +637,10 @@ this.rangeGridlineStroke = DEFAULT_GRIDLINE_STROKE; this.rangeGridlinePaint = DEFAULT_GRIDLINE_PAINT; + this.rangeMinorGridlinesVisible = false; + this.rangeMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; + this.rangeMinorGridlinePaint = Color.white; + this.rangeZeroBaselineVisible = false; this.rangeZeroBaselinePaint = Color.black; this.rangeZeroBaselineStroke = new BasicStroke(0.5f); @@ -1635,6 +1688,40 @@ } /** + * Returns <code>true</code> if the domain minor gridlines are visible, and + * <code>false<code> otherwise. + * + * @return <code>true</code> or <code>false</code>. + * + * @see #setDomainMinorGridlinesVisible(boolean) + * + * @since 1.0.12 + */ + public boolean isDomainMinorGridlinesVisible() { + return this.domainMinorGridlinesVisible; + } + + /** + * Sets the flag that controls whether or not the domain minor grid-lines + * are visible. + * <p> + * If the flag value is changed, a {@link PlotChangeEvent} is sent to all + * registered listeners. + * + * @param visible the new value of the flag. + * + * @see #isDomainMinorGridlinesVisible() + * + * @since 1.0.12 + */ + public void setDomainMinorGridlinesVisible(boolean visible) { + if (this.domainMinorGridlinesVisible != visible) { + this.domainMinorGridlinesVisible = visible; + fireChangeEvent(); + } + } + + /** * Returns the stroke for the grid-lines (if any) plotted against the * domain axis. * @@ -1649,8 +1736,6 @@ /** * Sets the stroke for the grid lines plotted against the domain axis, and * sends a {@link PlotChangeEvent} to all registered listeners. - * <p> - * If you set this to <code>null</code>, no grid lines will be drawn. * * @param stroke the stroke (<code>null</code> not permitted). * @@ -1668,6 +1753,42 @@ } /** + * Returns the stroke for the minor grid-lines (if any) plotted against the + * domain axis. + * + * @return The stroke (never <code>null</code>). + * + * @see #setDomainMinorGridlineStroke(Stroke) + * + * @since 1.0.12 + */ + + public Stroke getDomainMinorGridlineStroke() { + return this.domainMinorGridlineStroke; + } + + /** + * Sets the stroke for the minor grid lines plotted against the domain + * axis, and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (<code>null</code> not permitted). + * + * @throws IllegalArgumentException if <code>stroke</code> is + * <code>null</code>. + * + * @see #getDomainMinorGridlineStroke() + * + * @since 1.0.12 + */ + public void setDomainMinorGridlineStroke(Stroke stroke) { + if (stroke == null) { + throw new IllegalArgumentException("Null 'stroke' argument."); + } + this.domainMinorGridlineStroke = stroke; + fireChangeEvent(); + } + + /** * Returns the paint for the grid lines (if any) plotted against the domain * axis. * @@ -1699,6 +1820,41 @@ } /** + * Returns the paint for the minor grid lines (if any) plotted against the + * domain axis. + * + * @return The paint (never <code>null</code>). + * + * @see #setDomainMinorGridlinePaint(Paint) + * + * @since 1.0.12 + */ + public Paint getDomainMinorGridlinePaint() { + return this.domainMinorGridlinePaint; + } + + /** + * Sets the paint for the minor grid lines plotted against the domain axis, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @throws IllegalArgumentException if <code>paint</code> is + * <code>null</code>. + * + * @see #getDomainMinorGridlinePaint() + * + * @since 1.0.12 + */ + public void setDomainMinorGridlinePaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.domainMinorGridlinePaint = paint; + fireChangeEvent(); + } + + /** * Returns <code>true</code> if the range axis grid is visible, and * <code>false<code> otherwise. * @@ -1785,6 +1941,104 @@ } /** + * Returns <code>true</code> if the range axis minor grid is visible, and + * <code>false<code> otherwise. + * + * @return A boolean. + * + * @see #setRangeMinorGridlinesVisible(boolean) + * + * @since 1.0.12 + */ + public boolean isRangeMinorGridlinesVisible() { + return this.rangeMinorGridlinesVisible; + } + + /** + * Sets the flag that controls whether or not the range axis minor grid + * lines are visible. + * <p> + * If the flag value is changed, a {@link PlotChangeEvent} is sent to all + * registered listeners. + * + * @param visible the new value of the flag. + * + * @see #isRangeMinorGridlinesVisible() + * + * @since 1.0.12 + */ + public void setRangeMinorGridlinesVisible(boolean visible) { + if (this.rangeMinorGridlinesVisible != visible) { + this.rangeMinorGridlinesVisible = visible; + fireChangeEvent(); + } + } + + /** + * Returns the stroke for the minor grid lines (if any) plotted against the + * range axis. + * + * @return The stroke (never <code>null</code>). + * + * @see #setRangeMinorGridlineStroke(Stroke) + * + * @since 1.0.12 + */ + public Stroke getRangeMinorGridlineStroke() { + return this.rangeMinorGridlineStroke; + } + + /** + * Sets the stroke for the minor grid lines plotted against the range axis, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (<code>null</code> not permitted). + * + * @see #getRangeMinorGridlineStroke() + * + * @since 1.0.12 + */ + public void setRangeMinorGridlineStroke(Stroke stroke) { + if (stroke == null) { + throw new IllegalArgumentException("Null 'stroke' argument."); + } + this.rangeMinorGridlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint for the minor grid lines (if any) plotted against the range + * axis. + * + * @return The paint (never <code>null</code>). + * + * @see #setRangeMinorGridlinePaint(Paint) + * + * @since 1.0.12 + */ + public Paint getRangeMinorGridlinePaint() { + return this.rangeMinorGridlinePaint; + } + + /** + * Sets the paint for the minor grid lines plotted against the range axis + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getRangeMinorGridlinePaint() + * + * @since 1.0.12 + */ + public void setRangeMinorGridlinePaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.rangeMinorGridlinePaint = paint; + fireChangeEvent(); + } + + /** * Returns a flag that controls whether or not a zero baseline is * displayed for the domain axis. * @@ -3486,16 +3740,30 @@ } // draw the domain grid lines, if any... - if (isDomainGridlinesVisible()) { - Stroke gridStroke = getDomainGridlineStroke(); - Paint gridPaint = getDomainGridlinePaint(); - if ((gridStroke != null) && (gridPaint != null)) { - Iterator iterator = ticks.iterator(); - while (iterator.hasNext()) { - ValueTick tick = (ValueTick) iterator.next(); - getRenderer().drawDomainGridLine(g2, this, getDomainAxis(), - dataArea, tick.getValue()); + if (isDomainGridlinesVisible() || isDomainMinorGridlinesVisible()) { + Stroke gridStroke = null; + Paint gridPaint = null; + Iterator iterator = ticks.iterator(); + boolean paintLine = false; + while (iterator.hasNext()) { + paintLine = false; + ValueTick tick = (ValueTick) iterator.next(); + if ((tick.getTickType() == TickType.MINOR) && isDomainMinorGridlinesVisible()){ + gridStroke = getDomainMinorGridlineStroke(); + gridPaint = getDomainMinorGridlinePaint(); + paintLine = true; } + else if ((tick.getTickType() == TickType.MAJOR) && isDomainGridlinesVisible()){ + gridStroke = getDomainGridlineStroke(); + gridPaint = getDomainGridlinePaint(); + paintLine = true; + } + XYItemRenderer r = getRenderer(); + if ((r instanceof AbstractXYItemRenderer) && paintLine) { + ((AbstractXYItemRenderer) r).drawDomainLine(g2, this, + getDomainAxis(), dataArea, tick.getValue(), + gridPaint, gridStroke); + } } } } @@ -3519,16 +3787,28 @@ } // draw the range grid lines, if any... - if (isRangeGridlinesVisible()) { - Stroke gridStroke = getRangeGridlineStroke(); - Paint gridPaint = getRangeGridlinePaint(); + if (isRangeGridlinesVisible() || isRangeMinorGridlinesVisible()) { + Stroke gridStroke = null; + Paint gridPaint = null; ValueAxis axis = getRangeAxis(); if (axis != null) { Iterator iterator = ticks.iterator(); + boolean paintLine = false; while (iterator.hasNext()) { + paintLine = false; ValueTick tick = (ValueTick) iterator.next(); + if ((tick.getTickType() == TickType.MINOR) && isRangeMinorGridlinesVisible()){ + gridStroke = getRangeMinorGridlineStroke(); + gridPaint = getRangeMinorGridlinePaint(); + paintLine = true; + } + else if ((tick.getTickType() == TickType.MAJOR) && isRangeGridlinesVisible()){ + gridStroke = getRangeGridlineStroke(); + gridPaint = getRangeGridlinePaint(); + paintLine = true; + } if (tick.getValue() != 0.0 - || !isRangeZeroBaselineVisible()) { + || !isRangeZeroBaselineVisible() && (paintLine)) { getRenderer().drawRangeLine(g2, this, getRangeAxis(), area, tick.getValue(), gridPaint, gridStroke); } @@ -4748,14 +5028,12 @@ * @return <code>true</code> or <code>false</code>. */ public boolean equals(Object obj) { - if (obj == this) { return true; } if (!(obj instanceof XYPlot)) { return false; } - XYPlot that = (XYPlot) obj; if (this.weight != that.weight) { return false; @@ -4779,6 +5057,12 @@ if (this.rangeGridlinesVisible != that.rangeGridlinesVisible) { return false; } + if (this.domainMinorGridlinesVisible != that.domainMinorGridlinesVisible) { + return false; + } + if (this.rangeMinorGridlinesVisible != that.rangeMinorGridlinesVisible) { + return false; + } if (this.domainZeroBaselineVisible != that.domainZeroBaselineVisible) { return false; } @@ -4837,6 +5121,22 @@ that.rangeGridlinePaint)) { return false; } + if (!ObjectUtilities.equal(this.domainMinorGridlineStroke, + that.domainMinorGridlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.domainMinorGridlinePaint, + that.domainMinorGridlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.rangeMinorGridlineStroke, + that.rangeMinorGridlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.rangeMinorGridlinePaint, + that.rangeMinorGridlinePaint)) { + return false; + } if (!PaintUtilities.equal(this.domainZeroBaselinePaint, that.domainZeroBaselinePaint)) { return false; @@ -5021,6 +5321,10 @@ SerialUtilities.writePaint(this.domainGridlinePaint, stream); SerialUtilities.writeStroke(this.rangeGridlineStroke, stream); SerialUtilities.writePaint(this.rangeGridlinePaint, stream); + SerialUtilities.writeStroke(this.domainMinorGridlineStroke, stream); + SerialUtilities.writePaint(this.domainMinorGridlinePaint, stream); + SerialUtilities.writeStroke(this.rangeMinorGridlineStroke, stream); + SerialUtilities.writePaint(this.rangeMinorGridlinePaint, stream); SerialUtilities.writeStroke(this.rangeZeroBaselineStroke, stream); SerialUtilities.writePaint(this.rangeZeroBaselinePaint, stream); SerialUtilities.writeStroke(this.domainCrosshairStroke, stream); @@ -5053,6 +5357,10 @@ this.domainGridlinePaint = SerialUtilities.readPaint(stream); this.rangeGridlineStroke = SerialUtilities.readStroke(stream); this.rangeGridlinePaint = SerialUtilities.readPaint(stream); + this.domainMinorGridlineStroke = SerialUtilities.readStroke(stream); + this.domainMinorGridlinePaint = SerialUtilities.readPaint(stream); + this.rangeMinorGridlineStroke = SerialUtilities.readStroke(stream); + this.rangeMinorGridlinePaint = SerialUtilities.readPaint(stream); this.rangeZeroBaselineStroke = SerialUtilities.readStroke(stream); this.rangeZeroBaselinePaint = SerialUtilities.readPaint(stream); this.domainCrosshairStroke = SerialUtilities.readStroke(stream); Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/junit/AxisTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/junit/AxisTests.java 2008-09-25 10:02:23 UTC (rev 1641) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/junit/AxisTests.java 2008-09-25 15:34:01 UTC (rev 1642) @@ -37,6 +37,8 @@ * 13-Aug-2003 : Version 1 (DG); * 06-Jan-2004 : Added tests for axis line attributes (DG); * 07-Jan-2005 : Added hashCode() test (DG); + * 25-Sep-2008 : Extended equals() to cover new fields (DG); + * */ package org.jfree.chart.axis.junit; @@ -227,6 +229,21 @@ a2.setFixedDimension(3.21f); assertTrue(a1.equals(a2)); + a1.setMinorTickMarksVisible(true); + assertFalse(a1.equals(a2)); + a2.setMinorTickMarksVisible(true); + assertTrue(a1.equals(a2)); + + a1.setMinorTickMarkInsideLength(1.23f); + assertFalse(a1.equals(a2)); + a2.setMinorTickMarkInsideLength(1.23f); + assertTrue(a1.equals(a2)); + + a1.setMinorTickMarkOutsideLength(3.21f); + assertFalse(a1.equals(a2)); + a2.setMinorTickMarkOutsideLength(3.21f); + assertTrue(a1.equals(a2)); + } /** Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/junit/DateTickTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/junit/DateTickTests.java 2008-09-25 10:02:23 UTC (rev 1641) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/junit/DateTickTests.java 2008-09-25 15:34:01 UTC (rev 1642) @@ -35,7 +35,7 @@ * Changes * ------- * 13-May-2004 : Version 1 (DG); - * + * 25-Sep-2008 : Extended testEquals() to cover new fields (DG); */ package org.jfree.chart.axis.junit; @@ -53,6 +53,7 @@ import junit.framework.TestSuite; import org.jfree.chart.axis.DateTick; +import org.jfree.chart.axis.TickType; import org.jfree.ui.TextAnchor; /** @@ -119,6 +120,12 @@ t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0); assertTrue(t1.equals(t2)); + t1 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI); + t2 = new DateTick(TickType.MAJOR, d1, l1, ta1, ta1, Math.PI); + assertFalse(t1.equals(t2)); + t2 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI); + assertTrue(t1.equals(t2)); + } /** Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/XYPlotTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/XYPlotTests.java 2008-09-25 10:02:23 UTC (rev 1641) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/junit/XYPlotTests.java 2008-09-25 15:34:01 UTC (rev 1642) @@ -386,6 +386,36 @@ plot2.setRangeTickBandPaint(Color.blue); assertTrue(plot1.equals(plot2)); + plot1.setDomainMinorGridlinesVisible(true); + assertFalse(plot1.equals(plot2)); + plot2.setDomainMinorGridlinesVisible(true); + assertTrue(plot1.equals(plot2)); + + plot1.setDomainMinorGridlinePaint(Color.red); + assertFalse(plot1.equals(plot2)); + plot2.setDomainMinorGridlinePaint(Color.red); + assertTrue(plot1.equals(plot2)); + + plot1.setDomainGridlineStroke(new BasicStroke(1.1f)); + assertFalse(plot1.equals(plot2)); + plot2.setDomainGridlineStroke(new BasicStroke(1.1f)); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeMinorGridlinesVisible(true); + assertFalse(plot1.equals(plot2)); + plot2.setRangeMinorGridlinesVisible(true); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeMinorGridlinePaint(Color.blue); + assertFalse(plot1.equals(plot2)); + plot2.setRangeMinorGridlinePaint(Color.blue); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeMinorGridlineStroke(new BasicStroke(1.23f)); + assertFalse(plot1.equals(plot2)); + plot2.setRangeMinorGridlineStroke(new BasicStroke(1.23f)); + assertTrue(plot1.equals(plot2)); + } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-26 08:02:17
|
Revision: 1646 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1646&view=rev Author: mungady Date: 2008-09-26 08:02:11 +0000 (Fri, 26 Sep 2008) Log Message: ----------- 2008-09-26 David Gilbert <dav...@ob...> * source/org/jfree/chart/renderer/xy/VectorRenderer.java (drawItem): Add chart entity. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/VectorRenderer.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-26 07:25:48 UTC (rev 1645) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-26 08:02:11 UTC (rev 1646) @@ -1,3 +1,8 @@ +2008-09-26 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/renderer/xy/VectorRenderer.java + (drawItem): Add chart entity. + 2008-09-25 David Gilbert <dav...@ob...> Patch 1934255 (incorporating 1870189): Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/VectorRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/VectorRenderer.java 2008-09-26 07:25:48 UTC (rev 1645) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/xy/VectorRenderer.java 2008-09-26 08:02:11 UTC (rev 1646) @@ -40,6 +40,7 @@ * 18-Feb-2008 : Fixed bug 1880114, arrows for horizontal plot * orientation (DG); * 22-Apr-2008 : Implemented PublicCloneable (DG); + * 26-Sep-2008 : Added chart entity support (tooltips etc) (DG); * */ @@ -52,6 +53,7 @@ import java.io.Serializable; import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; import org.jfree.chart.plot.CrosshairState; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; @@ -281,6 +283,15 @@ p.closePath(); g2.draw(p); + // setup for collecting optional entity info... + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + if (entities != null) { + addEntity(entities, line.getBounds(), dataset, series, item, + 0.0, 0.0); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-26 09:26:06
|
Revision: 1648 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1648&view=rev Author: mungady Date: 2008-09-26 09:25:37 +0000 (Fri, 26 Sep 2008) Log Message: ----------- 2008-09-26 David Gilbert <dav...@ob...> * source/org/jfree/chart/renderer/category/WaterfallRenderer.java (drawItem): Fixed bar misalignment when maxBarWidth is applied. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/WaterfallBarRenderer.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-26 08:48:21 UTC (rev 1647) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-26 09:25:37 UTC (rev 1648) @@ -1,5 +1,10 @@ 2008-09-26 David Gilbert <dav...@ob...> + * source/org/jfree/chart/renderer/category/WaterfallRenderer.java + (drawItem): Fixed bar misalignment when maxBarWidth is applied. + +2008-09-26 David Gilbert <dav...@ob...> + * source/org/jfree/chart/renderer/xy/VectorRenderer.java (drawItem): Add chart entity. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/WaterfallBarRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/WaterfallBarRenderer.java 2008-09-26 08:48:21 UTC (rev 1647) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/WaterfallBarRenderer.java 2008-09-26 09:25:37 UTC (rev 1648) @@ -49,6 +49,8 @@ * --> CategoryItemLabelGenerator (DG); * 09-Jun-2005 : Use addItemEntity() from superclass (DG); * 27-Mar-2008 : Fixed error in findRangeBounds() method (DG); + * 26-Sep-2008 : Fixed bug with bar alignment when maximumBarWidth is + * applied (DG); * */ @@ -338,14 +340,12 @@ } state.setSeriesRunningTotal(current); - int seriesCount = getRowCount(); int categoryCount = getColumnCount(); PlotOrientation orientation = plot.getOrientation(); double rectX = 0.0; double rectY = 0.0; - RectangleEdge domainAxisLocation = plot.getDomainAxisEdge(); RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); // Y0 @@ -370,39 +370,23 @@ double rectHeight = Math.max(getMinimumBarLength(), Math.abs(j2dy1 - j2dy0)); + Comparable seriesKey = dataset.getRowKey(row); + Comparable categoryKey = dataset.getColumnKey(column); if (orientation == PlotOrientation.HORIZONTAL) { - // BAR Y - rectY = domainAxis.getCategoryStart(column, getColumnCount(), - dataArea, domainAxisLocation); - if (seriesCount > 1) { - double seriesGap = dataArea.getHeight() * getItemMargin() - / (categoryCount * (seriesCount - 1)); - rectY = rectY + row * (state.getBarWidth() + seriesGap); - } - else { - rectY = rectY + row * state.getBarWidth(); - } + rectY = domainAxis.getCategorySeriesMiddle(categoryKey, seriesKey, + dataset, getItemMargin(), dataArea, RectangleEdge.LEFT); rectX = j2dy0; rectHeight = state.getBarWidth(); + rectY = rectY - rectHeight / 2.0; rectWidth = Math.max(getMinimumBarLength(), Math.abs(j2dy1 - j2dy0)); } else if (orientation == PlotOrientation.VERTICAL) { - // BAR X - rectX = domainAxis.getCategoryStart(column, getColumnCount(), - dataArea, domainAxisLocation); - - if (seriesCount > 1) { - double seriesGap = dataArea.getWidth() * getItemMargin() - / (categoryCount * (seriesCount - 1)); - rectX = rectX + row * (state.getBarWidth() + seriesGap); - } - else { - rectX = rectX + row * state.getBarWidth(); - } - + rectX = domainAxis.getCategorySeriesMiddle(categoryKey, seriesKey, + dataset, getItemMargin(), dataArea, RectangleEdge.TOP); + rectX = rectX - rectWidth / 2.0; rectY = j2dy0; } Rectangle2D bar = new Rectangle2D.Double(rectX, rectY, rectWidth, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-10-02 07:21:38
|
Revision: 1650 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1650&view=rev Author: mungady Date: 2008-10-02 07:21:27 +0000 (Thu, 02 Oct 2008) Log Message: ----------- 2008-10-02 David Gilbert <dav...@ob...> * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java (drawItem): Check item visibility. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-26 09:46:14 UTC (rev 1649) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-10-02 07:21:27 UTC (rev 1650) @@ -1,3 +1,8 @@ +2008-10-02 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (drawItem): Check item visibility. + 2008-09-26 David Gilbert <dav...@ob...> * source/org/jfree/chart/axis/Axis.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java 2008-09-26 09:46:14 UTC (rev 1649) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java 2008-10-02 07:21:27 UTC (rev 1650) @@ -71,6 +71,7 @@ * 1888422 (RVdS); * 27-Mar-2008 : Boxes should use outlinePaint/Stroke settings (DG); * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * 02-Oct-2008 : Check item visibility in drawItem() method (DG); * */ @@ -395,6 +396,11 @@ int column, int pass) { + // do nothing if item is not visible + if (!getItemVisible(row, column)) { + return; + } + if (!(dataset instanceof BoxAndWhiskerCategoryDataset)) { throw new IllegalArgumentException( "BoxAndWhiskerRenderer.drawItem() : the data should be " This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-09-26 09:46:19
|
Revision: 1649 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1649&view=rev Author: mungady Date: 2008-09-26 09:46:14 +0000 (Fri, 26 Sep 2008) Log Message: ----------- 2008-09-26 David Gilbert <dav...@ob...> * source/org/jfree/chart/axis/Axis.java (fireChangeEvent): New method, also updated various other methods to call fireChangeEvent(). Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/Axis.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-26 09:25:37 UTC (rev 1648) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-09-26 09:46:14 UTC (rev 1649) @@ -1,5 +1,11 @@ 2008-09-26 David Gilbert <dav...@ob...> + * source/org/jfree/chart/axis/Axis.java + (fireChangeEvent): New method, + also updated various other methods to call fireChangeEvent(). + +2008-09-26 David Gilbert <dav...@ob...> + * source/org/jfree/chart/renderer/category/WaterfallRenderer.java (drawItem): Fixed bar misalignment when maxBarWidth is applied. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/Axis.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/Axis.java 2008-09-26 09:25:37 UTC (rev 1648) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/Axis.java 2008-09-26 09:46:14 UTC (rev 1649) @@ -80,6 +80,7 @@ * 22-Aug-2006 : API doc updates (DG); * 06-Jun-2008 : Added setTickLabelInsets(RectangleInsets, boolean) (DG); * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); + * 26-Sep-2008 : Added fireChangeEvent() method (DG); * */ @@ -339,7 +340,7 @@ public void setVisible(boolean flag) { if (flag != this.visible) { this.visible = flag; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } } @@ -372,13 +373,13 @@ if (existing != null) { if (!existing.equals(label)) { this.label = label; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } } else { if (label != null) { this.label = label; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } } @@ -409,7 +410,7 @@ } if (!this.labelFont.equals(font)) { this.labelFont = font; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } } @@ -437,7 +438,7 @@ throw new IllegalArgumentException("Null 'paint' argument."); } this.labelPaint = paint; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } /** @@ -480,7 +481,7 @@ if (!insets.equals(this.labelInsets)) { this.labelInsets = insets; if (notify) { - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } } } @@ -506,7 +507,7 @@ */ public void setLabelAngle(double angle) { this.labelAngle = angle; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } /** @@ -534,7 +535,7 @@ */ public void setAxisLineVisible(boolean visible) { this.axisLineVisible = visible; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } /** @@ -561,7 +562,7 @@ throw new IllegalArgumentException("Null 'paint' argument."); } this.axisLinePaint = paint; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } /** @@ -588,7 +589,7 @@ throw new IllegalArgumentException("Null 'stroke' argument."); } this.axisLineStroke = stroke; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } /** @@ -619,7 +620,7 @@ if (flag != this.tickLabelsVisible) { this.tickLabelsVisible = flag; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } } @@ -652,7 +653,7 @@ public void setMinorTickMarksVisible(boolean flag) { if (flag != this.minorTickMarksVisible) { this.minorTickMarksVisible = flag; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } } @@ -683,7 +684,7 @@ if (!this.tickLabelFont.equals(font)) { this.tickLabelFont = font; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } } @@ -712,7 +713,7 @@ throw new IllegalArgumentException("Null 'paint' argument."); } this.tickLabelPaint = paint; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } /** @@ -740,7 +741,7 @@ } if (!this.tickLabelInsets.equals(insets)) { this.tickLabelInsets = insets; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } } @@ -768,7 +769,7 @@ public void setTickMarksVisible(boolean flag) { if (flag != this.tickMarksVisible) { this.tickMarksVisible = flag; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } } @@ -794,7 +795,7 @@ */ public void setTickMarkInsideLength(float length) { this.tickMarkInsideLength = length; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } /** @@ -819,7 +820,7 @@ */ public void setTickMarkOutsideLength(float length) { this.tickMarkOutsideLength = length; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } /** @@ -847,7 +848,7 @@ } if (!this.tickMarkStroke.equals(stroke)) { this.tickMarkStroke = stroke; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } } @@ -875,7 +876,7 @@ throw new IllegalArgumentException("Null 'paint' argument."); } this.tickMarkPaint = paint; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } /** @@ -904,7 +905,7 @@ */ public void setMinorTickMarkInsideLength(float length) { this.minorTickMarkInsideLength = length; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } /** @@ -933,7 +934,7 @@ */ public void setMinorTickMarkOutsideLength(float length) { this.minorTickMarkOutsideLength = length; - notifyListeners(new AxisChangeEvent(this)); + fireChangeEvent(); } /** @@ -1095,14 +1096,21 @@ * @param event information about the change to the axis. */ protected void notifyListeners(AxisChangeEvent event) { - Object[] listeners = this.listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i -= 2) { if (listeners[i] == AxisChangeListener.class) { ((AxisChangeListener) listeners[i + 1]).axisChanged(event); } } + } + /** + * Sends an {@link AxisChangeEvent} to all registered listeners. + * + * @since 1.0.12 + */ + protected void fireChangeEvent() { + notifyListeners(new AxisChangeEvent(this)); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-10-08 13:51:47
|
Revision: 1654 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1654&view=rev Author: mungady Date: 2008-10-08 13:51:33 +0000 (Wed, 08 Oct 2008) Log Message: ----------- 2008-10-08 David Gilbert <dav...@ob...> * source/org/jfree/chart/labels/IntervalCategoryToolTipGenerator.java (equals): New method override, * source/org/jfree/chart/renderer/category/IntervalBarRenderer.java (equals): New method override. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/labels/IntervalCategoryToolTipGenerator.java branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/IntervalBarRenderer.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-10-02 08:57:27 UTC (rev 1653) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-10-08 13:51:33 UTC (rev 1654) @@ -1,3 +1,10 @@ +2008-10-08 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/labels/IntervalCategoryToolTipGenerator.java + (equals): New method override, + * source/org/jfree/chart/renderer/category/IntervalBarRenderer.java + (equals): New method override. + 2008-10-02 David Gilbert <dav...@ob...> * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/labels/IntervalCategoryToolTipGenerator.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/labels/IntervalCategoryToolTipGenerator.java 2008-10-02 08:57:27 UTC (rev 1653) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/labels/IntervalCategoryToolTipGenerator.java 2008-10-08 13:51:33 UTC (rev 1654) @@ -35,34 +35,31 @@ * Changes * ------- * 11-May-2004 : Version 1, split from IntervalCategoryItemLabelGenerator (DG); + * 08-Oct-2008 : Override equals() method (DG); * */ package org.jfree.chart.labels; -import java.io.Serializable; import java.text.DateFormat; import java.text.NumberFormat; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.IntervalCategoryDataset; -import org.jfree.util.PublicCloneable; /** * A tooltip generator for plots that use data from an * {@link IntervalCategoryDataset}. */ public class IntervalCategoryToolTipGenerator - extends StandardCategoryToolTipGenerator - implements CategoryToolTipGenerator, PublicCloneable, Cloneable, - Serializable { + extends StandardCategoryToolTipGenerator { /** For serialization. */ private static final long serialVersionUID = -3853824986520333437L; /** The default format string. */ public static final String DEFAULT_TOOL_TIP_FORMAT_STRING - = "({0}, {1}) = {3} - {4}"; + = "({0}, {1}) = {3} - {4}"; /** * Creates a new generator with a default number formatter. @@ -134,4 +131,23 @@ return result; } + /** + * Tests this tool tip generator 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 IntervalCategoryToolTipGenerator)) { + return false; + } + // no fields to test + return super.equals(obj); + } + } Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/IntervalBarRenderer.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/IntervalBarRenderer.java 2008-10-02 08:57:27 UTC (rev 1653) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/renderer/category/IntervalBarRenderer.java 2008-10-08 13:51:33 UTC (rev 1654) @@ -56,6 +56,7 @@ * --> CategoryItemLabelGenerator (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * 24-Jun-2008 : Added new barPainter mechanism (DG); + * 07-Oct-2008 : Override equals() method to fix minor bug (DG); * */ @@ -63,7 +64,6 @@ import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; -import java.io.Serializable; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.ValueAxis; @@ -74,17 +74,13 @@ import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.IntervalCategoryDataset; import org.jfree.ui.RectangleEdge; -import org.jfree.util.PublicCloneable; /** * A renderer that handles the drawing of bars for a bar plot where - * each bar has a high and low value. - * <p> - * For use with the {@link CategoryPlot} class. + * each bar has a high and low value. This renderer is for use with the + * {@link CategoryPlot} class. */ -public class IntervalBarRenderer extends BarRenderer - implements CategoryItemRenderer, Cloneable, PublicCloneable, - Serializable { +public class IntervalBarRenderer extends BarRenderer { /** For serialization. */ private static final long serialVersionUID = -5068857361615528725L; @@ -258,4 +254,22 @@ } + /** + * Tests this renderer 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 IntervalBarRenderer)) { + return false; + } + // there are no fields to check + 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-10-08 14:31:13
|
Revision: 1662 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1662&view=rev Author: mungady Date: 2008-10-08 14:30:59 +0000 (Wed, 08 Oct 2008) Log Message: ----------- 2008-10-08 David Gilbert <dav...@ob...> Incorporating patch 2131001: * source/org/jfree/data/general/DatasetUtilities.java (iterateDomainBounds(XYDataset, boolean)): Ignore Double.NaN values, (iterateRangeBounds(CategoryDataset, boolean)): Likewise, (findStackedRangeBounds(CategoryDataset, KeyToGroupMap)): Cleanup, (findMinimumStackedRangeValue(CategoryDataset)): Likewise, (findMaximumStackedRangeValue(CategoryDataset)): Likewise, (findCumulativeRangeBounds(CategoryDataset)): Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/data/general/DatasetUtilities.java branches/jfreechart-1.0.x-branch/tests/org/jfree/data/general/junit/DatasetUtilitiesTests.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-10-08 14:13:23 UTC (rev 1661) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-10-08 14:30:59 UTC (rev 1662) @@ -1,5 +1,16 @@ 2008-10-08 David Gilbert <dav...@ob...> + Incorporating patch 2131001: + * source/org/jfree/data/general/DatasetUtilities.java + (iterateDomainBounds(XYDataset, boolean)): Ignore Double.NaN values, + (iterateRangeBounds(CategoryDataset, boolean)): Likewise, + (findStackedRangeBounds(CategoryDataset, KeyToGroupMap)): Cleanup, + (findMinimumStackedRangeValue(CategoryDataset)): Likewise, + (findMaximumStackedRangeValue(CategoryDataset)): Likewise, + (findCumulativeRangeBounds(CategoryDataset)): Likewise. + +2008-10-08 David Gilbert <dav...@ob...> + * source/org/jfree/chart/labels/IntervalCategoryToolTipGenerator.java (equals): New method override, * source/org/jfree/chart/renderer/category/IntervalBarRenderer.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/data/general/DatasetUtilities.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/data/general/DatasetUtilities.java 2008-10-08 14:13:23 UTC (rev 1661) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/data/general/DatasetUtilities.java 2008-10-08 14:30:59 UTC (rev 1662) @@ -35,6 +35,7 @@ * Richard Atkinson; * Andreas Schroeder; * Rafal Skalny (patch 1925366); + * Jerome David (patch 2131001); * * Changes (from 18-Sep-2001) * -------------------------- @@ -108,6 +109,8 @@ * 28-Mar-2008 : Applied a variation of patch 1925366 (from Rafal Skalny) for * slightly more efficient iterateRangeBounds() methods (DG); * 08-Apr-2008 : Fixed typo in iterateRangeBounds() (DG); + * 08-Oct-2008 : Applied patch 2131001 by Jerome David, with some modifications + * and additions and some new unit tests (DG); * */ @@ -687,8 +690,12 @@ for (int item = 0; item < itemCount; item++) { lvalue = intervalXYData.getStartXValue(series, item); uvalue = intervalXYData.getEndXValue(series, item); - minimum = Math.min(minimum, lvalue); - maximum = Math.max(maximum, uvalue); + if (!Double.isNaN(lvalue)) { + minimum = Math.min(minimum, lvalue); + } + if (!Double.isNaN(uvalue)) { + maximum = Math.max(maximum, uvalue); + } } } } @@ -698,8 +705,10 @@ for (int item = 0; item < itemCount; item++) { lvalue = dataset.getXValue(series, item); uvalue = lvalue; - minimum = Math.min(minimum, lvalue); - maximum = Math.max(maximum, uvalue); + if (!Double.isNaN(lvalue)) { + minimum = Math.min(minimum, lvalue); + maximum = Math.max(maximum, uvalue); + } } } } @@ -845,10 +854,10 @@ for (int column = 0; column < columnCount; column++) { lvalue = icd.getStartValue(row, column); uvalue = icd.getEndValue(row, column); - if (lvalue != null) { + if (lvalue != null && !Double.isNaN(lvalue.doubleValue())) { minimum = Math.min(minimum, lvalue.doubleValue()); } - if (uvalue != null) { + if (uvalue != null && !Double.isNaN(uvalue.doubleValue())) { maximum = Math.max(maximum, uvalue.doubleValue()); } } @@ -861,8 +870,10 @@ Number value = dataset.getValue(row, column); if (value != null) { double v = value.doubleValue(); - minimum = Math.min(minimum, v); - maximum = Math.max(maximum, v); + if (!Double.isNaN(v)) { + minimum = Math.min(minimum, v); + maximum = Math.max(maximum, v); + } } } } @@ -1395,129 +1406,136 @@ */ public static Range findStackedRangeBounds(CategoryDataset dataset, KeyToGroupMap map) { - + if (dataset == null) { + throw new IllegalArgumentException("Null 'dataset' argument."); + } + boolean hasValidData = false; Range result = null; - if (dataset != null) { - // create an array holding the group indices... - int[] groupIndex = new int[dataset.getRowCount()]; - for (int i = 0; i < dataset.getRowCount(); i++) { - groupIndex[i] = map.getGroupIndex( - map.getGroup(dataset.getRowKey(i)) - ); - } + // create an array holding the group indices for each series... + int[] groupIndex = new int[dataset.getRowCount()]; + for (int i = 0; i < dataset.getRowCount(); i++) { + groupIndex[i] = map.getGroupIndex(map.getGroup( + dataset.getRowKey(i))); + } - // minimum and maximum for each group... - int groupCount = map.getGroupCount(); - double[] minimum = new double[groupCount]; - double[] maximum = new double[groupCount]; + // minimum and maximum for each group... + int groupCount = map.getGroupCount(); + double[] minimum = new double[groupCount]; + double[] maximum = new double[groupCount]; - int categoryCount = dataset.getColumnCount(); - for (int item = 0; item < categoryCount; item++) { - double[] positive = new double[groupCount]; - double[] negative = new double[groupCount]; - int seriesCount = dataset.getRowCount(); - for (int series = 0; series < seriesCount; series++) { - Number number = dataset.getValue(series, item); - if (number != null) { - double value = number.doubleValue(); - if (value > 0.0) { - positive[groupIndex[series]] + int categoryCount = dataset.getColumnCount(); + for (int item = 0; item < categoryCount; item++) { + double[] positive = new double[groupCount]; + double[] negative = new double[groupCount]; + int seriesCount = dataset.getRowCount(); + for (int series = 0; series < seriesCount; series++) { + Number number = dataset.getValue(series, item); + if (number != null) { + hasValidData = true; + double value = number.doubleValue(); + if (value > 0.0) { + positive[groupIndex[series]] = positive[groupIndex[series]] + value; - } - if (value < 0.0) { - negative[groupIndex[series]] + } + if (value < 0.0) { + negative[groupIndex[series]] = negative[groupIndex[series]] + value; - // '+', remember value is negative - } + // '+', remember value is negative } } - for (int g = 0; g < groupCount; g++) { - minimum[g] = Math.min(minimum[g], negative[g]); - maximum[g] = Math.max(maximum[g], positive[g]); - } } + for (int g = 0; g < groupCount; g++) { + minimum[g] = Math.min(minimum[g], negative[g]); + maximum[g] = Math.max(maximum[g], positive[g]); + } + } + if (hasValidData) { for (int j = 0; j < groupCount; j++) { - result = Range.combine( - result, new Range(minimum[j], maximum[j]) - ); + result = Range.combine(result, new Range(minimum[j], + maximum[j])); } } return result; - } /** * Returns the minimum value in the dataset range, assuming that values in * each category are "stacked". * - * @param dataset the dataset. + * @param dataset the dataset (<code>null</code> not permitted). * * @return The minimum value. + * + * @see #findMaximumStackedRangeValue(CategoryDataset) */ public static Number findMinimumStackedRangeValue(CategoryDataset dataset) { - + if (dataset == null) { + throw new IllegalArgumentException("Null 'dataset' argument."); + } Number result = null; - if (dataset != null) { - double minimum = 0.0; - int categoryCount = dataset.getRowCount(); - for (int item = 0; item < categoryCount; item++) { - double total = 0.0; - - int seriesCount = dataset.getColumnCount(); - for (int series = 0; series < seriesCount; series++) { - Number number = dataset.getValue(series, item); - if (number != null) { - double value = number.doubleValue(); - if (value < 0.0) { - total = total + value; - // '+', remember value is negative - } + boolean hasValidData = false; + double minimum = 0.0; + int categoryCount = dataset.getColumnCount(); + for (int item = 0; item < categoryCount; item++) { + double total = 0.0; + int seriesCount = dataset.getRowCount(); + for (int series = 0; series < seriesCount; series++) { + Number number = dataset.getValue(series, item); + if (number != null) { + hasValidData = true; + double value = number.doubleValue(); + if (value < 0.0) { + total = total + value; + // '+', remember value is negative } } - minimum = Math.min(minimum, total); - } + minimum = Math.min(minimum, total); + } + if (hasValidData) { result = new Double(minimum); } return result; - } /** * Returns the maximum value in the dataset range, assuming that values in * each category are "stacked". * - * @param dataset the dataset (<code>null</code> permitted). + * @param dataset the dataset (<code>null</code> not permitted). * * @return The maximum value (possibly <code>null</code>). + * + * @see #findMinimumStackedRangeValue(CategoryDataset) */ public static Number findMaximumStackedRangeValue(CategoryDataset dataset) { - + if (dataset == null) { + throw new IllegalArgumentException("Null 'dataset' argument."); + } Number result = null; - - if (dataset != null) { - double maximum = 0.0; - int categoryCount = dataset.getColumnCount(); - for (int item = 0; item < categoryCount; item++) { - double total = 0.0; - int seriesCount = dataset.getRowCount(); - for (int series = 0; series < seriesCount; series++) { - Number number = dataset.getValue(series, item); - if (number != null) { - double value = number.doubleValue(); - if (value > 0.0) { - total = total + value; - } + boolean hasValidData = false; + double maximum = 0.0; + int categoryCount = dataset.getColumnCount(); + for (int item = 0; item < categoryCount; item++) { + double total = 0.0; + int seriesCount = dataset.getRowCount(); + for (int series = 0; series < seriesCount; series++) { + Number number = dataset.getValue(series, item); + if (number != null) { + hasValidData = true; + double value = number.doubleValue(); + if (value > 0.0) { + total = total + value; } } - maximum = Math.max(maximum, total); } + maximum = Math.max(maximum, total); + } + if (hasValidData) { result = new Double(maximum); } - return result; - } /** @@ -1612,11 +1630,9 @@ * @see #findRangeBounds(CategoryDataset) */ public static Range findCumulativeRangeBounds(CategoryDataset dataset) { - if (dataset == null) { throw new IllegalArgumentException("Null 'dataset' argument."); } - boolean allItemsNull = true; // we'll set this to false if there is at // least one non-null data item... double minimum = 0.0; @@ -1629,9 +1645,11 @@ if (n != null) { allItemsNull = false; double value = n.doubleValue(); - runningTotal = runningTotal + value; - minimum = Math.min(minimum, runningTotal); - maximum = Math.max(maximum, runningTotal); + if (!Double.isNaN(value)) { + runningTotal = runningTotal + value; + minimum = Math.min(minimum, runningTotal); + maximum = Math.max(maximum, runningTotal); + } } } } @@ -1641,7 +1659,6 @@ else { return null; } - } } Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/data/general/junit/DatasetUtilitiesTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/data/general/junit/DatasetUtilitiesTests.java 2008-10-08 14:13:23 UTC (rev 1661) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/data/general/junit/DatasetUtilitiesTests.java 2008-10-08 14:30:59 UTC (rev 1662) @@ -41,6 +41,8 @@ * 03-Feb-2005 : Added testFindStackedRangeBounds2() method (DG); * 26-Sep-2007 : Added testIsEmptyOrNullXYDataset() method (DG); * 28-Mar-2008 : Added and renamed various tests (DG); + * 08-Oct-2008 : New tests to support patch 2131001 and related + * changes (DG); * */ @@ -60,7 +62,9 @@ import org.jfree.data.general.DatasetUtilities; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; +import org.jfree.data.xy.DefaultIntervalXYDataset; import org.jfree.data.xy.DefaultTableXYDataset; +import org.jfree.data.xy.DefaultXYDataset; import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.TableXYDataset; import org.jfree.data.xy.XYDataset; @@ -128,6 +132,69 @@ } /** + * This test checks that the standard method has 'includeInterval' + * defaulting to true. + */ + public void testFindDomainBounds2() { + DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset(); + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] x1Start = new double[] {0.9, 1.9, 2.9}; + double[] x1End = new double[] {1.1, 2.1, 3.1}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] y1Start = new double[] {1.09, 2.09, 3.09}; + double[] y1End = new double[] {1.11, 2.11, 3.11}; + double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, + y1End}; + dataset.addSeries("S1", data1); + Range r = DatasetUtilities.findDomainBounds(dataset); + assertEquals(0.9, r.getLowerBound(), EPSILON); + assertEquals(3.1, r.getUpperBound(), EPSILON); + } + + /** + * This test checks that when the 'includeInterval' flag is false, the + * bounds come from the regular x-values. + */ + public void testFindDomainBounds3() { + DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset(); + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] x1Start = new double[] {0.9, 1.9, 2.9}; + double[] x1End = new double[] {1.1, 2.1, 3.1}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] y1Start = new double[] {1.09, 2.09, 3.09}; + double[] y1End = new double[] {1.11, 2.11, 3.11}; + double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, + y1End}; + dataset.addSeries("S1", data1); + Range r = DatasetUtilities.findDomainBounds(dataset, false); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(3.0, r.getUpperBound(), EPSILON); + } + + /** + * This test checks that NaN values are ignored. + */ + public void testFindDomainBounds_NaN() { + DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset(); + double[] x1 = new double[] {1.0, 2.0, Double.NaN}; + double[] x1Start = new double[] {0.9, 1.9, Double.NaN}; + double[] x1End = new double[] {1.1, 2.1, Double.NaN}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] y1Start = new double[] {1.09, 2.09, 3.09}; + double[] y1End = new double[] {1.11, 2.11, 3.11}; + double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, + y1End}; + dataset.addSeries("S1", data1); + Range r = DatasetUtilities.findDomainBounds(dataset); + assertEquals(0.9, r.getLowerBound(), EPSILON); + assertEquals(2.1, r.getUpperBound(), EPSILON); + + r = DatasetUtilities.findDomainBounds(dataset, false); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(2.0, r.getUpperBound(), EPSILON); + } + + /** * Some tests for the iterateDomainBounds() method. */ public void testIterateDomainBounds() { @@ -138,9 +205,44 @@ } /** - * Some tests for the findRangeExtent() method. + * Check that NaN values in the dataset are ignored. */ - public void testFindRangeBounds1() { + public void testIterateDomainBounds_NaN() { + DefaultXYDataset dataset = new DefaultXYDataset(); + double[] x = new double[] {1.0, 2.0, Double.NaN, 3.0}; + double[] y = new double[] {9.0, 8.0, 7.0, 6.0}; + dataset.addSeries("S1", new double[][] {x, y}); + Range r = DatasetUtilities.iterateDomainBounds(dataset); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(3.0, r.getUpperBound(), EPSILON); + } + + /** + * Check that NaN values in the IntervalXYDataset are ignored. + */ + public void testIterateDomainBounds_NaN2() { + DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset(); + double[] x1 = new double[] {Double.NaN, 2.0, 3.0}; + double[] x1Start = new double[] {0.9, Double.NaN, 2.9}; + double[] x1End = new double[] {1.1, Double.NaN, 3.1}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] y1Start = new double[] {1.09, 2.09, 3.09}; + double[] y1End = new double[] {1.11, 2.11, 3.11}; + double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, + y1End}; + dataset.addSeries("S1", data1); + Range r = DatasetUtilities.iterateDomainBounds(dataset, false); + assertEquals(2.0, r.getLowerBound(), EPSILON); + assertEquals(3.0, r.getUpperBound(), EPSILON); + r = DatasetUtilities.iterateDomainBounds(dataset, true); + assertEquals(0.9, r.getLowerBound(), EPSILON); + assertEquals(3.1, r.getUpperBound(), EPSILON); + } + + /** + * Some tests for the findRangeBounds() for a CategoryDataset method. + */ + public void testFindRangeBounds_CategoryDataset() { CategoryDataset dataset = createCategoryDataset1(); Range r = DatasetUtilities.findRangeBounds(dataset); assertEquals(1.0, r.getLowerBound(), EPSILON); @@ -148,9 +250,9 @@ } /** - * Some tests for the findRangeBounds() method. + * Some tests for the findRangeBounds() method on an XYDataset. */ - public void testFindRangeBounds2() { + public void testFindRangeBounds() { XYDataset dataset = createXYDataset1(); Range r = DatasetUtilities.findRangeBounds(dataset); assertEquals(100.0, r.getLowerBound(), EPSILON); @@ -161,7 +263,7 @@ * A test for the findRangeBounds(XYDataset) method using * an IntervalXYDataset. */ - public void testFindRangeBounds3() { + public void testFindRangeBounds2() { YIntervalSeriesCollection dataset = new YIntervalSeriesCollection(); Range r = DatasetUtilities.findRangeBounds(dataset); assertNull(r); @@ -176,6 +278,10 @@ assertEquals(1.5, r.getLowerBound(), EPSILON); assertEquals(2.5, r.getUpperBound(), EPSILON); + r = DatasetUtilities.findRangeBounds(dataset, false); + assertEquals(2.0, r.getLowerBound(), EPSILON); + assertEquals(2.0, r.getUpperBound(), EPSILON); + // another item s1.add(2.0, 2.0, 1.4, 2.1); r = DatasetUtilities.findRangeBounds(dataset); @@ -199,7 +305,6 @@ r = DatasetUtilities.findRangeBounds(dataset, false); assertEquals(2.0, r.getLowerBound(), EPSILON); assertEquals(2.0, r.getUpperBound(), EPSILON); - } /** @@ -233,11 +338,11 @@ assertEquals(1.23, r.getLowerBound(), EPSILON); assertEquals(1.23, r.getUpperBound(), EPSILON); - // a Double.NaN messes things up + // a Double.NaN should be ignored dataset.addValue(Double.NaN, "R2", "C1"); r = DatasetUtilities.iterateRangeBounds(dataset, false); - assertTrue(Double.isNaN(r.getLowerBound())); - assertTrue(Double.isNaN(r.getUpperBound())); + assertEquals(1.23, r.getLowerBound(), EPSILON); + assertEquals(1.23, r.getUpperBound(), EPSILON); } /** @@ -268,7 +373,6 @@ r = DatasetUtilities.iterateRangeBounds(d, true); assertEquals(1.0, r.getLowerBound(), EPSILON); assertEquals(16.0, r.getUpperBound(), EPSILON); - } /** @@ -480,11 +584,25 @@ dataset.addValue(3.51, "Product 1", "Distribution"); dataset.addValue(32.64, "Product 1", "Total Expense"); Range range = DatasetUtilities.findCumulativeRangeBounds(dataset); - assertEquals(0.0, range.getLowerBound(), 0.00000001); - assertEquals(65.28, range.getUpperBound(), 0.00000001); + assertEquals(0.0, range.getLowerBound(), EPSILON); + assertEquals(65.28, range.getUpperBound(), EPSILON); } /** + * Check that the findCumulativeRangeBounds() method ignores Double.NaN + * values. + */ + public void testCumulativeRange_NaN() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(10.0, "Series 1", "Start"); + dataset.addValue(15.0, "Series 1", "Delta 1"); + dataset.addValue(Double.NaN, "Series 1", "Delta 2"); + Range range = DatasetUtilities.findCumulativeRangeBounds(dataset); + assertEquals(0.0, range.getLowerBound(), EPSILON); + assertEquals(25.0, range.getUpperBound(), EPSILON); + } + + /** * Test the creation of a dataset from an array. */ public void testCreateCategoryDataset1() { @@ -550,7 +668,7 @@ /** * Some checks for the findStackedRangeBounds() method. */ - public void testFindStackedRangeBoundsForCategoryDataset1() { + public void testFindStackedRangeBounds_CategoryDataset1() { CategoryDataset d1 = createCategoryDataset1(); Range r = DatasetUtilities.findStackedRangeBounds(d1); assertEquals(0.0, r.getLowerBound(), EPSILON); @@ -565,13 +683,68 @@ /** * Some checks for the findStackedRangeBounds() method. */ - public void testFindStackedRangeBoundsForCategoryDataset2() { - CategoryDataset d1 = new DefaultCategoryDataset(); - Range r = DatasetUtilities.findStackedRangeBounds(d1); + public void testFindStackedRangeBounds_CategoryDataset2() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + Range r = DatasetUtilities.findStackedRangeBounds(dataset); assertTrue(r == null); + + dataset.addValue(5.0, "R1", "C1"); + r = DatasetUtilities.findStackedRangeBounds(dataset, 3.0); + assertEquals(3.0, r.getLowerBound(), EPSILON); + assertEquals(8.0, r.getUpperBound(), EPSILON); + + dataset.addValue(-1.0, "R2", "C1"); + r = DatasetUtilities.findStackedRangeBounds(dataset, 3.0); + assertEquals(2.0, r.getLowerBound(), EPSILON); + assertEquals(8.0, r.getUpperBound(), EPSILON); + + dataset.addValue(null, "R3", "C1"); + r = DatasetUtilities.findStackedRangeBounds(dataset, 3.0); + assertEquals(2.0, r.getLowerBound(), EPSILON); + assertEquals(8.0, r.getUpperBound(), EPSILON); + + dataset.addValue(Double.NaN, "R4", "C1"); + r = DatasetUtilities.findStackedRangeBounds(dataset, 3.0); + assertEquals(2.0, r.getLowerBound(), EPSILON); + assertEquals(8.0, r.getUpperBound(), EPSILON); } /** + * Some checks for the findStackedRangeBounds(CategoryDataset, + * KeyToGroupMap) method. + */ + public void testFindStackedRangeBounds_CategoryDataset3() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + KeyToGroupMap map = new KeyToGroupMap("Group A"); + Range r = DatasetUtilities.findStackedRangeBounds(dataset, map); + assertTrue(r == null); + + dataset.addValue(1.0, "R1", "C1"); + dataset.addValue(2.0, "R2", "C1"); + dataset.addValue(3.0, "R3", "C1"); + dataset.addValue(4.0, "R4", "C1"); + + map.mapKeyToGroup("R1", "Group A"); + map.mapKeyToGroup("R2", "Group A"); + map.mapKeyToGroup("R3", "Group B"); + map.mapKeyToGroup("R4", "Group B"); + + r = DatasetUtilities.findStackedRangeBounds(dataset, map); + assertEquals(0.0, r.getLowerBound(), EPSILON); + assertEquals(7.0, r.getUpperBound(), EPSILON); + + dataset.addValue(null, "R5", "C1"); + r = DatasetUtilities.findStackedRangeBounds(dataset, map); + assertEquals(0.0, r.getLowerBound(), EPSILON); + assertEquals(7.0, r.getUpperBound(), EPSILON); + + dataset.addValue(Double.NaN, "R6", "C1"); + r = DatasetUtilities.findStackedRangeBounds(dataset, map); + assertEquals(0.0, r.getLowerBound(), EPSILON); + assertEquals(7.0, r.getUpperBound(), EPSILON); + } + + /** * Some checks for the findStackedRangeBounds() method. */ public void testFindStackedRangeBoundsForTableXYDataset1() { @@ -671,6 +844,88 @@ } /** + * A simple check for the findMinimumStackedRangeValue() method. + */ + public void testFindMinimumStackedRangeValue() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + + // an empty dataset should return a null max + Number min = DatasetUtilities.findMinimumStackedRangeValue(dataset); + assertNull(min); + + dataset.addValue(1.0, "R1", "C1"); + min = DatasetUtilities.findMinimumStackedRangeValue(dataset); + assertEquals(0.0, min.doubleValue(), EPSILON); + + dataset.addValue(2.0, "R2", "C1"); + min = DatasetUtilities.findMinimumStackedRangeValue(dataset); + assertEquals(0.0, min.doubleValue(), EPSILON); + + dataset.addValue(-3.0, "R3", "C1"); + min = DatasetUtilities.findMinimumStackedRangeValue(dataset); + assertEquals(-3.0, min.doubleValue(), EPSILON); + + dataset.addValue(Double.NaN, "R4", "C1"); + min = DatasetUtilities.findMinimumStackedRangeValue(dataset); + assertEquals(-3.0, min.doubleValue(), EPSILON); + } + + /** + * A simple check for the findMaximumStackedRangeValue() method. + */ + public void testFindMinimumStackedRangeValue2() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(-1.0, "R1", "C1"); + Number min = DatasetUtilities.findMinimumStackedRangeValue(dataset); + assertEquals(-1.0, min.doubleValue(), EPSILON); + + dataset.addValue(-2.0, "R2", "C1"); + min = DatasetUtilities.findMinimumStackedRangeValue(dataset); + assertEquals(-3.0, min.doubleValue(), EPSILON); + } + + /** + * A simple check for the findMaximumStackedRangeValue() method. + */ + public void testFindMaximumStackedRangeValue() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + + // an empty dataset should return a null max + Number max = DatasetUtilities.findMaximumStackedRangeValue(dataset); + assertNull(max); + + dataset.addValue(1.0, "R1", "C1"); + max = DatasetUtilities.findMaximumStackedRangeValue(dataset); + assertEquals(1.0, max.doubleValue(), EPSILON); + + dataset.addValue(2.0, "R2", "C1"); + max = DatasetUtilities.findMaximumStackedRangeValue(dataset); + assertEquals(3.0, max.doubleValue(), EPSILON); + + dataset.addValue(-3.0, "R3", "C1"); + max = DatasetUtilities.findMaximumStackedRangeValue(dataset); + assertEquals(3.0, max.doubleValue(), EPSILON); + + dataset.addValue(Double.NaN, "R4", "C1"); + max = DatasetUtilities.findMaximumStackedRangeValue(dataset); + assertEquals(3.0, max.doubleValue(), EPSILON); + } + + /** + * A simple check for the findMaximumStackedRangeValue() method. + */ + public void testFindMaximumStackedRangeValue2() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(-1.0, "R1", "C1"); + Number max = DatasetUtilities.findMaximumStackedRangeValue(dataset); + assertEquals(0.0, max.doubleValue(), EPSILON); + + dataset.addValue(-2.0, "R2", "C1"); + max = DatasetUtilities.findMaximumStackedRangeValue(dataset); + assertEquals(0.0, max.doubleValue(), EPSILON); + } + + /** * Creates a dataset for testing. * * @return A dataset. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-10-15 09:12:19
|
Revision: 1666 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1666&view=rev Author: mungady Date: 2008-10-15 09:12:08 +0000 (Wed, 15 Oct 2008) Log Message: ----------- 2008-10-15 David Gilbert <dav...@ob...> * source/org/jfree/chart/LegendItem.java (LegendItem(String, Paint)): New constructor. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/LegendItem.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-10-08 14:57:14 UTC (rev 1665) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-10-15 09:12:08 UTC (rev 1666) @@ -1,3 +1,8 @@ +2008-10-15 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/LegendItem.java + (LegendItem(String, Paint)): New constructor. + 2008-10-08 David Gilbert <dav...@ob...> Incorporating patch 2131001: Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/LegendItem.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/LegendItem.java 2008-10-08 14:57:14 UTC (rev 1665) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/LegendItem.java 2008-10-15 09:12:08 UTC (rev 1666) @@ -56,6 +56,7 @@ * 03-Aug-2007 : Fixed null pointer exception (DG); * 23-Apr-2008 : Added new constructor and implemented Cloneable (DG); * 17-Jun-2008 : Added optional labelFont and labelPaint attributes (DG); + * 15-Oct-2008 : Added new constructor (DG); * */ @@ -207,8 +208,21 @@ * @since 1.0.10 */ public LegendItem(String label) { + this(label, Color.black); + } + + /** + * Creates a legend item with the specified label and fill paint. The + * remaining attributes take default values. + * + * @param label the label (<code>null</code> not permitted). + * @param paint the paint (<code>null</code> not permitted). + * + * @since 1.0.12 + */ + public LegendItem(String label, Paint paint) { this(label, null, null, null, new Rectangle2D.Double(-4.0, -4.0, 8.0, - 8.0), Color.black); + 8.0), paint); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-10-23 08:05:06
|
Revision: 1668 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1668&view=rev Author: mungady Date: 2008-10-23 08:04:50 +0000 (Thu, 23 Oct 2008) Log Message: ----------- 2008-10-23 David Gilbert <dav...@ob...> * source/org/jfree/chart/ChartFactory.java (setChartTheme): Check if theme is "Legacy" and reset default bar painters. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartFactory.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-10-15 09:18:07 UTC (rev 1667) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-10-23 08:04:50 UTC (rev 1668) @@ -1,3 +1,8 @@ +2008-10-23 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/ChartFactory.java + (setChartTheme): Check if theme is "Legacy" and reset default bar painters. + 2008-10-15 David Gilbert <dav...@ob...> * source/org/jfree/chart/LegendItem.java 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-10-15 09:18:07 UTC (rev 1667) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/ChartFactory.java 2008-10-23 08:04:50 UTC (rev 1668) @@ -116,6 +116,8 @@ * 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); + * 23-Oct-2008 : Check for legacy theme in setChartTheme() and reset default + * bar painters (DG); * */ @@ -167,15 +169,19 @@ import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.chart.renderer.category.GanttRenderer; +import org.jfree.chart.renderer.category.GradientBarPainter; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.chart.renderer.category.LineRenderer3D; import org.jfree.chart.renderer.category.StackedAreaRenderer; import org.jfree.chart.renderer.category.StackedBarRenderer; import org.jfree.chart.renderer.category.StackedBarRenderer3D; +import org.jfree.chart.renderer.category.StandardBarPainter; import org.jfree.chart.renderer.category.WaterfallBarRenderer; import org.jfree.chart.renderer.xy.CandlestickRenderer; +import org.jfree.chart.renderer.xy.GradientXYBarPainter; import org.jfree.chart.renderer.xy.HighLowRenderer; import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; +import org.jfree.chart.renderer.xy.StandardXYBarPainter; import org.jfree.chart.renderer.xy.WindItemRenderer; import org.jfree.chart.renderer.xy.XYAreaRenderer; import org.jfree.chart.renderer.xy.XYBarRenderer; @@ -237,11 +243,12 @@ /** * Sets the current chart theme. This will be applied to all new charts - * as they are created. + * created via methods in this class. * * @param theme the theme (<code>null</code> not permitted). * * @see #getChartTheme() + * @see ChartUtilities#applyCurrentTheme(JFreeChart) * * @since 1.0.11 */ @@ -250,6 +257,20 @@ throw new IllegalArgumentException("Null 'theme' argument."); } currentTheme = theme; + + // here we do a check to see if the user is installing the "Legacy" + // theme, and reset the bar painters in that case... + if (theme instanceof StandardChartTheme) { + StandardChartTheme sct = (StandardChartTheme) theme; + if (sct.getName().equals("Legacy")) { + BarRenderer.setDefaultBarPainter(new StandardBarPainter()); + XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter()); + } + else { + BarRenderer.setDefaultBarPainter(new GradientBarPainter()); + XYBarRenderer.setDefaultBarPainter(new GradientXYBarPainter()); + } + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-10-27 14:07:08
|
Revision: 1670 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1670&view=rev Author: mungady Date: 2008-10-27 14:06:41 +0000 (Mon, 27 Oct 2008) Log Message: ----------- 2008-10-27 David Gilbert <dav...@ob...> * source/org/jfree/chart/axis/CategoryAxis.java (refreshTicks): Set correct for for category label. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/CategoryAxis.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-10-23 08:19:01 UTC (rev 1669) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-10-27 14:06:41 UTC (rev 1670) @@ -1,3 +1,8 @@ +2008-10-27 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/axis/CategoryAxis.java + (refreshTicks): Set correct for for category label. + 2008-10-23 David Gilbert <dav...@ob...> * source/org/jfree/chart/ChartFactory.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/CategoryAxis.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/CategoryAxis.java 2008-10-23 08:19:01 UTC (rev 1669) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/CategoryAxis.java 2008-10-27 14:06:41 UTC (rev 1670) @@ -87,6 +87,7 @@ * 23-Apr-2008 : Fixed bug 1942059, bad use of insets in * calculateTextBlockWidth() (DG); * 26-Jun-2008 : Added new getCategoryMiddle() method (DG); + * 27-Oct-2008 : Set font on Graphics2D when creating category labels (DG); * */ @@ -1101,6 +1102,7 @@ Iterator iterator = categories.iterator(); while (iterator.hasNext()) { Comparable category = (Comparable) iterator.next(); + g2.setFont(getTickLabelFont(category)); TextBlock label = createLabel(category, l * r, edge, g2); if (edge == RectangleEdge.TOP || edge == RectangleEdge.BOTTOM) { max = Math.max(max, calculateTextBlockHeight(label, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-11-05 16:44:20
|
Revision: 1672 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1672&view=rev Author: mungady Date: 2008-11-05 16:44:02 +0000 (Wed, 05 Nov 2008) Log Message: ----------- 2008-11-05 David Gilbert <dav...@ob...> Bug 2221495: * source/org/jfree/chart/annotations/XYLineAnnotation.java (draw): Clip line before drawing, * source/org/jfree/chart/util/LineUtilities.java: New file, * tests/org/jfree/chart/util/junit/LineUtilitiesTests.java: Likewise. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/annotations/XYLineAnnotation.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/util/junit/UtilPackageTests.java Added Paths: ----------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/LineUtilities.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/util/junit/LineUtilitiesTests.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-10-27 14:36:25 UTC (rev 1671) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-11-05 16:44:02 UTC (rev 1672) @@ -1,3 +1,11 @@ +2008-11-05 David Gilbert <dav...@ob...> + + Bug 2221495: + * source/org/jfree/chart/annotations/XYLineAnnotation.java + (draw): Clip line before drawing, + * source/org/jfree/chart/util/LineUtilities.java: New file, + * tests/org/jfree/chart/util/junit/LineUtilitiesTests.java: Likewise. + 2008-10-27 David Gilbert <dav...@ob...> * source/org/jfree/chart/axis/CategoryAxis.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/annotations/XYLineAnnotation.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/annotations/XYLineAnnotation.java 2008-10-27 14:36:25 UTC (rev 1671) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/annotations/XYLineAnnotation.java 2008-11-05 16:44:02 UTC (rev 1672) @@ -43,6 +43,8 @@ * AbstractXYAnnotation (DG); * 04-Oct-2004 : Renamed ShapeUtils --> ShapeUtilities (DG); * 08-Jun-2005 : Fixed equals() method to handle GradientPaint() (DG); + * 05-Nov-2008 : Added workaround for JRE bug 6574155, see JFreeChart bug + * 2221495 (DG); * */ @@ -65,6 +67,7 @@ import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.PlotRenderingInfo; import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.util.LineUtilities; import org.jfree.io.SerialUtilities; import org.jfree.ui.RectangleEdge; import org.jfree.util.ObjectUtilities; @@ -193,7 +196,12 @@ g2.setPaint(this.paint); g2.setStroke(this.stroke); Line2D line = new Line2D.Float(j2DX1, j2DY1, j2DX2, j2DY2); - g2.draw(line); + // line is clipped to avoid JRE bug 6574155, for more info + // see JFreeChart bug 2221495 + boolean visible = LineUtilities.clipLine(line, dataArea); + if (visible) { + g2.draw(line); + } String toolTip = getToolTipText(); String url = getURL(); Added: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/LineUtilities.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/LineUtilities.java (rev 0) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/util/LineUtilities.java 2008-11-05 16:44:02 UTC (rev 1672) @@ -0,0 +1,142 @@ +/* =========================================================== + * 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.] + * + * ------------------ + * LineUtilities.java + * ------------------ + * (C) Copyright 2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Nov-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.util; + +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; + +/** + * Some utility methods for {@link Line2D} objects. + * + * @since 1.0.12 + */ +public class LineUtilities { + + /** + * Clips the specified line to the given rectangle. + * + * @param line the line (<code>null</code> not permitted). + * @param rect the clipping rectangle (<code>null</code> not permitted). + * + * @return <code>true</code> if the clipped line is visible, and + * <code>false</code> otherwise. + */ + public static boolean clipLine(Line2D line, Rectangle2D rect) { + + double x1 = line.getX1(); + double y1 = line.getY1(); + double x2 = line.getX2(); + double y2 = line.getY2(); + + double minX = rect.getMinX(); + double maxX = rect.getMaxX(); + double minY = rect.getMinY(); + double maxY = rect.getMaxY(); + + int f1 = rect.outcode(x1, y1); + int f2 = rect.outcode(x2, y2); + + while ((f1 | f2) != 0) { + if ((f1 & f2) != 0) { + return false; + } + double dx = (x2 - x1); + double dy = (y2 - y1); + // update (x1, y1), (x2, y2) and f1 and f2 using intersections + // then recheck + if (f1 != 0) { + // first point is outside, so we update it against one of the + // four sides then continue + if ((f1 & Rectangle2D.OUT_LEFT) == Rectangle2D.OUT_LEFT + && dx != 0.0) { + y1 = y1 + (minX - x1) * dy / dx; + x1 = minX; + } + else if ((f1 & Rectangle2D.OUT_RIGHT) == Rectangle2D.OUT_RIGHT + && dx != 0.0) { + y1 = y1 + (maxX - x1) * dy / dx; + x1 = maxX; + } + else if ((f1 & Rectangle2D.OUT_BOTTOM) == Rectangle2D.OUT_BOTTOM + && dy != 0.0) { + x1 = x1 + (maxY - y1) * dx / dy; + y1 = maxY; + } + else if ((f1 & Rectangle2D.OUT_TOP) == Rectangle2D.OUT_TOP + && dy != 0.0) { + x1 = x1 + (minY - y1) * dx / dy; + y1 = minY; + } + f1 = rect.outcode(x1, y1); + } + else if (f2 != 0) { + // second point is outside, so we update it against one of the + // four sides then continue + if ((f2 & Rectangle2D.OUT_LEFT) == Rectangle2D.OUT_LEFT + && dx != 0.0) { + y2 = y2 + (minX - x2) * dy / dx; + x2 = minX; + } + else if ((f2 & Rectangle2D.OUT_RIGHT) == Rectangle2D.OUT_RIGHT + && dx != 0.0) { + y2 = y2 + (maxX - x2) * dy / dx; + x2 = maxX; + } + else if ((f2 & Rectangle2D.OUT_BOTTOM) == Rectangle2D.OUT_BOTTOM + && dy != 0.0) { + x2 = x2 + (maxY - y2) * dx / dy; + y2 = maxY; + } + else if ((f2 & Rectangle2D.OUT_TOP) == Rectangle2D.OUT_TOP + && dy != 0.0) { + x2 = x2 + (minY - y2) * dx / dy; + y2 = minY; + } + f2 = rect.outcode(x2, y2); + } + } + + line.setLine(x1, y1, x2, y2); + return true; // the line is visible - if it wasn't, we'd have + // returned false from within the while loop above + + } +} Added: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/util/junit/LineUtilitiesTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/util/junit/LineUtilitiesTests.java (rev 0) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/util/junit/LineUtilitiesTests.java 2008-11-05 16:44:02 UTC (rev 1672) @@ -0,0 +1,147 @@ +/* =========================================================== + * 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.] + * + * ----------------------- + * LineUtilitiesTests.java + * ----------------------- + * (C) Copyright 2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Nov-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.util.junit; + +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.jfree.chart.util.LineUtilities; + +/** + * Tests for the {@link LineUtilities} class. + */ +public class LineUtilitiesTests extends TestCase { + + /** + * Returns the tests as a test suite. + * + * @return The test suite. + */ + public static Test suite() { + return new TestSuite(LineUtilitiesTests.class); + } + + /** + * Constructs a new set of tests. + * + * @param name the name of the tests. + */ + public LineUtilitiesTests(String name) { + super(name); + } + + private boolean lineEquals(Line2D line, double x1, double y1, double x2, + double y2) { + boolean result = true; + double epsilon = 0.0000000001; + if (Math.abs(line.getX1() - x1) > epsilon) result = false; + if (Math.abs(line.getY1() - y1) > epsilon) result = false; + if (Math.abs(line.getX2() - x2) > epsilon) result = false; + if (Math.abs(line.getY2() - y2) > epsilon) result = false; + if (result == false) { + System.out.println(line.getX1() + ", " + line.getY1() + ", " + + line.getX2() + ", " + line.getY2()); + } + return result; + } + + public void testClipLine() { + Rectangle2D rect = new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0); + Line2D line = new Line2D.Double(); + + assertFalse(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 0.0, 0.0, 0.0, 0.0)); + + line.setLine(0.5, 0.5, 0.6, 0.6); + assertFalse(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 0.5, 0.5, 0.6, 0.6)); + + line.setLine(0.5, 0.5, 1.6, 0.6); + assertFalse(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 0.5, 0.5, 1.6, 0.6)); + + line.setLine(0.5, 0.5, 2.6, 0.6); + assertFalse(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 0.5, 0.5, 2.6, 0.6)); + + line.setLine(0.5, 0.5, 0.6, 1.6); + assertFalse(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 0.5, 0.5, 0.6, 1.6)); + + line.setLine(0.5, 0.5, 1.6, 1.6); + assertTrue(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 1.0, 1.0, 1.6, 1.6)); + + line.setLine(0.5, 0.5, 2.6, 1.6); + assertTrue(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 1.4545454545454546, 1.0, 2.0, + 1.2857142857142858)); + + line.setLine(0.5, 0.5, 0.5, 2.6); + assertFalse(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 0.5, 0.5, 0.5, 2.6)); + + line.setLine(0.5, 0.5, 1.5, 2.6); + assertTrue(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 1.0, 1.55, 1.2142857142857142, 2.0)); + + line.setLine(0.5, 0.5, 2.5, 2.6); + assertTrue(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 1.0, 1.025, 1.9285714285714284, 2.0)); + + line.setLine(0.5, 0.5, 1.5, 1.5); + assertTrue(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 1.0, 1.0, 1.5, 1.5)); + + line.setLine(2.5, 1.0, 1.5, 1.5); + assertTrue(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 2.0, 1.25, 1.5, 1.5)); + + line.setLine(1.5, 1.5, 2.5, 1.0); + assertTrue(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 1.5, 1.5, 2.0, 1.25)); + } + +} Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/util/junit/UtilPackageTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/util/junit/UtilPackageTests.java 2008-10-27 14:36:25 UTC (rev 1671) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/util/junit/UtilPackageTests.java 2008-11-05 16:44:02 UTC (rev 1672) @@ -36,6 +36,7 @@ * -------- * 23-Nov-2006 : Version 1 (DG); * 08-Apr-2008 : Added LogFormatTests (DG); + * 05-Nov-2008 : Added LineUtilitiesTests (DG); * */ @@ -59,6 +60,7 @@ */ public static Test suite() { TestSuite suite = new TestSuite("org.jfree.chart.util"); + suite.addTestSuite(LineUtilitiesTests.class); suite.addTestSuite(LogFormatTests.class); suite.addTestSuite(RelativeDateFormatTests.class); return suite; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-11-13 13:28:17
|
Revision: 1677 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1677&view=rev Author: mungady Date: 2008-11-13 13:28:09 +0000 (Thu, 13 Nov 2008) Log Message: ----------- 2008-11-13 David Gilbert <dav...@ob...> Bug 2275695: * source/org/jfree/chart/axis/SubCategoryAxis.java (drawSubCategoryLabels): Check for null, * tests/org/jfree/chart/axis/junit/SubCategoryAxisTests.java (test2275695): New method. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/NEWS branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/SubCategoryAxis.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/junit/SubCategoryAxisTests.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-11-13 10:05:49 UTC (rev 1676) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-11-13 13:28:09 UTC (rev 1677) @@ -1,3 +1,11 @@ +2008-11-13 David Gilbert <dav...@ob...> + + Bug 2275695: + * source/org/jfree/chart/axis/SubCategoryAxis.java + (drawSubCategoryLabels): Check for null, + * tests/org/jfree/chart/axis/junit/SubCategoryAxisTests.java + (test2275695): New method. + 2008-11-05 David Gilbert <dav...@ob...> Bug 2221495: Modified: branches/jfreechart-1.0.x-branch/NEWS =================================================================== --- branches/jfreechart-1.0.x-branch/NEWS 2008-11-13 10:05:49 UTC (rev 1676) +++ branches/jfreechart-1.0.x-branch/NEWS 2008-11-13 13:28:09 UTC (rev 1677) @@ -3,6 +3,7 @@ ?? ??? 2008 Bug Fixes: +2275695 : NullPointerException for SubCategoryAxis on plot with null dataset; 2121818 : Label link lines for very thin RingPlot; Also fixed StackedXYBarRenderer which was ignoring the shadowsVisible attribute. Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/SubCategoryAxis.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/SubCategoryAxis.java 2008-11-13 10:05:49 UTC (rev 1676) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/axis/SubCategoryAxis.java 2008-11-13 13:28:09 UTC (rev 1677) @@ -43,6 +43,8 @@ * Joubert (1277726) (DG); * 30-May-2007 : Added argument check and event notification to * addSubCategory() (DG); + * 13-Nov-2008 : Fix NullPointerException when dataset is null - see bug + * report 2275695 (DG); * */ @@ -306,8 +308,11 @@ g2.setFont(this.subLabelFont); g2.setPaint(this.subLabelPaint); CategoryPlot plot = (CategoryPlot) getPlot(); + int categoryCount = 0; CategoryDataset dataset = plot.getDataset(); - int categoryCount = dataset.getColumnCount(); + if (dataset != null) { + categoryCount = dataset.getColumnCount(); + } double maxdim = getMaxDim(g2, edge); for (int categoryIndex = 0; categoryIndex < categoryCount; Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/junit/SubCategoryAxisTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/junit/SubCategoryAxisTests.java 2008-11-13 10:05:49 UTC (rev 1676) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/axis/junit/SubCategoryAxisTests.java 2008-11-13 13:28:09 UTC (rev 1677) @@ -36,6 +36,7 @@ * ------- * 12-May-2004 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() (DG); + * 13-Nov-2008 : Added test2275695() (DG); * */ @@ -43,6 +44,9 @@ import java.awt.Color; import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInput; @@ -54,7 +58,11 @@ import junit.framework.TestCase; import junit.framework.TestSuite; +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.SubCategoryAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; /** * Tests for the {@link SubCategoryAxis} class. @@ -67,7 +75,7 @@ * @return The test suite. */ public static Test suite() { - return new TestSuite(CategoryAxisTests.class); + return new TestSuite(SubCategoryAxisTests.class); } /** @@ -126,12 +134,13 @@ */ public void testCloning() { SubCategoryAxis a1 = new SubCategoryAxis("Test"); + a1.addSubCategory("SubCategoryA"); SubCategoryAxis a2 = null; try { a2 = (SubCategoryAxis) a1.clone(); } catch (CloneNotSupportedException e) { - System.err.println("Failed to clone."); + e.printStackTrace(); } assertTrue(a1 != a2); assertTrue(a1.getClass() == a2.getClass()); @@ -142,10 +151,9 @@ * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { - SubCategoryAxis a1 = new SubCategoryAxis("Test Axis"); + a1.addSubCategory("SubCategoryA"); SubCategoryAxis a2 = null; - try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); @@ -161,7 +169,30 @@ e.printStackTrace(); } assertEquals(a1, a2); + } + /** + * A check for the NullPointerException in bug 2275695. + */ + public void test2275695() { + JFreeChart chart = ChartFactory.createStackedBarChart("Test", + "Category", "Value", null, PlotOrientation.VERTICAL, + true, false, false); + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + plot.setDomainAxis(new SubCategoryAxis("SubCategoryAxis")); + boolean success = false; + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); + g2.dispose(); + success = true; + } + catch (Exception e) { + success = false; + } + assertTrue(success); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mu...@us...> - 2008-11-18 09:12:38
|
Revision: 1680 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=1680&view=rev Author: mungady Date: 2008-11-18 09:12:31 +0000 (Tue, 18 Nov 2008) Log Message: ----------- 2008-11-18 David Gilbert <dav...@ob...> Bug 2216511: * swt/org/jfree/experimental/chart/demo/SWTBarChartDemo1.java (createChart): Reset the bar painter to avoid using gradients, * swt/org/jfree/experimental/swt/SWTGraphics2D.java (setPaint): Don't fail for GradientPaint. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/NEWS branches/jfreechart-1.0.x-branch/swt/org/jfree/experimental/chart/swt/demo/SWTBarChartDemo1.java branches/jfreechart-1.0.x-branch/swt/org/jfree/experimental/swt/SWTGraphics2D.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2008-11-13 15:26:56 UTC (rev 1679) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2008-11-18 09:12:31 UTC (rev 1680) @@ -1,3 +1,11 @@ +2008-11-18 David Gilbert <dav...@ob...> + + Bug 2216511: + * swt/org/jfree/experimental/chart/demo/SWTBarChartDemo1.java + (createChart): Reset the bar painter to avoid using gradients, + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + (setPaint): Don't fail for GradientPaint. + 2008-11-13 David Gilbert <dav...@ob...> Bug 2275695: Modified: branches/jfreechart-1.0.x-branch/NEWS =================================================================== --- branches/jfreechart-1.0.x-branch/NEWS 2008-11-13 15:26:56 UTC (rev 1679) +++ branches/jfreechart-1.0.x-branch/NEWS 2008-11-18 09:12:31 UTC (rev 1680) @@ -4,7 +4,10 @@ Bug Fixes: 2275695 : NullPointerException for SubCategoryAxis on plot with null dataset; +2221495 : XYLineAnnotation with dashed stroke; +2216511 : SWTBarChartDemo1 throws RuntimeException; 2121818 : Label link lines for very thin RingPlot; +2113627 : XYStepRenderer item labels. Also fixed StackedXYBarRenderer which was ignoring the shadowsVisible attribute. Modified: branches/jfreechart-1.0.x-branch/swt/org/jfree/experimental/chart/swt/demo/SWTBarChartDemo1.java =================================================================== --- branches/jfreechart-1.0.x-branch/swt/org/jfree/experimental/chart/swt/demo/SWTBarChartDemo1.java 2008-11-13 15:26:56 UTC (rev 1679) +++ branches/jfreechart-1.0.x-branch/swt/org/jfree/experimental/chart/swt/demo/SWTBarChartDemo1.java 2008-11-18 09:12:31 UTC (rev 1680) @@ -2,32 +2,32 @@ * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * - * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. + * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. * * Project Info: http://www.jfree.org/jfreechart/index.html * - * 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 + * 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 + * 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. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. * - * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * --------------------- * SWTBarChartDemo1.java * --------------------- - * (C) Copyright 2006, 2007, by Object Refinery Limited and Contributors. + * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): @@ -35,13 +35,11 @@ * Changes * ------- * 23-Aug-2006 : New class (DG); - * + * */ package org.jfree.experimental.chart.swt.demo; -import java.awt.Color; - import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; @@ -54,6 +52,7 @@ import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.BarRenderer; +import org.jfree.chart.renderer.category.StandardBarPainter; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.experimental.chart.swt.ChartComposite; @@ -62,14 +61,14 @@ * An SWT demo. */ public class SWTBarChartDemo1 { - + /** * Returns a sample dataset. - * + * * @return The dataset. */ private static CategoryDataset createDataset() { - + // row keys... String series1 = "First"; String series2 = "Second"; @@ -102,23 +101,23 @@ dataset.addValue(2.0, series3, category3); dataset.addValue(3.0, series3, category4); dataset.addValue(6.0, series3, category5); - + return dataset; - + } - + /** * Creates a sample chart. - * + * * @param dataset the dataset. - * + * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { - + // create the chart... JFreeChart chart = ChartFactory.createBarChart( - "Bar Chart Demo", // chart title + "SWTBarChartDemo1", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data @@ -130,34 +129,32 @@ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... - // set the background color for the chart... - chart.setBackgroundPaint(Color.white); - // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); - plot.setBackgroundPaint(Color.lightGray); - plot.setDomainGridlinePaint(Color.white); - plot.setDomainGridlinesVisible(true); - plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... - final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); + // the SWTGraphics2D class doesn't handle GradientPaint well, so + // replace the gradient painter from the default theme with a + // standard painter... + renderer.setBarPainter(new StandardBarPainter()); + CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions( - CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0) - ); + CategoryLabelPositions.createUpRotationLabelPositions( + Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. - + return chart; - + } - + /** * Starting point for the demonstration application. * @@ -170,7 +167,7 @@ shell.setSize(600, 300); shell.setLayout(new FillLayout()); shell.setText("Test for jfreechart running with SWT"); - final ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, + ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true); frame.pack(); shell.open(); Modified: branches/jfreechart-1.0.x-branch/swt/org/jfree/experimental/swt/SWTGraphics2D.java =================================================================== --- branches/jfreechart-1.0.x-branch/swt/org/jfree/experimental/swt/SWTGraphics2D.java 2008-11-13 15:26:56 UTC (rev 1679) +++ branches/jfreechart-1.0.x-branch/swt/org/jfree/experimental/swt/SWTGraphics2D.java 2008-11-18 09:12:31 UTC (rev 1680) @@ -50,6 +50,7 @@ * 23-Oct-2007 : Implemented drawPolygon(), drawPolyline(), drawOval(), * fillOval(), drawArc() and fillArc() (DG); * 27-Nov-2007 : Implemented a couple of drawImage() methods (DG); + * 18-Nov-2008 : Check for GradientPaint in setPaint() method (DG); * */ @@ -61,6 +62,7 @@ import java.awt.Composite; import java.awt.Font; import java.awt.FontMetrics; +import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; @@ -242,7 +244,10 @@ /** * Sets the paint for this graphics context. For now, this graphics - * context only supports instances of {@link Color}. + * context only supports instances of {@link Color} or + * {@link GradientPaint} (in the latter case there is no real gradient + * support, the paint used is the <code>Color</code> returned by + * <code>getColor1()</code>). * * @param paint the paint (<code>null</code> not permitted). * @@ -253,6 +258,10 @@ if (paint instanceof Color) { setColor((Color) paint); } + else if (paint instanceof GradientPaint) { + GradientPaint gp = (GradientPaint) paint; + setColor(gp.getColor1()); + } else { throw new RuntimeException("Can only handle 'Color' at present."); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |