/hg/gfx-test: * src/org/gfxtest/testsuites/NormalQuadraticCurves...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Mon Aug 8 04:39:07 PDT 2011


changeset 1ab36617f4cf in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=1ab36617f4cf
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Aug 08 13:40:47 2011 +0200

	* src/org/gfxtest/testsuites/NormalQuadraticCurvesAsPaths.java:
	Fixed minor issues in two tests.
	* src/org/gfxtest/testsuites/NormalCubisCurvesAsPaths.java: Created
	new test suite containing 12 gfx.tests.


diffstat:

 ChangeLog                                                    |    6 +
 Makefile                                                     |    2 +
 src/org/gfxtest/testsuites/NormalCubicCurvesAsPaths.java     |  666 +++++++++++
 src/org/gfxtest/testsuites/NormalQuadraticCurvesAsPaths.java |    4 +-
 4 files changed, 676 insertions(+), 2 deletions(-)

diffs (truncated from 723 to 500 lines):

diff -r 504ee1c39140 -r 1ab36617f4cf ChangeLog
--- a/ChangeLog	Fri Aug 05 14:36:35 2011 +0200
+++ b/ChangeLog	Mon Aug 08 13:40:47 2011 +0200
@@ -1,3 +1,9 @@
+2011-08-08  Pavel Tisnovsky  <ptisnovs at redhat.com>
+	* src/org/gfxtest/testsuites/NormalQuadraticCurvesAsPaths.java:
+	Fixed minor issues in two tests.
+	* src/org/gfxtest/testsuites/NormalCubisCurvesAsPaths.java:
+	Created new test suite containing 12 gfx.tests.
+
 2011-08-05  Pavel Tisnovsky  <ptisnovs at redhat.com>
 	* src/org/gfxtest/framework/CubicCurvePointSet.java:
 	Added new methods for fetching points arrays.
diff -r 504ee1c39140 -r 1ab36617f4cf Makefile
--- a/Makefile	Fri Aug 05 14:36:35 2011 +0200
+++ b/Makefile	Mon Aug 08 13:40:47 2011 +0200
@@ -108,6 +108,7 @@
 	$(CLASSES)/$(TESTSUITE_DIR)/NormalQuadraticCurves.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/NormalQuadraticCurvesAsPaths.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/NormalCubicCurves.class \
+	$(CLASSES)/$(TESTSUITE_DIR)/NormalCubicCurvesAsPaths.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/FilledArcs.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/FilledCircles.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/FilledEllipses.class \
@@ -143,6 +144,7 @@
 	$(RESULTS)/NormalQuadraticCurves \
 	$(RESULTS)/NormalQuadraticCurvesAsPaths \
 	$(RESULTS)/NormalCubicCurves \
+	$(RESULTS)/NormalCubicCurvesAsPaths \
 	$(RESULTS)/FilledArcs \
 	$(RESULTS)/FilledCircles \
 	$(RESULTS)/FilledEllipses \
diff -r 504ee1c39140 -r 1ab36617f4cf src/org/gfxtest/testsuites/NormalCubicCurvesAsPaths.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/testsuites/NormalCubicCurvesAsPaths.java	Mon Aug 08 13:40:47 2011 +0200
@@ -0,0 +1,666 @@
+/*
+  Java gfx-test framework
+
+   Copyright (C) 2010, 2011  Red Hat
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+IcedTea 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
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version.
+*/
+
+package org.gfxtest.testsuites;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.Path2D;
+
+import org.gfxtest.framework.*;
+import org.gfxtest.framework.annotations.*;
+
+
+
+/**
+ * This test renders various cubic curves using identity transformation matrix.
+ * Quadratic curves are constructed using Path class.
+ * 
+ * @author Pavel Tisnovsky
+ */
+ at TestType(TestTypes.RENDER_TEST)
+ at GraphicsPrimitive(GraphicsPrimitives.CUBIC_CURVE)
+ at RenderStyle(RenderStyles.NORMAL)
+ at Transformation(Transformations.NONE)
+ at Zoom(1)
+public class NormalCubicCurvesAsPaths extends GfxTest
+{
+    /**
+     * Stroke width used for drawing "thick" curves.
+     */
+    private static final int STROKE_WIDTH_THICK = 10;
+
+    /**
+     * Stroke width used for drawing extra "thick" curves.
+     */
+    private static final int STROKE_WIDTH_EXTRA_THICK = 30;
+
+    /**
+     * Default Y offset of curve end points.
+     */
+    private static final int DEFAULT_Y_OFFSET = -20;
+
+    /**
+     * Step between curves drawn by different colors onto the same image.
+     */
+    private static final int OFFSET_STEP = 20;
+
+    /**
+     * Draw crosses at the both end points and both control points of cubic
+     * curve.
+     * 
+     * @param graphics
+     *            graphics canvas
+     * @param xarray
+     *            array containing x coordinates of all four control points of
+     *            cubic curve
+     * @param yarray
+     *            array containing y coordinates of all four control points of
+     *            cubic curve
+     * @param pointIndexes
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     */
+    private void drawCrossesAtControlPoints(Graphics2D graphics, int[] xarray, int[] yarray, int[] pointIndexes)
+    {
+        for (int i = 0; i < 4; i++)
+        {
+            this.drawCross(graphics, xarray[pointIndexes[i]-1], yarray[pointIndexes[i]-1]);
+        }
+    }
+
+    /**
+     * Draw cubic curve onto canvas specified by Graphics2D class.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics canvas
+     * @param path
+     *            curve contained in the path to be drawn
+     * @param color
+     *            curve color or null when Color.BLACK can be used.
+     * @param pointIndexes
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    private TestResult drawPath(TestImage image, Graphics2D graphics, Path2D path, Color color, int[] pointIndexes)
+    {
+        // construct point set which consists of all four curve control points
+        CubicCurvePointSet pointSet = new CubicCurvePointSet(image);
+
+        // fill in arrays containing coordinates for all cubic curve control points
+        int[] x = pointSet.getXPointArray();
+        int[] y = pointSet.getYPointArray();
+
+        // set curve color
+        graphics.setColor(color);
+
+        // draw the cubic curve
+        graphics.draw(path);
+
+        // Draw crosses at the both end points and both control points of cubic
+        // curve.
+        drawCrossesAtControlPoints(graphics, x, y, pointIndexes);
+
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Draw cubic curve onto canvas specified by Graphics2D class.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics canvas
+     * @param path
+     *            curve contained in the path to be drawn
+     * @param color
+     *            curve color or null when Color.BLACK can be used.
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    private TestResult drawPath(TestImage image, Graphics2D graphics, Path2D path, Color color)
+    {
+        return drawPath(image, graphics, path, color, new int[] { 1, 2, 3, 4 });
+    }
+
+    /**
+     * Draw cubic curve onto canvas specified by Graphics2D class.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics canvas
+     * @param path
+     *            curve contained in the path to be drawn
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    private TestResult drawPath(TestImage image, Graphics2D graphics, Path2D path)
+    {
+        return drawPath(image, graphics, path, Color.BLACK);
+    }
+
+    /**
+     * Create new path using Path2D.Float() which contains just one cubic
+     * curve.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param xarray
+     *            array containing x coordinates of all four control points of
+     *            cubic curve
+     * @param yarray
+     *            array containing y coordinates of all four control points of
+     *            cubic curve
+     * @param pointIndexes
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @param yoffset
+     *            offset for all y-coordinates
+     * @return
+     */
+    private Path2D createPathFloat(TestImage image, int[] xarray, int[] yarray, int[] pointIndexes, int yoffset)
+    {
+        // construct path containing cubic curve
+        Path2D path = new Path2D.Float();
+        path.moveTo(xarray[pointIndexes[0]-1], yarray[pointIndexes[0]-1] + yoffset);
+        path.curveTo(xarray[pointIndexes[1]-1], yarray[pointIndexes[1]-1] + yoffset,
+                     xarray[pointIndexes[2]-1], yarray[pointIndexes[2]-1] + yoffset,
+                     xarray[pointIndexes[3]-1], yarray[pointIndexes[3]-1] + yoffset);
+        return path;
+    }
+
+    /**
+     * Create new path using Path2D.Float() which contains just one cubic
+     * curve.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param xarray
+     *            array containing x coordinates of all four control points of
+     *            cubic curve
+     * @param yarray
+     *            array containing y coordinates of all four control points of
+     *            cubic curve
+     * @param pointIndexes
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @return
+     */
+    private Path2D createPathFloat(TestImage image, int[] xarray, int[] yarray, int[] pointIndexes)
+    {
+        // construct path containing cubic curve
+        return createPathFloat(image, xarray, yarray, pointIndexes, 0);
+    }
+
+    /**
+     * Create new path using Path2D.Float() which contains just one cubic
+     * curve.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param pointIndexes 
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @return created path
+     */
+    private Path2D createPathFloat(TestImage image, int[] pointIndexes)
+    {
+        // construct point set which consists of all four curve control points
+        CubicCurvePointSet pointSet = new CubicCurvePointSet(image);
+
+        // fill in arrays containing coordinates for all cubic curve control points
+        int[] x = pointSet.getXPointArray();
+        int[] y = pointSet.getYPointArray();
+
+        // construct path containing cubic curve
+        return createPathFloat(image, x, y, pointIndexes);
+    }
+
+    /**
+     * Create new path using Path2D.Float() which contains just one cubic
+     * curve.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @return created path
+     */
+    private Path2D createPathFloat(TestImage image)
+    {
+        // construct path containing cubic curve
+        return createPathFloat(image, new int[] {1,2,3,4});
+    }
+
+    /**
+     * Create new path using Path2D.Double() which contains just one cubic
+     * curve.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param xarray
+     *            array containing x coordinates of all four control points of
+     *            cubic curve
+     * @param yarray
+     *            array containing y coordinates of all four control points of
+     *            cubic curve
+     * @param pointIndexes
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @param yoffset
+     *            offset for all y-coordinates
+     * @return
+     */
+    private Path2D createPathDouble(TestImage image, int[] xarray, int[] yarray, int[] pointIndexes, int yoffset)
+    {
+        // construct path containing cubic curve
+        Path2D path = new Path2D.Double();
+        path.moveTo(xarray[pointIndexes[0]-1], yarray[pointIndexes[0]-1] + yoffset);
+        path.curveTo(xarray[pointIndexes[1]-1], yarray[pointIndexes[1]-1] + yoffset,
+                     xarray[pointIndexes[2]-1], yarray[pointIndexes[2]-1] + yoffset,
+                     xarray[pointIndexes[3]-1], yarray[pointIndexes[3]-1] + yoffset);
+        return path;
+    }
+
+    /**
+     * Create new path using Path2D.Double() which contains just one cubic
+     * curve.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param xarray
+     *            array containing x coordinates of all four control points of
+     *            cubic curve
+     * @param yarray
+     *            array containing y coordinates of all four control points of
+     *            cubic curve
+     * @param pointIndexes
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @return
+     */
+    private Path2D createPathDouble(TestImage image, int[] xarray, int[] yarray, int[] pointIndexes)
+    {
+        return createPathDouble(image, xarray, yarray, pointIndexes, 0);
+    }
+
+    /**
+     * Create new path using Path2D.Double() which contains just one cubic
+     * curve.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param pointIndexes 
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @return created path
+     */
+    private Path2D createPathDouble(TestImage image, int[] pointIndexes)
+    {
+        // construct point set which consists of all four curve control points
+        CubicCurvePointSet pointSet = new CubicCurvePointSet(image);
+
+        // fill in arrays containing coordinates for all cubic curve control points
+        int[] x = pointSet.getXPointArray();
+        int[] y = pointSet.getYPointArray();
+
+        // construct path containing cubic curve
+        return createPathDouble(image, x, y, pointIndexes);
+    }
+
+    /**
+     * Create new path using Path2D.Double() which contains just one cubic
+     * curve.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @return created path
+     */
+    private Path2D createPathDouble(TestImage image)
+    {
+        // construct path containing cubic curve
+        return createPathDouble(image, new int[] {1,2,3,4});
+    }
+
+    /**
+     * Test if cubic curve created by Path2D.Float() is rendered correctly.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testBasicCubicCurveFloat(TestImage image, Graphics2D graphics)
+    {
+        // create cubic curve and draw it
+        Path2D path = createPathFloat(image);
+        return drawPath(image, graphics, path);
+    }
+
+    /**
+     * Test if cubic curve created by Path2D.Double() is rendered correctly.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testBasicCubicCurveDouble(TestImage image, Graphics2D graphics)
+    {
+        // create cubic curve and draw it
+        Path2D path = createPathDouble(image);
+        return drawPath(image, graphics, path);
+    }
+
+    /**
+     * Test if cubic curve created by Path2D.Float() is rendered
+     * correctly. Curve is to be drawn with 10 pixels wide stroke and default
+     * caps.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testThickStroke(TestImage image, Graphics2D graphics)
+    {
+        // set 30 pixels wide stroke
+        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK));
+
+        // create cubic curve and draw it
+        Path2D path = createPathFloat(image);
+        return drawPath(image, graphics, path);
+    }
+
+    /**
+     * Test if cubic curve created by Path2D.Float() is rendered correctly.
+     * Curve is to be drawn with 10 pixels wide stroke and the curve caps is set
+     * to CAP_BUTT.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testThickStrokeCapsButt(TestImage image, Graphics2D graphics)
+    {
+        // set 10 pixels wide stroke
+        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+
+        // create cubic curve and draw it
+        Path2D path = createPathFloat(image);
+        return drawPath(image, graphics, path);
+    }
+
+    /**
+     * Test if cubic curve created by Path2D.Float() is rendered correctly.
+     * Curve is to be drawn with 10 pixels wide stroke and the curve caps is set
+     * to CAP_ROUND.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testThickStrokeCapsRound(TestImage image, Graphics2D graphics)
+    {
+        // set 10 pixels wide stroke
+        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
+
+        // create cubic curve and draw it
+        Path2D path = createPathFloat(image);
+        return drawPath(image, graphics, path);
+    }
+
+    /**
+     * Test if cubic curve created by Path2D.Float() is rendered correctly.
+     * Curve is to be drawn with 10 pixels wide stroke and the curve caps is set
+     * to CAP_SQUARE.
+     * 
+     * @param image



More information about the distro-pkg-dev mailing list