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

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Tue Aug 9 07:45:06 PDT 2011


changeset 2d2f7eecc246 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=2d2f7eecc246
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Tue Aug 09 16:46:47 2011 +0200

	* src/org/gfxtest/testsuites/ColorPaint.java: Created new test
	suite containing 12 gfx.tests.


diffstat:

 ChangeLog                                  |    4 +
 Makefile                                   |    3 +
 src/org/gfxtest/testsuites/ColorPaint.java |  588 +++++++++++++++++++++++++++++
 3 files changed, 595 insertions(+), 0 deletions(-)

diffs (truncated from 630 to 500 lines):

diff -r 1ab36617f4cf -r 2d2f7eecc246 ChangeLog
--- a/ChangeLog	Mon Aug 08 13:40:47 2011 +0200
+++ b/ChangeLog	Tue Aug 09 16:46:47 2011 +0200
@@ -1,3 +1,7 @@
+2011-08-09  Pavel Tisnovsky  <ptisnovs at redhat.com>
+	* src/org/gfxtest/testsuites/ColorPaint.java:
+	Created new test suite containing 12 gfx.tests.
+
 2011-08-08  Pavel Tisnovsky  <ptisnovs at redhat.com>
 	* src/org/gfxtest/testsuites/NormalQuadraticCurvesAsPaths.java:
 	Fixed minor issues in two tests.
diff -r 1ab36617f4cf -r 2d2f7eecc246 Makefile
--- a/Makefile	Mon Aug 08 13:40:47 2011 +0200
+++ b/Makefile	Tue Aug 09 16:46:47 2011 +0200
@@ -96,6 +96,7 @@
 TESTSUITE_CLASSES = \
 	$(CLASSES)/$(TESTSUITE_DIR)/AALines.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/BlankImage.class \
+	$(CLASSES)/$(TESTSUITE_DIR)/ColorPaint.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/NormalArcs.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/NormalLines.class \
 	$(CLASSES)/$(TESTSUITE_DIR)/NormalCircles.class \
@@ -132,6 +133,7 @@
 COMPARE_RESULTS = \
 	$(RESULTS)/AALines \
 	$(RESULTS)/BlankImage \
+	$(RESULTS)/ColorPaint \
 	$(RESULTS)/NormalArcs \
 	$(RESULTS)/NormalLines \
 	$(RESULTS)/NormalCircles \
@@ -258,6 +260,7 @@
 
 clean-output:
 	rm -rf $(OUTPUT)
+	rm *.png
 
 clean-test-build:
 	rm -rf $(TEST_BUILD)
diff -r 1ab36617f4cf -r 2d2f7eecc246 src/org/gfxtest/testsuites/ColorPaint.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/testsuites/ColorPaint.java	Tue Aug 09 16:46:47 2011 +0200
@@ -0,0 +1,588 @@
+/*
+  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 filled shapes using simple ColorPaint.
+ *
+ * @author Pavel Tisnovsky
+ */
+ at TestType(TestTypes.RENDER_TEST)
+ at RenderStyle(RenderStyles.FILL)
+ at Transformation(Transformations.NONE)
+ at Zoom(1)
+public class ColorPaint 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 stroke color.
+     */
+    private static final Color DEFAULT_STROKE_COLOR = Color.BLACK;
+
+    /**
+     * Default fill color.
+     */
+    private static final Color DEFAULT_FILL_COLOR = Color.GREEN.darker();
+
+    /**
+     * Radius of round rectangle.
+     */
+    private static final int ROUND_RECT_RADIUS = 80;
+
+    /**
+     * Draw circle onto the graphics canvas.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     */
+    private void drawCircle(TestImage image, Graphics2D graphics)
+    {
+        // calculate center of the image
+        int xc = image.getCenterX();
+        int yc = image.getCenterY();
+        
+        // calculate radius of circle
+        int radius = calculateRadius(image);
+        
+        // draw the circle
+        graphics.drawOval(xc - radius, yc - radius, radius << 1, radius << 1);
+
+        // draw crosses at interesting points of image
+        drawCrossesForBasicShapes(graphics, xc, yc, radius);
+    }
+
+    /**
+     * Calculate radius of circle/arc/rectangle based on image size.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @return radius
+     */
+    private int calculateRadius(TestImage image)
+    {
+        return Math.min(image.getWidth(), image.getHeight()) / 3;
+    }
+
+    /**
+     * Draw crosses at interesting points of image.
+     *
+     * @param graphics
+     *            graphics context for image
+     * @param xc center of image
+     * @param yc center of image
+     * @param radius radius of shape(s)
+     */
+    private void drawCrossesForBasicShapes(Graphics2D graphics, int xc, int yc, int radius)
+    {
+        // move in vertical direction
+        for (int y = yc - radius; y <= yc + radius; y += radius)
+        {
+            // move in horizontal direction
+            for (int x = xc - radius; x <= xc + radius; x += radius)
+            {
+                drawCross(graphics, x, y);
+            }
+        }
+    }
+
+    /**
+     * Draw filled circle onto the graphics canvas.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     */
+    private void drawFilledCircle(TestImage image, Graphics2D graphics)
+    {
+        // calculate center of the image
+        int xc = image.getCenterX();
+        int yc = image.getCenterY();
+        
+        // calculate radius of circle
+        int radius = calculateRadius(image);
+        
+        // draw the filled circle
+        graphics.fillOval(xc - radius, yc - radius, radius << 1, radius << 1);
+
+        // draw crosses at interesting points of image
+        drawCrossesForBasicShapes(graphics, xc, yc, radius);
+    }
+
+    /**
+     * Draw filled arc onto the graphics canvas.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     */
+    private void drawFilledArc(TestImage image, Graphics2D graphics)
+    {
+        // calculate center of the image
+        int xc = image.getCenterX();
+        int yc = image.getCenterY();
+        
+        // calculate radius of circle
+        int radius = calculateRadius(image);
+        
+        // draw the filled arc
+        graphics.fillArc(xc - radius, yc - radius, radius << 1, radius << 1, 0, 135 + 180);
+
+        // draw crosses at interesting points of image
+        drawCrossesForBasicShapes(graphics, xc, yc, radius);
+    }
+
+    /**
+     * Draw filled rectangle onto the graphics canvas.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     */
+    private void drawFilledRect(TestImage image, Graphics2D graphics)
+    {
+        // calculate center of the image
+        int xc = image.getCenterX();
+        int yc = image.getCenterY();
+
+        // calculate radius of circle
+        int radius = calculateRadius(image);
+
+        // draw the filled rectangle
+        graphics.fillRect(xc - radius, yc - radius, radius << 1, radius << 1);
+
+        // draw crosses at interesting points of image
+        drawCrossesForBasicShapes(graphics, xc, yc, radius);
+    }
+
+    /**
+     * Draw filled rounded rectangle onto the graphics canvas.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     */
+    private void drawFilledRoundRect(TestImage image, Graphics2D graphics)
+    {
+        // calculate center of the image
+        int xc = image.getCenterX();
+        int yc = image.getCenterY();
+
+        // calculate radius of circle
+        int radius = calculateRadius(image);
+
+        // draw the filled rectangle round rectangle
+        graphics.fillRoundRect(xc - radius, yc - radius, radius << 1, radius << 1, ROUND_RECT_RADIUS, ROUND_RECT_RADIUS);
+
+        // draw crosses at interesting points of image
+        drawCrossesForBasicShapes(graphics, xc, yc, radius);
+    }
+
+    /**
+     * Draw filled polygon onto the graphics canvas.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     */
+    private void drawFilledPolygon(TestImage image, Graphics2D graphics)
+    {
+        // calculate image size
+        int w = image.getWidth();
+        int h = image.getHeight();
+
+        // polygon vertexes
+        int xPoints[] = new int[] { OFFSET, w >> 1, w >> 1, w - OFFSET };
+        int yPoints[] = new int[] { h >> 1, OFFSET, h - OFFSET, h >> 1 };
+
+        // draw the polygon
+        graphics.fillPolygon(xPoints, yPoints, xPoints.length);
+
+        // draw crosses at interesting points of image
+        drawCross(graphics, OFFSET, h >> 1, CROSS_SIZE);
+        drawCross(graphics, w >> 1, OFFSET, CROSS_SIZE);
+        drawCross(graphics, w >> 1, h - OFFSET, CROSS_SIZE);
+        drawCross(graphics, w - OFFSET, h >> 1, CROSS_SIZE);
+    }
+
+    /**
+     * Draw filled closed path onto the graphics canvas.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     */
+    private void drawFilledClosedPath(TestImage image, Graphics2D graphics)
+    {
+        // calculate image size
+        int w = image.getWidth();
+        int h = image.getHeight();
+
+        // construct closed path
+        Path2D path = new Path2D.Float();
+        path.moveTo(OFFSET, OFFSET);
+        path.quadTo(w - OFFSET, OFFSET, w - OFFSET, h - OFFSET);
+        path.quadTo(OFFSET, h - OFFSET, w >> 1, h >> 1);
+        path.closePath();
+
+        // draw the closed path
+        graphics.fill(path);
+
+        // draw crosses at interesting points of image
+        drawCross(graphics, OFFSET, OFFSET);
+        drawCross(graphics, w - OFFSET, OFFSET);
+        drawCross(graphics, w - OFFSET, h - OFFSET);
+        drawCross(graphics, OFFSET, h - OFFSET);
+        drawCross(graphics, w >> 1, h >> 1);
+    }
+
+    /**
+     * Set default stroke color.
+     * 
+     * @param graphics
+     *            graphics context for image
+     */
+    private void setStrokeColor(Graphics2D graphics)
+    {
+        graphics.setColor(DEFAULT_STROKE_COLOR);
+    }
+
+    /**
+     * Set default fill color.
+     *
+     * @param graphics
+     *            graphics context for image
+     */
+    private void setFillColor(Graphics2D graphics)
+    {
+        graphics.setPaint(DEFAULT_FILL_COLOR);
+    }
+
+    /**
+     * Set 10 pixels wide stroke.
+     *
+     * @param graphics
+     *            graphics context for image
+     */
+    private void setStrokeThickWidth(Graphics2D graphics)
+    {
+        graphics.setStroke(new BasicStroke(STROKE_WIDTH_THICK));
+    }
+
+    /**
+     * Set 30 pixels wide stroke.
+     *
+     * @param graphics
+     *            graphics context for image
+     */
+    private void setStrokeExtraThickWidth(Graphics2D graphics)
+    {
+        graphics.setStroke(new BasicStroke(STROKE_WIDTH_EXTRA_THICK));
+    }
+
+    /**
+     * Test if circle drawn by graphics.drawOval() 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 testCircleBasicStrokeEmptyFill(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        setStrokeColor(graphics);
+        // draw the circle
+        drawCircle(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if circle drawn by graphics.drawOval() is rendered correctly.
+     * Stroke of the circle is 10 pixels wide.
+     * 
+     * @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 testCircleThickStrokeEmptyFill(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        setStrokeColor(graphics);
+        // set 10 pixels wide stroke
+        setStrokeThickWidth(graphics);
+        // draw the circle
+        drawCircle(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if circle drawn by graphics.drawOval() is rendered correctly.
+     * Stroke of the circle is 30 pixels wide.
+     * 
+     * @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 testCircleExtraThickStrokeEmptyFill(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        setStrokeColor(graphics);
+        // set 30 pixels wide stroke
+        setStrokeExtraThickWidth(graphics);
+        // draw the circle
+        drawCircle(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if filled circle drawn by graphics.fillOval() 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 testCircleBasicStrokeColorFill(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        setStrokeColor(graphics);
+        // set fill color
+        setFillColor(graphics);
+        // draw the circle
+        drawFilledCircle(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+     * Stroke of the circle is 10 pixels wide (but it cannot affect the draw
+     * process).
+     * 
+     * @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 testCircleThickStrokeColorFill(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        setStrokeColor(graphics);
+        // set 10 pixels wide stroke
+        setStrokeThickWidth(graphics);
+        // set fill color
+        setFillColor(graphics);
+        // draw the circle
+        drawFilledCircle(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+     * Stroke of the circle is 30 pixels wide (but it cannot affect the draw



More information about the distro-pkg-dev mailing list