/hg/gfx-test: Added ten new tests to a test suite src/org/gfxtes...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Mon Sep 19 02:49:31 PDT 2011


changeset 554c429d77b6 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=554c429d77b6
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Sep 19 11:51:26 2011 +0200

	Added ten new tests to a test suite
	src/org/gfxtest/testsuites/Areas.java: rendering using various
	stroke width, creating areas constructed from open and closed paths
	etc.


diffstat:

 ChangeLog                             |    6 +
 src/org/gfxtest/testsuites/Areas.java |  400 +++++++++++++++++++++++++++++----
 2 files changed, 358 insertions(+), 48 deletions(-)

diffs (truncated from 616 to 500 lines):

diff -r 871ca0408974 -r 554c429d77b6 ChangeLog
--- a/ChangeLog	Fri Sep 16 11:12:25 2011 +0200
+++ b/ChangeLog	Mon Sep 19 11:51:26 2011 +0200
@@ -1,3 +1,9 @@
+2011-09-19  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/testsuites/Areas.java:
+	Added ten new tests: rendering using various stroke width, creating
+	areas constructed from open and closed paths etc.
+
 2011-09-16  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/framework/CommonRenderingStyles.java:
diff -r 871ca0408974 -r 554c429d77b6 src/org/gfxtest/testsuites/Areas.java
--- a/src/org/gfxtest/testsuites/Areas.java	Fri Sep 16 11:12:25 2011 +0200
+++ b/src/org/gfxtest/testsuites/Areas.java	Mon Sep 19 11:51:26 2011 +0200
@@ -45,6 +45,7 @@
 import java.awt.Graphics2D;
 import java.awt.geom.Area;
 import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Path2D;
 import java.awt.geom.QuadCurve2D;
 
 
@@ -56,7 +57,8 @@
 
 /**
  * This test checks the process of creating and rendering new geometric shapes
- * represented by an Area class.
+ * represented by an Area class. Areas are drawn using various stroke or fill
+ * method.
  * 
  * @author Pavel Tisnovsky
  */
@@ -68,19 +70,22 @@
 public class Areas extends GfxTest
 {
     /**
-     * Default Y offset of curve end points.
+     * Default Y offset of curve end points. Used during construction of
+     * quadratic Bezier curves or cubic Bezier curves.
      */
     private static final int DEFAULT_Y_OFFSET = 40;
 
     /**
-     * Draw crosses at the both end points and control point of quadratic curve.
+     * Draw crosses at the both end points and control point of quadratic Bezier
+     * curve. Coordinates of curve control points are computed inside this
+     * method.
      * 
      * @param image
      *            image to which line is to be drawn
      * @param graphics
      *            graphics canvas
      */
-    private void drawCrossesAtQuadraticCurveControlPoints(TestImage image, Graphics2D graphics)
+    private void drawCrossesAtQuadraticCurveControlPoints(TestImage image, Graphics2D graphics2d)
     {
         // calculate image dimensions
         int width =  image.getWidth();
@@ -94,22 +99,23 @@
         int x3 = computeX3forQuadraticCurve(width);
         int y3 = computeY3forQuadraticCurve();
 
-        // draw all three crosses
-        drawCross(graphics, x1, y1);
-        drawCross(graphics, x2, y2);
-        drawCross(graphics, x3, y3);
+        // draw all three crosses at the coordinates of control points
+        drawCross(graphics2d, x1, y1);
+        drawCross(graphics2d, x2, y2);
+        drawCross(graphics2d, x3, y3);
     }
 
     /**
      * Draw crosses at the both end points and both control point of cubic
-     * curve.
+     * Bezier curve. Coordinates of curve control points are computed inside
+     * this method.
      * 
      * @param image
      *            image to which line is to be drawn
      * @param graphics
      *            graphics canvas
      */
-    private void drawCrossesAtCubicCurveControlPoints(TestImage image, Graphics2D graphics)
+    private void drawCrossesAtCubicCurveControlPoints(TestImage image, Graphics2D graphics2d)
     {
         // construct point set which consists of all four curve control points
         CubicCurvePointSet pointSet = new CubicCurvePointSet(image);
@@ -118,19 +124,19 @@
         int[] x = pointSet.getXPointArray();
         int[] y = pointSet.getYPointArray();
 
-        // draw all four crosses
+        // draw all four crosses at the coordinates of control points
         for (int i = 0; i < 4; i++)
         {
-            drawCross(graphics, x[i], y[i]);
+            drawCross(graphics2d, x[i], y[i]);
         }
     }
 
     /**
-     * Create area from the open quadratic curve.
+     * Create area from the open quadratic Bezier curve.
      *
      * @param image
      *            image to which area is to be drawn
-     * @return area created from open quadratic curve.
+     * @return area created from open quadratic Bezier curve.
      */
     private Area createAreaFromQuadraticCurve(TestImage image)
     {
@@ -152,11 +158,11 @@
     }
 
     /**
-     * Create area from the open cubic curve.
+     * Create area from the open cubic Bezier curve.
      *
      * @param image
      *            image to which area is to be drawn
-     * @return area created from open cubic curve.
+     * @return area created from open cubic Bezier curve.
      */
     private Area createAreaFromCubicCurve(TestImage image)
     {
@@ -169,16 +175,66 @@
 
         // create open cubic curve
         CubicCurve2D curve = new CubicCurve2D.Double();
+        // set control points coordinates
         curve.setCurve(x[0], y[0], x[1], y[1], x[2], y[2], x[3], y[3]);
         return new Area(curve);
     }
 
     /**
-     * Compute X coordinate of first curve end point.
+     * Create area from the open Path constructed from line segments
+     *
+     * @param image
+     *            image to which area is to be drawn
+     * @return area created from open Path
+     */
+    private Area createAreaFromOpenPath(TestImage image)
+    {
+        // construct point set which consists of all four curve control points
+        CubicCurvePointSet pointSet = new CubicCurvePointSet(image);
+
+        // fill in arrays containing path coordinates
+        int[] x = pointSet.getXPointArray();
+        int[] y = pointSet.getYPointArray();
+
+        Path2D path = new Path2D.Double();
+        path.moveTo(x[0], y[0]);
+        path.lineTo(x[1], y[1]);
+        path.lineTo(x[2], y[2]);
+        path.lineTo(x[3], y[3]);
+        return new Area(path);
+    }
+
+    /**
+     * Create area from the closed Path constructed from line segments.
+     * 
+     * @param image
+     *            image to which area is to be drawn
+     * @return area created from closed Path
+     */
+    private Area createAreaFromClosedPath(TestImage image)
+    {
+        // construct point set which consists of all four curve control points
+        CubicCurvePointSet pointSet = new CubicCurvePointSet(image);
+
+        // fill in arrays containing path coordinates
+        int[] x = pointSet.getXPointArray();
+        int[] y = pointSet.getYPointArray();
+
+        Path2D path = new Path2D.Double();
+        path.moveTo(x[0], y[0]);
+        path.lineTo(x[1], y[1]);
+        path.lineTo(x[2], y[2]);
+        path.lineTo(x[3], y[3]);
+        path.closePath();
+        return new Area(path);
+    }
+
+    /**
+     * Compute X coordinate of quadratic Bezier curve first end point.
      * 
      * @param width
      *            canvas width
-     * @return X coordinate of first curve end point.
+     * @return X coordinate of quadratic Bezier curve first end point.
      */
     private int computeX1forQuadraticCurve(int width)
     {
@@ -186,11 +242,11 @@
     }
 
     /**
-     * Compute X coordinate of curve control point.
-     *
+     * Compute X coordinate of quadratic Bezier curve control point.
+     * 
      * @param width
      *            canvas width
-     * @return X coordinate of curve control point.
+     * @return X coordinate of quadratic Bezier curve control point.
      */
     private int computeX2forQuadraticCurve(int width)
     {
@@ -198,11 +254,11 @@
     }
 
     /**
-     * Compute X coordinate of second curve end point.
+     * Compute X coordinate of quadratic Bezier curve second end point.
      * 
      * @param width
      *            canvas width
-     * @return X coordinate of second curve end point.
+     * @return X coordinate of quadratic Bezier curve second end point.
      */
     private int computeX3forQuadraticCurve(int width)
     {
@@ -210,9 +266,9 @@
     }
 
     /**
-     * Compute Y coordinate of first curve end point.
+     * Compute Y coordinate of quadratic Bezier curve first end point.
      *
-     * @return Y coordinate of first curve end point.
+     * @return Y coordinate of quadratic Bezier curve first end point.
      */
     private int computeY1forQuadraticCurve()
     {
@@ -220,11 +276,11 @@
     }
 
     /**
-     * Compute Y coordinate of curve control point.
+     * Compute Y coordinate of quadratic Bezier curve control point.
      *
      * @param height
      *            canvas height
-     * @return Y coordinate of curve control point.
+     * @return Y coordinate of quadratic Bezier curve control point.
      */
     private int computeY2forQuadraticCurve(int height)
     {
@@ -232,9 +288,9 @@
     }
 
     /**
-     * Compute Y coordinate of second curve end point.
+     * Compute Y coordinate of quadratic Bezier curve second end point.
      *
-     * @return Y coordinate of second curve end point.
+     * @return Y coordinate of quadratic Bezier curve second end point.
      */
     private int computeY3forQuadraticCurve()
     {
@@ -242,7 +298,8 @@
     }
 
     /**
-     * Test the result of creating area using an opened quadratic curve.
+     * Test the result of creating area using an opened quadratic Bezier curve.
+     * Area is rendered using stroke paint.
      * 
      * @param image
      *            image to which line is to be drawn
@@ -250,16 +307,66 @@
      *            graphics canvas
      * @return test result status - PASSED, FAILED or ERROR
      */
-    public TestResult testQuadraticCurveStrokePaint(TestImage image, Graphics2D graphics)
+    public TestResult testQuadraticCurveStrokePaint(TestImage image, Graphics2D graphics2d)
     {
         // set stroke color
-        CommonRenderingStyles.setStrokeColor(graphics);
+        CommonRenderingStyles.setStrokeColor(graphics2d);
         // create area from open quadratic curve
         Area area = createAreaFromQuadraticCurve(image);
         // draw the area
-        graphics.draw(area);
+        graphics2d.draw(area);
         // draw crosses at control points
-        drawCrossesAtQuadraticCurveControlPoints(image, graphics);
+        drawCrossesAtQuadraticCurveControlPoints(image, graphics2d);
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test the result of creating area using an opened quadratic Bezier curve.
+     * Area is rendered using wide stroke paint.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testQuadraticCurveWideStrokePaint(TestImage image, Graphics2D graphics2d)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics2d);
+        // set stroke width
+        CommonRenderingStyles.setStrokeThickWidth(graphics2d);
+        // create area from open quadratic curve
+        Area area = createAreaFromQuadraticCurve(image);
+        // draw the area
+        graphics2d.draw(area);
+        // draw crosses at control points
+        drawCrossesAtQuadraticCurveControlPoints(image, graphics2d);
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test the result of creating area using an opened quadratic Bezier curve.
+     * Area is rendered using extra wide stroke paint.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testQuadraticCurveExtraWideStrokePaint(TestImage image, Graphics2D graphics2d)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics2d);
+        // set stroke extra width
+        CommonRenderingStyles.setStrokeExtraThickWidth(graphics2d);
+        // create area from open quadratic curve
+        Area area = createAreaFromQuadraticCurve(image);
+        // draw the area
+        graphics2d.draw(area);
+        // draw crosses at control points
+        drawCrossesAtQuadraticCurveControlPoints(image, graphics2d);
         return TestResult.PASSED;
     }
 
@@ -272,23 +379,24 @@
      *            graphics canvas
      * @return test result status - PASSED, FAILED or ERROR
      */
-    public TestResult testQuadraticCurveColorPaint(TestImage image, Graphics2D graphics)
+    public TestResult testQuadraticCurveColorPaint(TestImage image, Graphics2D graphics2d)
     {
         // set stroke color
-        CommonRenderingStyles.setStrokeColor(graphics);
+        CommonRenderingStyles.setStrokeColor(graphics2d);
         // set fill color
-        CommonRenderingStyles.setFillColor(graphics);
+        CommonRenderingStyles.setFillColor(graphics2d);
         // create area from open quadratic curve
         Area area = createAreaFromQuadraticCurve(image);
         // draw the area
-        graphics.fill(area);
+        graphics2d.fill(area);
         // draw crosses at control points
-        drawCrossesAtQuadraticCurveControlPoints(image, graphics);
+        drawCrossesAtQuadraticCurveControlPoints(image, graphics2d);
         return TestResult.PASSED;
     }
 
     /**
      * Test the result of creating area using an opened cubic curve.
+     * Area is rendered using stroke paint.
      * 
      * @param image
      *            image to which line is to be drawn
@@ -296,16 +404,66 @@
      *            graphics canvas
      * @return test result status - PASSED, FAILED or ERROR
      */
-    public TestResult testCubicCurveStrokePaint(TestImage image, Graphics2D graphics)
+    public TestResult testCubicCurveStrokePaint(TestImage image, Graphics2D graphics2d)
     {
         // set stroke color
-        CommonRenderingStyles.setStrokeColor(graphics);
+        CommonRenderingStyles.setStrokeColor(graphics2d);
         // create area from open cubic curve
         Area area = createAreaFromCubicCurve(image);
         // draw the area
-        graphics.draw(area);
+        graphics2d.draw(area);
         // draw crosses at control points
-        drawCrossesAtCubicCurveControlPoints(image, graphics);
+        drawCrossesAtCubicCurveControlPoints(image, graphics2d);
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test the result of creating area using an opened cubic curve.
+     * Area is rendered using wide stroke paint.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testCubicCurveWideStrokePaint(TestImage image, Graphics2D graphics2d)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics2d);
+        // set stroke width
+        CommonRenderingStyles.setStrokeThickWidth(graphics2d);
+        // create area from open cubic curve
+        Area area = createAreaFromCubicCurve(image);
+        // draw the area
+        graphics2d.draw(area);
+        // draw crosses at control points
+        drawCrossesAtCubicCurveControlPoints(image, graphics2d);
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test the result of creating area using an opened cubic curve.
+     * Area is rendered using extra wide stroke paint.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testCubicCurveExtraWideStrokePaint(TestImage image, Graphics2D graphics2d)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics2d);
+        // set stroke extra width
+        CommonRenderingStyles.setStrokeExtraThickWidth(graphics2d);
+        // create area from open cubic curve
+        Area area = createAreaFromCubicCurve(image);
+        // draw the area
+        graphics2d.draw(area);
+        // draw crosses at control points
+        drawCrossesAtCubicCurveControlPoints(image, graphics2d);
         return TestResult.PASSED;
     }
 
@@ -318,18 +476,164 @@
      *            graphics canvas
      * @return test result status - PASSED, FAILED or ERROR
      */
-    public TestResult testCubicCurveColorPaint(TestImage image, Graphics2D graphics)
+    public TestResult testCubicCurveColorPaint(TestImage image, Graphics2D graphics2d)
     {
         // set stroke color
-        CommonRenderingStyles.setStrokeColor(graphics);
+        CommonRenderingStyles.setStrokeColor(graphics2d);
         // set fill color
-        CommonRenderingStyles.setFillColor(graphics);
+        CommonRenderingStyles.setFillColor(graphics2d);
         // create area from open cubic curve
         Area area = createAreaFromCubicCurve(image);
         // draw the area
-        graphics.fill(area);
+        graphics2d.fill(area);
         // draw crosses at control points
-        drawCrossesAtCubicCurveControlPoints(image, graphics);
+        drawCrossesAtCubicCurveControlPoints(image, graphics2d);
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test the result of creating area using an open Path constructed from line
+     * segments. Area is rendered using stroke paint.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testOpenPathStrokePaint(TestImage image, Graphics2D graphics2d)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics2d);
+        // create area from open path constructed from line segment
+        Area area = createAreaFromOpenPath(image);
+        // draw the area
+        graphics2d.draw(area);
+        // draw crosses at control points
+        drawCrossesAtCubicCurveControlPoints(image, graphics2d);
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test the result of creating area using an open Path constructed from line
+     * segments. Area is rendered using wide stroke paint.
+     * 
+     * @param image
+     *            image to which line is to be drawn
+     * @param graphics2d



More information about the distro-pkg-dev mailing list