From: <mu...@us...> - 2007-10-29 14:42:35
|
Revision: 447 http://jfreechart.svn.sourceforge.net/jfreechart/?rev=447&view=rev Author: mungady Date: 2007-10-29 07:42:30 -0700 (Mon, 29 Oct 2007) Log Message: ----------- 2007-10-29 David Gilbert <dav...@ob...> * source/org/jfree/chart/plot/dial/SimpleDialFrame.java: Renamed StandardDialFrame.java. Modified Paths: -------------- branches/jfreechart-1.0.x-branch/ChangeLog branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/DialFrame.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/DialPackageTests.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/DialPlotTests.java Added Paths: ----------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/StandardDialFrame.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/StandardDialFrameTests.java Removed Paths: ------------- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/SimpleDialFrame.java branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/SimpleDialFrameTests.java Modified: branches/jfreechart-1.0.x-branch/ChangeLog =================================================================== --- branches/jfreechart-1.0.x-branch/ChangeLog 2007-10-26 10:35:54 UTC (rev 446) +++ branches/jfreechart-1.0.x-branch/ChangeLog 2007-10-29 14:42:30 UTC (rev 447) @@ -1,3 +1,8 @@ +2007-10-29 David Gilbert <dav...@ob...> + + * source/org/jfree/chart/plot/dial/SimpleDialFrame.java: + Renamed StandardDialFrame.java. + 2007-10-26 David Gilbert <dav...@ob...> * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java Modified: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/DialFrame.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/DialFrame.java 2007-10-26 10:35:54 UTC (rev 446) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/DialFrame.java 2007-10-29 14:42:30 UTC (rev 447) @@ -47,7 +47,7 @@ /** * A dial frame is the face plate for a dial plot - it is always drawn last. * JFreeChart includes a couple of implementations of this interface - * ({@link SimpleDialFrame} and {@link ArcDialFrame}). + * ({@link StandardDialFrame} and {@link ArcDialFrame}). * <br><br> * Classes that implement this interface should be {@link Serializable}, * otherwise chart serialization may fail. Deleted: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/SimpleDialFrame.java =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/SimpleDialFrame.java 2007-10-26 10:35:54 UTC (rev 446) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/SimpleDialFrame.java 2007-10-29 14:42:30 UTC (rev 447) @@ -1,354 +0,0 @@ -/* =========================================================== - * JFreeChart : a free chart library for the Java(tm) platform - * =========================================================== - * - * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. - * - * Project Info: http://www.jfree.org/jfreechart/index.html - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * [Java is a trademark or registered trademark of Sun Microsystems, Inc. - * in the United States and other countries.] - * - * -------------------- - * SimpleDialFrame.java - * -------------------- - * (C) Copyright 2006, 2007, by Object Refinery Limited. - * - * Original Author: David Gilbert (for Object Refinery Limited); - * Contributor(s): -; - * - * Changes - * ------- - * 03-Nov-2006 : Version 1 (DG); - * 08-Mar-2007 : Fix in hashCode() (DG); - * - */ - -package org.jfree.chart.plot.dial; - -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.Area; -import java.awt.geom.Ellipse2D; -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.HashUtilities; -import org.jfree.io.SerialUtilities; -import org.jfree.util.PaintUtilities; -import org.jfree.util.PublicCloneable; - -/** - * A simple circular frame for the {@link DialPlot} class. - */ -public class SimpleDialFrame extends AbstractDialLayer implements DialFrame, - Cloneable, PublicCloneable, Serializable { - - /** The outer radius, relative to the framing rectangle. */ - private double radius; - - /** - * The color used for the front of the panel. This field is transient - * because it requires special handling for serialization. - */ - private transient Paint backgroundPaint; - - /** - * The color used for the border around the window. This field is transient - * because it requires special handling for serialization. - */ - private transient Paint foregroundPaint; - - /** - * The stroke for drawing the frame outline. This field is transient - * because it requires special handling for serialization. - */ - private transient Stroke stroke; - - /** - * Creates a new instance of <code>SimpleDialFrame</code>. - */ - public SimpleDialFrame() { - this.backgroundPaint = Color.gray; - this.foregroundPaint = Color.black; - this.stroke = new BasicStroke(2.0f); - this.radius = 0.95; - } - - /** - * Returns the radius, relative to the framing rectangle. - * - * @return The radius. - * - * @see #setRadius(double) - */ - public double getRadius() { - return this.radius; - } - - /** - * Sets the radius and sends a {@link DialLayerChangeEvent} to all - * registered listeners. - * - * @param radius the radius (must be positive). - * - * @see #getRadius() - */ - public void setRadius(double radius) { - if (radius <= 0) { - throw new IllegalArgumentException("" + - "The 'radius' must be positive."); - } - this.radius = radius; - notifyListeners(new DialLayerChangeEvent(this)); - } - - /** - * Returns the background paint. - * - * @return The background paint (never <code>null</code>). - * - * @see #setBackgroundPaint(Paint) - */ - public Paint getBackgroundPaint() { - return this.backgroundPaint; - } - - /** - * Sets the background paint and sends a {@link DialLayerChangeEvent} to - * all registered listeners. - * - * @param paint the paint (<code>null</code> not permitted). - * - * @see #getBackgroundPaint() - */ - public void setBackgroundPaint(Paint paint) { - if (paint == null) { - throw new IllegalArgumentException("Null 'paint' argument."); - } - this.backgroundPaint = paint; - notifyListeners(new DialLayerChangeEvent(this)); - } - - /** - * Returns the foreground paint. - * - * @return The foreground paint (never <code>null</code>). - * - * @see #setForegroundPaint(Paint) - */ - public Paint getForegroundPaint() { - return this.foregroundPaint; - } - - /** - * Sets the foreground paint and sends a {@link DialLayerChangeEvent} to - * all registered listeners. - * - * @param paint the paint (<code>null</code> not permitted). - * - * @see #getForegroundPaint() - */ - public void setForegroundPaint(Paint paint) { - if (paint == null) { - throw new IllegalArgumentException("Null 'paint' argument."); - } - this.foregroundPaint = paint; - notifyListeners(new DialLayerChangeEvent(this)); - } - - /** - * Returns the stroke for the frame. - * - * @return The stroke (never <code>null</code>). - * - * @see #setStroke(Stroke) - */ - public Stroke getStroke() { - return this.stroke; - } - - /** - * Sets the stroke and sends a {@link DialLayerChangeEvent} to all - * registered listeners. - * - * @param stroke the stroke (<code>null</code> not permitted). - * - * @see #getStroke() - */ - public void setStroke(Stroke stroke) { - if (stroke == null) { - throw new IllegalArgumentException("Null 'stroke' argument."); - } - this.stroke = stroke; - notifyListeners(new DialLayerChangeEvent(this)); - } - - /** - * Returns the shape for the window for this dial. Some dial layers will - * request that their drawing be clipped within this window. - * - * @param frame the reference frame (<code>null</code> not permitted). - * - * @return The shape of the dial's window. - */ - public Shape getWindow(Rectangle2D frame) { - Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, - this.radius); - return new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(), - f.getHeight()); - } - - /** - * Returns <code>false</code> to indicate that this dial layer is not - * clipped to the dial window. - * - * @return A boolean. - */ - public boolean isClippedToWindow() { - return false; - } - - /** - * Draws the frame. This method is called by the {@link DialPlot} class, - * you shouldn't need to call it directly. - * - * @param g2 the graphics target (<code>null</code> not permitted). - * @param plot the plot (<code>null</code> not permitted). - * @param frame the frame (<code>null</code> not permitted). - * @param view the view (<code>null</code> not permitted). - */ - public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, - Rectangle2D view) { - - Shape window = getWindow(frame); - - Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius + 0.02, - this.radius + 0.02); - Ellipse2D e = new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(), - f.getHeight()); - - Area area = new Area(e); - Area area2 = new Area(window); - area.subtract(area2); - g2.setPaint(this.backgroundPaint); - g2.fill(area); - - g2.setStroke(this.stroke); - g2.setPaint(this.foregroundPaint); - g2.draw(window); - g2.draw(e); - } - - /** - * Tests this instance 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 SimpleDialFrame)) { - return false; - } - SimpleDialFrame that = (SimpleDialFrame) obj; - if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { - return false; - } - if (!PaintUtilities.equal(this.foregroundPaint, that.foregroundPaint)) { - return false; - } - if (this.radius != that.radius) { - return false; - } - if (!this.stroke.equals(that.stroke)) { - return false; - } - return super.equals(obj); - } - - /** - * Returns a hash code for this instance. - * - * @return The hash code. - */ - public int hashCode() { - int result = 193; - long temp = Double.doubleToLongBits(this.radius); - result = 37 * result + (int) (temp ^ (temp >>> 32)); - result = 37 * result + HashUtilities.hashCodeForPaint( - this.backgroundPaint); - result = 37 * result + HashUtilities.hashCodeForPaint( - this.foregroundPaint); - result = 37 * result + this.stroke.hashCode(); - return result; - } - - /** - * Returns a clone of this instance. - * - * @return A clone. - * - * @throws CloneNotSupportedException if any of the frame's attributes - * cannot be cloned. - */ - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - /** - * Provides serialization support. - * - * @param stream the output stream. - * - * @throws IOException if there is an I/O error. - */ - private void writeObject(ObjectOutputStream stream) throws IOException { - stream.defaultWriteObject(); - SerialUtilities.writePaint(this.backgroundPaint, stream); - SerialUtilities.writePaint(this.foregroundPaint, stream); - SerialUtilities.writeStroke(this.stroke, stream); - } - - /** - * Provides serialization support. - * - * @param stream the input stream. - * - * @throws IOException if there is an I/O error. - * @throws ClassNotFoundException if there is a classpath problem. - */ - private void readObject(ObjectInputStream stream) - throws IOException, ClassNotFoundException { - stream.defaultReadObject(); - this.backgroundPaint = SerialUtilities.readPaint(stream); - this.foregroundPaint = SerialUtilities.readPaint(stream); - this.stroke = SerialUtilities.readStroke(stream); - } - -} Copied: branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/StandardDialFrame.java (from rev 429, branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/SimpleDialFrame.java) =================================================================== --- branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/StandardDialFrame.java (rev 0) +++ branches/jfreechart-1.0.x-branch/source/org/jfree/chart/plot/dial/StandardDialFrame.java 2007-10-29 14:42:30 UTC (rev 447) @@ -0,0 +1,355 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. + * + * Project Info: http://www.jfree.org/jfreechart/index.html + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * ---------------------- + * StandardDialFrame.java + * ---------------------- + * (C) Copyright 2006, 2007, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 08-Mar-2007 : Fix in hashCode() (DG); + * 29-Oct-2007 : Renamed StandardDialFrame (DG); + * + */ + +package org.jfree.chart.plot.dial; + +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.Area; +import java.awt.geom.Ellipse2D; +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.HashUtilities; +import org.jfree.io.SerialUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A simple circular frame for the {@link DialPlot} class. + */ +public class StandardDialFrame extends AbstractDialLayer implements DialFrame, + Cloneable, PublicCloneable, Serializable { + + /** The outer radius, relative to the framing rectangle. */ + private double radius; + + /** + * The color used for the front of the panel. This field is transient + * because it requires special handling for serialization. + */ + private transient Paint backgroundPaint; + + /** + * The color used for the border around the window. This field is transient + * because it requires special handling for serialization. + */ + private transient Paint foregroundPaint; + + /** + * The stroke for drawing the frame outline. This field is transient + * because it requires special handling for serialization. + */ + private transient Stroke stroke; + + /** + * Creates a new instance of <code>StandardDialFrame</code>. + */ + public StandardDialFrame() { + this.backgroundPaint = Color.gray; + this.foregroundPaint = Color.black; + this.stroke = new BasicStroke(2.0f); + this.radius = 0.95; + } + + /** + * Returns the radius, relative to the framing rectangle. + * + * @return The radius. + * + * @see #setRadius(double) + */ + public double getRadius() { + return this.radius; + } + + /** + * Sets the radius and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param radius the radius (must be positive). + * + * @see #getRadius() + */ + public void setRadius(double radius) { + if (radius <= 0) { + throw new IllegalArgumentException("" + + "The 'radius' must be positive."); + } + this.radius = radius; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the background paint. + * + * @return The background paint (never <code>null</code>). + * + * @see #setBackgroundPaint(Paint) + */ + public Paint getBackgroundPaint() { + return this.backgroundPaint; + } + + /** + * Sets the background paint and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getBackgroundPaint() + */ + public void setBackgroundPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.backgroundPaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the foreground paint. + * + * @return The foreground paint (never <code>null</code>). + * + * @see #setForegroundPaint(Paint) + */ + public Paint getForegroundPaint() { + return this.foregroundPaint; + } + + /** + * Sets the foreground paint and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param paint the paint (<code>null</code> not permitted). + * + * @see #getForegroundPaint() + */ + public void setForegroundPaint(Paint paint) { + if (paint == null) { + throw new IllegalArgumentException("Null 'paint' argument."); + } + this.foregroundPaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the stroke for the frame. + * + * @return The stroke (never <code>null</code>). + * + * @see #setStroke(Stroke) + */ + public Stroke getStroke() { + return this.stroke; + } + + /** + * Sets the stroke and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param stroke the stroke (<code>null</code> not permitted). + * + * @see #getStroke() + */ + public void setStroke(Stroke stroke) { + if (stroke == null) { + throw new IllegalArgumentException("Null 'stroke' argument."); + } + this.stroke = stroke; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the shape for the window for this dial. Some dial layers will + * request that their drawing be clipped within this window. + * + * @param frame the reference frame (<code>null</code> not permitted). + * + * @return The shape of the dial's window. + */ + public Shape getWindow(Rectangle2D frame) { + Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, + this.radius); + return new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(), + f.getHeight()); + } + + /** + * Returns <code>false</code> to indicate that this dial layer is not + * clipped to the dial window. + * + * @return A boolean. + */ + public boolean isClippedToWindow() { + return false; + } + + /** + * Draws the frame. This method is called by the {@link DialPlot} class, + * you shouldn't need to call it directly. + * + * @param g2 the graphics target (<code>null</code> not permitted). + * @param plot the plot (<code>null</code> not permitted). + * @param frame the frame (<code>null</code> not permitted). + * @param view the view (<code>null</code> not permitted). + */ + public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, + Rectangle2D view) { + + Shape window = getWindow(frame); + + Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius + 0.02, + this.radius + 0.02); + Ellipse2D e = new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(), + f.getHeight()); + + Area area = new Area(e); + Area area2 = new Area(window); + area.subtract(area2); + g2.setPaint(this.backgroundPaint); + g2.fill(area); + + g2.setStroke(this.stroke); + g2.setPaint(this.foregroundPaint); + g2.draw(window); + g2.draw(e); + } + + /** + * Tests this instance 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 StandardDialFrame)) { + return false; + } + StandardDialFrame that = (StandardDialFrame) obj; + if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { + return false; + } + if (!PaintUtilities.equal(this.foregroundPaint, that.foregroundPaint)) { + return false; + } + if (this.radius != that.radius) { + return false; + } + if (!this.stroke.equals(that.stroke)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return The hash code. + */ + public int hashCode() { + int result = 193; + long temp = Double.doubleToLongBits(this.radius); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + result = 37 * result + HashUtilities.hashCodeForPaint( + this.backgroundPaint); + result = 37 * result + HashUtilities.hashCodeForPaint( + this.foregroundPaint); + result = 37 * result + this.stroke.hashCode(); + return result; + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if any of the frame's attributes + * cannot be cloned. + */ + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Provides serialization support. + * + * @param stream the output stream. + * + * @throws IOException if there is an I/O error. + */ + private void writeObject(ObjectOutputStream stream) throws IOException { + stream.defaultWriteObject(); + SerialUtilities.writePaint(this.backgroundPaint, stream); + SerialUtilities.writePaint(this.foregroundPaint, stream); + SerialUtilities.writeStroke(this.stroke, stream); + } + + /** + * Provides serialization support. + * + * @param stream the input stream. + * + * @throws IOException if there is an I/O error. + * @throws ClassNotFoundException if there is a classpath problem. + */ + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + this.backgroundPaint = SerialUtilities.readPaint(stream); + this.foregroundPaint = SerialUtilities.readPaint(stream); + this.stroke = SerialUtilities.readStroke(stream); + } + +} Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/DialPackageTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/DialPackageTests.java 2007-10-26 10:35:54 UTC (rev 446) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/DialPackageTests.java 2007-10-29 14:42:30 UTC (rev 447) @@ -66,7 +66,7 @@ suite.addTestSuite(DialPointerTests.class); suite.addTestSuite(DialTextAnnotationTests.class); suite.addTestSuite(DialValueIndicatorTests.class); - suite.addTestSuite(SimpleDialFrameTests.class); + suite.addTestSuite(StandardDialFrameTests.class); suite.addTestSuite(ArcDialFrameTests.class); suite.addTestSuite(StandardDialRangeTests.class); suite.addTestSuite(StandardDialScaleTests.class); Modified: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/DialPlotTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/DialPlotTests.java 2007-10-26 10:35:54 UTC (rev 446) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/DialPlotTests.java 2007-10-29 14:42:30 UTC (rev 447) @@ -59,7 +59,7 @@ import org.jfree.chart.plot.dial.DialBackground; import org.jfree.chart.plot.dial.DialCap; import org.jfree.chart.plot.dial.DialPlot; -import org.jfree.chart.plot.dial.SimpleDialFrame; +import org.jfree.chart.plot.dial.StandardDialFrame; import org.jfree.chart.plot.dial.StandardDialScale; /** @@ -133,12 +133,12 @@ assertTrue(p1.equals(p2)); // frame - SimpleDialFrame f1 = new SimpleDialFrame(); + StandardDialFrame f1 = new StandardDialFrame(); f1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); p1.setDialFrame(f1); assertFalse(p1.equals(p2)); - SimpleDialFrame f2 = new SimpleDialFrame(); + StandardDialFrame f2 = new StandardDialFrame(); f2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.white)); p2.setDialFrame(f2); Deleted: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/SimpleDialFrameTests.java =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/SimpleDialFrameTests.java 2007-10-26 10:35:54 UTC (rev 446) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/SimpleDialFrameTests.java 2007-10-29 14:42:30 UTC (rev 447) @@ -1,184 +0,0 @@ -/* =========================================================== - * JFreeChart : a free chart library for the Java(tm) platform - * =========================================================== - * - * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. - * - * Project Info: http://www.jfree.org/jfreechart/index.html - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * [Java is a trademark or registered trademark of Sun Microsystems, Inc. - * in the United States and other countries.] - * - * ------------------------- - * SimpleDialFrameTests.java - * ------------------------- - * (C) Copyright 2006-2007, by Object Refinery Limited and Contributors. - * - * Original Author: David Gilbert (for Object Refinery Limited); - * Contributor(s): -; - * - * Changes - * ------- - * 03-Nov-2006 : Version 1 (DG); - * - */ - -package org.jfree.chart.plot.dial.junit; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.GradientPaint; -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.plot.dial.SimpleDialFrame; - -/** - * Tests for the {@link SimpleDialFrame} class. - */ -public class SimpleDialFrameTests extends TestCase { - - /** - * Returns the tests as a test suite. - * - * @return The test suite. - */ - public static Test suite() { - return new TestSuite(SimpleDialFrameTests.class); - } - - /** - * Constructs a new set of tests. - * - * @param name the name of the tests. - */ - public SimpleDialFrameTests(String name) { - super(name); - } - - /** - * Confirm that the equals method can distinguish all the required fields. - */ - public void testEquals() { - SimpleDialFrame f1 = new SimpleDialFrame(); - SimpleDialFrame f2 = new SimpleDialFrame(); - assertTrue(f1.equals(f2)); - - // radius - f1.setRadius(0.2); - assertFalse(f1.equals(f2)); - f2.setRadius(0.2); - assertTrue(f1.equals(f2)); - - // backgroundPaint - f1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, - 4.0f, Color.yellow)); - assertFalse(f1.equals(f2)); - f2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, - 4.0f, Color.yellow)); - assertTrue(f1.equals(f2)); - - // foregroundPaint - f1.setForegroundPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, - 4.0f, Color.green)); - assertFalse(f1.equals(f2)); - f2.setForegroundPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, - 4.0f, Color.green)); - assertTrue(f1.equals(f2)); - - // stroke - f1.setStroke(new BasicStroke(2.4f)); - assertFalse(f1.equals(f2)); - f2.setStroke(new BasicStroke(2.4f)); - assertTrue(f1.equals(f2)); - - // check an inherited attribute - f1.setVisible(false); - assertFalse(f1.equals(f2)); - f2.setVisible(false); - assertTrue(f1.equals(f2)); - } - - /** - * Two objects that are equal are required to return the same hashCode. - */ - public void testHashCode() { - SimpleDialFrame f1 = new SimpleDialFrame(); - SimpleDialFrame f2 = new SimpleDialFrame(); - assertTrue(f1.equals(f2)); - int h1 = f1.hashCode(); - int h2 = f2.hashCode(); - assertEquals(h1, h2); - } - - /** - * Confirm that cloning works. - */ - public void testCloning() { - SimpleDialFrame f1 = new SimpleDialFrame(); - SimpleDialFrame f2 = null; - try { - f2 = (SimpleDialFrame) f1.clone(); - } - catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - assertTrue(f1 != f2); - assertTrue(f1.getClass() == f2.getClass()); - assertTrue(f1.equals(f2)); - - // check that the listener lists are independent - MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); - f1.addChangeListener(l1); - assertTrue(f1.hasListener(l1)); - assertFalse(f2.hasListener(l1)); - } - - /** - * Serialize an instance, restore it, and check for equality. - */ - public void testSerialization() { - SimpleDialFrame f1 = new SimpleDialFrame(); - SimpleDialFrame f2 = null; - - try { - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - ObjectOutput out = new ObjectOutputStream(buffer); - out.writeObject(f1); - out.close(); - - ObjectInput in = new ObjectInputStream( - new ByteArrayInputStream(buffer.toByteArray())); - f2 = (SimpleDialFrame) in.readObject(); - in.close(); - } - catch (Exception e) { - e.printStackTrace(); - } - assertEquals(f1, f2); - } - -} Copied: branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/StandardDialFrameTests.java (from rev 429, branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/SimpleDialFrameTests.java) =================================================================== --- branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/StandardDialFrameTests.java (rev 0) +++ branches/jfreechart-1.0.x-branch/tests/org/jfree/chart/plot/dial/junit/StandardDialFrameTests.java 2007-10-29 14:42:30 UTC (rev 447) @@ -0,0 +1,185 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2007, by Object Refinery Limited and Contributors. + * + * Project Info: http://www.jfree.org/jfreechart/index.html + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * --------------------------- + * StandardDialFrameTests.java + * --------------------------- + * (C) Copyright 2006-2007, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 29-Oct-2007 : Renamed StandardDialFrameTests (DG); + * + */ + +package org.jfree.chart.plot.dial.junit; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; +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.plot.dial.StandardDialFrame; + +/** + * Tests for the {@link StandardDialFrame} class. + */ +public class StandardDialFrameTests extends TestCase { + + /** + * Returns the tests as a test suite. + * + * @return The test suite. + */ + public static Test suite() { + return new TestSuite(StandardDialFrameTests.class); + } + + /** + * Constructs a new set of tests. + * + * @param name the name of the tests. + */ + public StandardDialFrameTests(String name) { + super(name); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + public void testEquals() { + StandardDialFrame f1 = new StandardDialFrame(); + StandardDialFrame f2 = new StandardDialFrame(); + assertTrue(f1.equals(f2)); + + // radius + f1.setRadius(0.2); + assertFalse(f1.equals(f2)); + f2.setRadius(0.2); + assertTrue(f1.equals(f2)); + + // backgroundPaint + f1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, + 4.0f, Color.yellow)); + assertFalse(f1.equals(f2)); + f2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, + 4.0f, Color.yellow)); + assertTrue(f1.equals(f2)); + + // foregroundPaint + f1.setForegroundPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, + 4.0f, Color.green)); + assertFalse(f1.equals(f2)); + f2.setForegroundPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, + 4.0f, Color.green)); + assertTrue(f1.equals(f2)); + + // stroke + f1.setStroke(new BasicStroke(2.4f)); + assertFalse(f1.equals(f2)); + f2.setStroke(new BasicStroke(2.4f)); + assertTrue(f1.equals(f2)); + + // check an inherited attribute + f1.setVisible(false); + assertFalse(f1.equals(f2)); + f2.setVisible(false); + assertTrue(f1.equals(f2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + public void testHashCode() { + StandardDialFrame f1 = new StandardDialFrame(); + StandardDialFrame f2 = new StandardDialFrame(); + assertTrue(f1.equals(f2)); + int h1 = f1.hashCode(); + int h2 = f2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + public void testCloning() { + StandardDialFrame f1 = new StandardDialFrame(); + StandardDialFrame f2 = null; + try { + f2 = (StandardDialFrame) f1.clone(); + } + catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + assertTrue(f1 != f2); + assertTrue(f1.getClass() == f2.getClass()); + assertTrue(f1.equals(f2)); + + // check that the listener lists are independent + MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); + f1.addChangeListener(l1); + assertTrue(f1.hasListener(l1)); + assertFalse(f2.hasListener(l1)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + public void testSerialization() { + StandardDialFrame f1 = new StandardDialFrame(); + StandardDialFrame f2 = null; + + try { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + ObjectOutput out = new ObjectOutputStream(buffer); + out.writeObject(f1); + out.close(); + + ObjectInput in = new ObjectInputStream( + new ByteArrayInputStream(buffer.toByteArray())); + f2 = (StandardDialFrame) in.readObject(); + in.close(); + } + catch (Exception e) { + e.printStackTrace(); + } + assertEquals(f1, f2); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |