Revision: 1033
Author: heuermh
Date: Tue Aug  3 13:33:18 2010
Log: adding javadoc API documentation, adding stroke parameter to ctrs, additional unit tests
http://code.google.com/p/piccolo2d/source/detail?r=1033

Modified:
/piccolo2d.java/branches/ppath-refactoring/core/src/main/java/org/piccolo2d/nodes/PArea.java /piccolo2d.java/branches/ppath-refactoring/core/src/main/java/org/piccolo2d/nodes/PPath.java /piccolo2d.java/branches/ppath-refactoring/core/src/main/java/org/piccolo2d/nodes/PShape.java /piccolo2d.java/branches/ppath-refactoring/core/src/test/java/org/piccolo2d/nodes/PAreaTest.java /piccolo2d.java/branches/ppath-refactoring/core/src/test/java/org/piccolo2d/nodes/PPathDoubleTest.java /piccolo2d.java/branches/ppath-refactoring/core/src/test/java/org/piccolo2d/nodes/PPathFloatTest.java

=======================================
--- /piccolo2d.java/branches/ppath-refactoring/core/src/main/java/org/piccolo2d/nodes/PArea.java Mon Aug 2 09:49:24 2010 +++ /piccolo2d.java/branches/ppath-refactoring/core/src/main/java/org/piccolo2d/nodes/PArea.java Tue Aug 3 13:33:18 2010
@@ -36,15 +36,24 @@
 /**
  * Area node.
  */
-public final class PArea extends PShape
-{
+public final class PArea extends PShape {
+
+    /** Area for this area node. */
     private transient Area area;


+    /**
+     * Create a new area node with an empty area.
+     */
     public PArea() {
         area = new Area();
     }

+    /**
+     * Create a new area node with the specified shape.
+     *
+     * @param shape shape, must not be null
+     */
     public PArea(final Shape shape) {
         if (shape == null) {
             throw new NullPointerException("shape must not be null");
@@ -52,6 +61,11 @@
         this.area = new Area(shape);
     }

+    /**
+     * Create a new area node with the specified area.
+     *
+     * @param area area, must not be null
+     */
     public PArea(final Area area) {
         if (area == null) {
             throw new NullPointerException("area must not be null");
@@ -61,34 +75,103 @@
     }


+    /**
+     * Add the shape of the specified area to the shape of this area node.
+ * The resulting shape of this area node will include the union of both shapes, + * or all areas that were contained in either this or the specified area.
+     *
+     * @param area area to add, must not be null
+     * @throws NullPointerException if area is null
+     */
     public void add(final Area area) {
         this.area.add(area);
         updateBoundsFromShape();
     }

+    /**
+ * Set the shape of this area node to be the combined area of its current + * shape and the shape of the specified area, minus their intersection. The + * resulting shape of this area node will include only areas that were contained
+     * in either this area node or in the specified area, but not in both.
+     *
+     * @param area area to exclusive or, must not be null
+     * @throws NullPointerException if area is null
+     */
     public void exclusiveOr(final Area area) {
         this.area.exclusiveOr(area);
         updateBoundsFromShape();
     }

+    /**
+ * Set the shape of this area node to the intersection of its current shape + * and the shape of the specified area. The resulting shape of this area node + * will include only areas that were contained in both this area node and also
+     * in the specified area.
+     *
+     * @param area area to intersect, must not be null
+     * @throws NullPointerException if area is null
+     */
     public void intersect(final Area area) {
         this.area.intersect(area);
         updateBoundsFromShape();
     }

+    /**
+ * Subtract the shape of the specified area from the shape of this area node. + * The resulting shape of this area node will include areas that were contained
+     * only in this area node and not in the specified area.
+     *
+     * @param area area to subtract, must not be null
+     * @throws NullPointerException if area is null
+     */
     public void subtract(final Area area) {
         this.area.subtract(area);
         updateBoundsFromShape();
     }

+    /**
+ * Removes all of the geometry from this area node and restores it to an empty area.
+     */
+    public void reset() {
+        area.reset();
+        updateBoundsFromShape();
+    }
+
+    /**
+     * Return true if this area node represents an empty area.
+     *
+     * @return true if this area node represents an empty area
+     */
+    public boolean isEmpty() {
+        return area.isEmpty();
+    }
+
+    /**
+ * Return true if this area node consists entirely of straight-edged polygonal geometry.
+     *
+ * @return true if this area node consists entirely of straight-edged polygonal geometry
+     */
     public boolean isPolygonal() {
         return area.isPolygonal();
     }

+    /**
+     * Return true if this area node is rectangular in shape.
+     *
+     * @return true if this area node is rectangular in shape
+     */
     public boolean isRectangular() {
         return area.isRectangular();
     }

+    /**
+ * Return true if this area node is comprised of a single closed subpath. This + * method returns true if the path contains 0 or 1 subpaths, or false if the path + * contains more than 1 subpath. The subpaths are counted by the number of
+     * <code>SEG_MOVETO</code> segments that appear in the path.
+     *
+ * @return true if this area node is comprised of a single closed subpath
+     */
     public boolean isSingular() {
         return area.isSingular();
     }
@@ -96,6 +179,8 @@
     // todo:
     //    area property change events?
     //    static methods
+ // should modifiers return this to allow chaining, e.g. add(area0).intersect(area1) + // test serialization, may have to add custom code to serialize areas

     /** {...@inheritdoc} */
     protected Shape getShape() {
=======================================
--- /piccolo2d.java/branches/ppath-refactoring/core/src/main/java/org/piccolo2d/nodes/PPath.java Mon Aug 2 09:49:24 2010 +++ /piccolo2d.java/branches/ppath-refactoring/core/src/main/java/org/piccolo2d/nodes/PPath.java Tue Aug 3 13:33:18 2010
@@ -29,6 +29,7 @@
 package org.piccolo2d.nodes;

 import java.awt.Shape;
+import java.awt.Stroke;

 import java.awt.geom.AffineTransform;
 import java.awt.geom.Arc2D;
@@ -42,59 +43,242 @@
 import java.awt.geom.PathIterator;

 /**
- * Path node.
+ * Abstract path node.
  */
-public abstract class PPath extends PShape
-{
+public abstract class PPath extends PShape {
+
+    /** Path for this path node. */
     private Path2D path;

-    // todo: ctr with stroke?
-
+
+    /**
+     * Create a new path node with the specified path.
+     *
+     * @param path path
+     */
     private PPath(final Path2D path) {
         this.path = (Path2D) path.clone();
-        // todo:
- // not sure why this call is required for this class, it is not present in original PPath
         updateBoundsFromShape();
     }

-
+    /**
+     * Create a new path node with the specified path and stroke.
+     *
+     * @param path path
+     * @param stroke stroke
+     */
+    private PPath(final Path2D path, final Stroke stroke) {
+        this.path = (Path2D) path.clone();
+        setStroke(stroke);
+    }
+
+
+    /**
+ * Path node with coordinates stored in single precision floating point.
+     */
     public static final class Float extends PPath {
+
+        /**
+         * Create a new empty path node.
+         */
         public Float() {
             super(new Path2D.Float());
         }
+
+        /**
+         * Create a new empty path node with the specified stroke.
+         *
+         * @param stroke stroke
+         */
+        public Float(final Stroke stroke) {
+            super(new Path2D.Float(), stroke);
+        }
+
+        /**
+         * Create a new path node with the specified shape.
+         *
+         * @param shape shape, must not be null
+         * @throws NullPointerException if shape is null
+         */
         public Float(final Shape shape) {
             super(new Path2D.Float(shape));
         }
+
+        /**
+         * Create a new path node with the specified shape and stroke.
+         *
+         * @param shape shape, must not be null
+         * @param stroke stroke
+         * @throws NullPointerException if shape is null
+         */
+        public Float(final Shape shape, final Stroke stroke) {
+            super(new Path2D.Float(shape), stroke);
+        }
+
+        /**
+         * Create a new path node with the specified path.
+         *
+         * @param path path, must not be null
+         * @throws NullPointerException if path is null
+         */
         public Float(final Path2D.Float path) {
             super(path);
         }
+
+        /**
+         * Create a new path node with the specified path and stroke.
+         *
+         * @param path path, must not be null
+         * @param stroke stroke, must not be null
+         * @throws NullPointerException if path is null
+         */
+        public Float(final Path2D.Float path, final Stroke stroke) {
+            super(path, stroke);
+        }
     }

+    /**
+ * Path node with coordinates stored in double precision floating point.
+     */
     public static final class Double extends PPath {
+
+        /**
+         * Create a new empty path node.
+         */
         public Double() {
             super(new Path2D.Double());
         }
+
+        /**
+         * Create a new empty path node with the specified stroke.
+         *
+         * @param stroke stroke
+         */
+        public Double(final Stroke stroke) {
+            super(new Path2D.Double(), stroke);
+        }
+
+        /**
+         * Create a new path node with the specified shape.
+         *
+         * @param shape shape, must not be null
+         * @throws NullPointerException if shape is null
+         */
         public Double(final Shape shape) {
             super(new Path2D.Double(shape));
         }
+
+        /**
+         * Create a new path node with the specified shape and stroke.
+         *
+         * @param shape shape, must not be null
+         * @param stroke stroke
+         * @throws NullPointerException if shape is null
+         */
+        public Double(final Shape shape, final Stroke stroke) {
+            super(new Path2D.Double(shape), stroke);
+        }
+
+        /**
+         * Create a new path node with the specified path.
+         *
+         * @param path path, must not be null
+         * @throws NullPointerException if path is null
+         */
         public Double(final Path2D.Double path) {
             super(path);
         }
+
+        /**
+         * Create a new path node with the specified path and stroke.
+         *
+         * @param path path, must not be null
+         * @param stroke stroke
+         * @throws NullPointerException if path is null
+         */
+        public Double(final Path2D.Double path, final Stroke stroke) {
+            super(path, stroke);
+        }
     }


- public static final PPath createArc(final float x, final float y, final float width, final float height, final float start, final float extent, final int type) {
+    /**
+     * Create and return a new path node with the specified arc in single
+     * precision floating point coordinates.
+     *
+ * @param x x coordinate of the upper-left corner of the arc's framing rectangle + * @param y y coordinate of the upper-left corner of the arc's framing rectangle + * @param width width of the full ellipse of which this arc is a partial section + * @param height height of the full ellipse of which this arc is a partial section
+     * @param start starting angle of the arc in degrees
+     * @param extent angular extent of the arc in degrees
+ * @param type closure type for the arc, one of {...@link Arc2D#OPEN}, {...@link Arc2D#CHORD},
+     *    or {...@link Arc2D#PIE}
+     * @return a new path node with the specified arc in single
+     *    precision floating point coordinates
+     */
+    public static final PPath createArc(final float x,
+                                        final float y,
+                                        final float width,
+                                        final float height,
+                                        final float start,
+                                        final float extent,
+                                        final int type) {
return new PPath.Float(new Arc2D.Float(x, y, width, height, start, extent, type));
     }

- public static final PPath createCubicCurve(final float x1, final float y1, final float ctrlx1, final float ctrly1, final float ctrlx2, final float ctrly2, final float x2, final float y2) {
+    /**
+ * Create and return a new path node with the specified cubic curve in single
+     * precision floating point coordinates.
+     *
+     * @param x1 x coordinate of the start point
+     * @param y1 y coordinate of the start point
+     * @param ctrlx1 x coordinate of the first control point
+     * @param ctrly1 y coordinate of the first control point
+     * @param ctrlx2 x coordinate of the second control point
+     * @param ctrly2 y coordinate of the second control point
+     * @param x2 x coordinate of the end point
+     * @param y2 y coordinate of the end point
+     * @return a new path node with the specified cubic curve in single
+     *    precision floating point coordinates
+     */
+    public static final PPath createCubicCurve(final float x1,
+                                               final float y1,
+                                               final float ctrlx1,
+                                               final float ctrly1,
+                                               final float ctrlx2,
+                                               final float ctrly2,
+                                               final float x2,
+                                               final float y2) {
return new PPath.Float(new CubicCurve2D.Float(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2));
     }

+    /**
+ * Create and return a new path node with the specified ellipse in single
+     * precision floating point coordinates.
+     *
+     * @param x x coordinate
+     * @param y y coordinate
+     * @param width width
+     * @param height height
+     * @return a new path node with the specified ellipse in single
+     *    precision floating point coordinates
+     */
public static final PPath createEllipse(final float x, final float y, final float width, final float height) {
         return new PPath.Float(new Ellipse2D.Float(x, y, width, height));
     }

+    /**
+     * Create and return a new path node with the specified line in single
+     * precision floating point coordinates.
+     *
+     * @param x1 x coordinate of the start point
+     * @param y1 y coordinate of the start point
+     * @param x2 x coordinate of the end point
+     * @param y2 y coordinate of the end point
+     * @return a new path node with the specified line in single
+     *    precision floating point coordinates
+     */
public static final PPath createLine(final float x1, final float y1, final float x2, final float y2) {
         return new PPath.Float(new Line2D.Float(x1, y1, x2, y2));
     }
@@ -108,30 +292,142 @@
     }
     */

- public static final PPath createQuadCurve(final float x1, final float y1, final float ctrlx, final float ctrly, final float x2, final float y2) {
+    /**
+ * Create and return a new path node with the specified quadratic curve in single
+     * precision floating point coordinates.
+     *
+     * @param x1 x coordinate of the start point
+     * @param y1 y coordinate of the start point
+     * @param ctrlx x coordinate of the control point
+     * @param ctrly y coordinate of the control point
+     * @param x2 x coordinate of the end point
+     * @param y2 y coordinate of the end point
+     * @return a new path node with the specified quadratic curve in single
+     *    precision floating point coordinates
+     */
+    public static final PPath createQuadCurve(final float x1,
+                                              final float y1,
+                                              final float ctrlx,
+                                              final float ctrly,
+                                              final float x2,
+                                              final float y2) {
return new PPath.Float(new QuadCurve2D.Float(x1, y1, ctrlx, ctrly, x2, y2));
     }

+    /**
+ * Create and return a new path node with the specified rectangle in single
+     * precision floating point coordinates.
+     *
+     * @param x x coordinate
+     * @param y y coordinate
+     * @param width width
+     * @param height height
+     * @return a new path node with the specified rectangle in single
+     *    precision floating point coordinates
+     */
public static final PPath createRectangle(final float x, final float y, final float width, final float height) {
         return new PPath.Float(new Rectangle2D.Float(x, y, width, height));
     }

- public static final PPath createRoundRectangle(final float x, final float y, final float width, final float height, final float arcWidth, final float arcHeight) {
+    /**
+ * Create and return a new path node with the specified round rectangle in single
+     * precision floating point coordinates.
+     *
+     * @param x x coordinate
+     * @param y y coordinate
+     * @param width width
+     * @param height height
+     * @param arcWidth width of the arc that rounds off the corners
+     * @param arcHeight height of the arc that rounds off the corners
+     * @return a new path node with the specified round rectangle in single
+     *    precision floating point coordinates
+     */
+    public static final PPath createRoundRectangle(final float x,
+                                                   final float y,
+                                                   final float width,
+                                                   final float height,
+                                                   final float arcWidth,
+                                                   final float arcHeight) {
return new PPath.Float(new RoundRectangle2D.Float(x, y, width, height, arcWidth, arcHeight));
     }

- public static final PPath createArc(final double x, final double y, final double width, final double height, final double start, final double extent, final int type) {
+    /**
+     * Create and return a new path node with the specified arc in double
+     * precision floating point coordinates.
+     *
+ * @param x x coordinate of the upper-left corner of the arc's framing rectangle + * @param y y coordinate of the upper-left corner of the arc's framing rectangle + * @param width width of the full ellipse of which this arc is a partial section + * @param height height of the full ellipse of which this arc is a partial section
+     * @param start starting angle of the arc in degrees
+     * @param extent angular extent of the arc in degrees
+ * @param type closure type for the arc, one of {...@link Arc2D#OPEN}, {...@link Arc2D#CHORD},
+     *    or {...@link Arc2D#PIE}
+     * @return a new path node with the specified arc in double
+     *    precision floating point coordinates
+     */
+    public static final PPath createArc(final double x,
+                                        final double y,
+                                        final double width,
+                                        final double height,
+                                        final double start,
+                                        final double extent,
+                                        final int type) {
return new PPath.Double(new Arc2D.Double(x, y, width, height, start, extent, type));
     }

- public static final PPath createCubicCurve(final double x1, final double y1, final double ctrlx1, final double ctrly1, final double ctrlx2, final double ctrly2, final double x2, final double y2) {
+    /**
+ * Create and return a new path node with the specified cubic curve in double
+     * precision floating point coordinates.
+     *
+     * @param x1 x coordinate of the start point
+     * @param y1 y coordinate of the start point
+     * @param ctrlx1 x coordinate of the first control point
+     * @param ctrly1 y coordinate of the first control point
+     * @param ctrlx2 x coordinate of the second control point
+     * @param ctrly2 y coordinate of the second control point
+     * @param x2 x coordinate of the end point
+     * @param y2 y coordinate of the end point
+     * @return a new path node with the specified cubic curve in double
+     *    precision floating point coordinates
+     */
+    public static final PPath createCubicCurve(final double x1,
+                                               final double y1,
+                                               final double ctrlx1,
+                                               final double ctrly1,
+                                               final double ctrlx2,
+                                               final double ctrly2,
+                                               final double x2,
+                                               final double y2) {
return new PPath.Double(new CubicCurve2D.Double(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2));
     }

+    /**
+ * Create and return a new path node with the specified ellipse in double
+     * precision floating point coordinates.
+     *
+     * @param x x coordinate
+     * @param y y coordinate
+     * @param width width
+     * @param height height
+     * @return a new path node with the specified ellipse in double
+     *    precision floating point coordinates
+     */
public static final PPath createEllipse(final double x, final double y, final double width, final double height) {
         return new PPath.Double(new Ellipse2D.Double(x, y, width, height));
     }

+    /**
+     * Create and return a new path node with the specified line in double
+     * precision floating point coordinates.
+     *
+     * @param x1 x coordinate of the start point
+     * @param y1 y coordinate of the start point
+     * @param x2 x coordinate of the end point
+     * @param y2 y coordinate of the end point
+     * @return a new path node with the specified line in double
+     *    precision floating point coordinates
+     */
public static final PPath createLine(final double x1, final double y1, final double x2, final double y2) {
         return new PPath.Double(new Line2D.Double(x1, y1, x2, y2));
     }
@@ -144,49 +440,169 @@
     }
     */

- public static final PPath createQuadCurve(final double x1, final double y1, final double ctrlx, final double ctrly, final double x2, final double y2) {
+    /**
+ * Create and return a new path node with the specified quadratic curve in double
+     * precision floating point coordinates.
+     *
+     * @param x1 x coordinate of the start point
+     * @param y1 y coordinate of the start point
+     * @param ctrlx x coordinate of the control point
+     * @param ctrly y coordinate of the control point
+     * @param x2 x coordinate of the end point
+     * @param y2 y coordinate of the end point
+     * @return a new path node with the specified quadratic curve in double
+     *    precision floating point coordinates
+     */
+    public static final PPath createQuadCurve(final double x1,
+                                              final double y1,
+                                              final double ctrlx,
+                                              final double ctrly,
+                                              final double x2,
+                                              final double y2) {
return new PPath.Double(new QuadCurve2D.Double(x1, y1, ctrlx, ctrly, x2, y2));
     }

+    /**
+ * Create and return a new path node with the specified rectangle in double
+     * precision floating point coordinates.
+     *
+     * @param x x coordinate
+     * @param y y coordinate
+     * @param width width
+     * @param height height
+     * @return a new path node with the specified rectangle in double
+     *    precision floating point coordinates
+     */
public static final PPath createRectangle(final double x, final double y, final double width, final double height) { return new PPath.Double(new Rectangle2D.Double(x, y, width, height));
     }

- public static final PPath createRoundRectangle(final double x, final double y, final double width, final double height, final double arcWidth, final double arcHeight) {
+    /**
+ * Create and return a new path node with the specified round rectangle in double
+     * precision floating point coordinates.
+     *
+     * @param x x coordinate
+     * @param y y coordinate
+     * @param width width
+     * @param height height
+     * @param arcWidth width of the arc that rounds off the corners
+     * @param arcHeight height of the arc that rounds off the corners
+     * @return a new path node with the specified round rectangle in double
+     *    precision floating point coordinates
+     */
+    public static final PPath createRoundRectangle(final double x,
+                                                   final double y,
+                                                   final double width,
+                                                   final double height,
+                                                   final double arcWidth,
+ final double arcHeight) { return new PPath.Double(new RoundRectangle2D.Double(x, y, width, height, arcWidth, arcHeight));
     }


+    /**
+ * Append the geometry of the specified shape to this path node, possibly + * connecting the new geometry to the existing path segments with a line + * segment. If the connect parameter is true and the path is not empty then + * any initial <code>moveTo</code> in the geometry of the appended shape is turned into + * a <code>lineTo</code> segment. If the destination coordinates of such a connecting + * <code>lineTo</code> segment match the ending coordinates of a currently open subpath + * then the segment is omitted as superfluous. The winding rule of the specified + * shape is ignored and the appended geometry is governed by the winding
+     * rule specified for this path node.
+     *
+     * @param shape shape to append to this path node
+ * @param connect true to turn an initial <code>moveTo</code> segment into a + * <code>lineTo</code> segment to connect the new geometry to the existing path
+     */
     public final void append(final Shape shape, final boolean connect) {
         path.append(shape, connect);
         updateBoundsFromShape();
     }

+    /**
+ * Append the geometry of the specified path iterator to this path node, possibly + * connecting the new geometry to the existing path segments with a line segment. + * If the connect parameter is true and the path is not empty then any initial <code>moveTo</code> + * in the geometry of the appended path iterator is turned into a <code>lineTo</code> segment. + * If the destination coordinates of such a connecting <code>lineTo</code> segment match + * the ending coordinates of a currently open subpath then the segment is omitted
+     * as superfluous.
+     *
+     * @param pathIterator path iterator to append to this path node
+ * @param connect true to turn an initial <code>moveTo</code> segment into a + * <code>lineTo</code> segment to connect the new geometry to the existing path
+     */
public final void append(final PathIterator pathIterator, final boolean connect) {
         path.append(pathIterator, connect);
         updateBoundsFromShape();
     }

+    /**
+ * Add a curved segment, defined by three new points, to this path node by drawing + * a B&eacute;zier curve that intersects both the current coordinates and the specified + * coordinates <code>(x3,y3)</code>, using the specified points <code>(x1,y1)</code> + * and <code>(x2,y2)</code> as B&eacute;zier control points. All coordinates are specified in
+     * double precision.
+     *
+     * @param x1 x coordinate of the first B&eacute;zier control point
+     * @param y1 y coordinate of the first B&eacute;zier control point
+     * @param x2 x coordinate of the second B&eacute;zier control point
+     * @param y2 y coordinate of the second B&eacute;zier control point
+     * @param x3 x coordinate of the final end point
+     * @param y3 y coordinate of the final end point
+     */
public final void curveTo(final double x1, final double y1, final double x2, final double y2, final double x3, final double y3) {
         path.curveTo(x1, y1, x2, y2, x3, y3);
         updateBoundsFromShape();
     }

+    /**
+     * Add a point to this path node by drawing a straight line from the
+ * current coordinates to the new specified coordinates specified in double precision.
+     *
+     * @param x x coordinate
+     * @param y y coordinate
+     */
     public final void lineTo(final double x, final double y) {
         path.lineTo(x, y);
         updateBoundsFromShape();
     }

+    /**
+     * Add a point to this path node by moving to the specified coordinates
+     * specified in double precision.
+     *
+     * @param x x coordinate
+     * @param y y coordinate
+     */
     public final void moveTo(final double x, final double y) {
         path.moveTo(x, y);
         updateBoundsFromShape();
     }

+    /**
+ * Add a curved segment, defined by two new points, to this path node by + * drawing a Quadratic curve that intersects both the current coordinates and + * the specified coordinates <code>(x2,y2)</code>, using the specified point + * <code>(x1,y1)</code> as a quadratic parametric control point. All coordinates
+     * are specified in double precision.
+     *
+     * @param x1 x coordinate of the quadratic control point
+     * @param y1 y coordinate of the quadratic control point
+     * @param x2 x coordinate of the final end point
+     * @param y2 y coordinate of the final end point
+     */
public final void quadTo(final double x1, final double y1, final double x2, final double y2) {
         path.quadTo(x1, y1, x2, y2);
         updateBoundsFromShape();
     }

+    /**
+ * Close the current subpath by drawing a straight line back to the coordinates + * of the last <code>moveTo</code>. If the path is already closed then this method
+     * has no effect.
+     */
     public final void closePath() {
         path.closePath();
         updateBoundsFromShape();
=======================================
--- /piccolo2d.java/branches/ppath-refactoring/core/src/main/java/org/piccolo2d/nodes/PShape.java Mon Aug 2 09:49:24 2010 +++ /piccolo2d.java/branches/ppath-refactoring/core/src/main/java/org/piccolo2d/nodes/PShape.java Tue Aug 3 13:33:18 2010
@@ -46,18 +46,58 @@
  * Abstract shape node.
  */
 public abstract class PShape extends PNode {
+
+    /** Stroke for this shape node, defaults to {...@link #DEFAULT_STROKE}. */
     private transient Stroke stroke = DEFAULT_STROKE;
+
+ /** Stroke paint for this shape node, defaults to {...@link #DEFAULT_STROKE_PAINT}. */
     private Paint strokePaint = DEFAULT_STROKE_PAINT;
+
+    /** Default stroke, a basic stroke of width <code>1.0f</code>. */
     public static final Stroke DEFAULT_STROKE = new BasicStroke(1.0f);
+
+    /** Default stroke paint, <code>Color.BLACK</code>. */
     public static final Paint DEFAULT_STROKE_PAINT = Color.BLACK;

+
+    /**
+     * This is an abstract class that cannot be instantiated directly.
+     */
+    protected PShape() {
+        super();
+    }
+
+
+    /**
+     * Return the shape for this shape node.
+     *
+     * @return the shape for this shape node
+     */
     protected abstract Shape getShape();
+
+    /**
+     * Apply the specified transform to the shape for this shape node.
+     *
+     * @param transform transform to apply to the shape for this shape node
+     */
     protected abstract void transform(AffineTransform transform);

+
+    /**
+ * Return the stroke for this shape node. Defaults to {...@link #DEFAULT_STROKE}.
+     *
+     * @return the stroke for this shape node
+     */
     public final Stroke getStroke() {
         return stroke;
     }

+    /**
+     * Set the stroke for this shape node to <code>stroke</code>.  This is
+     * a bound property.
+     *
+     * @param stroke stroke for this shape node
+     */
     public final void setStroke(final Stroke stroke) {
         Stroke oldStroke = this.stroke;
         this.stroke = stroke;
@@ -66,10 +106,21 @@
         firePropertyChange(-1, "stroke", oldStroke, this.stroke);
     }

+    /**
+ * Return the stroke paint for this shape node. Defaults to {...@link #DEFAULT_STROKE_PAINT}.
+     *
+     * @return the stroke paint for this shape node
+     */
     public final Paint getStrokePaint() {
         return strokePaint;
     }

+    /**
+ * Set the stroke paint for this shape node to <code>strokePaint</code>. This is
+     * a bound property.
+     *
+     * @param strokePaint stroke paint for this shape node
+     */
     public final void setStrokePaint(final Paint strokePaint) {
         Paint oldStrokePaint = this.strokePaint;
         this.strokePaint = strokePaint;
@@ -77,11 +128,19 @@
firePropertyChange(-1, "strokePaint", oldStrokePaint, this.strokePaint);
     }

+    /**
+     * Update the bounds of this shape node from its shape.
+     */
     protected final void updateBoundsFromShape() {
         final Rectangle2D b = getBoundsWithStroke();
         setBounds(b.getX(), b.getY(), b.getWidth(), b.getHeight());
     }

+    /**
+ * Return the bounds of this node, taking the stroke into consideration if necessary.
+     *
+ * @return the bounds of this node, taking the stroke into consideration if necessary
+     */
     protected final Rectangle2D getBoundsWithStroke() {
         if (stroke != null) {
             return stroke.createStrokedShape(getShape()).getBounds2D();
=======================================
--- /piccolo2d.java/branches/ppath-refactoring/core/src/test/java/org/piccolo2d/nodes/PAreaTest.java Fri Jul 23 13:43:12 2010 +++ /piccolo2d.java/branches/ppath-refactoring/core/src/test/java/org/piccolo2d/nodes/PAreaTest.java Tue Aug 3 13:33:18 2010
@@ -263,6 +263,32 @@
             // expected
         }
     }
+
+    public void testReset() {
+        PArea area = new PArea();
+        area.setStroke(null);
+        assertEquals(0.0d, area.getWidth(), TOLERANCE);
+        assertEquals(0.0d, area.getHeight(), TOLERANCE);
+
+ Area rect0 = new Area(new Rectangle2D.Double(0.0d, 0.0d, 100.0d, 100.0d));
+        area.add(rect0);
+ Area rect1 = new Area(new Rectangle2D.Double(50.0d, 0.0d, 100.0d, 100.0d));
+        area.add(rect1);
+
+        assertEquals(150.0d, area.getWidth(), TOLERANCE);
+        assertEquals(100.0, area.getHeight(), TOLERANCE);
+
+        area.reset();
+        assertEquals(0.0d, area.getWidth(), TOLERANCE);
+        assertEquals(0.0d, area.getHeight(), TOLERANCE);
+    }
+
+    public void testIsEmpty() {
+        assertTrue(new PArea().isEmpty());
+ assertFalse(new PArea(new Rectangle2D.Double(0.0d, 0.0d, 50.0d, 100.0d)).isEmpty()); + assertTrue(new PArea(new Line2D.Double(0.0d, 0.0d, 50.0d, 100.0d)).isEmpty()); + assertFalse(new PArea(new Ellipse2D.Double(0.0d, 0.0d, 50.0d, 100.0d)).isEmpty());
+    }

     public void testIsPolygonal() {
assertTrue(new PArea(new Rectangle2D.Double(0.0d, 0.0d, 50.0d, 100.0d)).isPolygonal());
=======================================
--- /piccolo2d.java/branches/ppath-refactoring/core/src/test/java/org/piccolo2d/nodes/PPathDoubleTest.java Fri Jul 23 13:43:12 2010 +++ /piccolo2d.java/branches/ppath-refactoring/core/src/test/java/org/piccolo2d/nodes/PPathDoubleTest.java Tue Aug 3 13:33:18 2010
@@ -28,7 +28,9 @@
  */
 package org.piccolo2d.nodes;

+import java.awt.BasicStroke;
 import java.awt.Shape;
+import java.awt.Stroke;

 import java.awt.geom.Path2D;
 import java.awt.geom.Rectangle2D;
@@ -46,9 +48,19 @@
     public void testNoArgConstructor() {
         assertNotNull(new PPath.Double());
     }
+
+    public void testStrokeConstructor() {
+        assertNotNull(new PPath.Double((Stroke) null));
+        assertNotNull(new PPath.Double(new BasicStroke(2.0f)));
+    }

     public void testShapeConstructor() {
- assertNotNull(new PPath.Double(new Rectangle2D.Double(0.0d, 0.0d, 100.0d, 100.0d ))); + assertNotNull(new PPath.Double(new Rectangle2D.Double(0.0d, 0.0d, 100.0d, 100.0d)));
+    }
+
+    public void testShapeStrokeConstructor() {
+ assertNotNull(new PPath.Double(new Rectangle2D.Double(0.0d, 0.0d, 100.0d, 100.0d), null)); + assertNotNull(new PPath.Double(new Rectangle2D.Double(0.0d, 0.0d, 100.0d, 100.0d), new BasicStroke(2.0f)));
     }

     public void testShapeConstructorNullArgument() {
@@ -60,10 +72,25 @@
             // expected
         }
     }
+
+    public void testShapeStrokeConstructorNullArgument() {
+        try {
+            new PPath.Double((Shape) null, null);
+            fail("ctr((Shape) null, ) expected NullPointerException");
+        }
+        catch (NullPointerException e) {
+            // expected
+        }
+    }

     public void testPathConstructor() {
         assertNotNull(new PPath.Double(new Path2D.Double()));
     }
+
+    public void testPathStrokeConstructor() {
+        assertNotNull(new PPath.Double(new Path2D.Double(), null));
+ assertNotNull(new PPath.Double(new Path2D.Double(), new BasicStroke(2.0f)));
+    }

     public void testPathConstructorNullArgument() {
         try {
@@ -74,4 +101,14 @@
             // expected
         }
     }
-}
+
+    public void testPathStrokeConstructorNullArgument() {
+        try {
+            new PPath.Double((Path2D) null, null);
+            fail("ctr((Path2D) null, ) expected NullPointerException");
+        }
+        catch (NullPointerException e) {
+            // expected
+        }
+    }
+}
=======================================
--- /piccolo2d.java/branches/ppath-refactoring/core/src/test/java/org/piccolo2d/nodes/PPathFloatTest.java Fri Jul 23 13:43:12 2010 +++ /piccolo2d.java/branches/ppath-refactoring/core/src/test/java/org/piccolo2d/nodes/PPathFloatTest.java Tue Aug 3 13:33:18 2010
@@ -28,7 +28,9 @@
  */
 package org.piccolo2d.nodes;

+import java.awt.BasicStroke;
 import java.awt.Shape;
+import java.awt.Stroke;

 import java.awt.geom.Path2D;
 import java.awt.geom.Rectangle2D;
@@ -46,10 +48,20 @@
     public void testNoArgConstructor() {
         assertNotNull(new PPath.Float());
     }
+
+    public void testStrokeConstructor() {
+        assertNotNull(new PPath.Float((Stroke) null));
+        assertNotNull(new PPath.Float(new BasicStroke(2.0f)));
+    }

     public void testShapeConstructor() {
assertNotNull(new PPath.Float(new Rectangle2D.Float(0.0f, 0.0f, 100.0f, 100.0f)));
     }
+
+    public void testShapeStrokeConstructor() {
+ assertNotNull(new PPath.Float(new Rectangle2D.Float(0.0f, 0.0f, 100.0f, 100.0f), null)); + assertNotNull(new PPath.Float(new Rectangle2D.Float(0.0f, 0.0f, 100.0f, 100.0f), new BasicStroke(2.0f)));
+    }

     public void testShapeConstructorNullArgument() {
         try {
@@ -60,10 +72,25 @@
             // expected
         }
     }
+
+    public void testShapeStrokeConstructorNullArgument() {
+        try {
+            new PPath.Float((Shape) null, null);
+            fail("ctr((Shape) null, ) expected NullPointerException");
+        }
+        catch (NullPointerException e) {
+            // expected
+        }
+    }

     public void testPathConstructor() {
         assertNotNull(new PPath.Float(new Path2D.Float()));
     }
+
+    public void testPathStrokeConstructor() {
+        assertNotNull(new PPath.Float(new Path2D.Float(), null));
+ assertNotNull(new PPath.Float(new Path2D.Float(), new BasicStroke(2.0f)));
+    }

     public void testPathConstructorNullArgument() {
         try {
@@ -74,4 +101,14 @@
             // expected
         }
     }
-}
+
+    public void testStrokePathConstructorNullArgument() {
+        try {
+            new PPath.Float((Path2D) null, null);
+            fail("ctr((Path2D) null, ) expected NullPointerException");
+        }
+        catch (NullPointerException e) {
+            // expected
+        }
+    }
+}

--
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en

Reply via email to