/hg/gfx-test: Added new test cases - subtraction, intersection a...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Fri Sep 9 04:46:34 PDT 2011
changeset 221ec39deecf in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=221ec39deecf
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Sep 09 13:48:28 2011 +0200
Added new test cases - subtraction, intersection and XOR
constructive area geometry operations.
diffstat:
ChangeLog | 9 +
Makefile | 4 +-
src/org/gfxtest/testsuites/CAGOperationsOnAreas.java | 603 +++++++++++++++++++
3 files changed, 614 insertions(+), 2 deletions(-)
diffs (truncated from 644 to 500 lines):
diff -r 9fe7efd696f4 -r 221ec39deecf ChangeLog
--- a/ChangeLog Thu Sep 08 12:53:15 2011 +0200
+++ b/ChangeLog Fri Sep 09 13:48:28 2011 +0200
@@ -1,3 +1,12 @@
+2011-09-09 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * Makefile: renamed classes to compile
+ * src/org/gfxtest/testsuites/CAGOperations.java:
+ * src/org/gfxtest/testsuites/CAGOperationsOnAreas.java:
+ Renamed, because new similar CAG tests will be prepared.
+ Added new test cases - subtraction, intersection and XOR
+ constructive area geometry operations.
+
2011-09-08 Pavel Tisnovsky <ptisnovs at redhat.com>
* Makefile: added new classes to compile
diff -r 9fe7efd696f4 -r 221ec39deecf Makefile
--- a/Makefile Thu Sep 08 12:53:15 2011 +0200
+++ b/Makefile Fri Sep 09 13:48:28 2011 +0200
@@ -134,7 +134,7 @@
$(CLASSES)/$(TESTSUITE_DIR)/GradientPaint.class \
$(CLASSES)/$(TESTSUITE_DIR)/LinearGradientPaint.class \
$(CLASSES)/$(TESTSUITE_DIR)/RadialGradientPaint.class \
- $(CLASSES)/$(TESTSUITE_DIR)/CAGOperations.class
+ $(CLASSES)/$(TESTSUITE_DIR)/CAGOperationsOnAreas.class
COMPARE_RESULTS = \
$(RESULTS)/AALines \
@@ -175,7 +175,7 @@
$(RESULTS)/GradientPaint \
$(RESULTS)/LinearGradientPaint \
$(RESULTS)/RadialGradientPaint \
- $(RESULTS)/CAGOperations
+ $(RESULTS)/CAGOperationsOnAreas
# targets for all test suites
TESTSUITES = $(shell ls -1 src/org/gfxtest/testsuites | sed -n -e 's/\([A-Za-z0-9]*\)\.java/\1/p')
diff -r 9fe7efd696f4 -r 221ec39deecf src/org/gfxtest/testsuites/CAGOperationsOnAreas.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/testsuites/CAGOperationsOnAreas.java Fri Sep 09 13:48:28 2011 +0200
@@ -0,0 +1,603 @@
+/*
+ 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.Graphics2D;
+import java.awt.geom.Area;
+import java.awt.geom.Ellipse2D;
+
+
+
+import org.gfxtest.framework.*;
+import org.gfxtest.framework.annotations.*;
+
+
+
+/**
+ * This test checks the process of creating and rendering new geometric shapes
+ * by performing boolean operations on existing ones. This process is often
+ * called Constructive area geometry (CAG). All CAG operations - union,
+ * intersection, subtraction and XOR - is processed on two Areas.
+ *
+ * @author Pavel Tisnovsky
+ */
+ at TestType(TestTypes.RENDER_TEST)
+ at RenderStyle(RenderStyles.FILL)
+ at Transformation(Transformations.NONE)
+ at Zoom(1)
+public class CAGOperationsOnAreas extends GfxTest
+{
+
+ /**
+ * Compute radius of circle from the position of center point in an image.
+ *
+ * @param xc
+ * x-coordinate of the center of the test image.
+ * @param y
+ * y-coordinate of the center of the test image.
+ * @return radius of circle
+ */
+ private int computeRadius(int xc, int yc)
+ {
+ return ((xc > yc ? yc : xc) << 1) / 3;
+ }
+
+ /**
+ * Create circle area.
+ *
+ * @param xc
+ * the X coordinate of the center of circle
+ * @param yc
+ * the Y coordinate of the center of circle
+ * @param radius
+ * radius of circle
+ * @return newly created area containing one circle
+ */
+ private Area createCircleArea(int xc, int yc, int radius)
+ {
+ Ellipse2D circle = new Ellipse2D.Double(xc - radius, yc - radius, radius << 1, radius << 1);
+ return new Area(circle);
+ }
+
+ /**
+ * Create area composed of only one circle. This circle is placed on the
+ * left side of the image.
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @return newly created area containing one circle
+ */
+ private Area createFirstCircleArea(TestImage image)
+ {
+ int xc = image.getCenterX();
+ int yc = image.getCenterY();
+ int radius = computeRadius(xc, yc);
+ int x1 = xc - 3 * (radius >> 2);
+ return createCircleArea(x1, yc, radius);
+ }
+
+ /**
+ * Create area composed of only one circle. This circle is placed on the
+ * right side of the image.
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @return newly created area containing one circle
+ */
+ private Area createSecondCircleArea(TestImage image)
+ {
+ int xc = image.getCenterX();
+ int yc = image.getCenterY();
+ int radius = computeRadius(xc, yc);
+ int x2 = xc + 3 * (radius >> 2);
+ return createCircleArea(x2, yc, radius);
+ }
+
+ /**
+ * Create new area composed from two circles using union operator.
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @return new area composed of two circles
+ */
+ private Area createAreaFromCirclesUsingUnionOperator(TestImage image)
+ {
+ Area circle1Area = createFirstCircleArea(image);
+ Area circle2Area = createSecondCircleArea(image);
+ Area area = new Area();
+ area.add(circle1Area);
+ area.add(circle2Area);
+ return area;
+ }
+
+ /**
+ * Create new area composed from two circles using subtract operator.
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @return new area composed of two circles
+ */
+ private Area createAreaFromCirclesUsingSubtractOperator(TestImage image)
+ {
+ Area circle1Area = createFirstCircleArea(image);
+ Area circle2Area = createSecondCircleArea(image);
+ Area area = new Area();
+ area.add(circle1Area);
+ area.subtract(circle2Area);
+ return area;
+ }
+
+ /**
+ * Create new area composed from two circles using subtract operator.
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @return new area composed of two circles
+ */
+ private Area createAreaFromCirclesUsingInverseSubtractOperator(TestImage image)
+ {
+ Area circle1Area = createFirstCircleArea(image);
+ Area circle2Area = createSecondCircleArea(image);
+ Area area = new Area();
+ area.add(circle2Area);
+ area.subtract(circle1Area);
+ return area;
+ }
+
+ /**
+ * Create new area composed from two circles using intersect operator.
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @return new area composed of two circles
+ */
+ private Area createAreaFromCirclesUsingIntersectOperator(TestImage image)
+ {
+ Area circle1Area = createFirstCircleArea(image);
+ Area circle2Area = createSecondCircleArea(image);
+ Area area = new Area();
+ area.add(circle1Area);
+ area.intersect(circle2Area);
+ return area;
+ }
+
+ /**
+ * Create new area composed from two circles using XOR operator.
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @return new area composed of two circles
+ */
+ private Area createAreaFromCirclesUsingXorOperator(TestImage image)
+ {
+ Area circle1Area = createFirstCircleArea(image);
+ Area circle2Area = createSecondCircleArea(image);
+ Area area = new Area();
+ area.add(circle1Area);
+ area.exclusiveOr(circle2Area);
+ return area;
+ }
+
+ /**
+ * Checks the process of creating and rendering new geometric shape
+ * constructed from two circles using union operator. The shape is rendered
+ * using stroke.
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testUnionStrokePaint(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // create area using union operator
+ Area area = createAreaFromCirclesUsingUnionOperator(image);
+ // draw the area
+ graphics.draw(area);
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Checks the process of creating and rendering new geometric shape
+ * constructed from two circles using subtract operator. The shape is
+ * rendered using stroke.
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testSubtractStrokePaint(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // create area using subtract operator
+ Area area = createAreaFromCirclesUsingSubtractOperator(image);
+ // draw the area
+ graphics.draw(area);
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Checks the process of creating and rendering new geometric shape
+ * constructed from two circles using inverse subtract operator. The shape
+ * is rendered using stroke.
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testInverseSubtractStrokePaint(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // create area using subtract operator
+ Area area = createAreaFromCirclesUsingInverseSubtractOperator(image);
+ // draw the area
+ graphics.draw(area);
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Checks the process of creating and rendering new geometric shape
+ * constructed from two circles using intersect operator. The shape is
+ * rendered using stroke.
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testIntersectStrokePaint(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // create area using intersect operator
+ Area area = createAreaFromCirclesUsingIntersectOperator(image);
+ // draw the area
+ graphics.draw(area);
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Checks the process of creating and rendering new geometric shape
+ * constructed from two circles using XOR operator. The shape is rendered
+ * using stroke.
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testXorStrokePaint(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // create area using XOR operator
+ Area area = createAreaFromCirclesUsingXorOperator(image);
+ // draw the area
+ graphics.draw(area);
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Checks the process of creating and rendering new geometric shape
+ * constructed from two circles using union operator. The shape is rendered
+ * using color paint (fill).
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testUnionColorPaint(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setFillColor(graphics);
+ // create area using union operator
+ Area area = createAreaFromCirclesUsingUnionOperator(image);
+ // draw the area
+ graphics.fill(area);
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Checks the process of creating and rendering new geometric shape
+ * constructed from two circles using subtract operator. The shape is
+ * rendered using color paint (fill).
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testSubtractColorPaint(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setFillColor(graphics);
+ // create area using subtract operator
+ Area area = createAreaFromCirclesUsingSubtractOperator(image);
+ // draw the area
+ graphics.fill(area);
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Checks the process of creating and rendering new geometric shape
+ * constructed from two circles using intersect operator. The shape is
+ * rendered using color paint (fill).
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testIntersectColorPaint(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setFillColor(graphics);
+ // create area using intersect operator
+ Area area = createAreaFromCirclesUsingIntersectOperator(image);
+ // draw the area
+ graphics.fill(area);
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Checks the process of creating and rendering new geometric shape
+ * constructed from two circles using XOR operator. The shape is rendered
+ * using color paint (fill).
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testXorColorPaint(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setFillColor(graphics);
+ // create area using XOR operator
+ Area area = createAreaFromCirclesUsingXorOperator(image);
+ // draw the area
+ graphics.fill(area);
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Checks the process of creating and rendering new geometric shape
+ * constructed from two circles using union operator. The shape is rendered
+ * using horizontal gradient paint (fill).
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testUnionColorHorizontalGradientPaint(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setHorizontalGradientFill(image, graphics);
+ // create area using union operator
+ Area area = createAreaFromCirclesUsingUnionOperator(image);
+ // draw the area
+ graphics.fill(area);
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Checks the process of creating and rendering new geometric shape
+ * constructed from two circles using subtract operator. The shape is rendered
+ * using horizontal gradient paint (fill).
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
More information about the distro-pkg-dev
mailing list