Mercurial > hg > gfx-test
changeset 487:c446518578d9 draft
Added helper methods for rendering various types of chords.
Add one test into CAGOperationsOnChordAndRectangle test suite.
author | Pavel Tisnovsky <ptisnovs@redhat.com> |
---|---|
date | Fri, 22 Nov 2013 09:08:32 +0100 |
parents | 0c79e2cd45c7 |
children | c9b9cc4c7aaf |
files | ChangeLog src/org/gfxtest/framework/CommonCAGOperations.java src/org/gfxtest/testsuites/CAGOperationsOnChordAndRectangle.java |
diffstat | 3 files changed, 111 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Nov 21 09:21:51 2013 +0100 +++ b/ChangeLog Fri Nov 22 09:08:32 2013 +0100 @@ -1,3 +1,10 @@ +2013-11-22 Pavel Tisnovsky <ptisnovs@redhat.com> + + * src/org/gfxtest/framework/CommonCAGOperations.java: + Added helper methods for rendering various types of chords. + * src/org/gfxtest/testsuites/CAGOperationsOnChordAndRectangle.java: + Add one test into CAGOperationsOnChordAndRectangle test suite. + 2013-11-21 Pavel Tisnovsky <ptisnovs@redhat.com> * src/org/gfxtest/testsuites/BitBltAffineQuadrantRotateTransformOp.java:
--- a/src/org/gfxtest/framework/CommonCAGOperations.java Thu Nov 21 09:21:51 2013 +0100 +++ b/src/org/gfxtest/framework/CommonCAGOperations.java Fri Nov 22 09:08:32 2013 +0100 @@ -40,6 +40,7 @@ package org.gfxtest.framework; +import java.awt.geom.Arc2D; import java.awt.geom.Area; import java.awt.geom.Ellipse2D; import java.awt.geom.Rectangle2D; @@ -52,6 +53,25 @@ */ public class CommonCAGOperations { + /** + * Start angle for arcs. + */ + private final static int ARC_START_ANGLE = 45; + + /** + * Extend angle for arcs. + */ + private final static int ARC_EXTEND_ANGLE = 270; + + /** + * Start angle for chords. + */ + private final static int CHORD_START_ANGLE = 45; + + /** + * Extend angle for chords. + */ + private final static int CHORD_EXTEND_ANGLE = 270; /** * Compute radius of circle from the position of its center point in an @@ -159,6 +179,23 @@ } /** + * Create chord area i.e. area consisting of just one chord. + * + * @param xc + * the X coordinate of the center of chord + * @param yc + * the Y coordinate of the center of chord + * @param radius + * radius of circle + * @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); + } + + /** * Create rectangular area i.e. area consisting of just one rectangle. * * @param xc @@ -329,6 +366,25 @@ } /** + * Create area composed of only one chord. This chord 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 circle + */ + private static Area createBiggerCenteredChordArea(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 createChordArea(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). @@ -570,6 +626,22 @@ } /** + * 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. *
--- a/src/org/gfxtest/testsuites/CAGOperationsOnChordAndRectangle.java Thu Nov 21 09:21:51 2013 +0100 +++ b/src/org/gfxtest/testsuites/CAGOperationsOnChordAndRectangle.java Fri Nov 22 09:08:32 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; @@ -70,6 +79,29 @@ { /** + * Checks the process of creating and rendering new geometric shape + * constructed from chord 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 testBigChordRectangleUnionStrokePaint(TestImage image, Graphics2D graphics2d) + { + // set stroke color + CommonRenderingStyles.setStrokeColor(graphics2d); + // create area using union operator + Area area = CommonCAGOperations.createAreaFromBiggerChordAndRectangleUsingUnionOperator(image); + // draw the area + graphics2d.draw(area); + // test result + return TestResult.PASSED; + } + + /** * Entry point to the test suite. * * @param args not used in this case