/hg/gfx-test: Added helper methods for rendering various types o...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Mon Nov 25 00:29:53 PST 2013
changeset c9b9cc4c7aaf in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=c9b9cc4c7aaf
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Nov 25 09:33:47 2013 +0100
Added helper methods for rendering various types of pies.
Add one test into CAGOperationsOnPieAndRectangle test suite.
diffstat:
ChangeLog | 7 +
src/org/gfxtest/framework/CommonCAGOperations.java | 102 ++++++++-
src/org/gfxtest/testsuites/CAGOperationsOnPieAndRectangle.java | 34 +++-
3 files changed, 122 insertions(+), 21 deletions(-)
diffs (217 lines):
diff -r c446518578d9 -r c9b9cc4c7aaf ChangeLog
--- a/ChangeLog Fri Nov 22 09:08:32 2013 +0100
+++ b/ChangeLog Mon Nov 25 09:33:47 2013 +0100
@@ -1,3 +1,10 @@
+2013-11-25 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/framework/CommonCAGOperations.java:
+ Added helper methods for rendering various types of pies.
+ * src/org/gfxtest/testsuites/CAGOperationsOnPieAndRectangle.java:
+ Add one test into CAGOperationsOnPieAndRectangle test suite.
+
2013-11-22 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/framework/CommonCAGOperations.java:
diff -r c446518578d9 -r c9b9cc4c7aaf src/org/gfxtest/framework/CommonCAGOperations.java
--- a/src/org/gfxtest/framework/CommonCAGOperations.java Fri Nov 22 09:08:32 2013 +0100
+++ b/src/org/gfxtest/framework/CommonCAGOperations.java Mon Nov 25 09:33:47 2013 +0100
@@ -74,6 +74,16 @@
private final static int CHORD_EXTEND_ANGLE = 270;
/**
+ * Start angle for pies.
+ */
+ private final static int PIE_START_ANGLE = 45;
+
+ /**
+ * Extend angle for pies.
+ */
+ private final static int PIE_EXTEND_ANGLE = 270;
+
+ /**
* Compute radius of circle from the position of its center point in an
* image size (width and height).
*
@@ -186,13 +196,30 @@
* @param yc
* the Y coordinate of the center of chord
* @param radius
- * radius of circle
+ * radius of chord
* @return newly created area containing one chord
*/
private static Area createChordArea(int xc, int yc, int radius)
{
- Arc2D circle = new Arc2D.Double(xc - radius, yc - radius, radius << 1, radius << 1, CHORD_START_ANGLE, CHORD_EXTEND_ANGLE, Arc2D.CHORD);
- return new Area(circle);
+ Arc2D chord = new Arc2D.Double(xc - radius, yc - radius, radius << 1, radius << 1, CHORD_START_ANGLE, CHORD_EXTEND_ANGLE, Arc2D.CHORD);
+ return new Area(chord);
+ }
+
+ /**
+ * Create pie area i.e. area consisting of just one pie.
+ *
+ * @param xc
+ * the X coordinate of the center of pie
+ * @param yc
+ * the Y coordinate of the center of pie
+ * @param radius
+ * radius of pie
+ * @return newly created area containing one pie
+ */
+ private static Area createPieArea(int xc, int yc, int radius)
+ {
+ Arc2D pie = new Arc2D.Double(xc - radius, yc - radius, radius << 1, radius << 1, PIE_START_ANGLE, PIE_EXTEND_ANGLE, Arc2D.PIE);
+ return new Area(pie);
}
/**
@@ -372,7 +399,7 @@
*
* @param image
* image to which area is to be drawn
- * @return newly created area containing one circle
+ * @return newly created area containing one chord
*/
private static Area createBiggerCenteredChordArea(TestImage image)
{
@@ -385,6 +412,25 @@
}
/**
+ * Create area composed of only one pie. This pie is placed on
+ * the center of the image and its radius is bigger than the length
+ * of rectangle side(s).
+ *
+ * @param image
+ * image to which area is to be drawn
+ * @return newly created area containing one pie
+ */
+ private static Area createBiggerCenteredPieArea(TestImage image)
+ {
+ // compute center of the image
+ int xc = image.getCenterX();
+ int yc = image.getCenterY();
+ // compute size of the circle
+ int size = computeSizeOfCircleOrRectangle(xc, yc) * 5 / 3;
+ return createPieArea(xc, yc, size);
+ }
+
+ /**
* Create area composed of only one circle. This circle is placed on
* the center of the image and its radius is smaller than the length
* of rectangle side(s).
@@ -626,22 +672,6 @@
}
/**
- * Create new area constructed from bigger chord and rectangle using union
- * operation.
- *
- * @param image
- * image to which area is to be drawn
- * @return newly created area
- */
- public static Area createAreaFromBiggerChordAndRectangleUsingUnionOperator(TestImage image)
- {
- Area area = new Area();
- area.add(createBiggerCenteredChordArea(image));
- area.add(createCenteredRectangularArea(image));
- return area;
- }
-
- /**
* Create new area constructed from bigger circle and rectangle using intersect
* operation.
*
@@ -706,6 +736,38 @@
}
/**
+ * Create new area constructed from bigger chord and rectangle using union
+ * operation.
+ *
+ * @param image
+ * image to which area is to be drawn
+ * @return newly created area
+ */
+ public static Area createAreaFromBiggerChordAndRectangleUsingUnionOperator(TestImage image)
+ {
+ Area area = new Area();
+ area.add(createBiggerCenteredChordArea(image));
+ area.add(createCenteredRectangularArea(image));
+ return area;
+ }
+
+ /**
+ * Create new area constructed from bigger pie and rectangle using union
+ * operation.
+ *
+ * @param image
+ * image to which area is to be drawn
+ * @return newly created area
+ */
+ public static Area createAreaFromBiggerPieAndRectangleUsingUnionOperator(TestImage image)
+ {
+ Area area = new Area();
+ area.add(createBiggerCenteredPieArea(image));
+ area.add(createCenteredRectangularArea(image));
+ return area;
+ }
+
+ /**
* Create new area constructed from smaller circle placed inside a rectangle
* using union operation.
*
diff -r c446518578d9 -r c9b9cc4c7aaf src/org/gfxtest/testsuites/CAGOperationsOnPieAndRectangle.java
--- a/src/org/gfxtest/testsuites/CAGOperationsOnPieAndRectangle.java Fri Nov 22 09:08:32 2013 +0100
+++ b/src/org/gfxtest/testsuites/CAGOperationsOnPieAndRectangle.java Mon Nov 25 09:33:47 2013 +0100
@@ -40,7 +40,16 @@
package org.gfxtest.testsuites;
+import java.awt.Graphics2D;
+import java.awt.geom.Area;
+
+
+
+import org.gfxtest.framework.CommonCAGOperations;
+import org.gfxtest.framework.CommonRenderingStyles;
import org.gfxtest.framework.GfxTest;
+import org.gfxtest.framework.TestImage;
+import org.gfxtest.framework.TestResult;
import org.gfxtest.framework.annotations.GraphicsPrimitive;
import org.gfxtest.framework.annotations.GraphicsPrimitives;
import org.gfxtest.framework.annotations.RenderStyle;
@@ -68,7 +77,30 @@
@Zoom(1)
public class CAGOperationsOnPieAndRectangle extends GfxTest
{
-
+
+ /**
+ * Checks the process of creating and rendering new geometric shape
+ * constructed from pie and rectangle using union operator. The shape is
+ * rendered using stroke paint.
+ *
+ * @param image
+ * image to which area is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testBigPieRectangleUnionStrokePaint(TestImage image, Graphics2D graphics2d)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics2d);
+ // create area using union operator
+ Area area = CommonCAGOperations.createAreaFromBiggerPieAndRectangleUsingUnionOperator(image);
+ // draw the area
+ graphics2d.draw(area);
+ // test result
+ return TestResult.PASSED;
+ }
+
/**
* Entry point to the test suite.
*
More information about the distro-pkg-dev
mailing list