/hg/gfx-test: * src/org/gfxtest/testsuites/RadialGradientPaint.j...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Wed Sep 7 02:53:44 PDT 2011
changeset c43356096cb8 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=c43356096cb8
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Wed Sep 07 11:55:36 2011 +0200
* src/org/gfxtest/testsuites/RadialGradientPaint.java: Added 6 new
gfx. tests.
* src/org/gfxtest/framework/CommonRenderingStyles.java: Added methods
supporting rendering shapes filled by radial fill with various color
bands.
diffstat:
ChangeLog | 8 +
src/org/gfxtest/framework/CommonRenderingStyles.java | 25 ++
src/org/gfxtest/testsuites/RadialGradientPaint.java | 164 ++++++++++++++++++-
3 files changed, 191 insertions(+), 6 deletions(-)
diffs (273 lines):
diff -r b92ad5c954c0 -r c43356096cb8 ChangeLog
--- a/ChangeLog Tue Sep 06 11:39:17 2011 +0200
+++ b/ChangeLog Wed Sep 07 11:55:36 2011 +0200
@@ -1,3 +1,11 @@
+2011-09-07 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/testsuites/RadialGradientPaint.java:
+ Added 6 new gfx. tests.
+ * src/org/gfxtest/framework/CommonRenderingStyles.java:
+ Added methods supporting rendering shapes filled by radial
+ fill with various color bands.
+
2011-09-06 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/testsuites/LinearGradientPaint.java:
diff -r b92ad5c954c0 -r c43356096cb8 src/org/gfxtest/framework/CommonRenderingStyles.java
--- a/src/org/gfxtest/framework/CommonRenderingStyles.java Tue Sep 06 11:39:17 2011 +0200
+++ b/src/org/gfxtest/framework/CommonRenderingStyles.java Wed Sep 07 11:55:36 2011 +0200
@@ -910,6 +910,31 @@
}
/**
+ * Set radial gradient fill for given graphics context.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics context for image
+ * @param fractions
+ * numbers ranging from 0.0 to 1.0 specifying the distribution of
+ * colors along the gradient
+ * @param colors
+ * array of colors corresponding to each fractional value
+ */
+ public static void setRadialGradientFill(TestImage image, Graphics2D graphics, float[] fractions, Color[] colors)
+ {
+ // calculate center of the image
+ int xc = image.getCenterX();
+ int yc = image.getCenterY();
+
+ // calculate radius of circle
+ int radius = CommonShapesRenderer.calculateRadius(image);
+ RadialGradientPaint gradientPaint = new RadialGradientPaint(xc, yc, radius, fractions, colors);
+ graphics.setPaint(gradientPaint);
+ }
+
+ /**
* Set zero pixels wide stroke and default cap and join style.
*
* @param graphics
diff -r b92ad5c954c0 -r c43356096cb8 src/org/gfxtest/testsuites/RadialGradientPaint.java
--- a/src/org/gfxtest/testsuites/RadialGradientPaint.java Tue Sep 06 11:39:17 2011 +0200
+++ b/src/org/gfxtest/testsuites/RadialGradientPaint.java Wed Sep 07 11:55:36 2011 +0200
@@ -40,6 +40,7 @@
package org.gfxtest.testsuites;
+import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.MultipleGradientPaint.CycleMethod;
@@ -59,7 +60,20 @@
@Zoom(1)
public class RadialGradientPaint extends GfxTest
{
-
+ // numbers ranging from 0.0 to 1.0 specifying the distribution of colors along the gradient
+ private static final float[] SpectrumFractions = { 0.0f, 1.0f/6, 2.0f/6, 3.0f/6, 4.0f/6, 5.0f/6, 1.0f };
+
+ // array of colors corresponding to each fractional value
+ private static final Color[] SpectrumColors = {
+ Color.MAGENTA,
+ Color.BLUE,
+ Color.CYAN,
+ Color.GREEN,
+ Color.YELLOW,
+ Color.ORANGE,
+ Color.RED
+ };
+
/**
* Test if filled circle drawn by graphics.fillOval() is rendered correctly.
* Radial gradient paint is used for filling this circle.
@@ -215,6 +229,29 @@
}
/**
+ * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+ * Radial Gradient paint is used for filling this circle using whole color
+ * spectrum.
+ *
+ * @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 testCircleRadialGradientFillColorSpectrum(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setRadialGradientFill(image, graphics, SpectrumFractions, SpectrumColors);
+ // draw the circle
+ CommonShapesRenderer.drawFilledCircle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
* Test if filled rectangle is rendered correctly.
* Radial gradient paint is used for filling this rectangle.
*
@@ -230,7 +267,30 @@
CommonRenderingStyles.setStrokeColor(graphics);
// set fill color
CommonRenderingStyles.setRadialGradientFill(image, graphics);
- // draw the circle
+ // draw the rectangle
+ CommonShapesRenderer.drawFilledRect(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled rectangle is rendered correctly.
+ * Radial Gradient paint is used for filling this shape using whole color
+ * spectrum.
+ *
+ * @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 testRectangleRadialGradientFillColorSpectrum(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setRadialGradientFill(image, graphics, SpectrumFractions, SpectrumColors);
+ // draw the rectangle
CommonShapesRenderer.drawFilledRect(image, graphics);
// test return value
return TestResult.PASSED;
@@ -252,7 +312,30 @@
CommonRenderingStyles.setStrokeColor(graphics);
// set fill color
CommonRenderingStyles.setRadialGradientFill(image, graphics);
- // draw the circle
+ // draw the round rectangle
+ CommonShapesRenderer.drawFilledRoundRect(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled round rectangle is rendered correctly.
+ * Radial Gradient paint is used for filling this shape using whole color
+ * spectrum.
+ *
+ * @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 testRoundRectangleRadialGradientFillColorSpectrum(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setRadialGradientFill(image, graphics, SpectrumFractions, SpectrumColors);
+ // draw the round rectangle
CommonShapesRenderer.drawFilledRoundRect(image, graphics);
// test return value
return TestResult.PASSED;
@@ -274,7 +357,30 @@
CommonRenderingStyles.setStrokeColor(graphics);
// set fill color
CommonRenderingStyles.setRadialGradientFill(image, graphics);
- // draw the circle
+ // draw the arc
+ CommonShapesRenderer.drawFilledArc(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled arc is rendered correctly.
+ * Radial Gradient paint is used for filling this shape using whole color
+ * spectrum.
+ *
+ * @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 testArcRadialGradientFillColorSpectrum(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setRadialGradientFill(image, graphics, SpectrumFractions, SpectrumColors);
+ // draw the arc
CommonShapesRenderer.drawFilledArc(image, graphics);
// test return value
return TestResult.PASSED;
@@ -296,7 +402,30 @@
CommonRenderingStyles.setStrokeColor(graphics);
// set fill color
CommonRenderingStyles.setRadialGradientFill(image, graphics);
- // draw the circle
+ // draw the polygon
+ CommonShapesRenderer.drawFilledPolygon(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled polygon is rendered correctly.
+ * Radial Gradient paint is used for filling this shape using whole color
+ * spectrum.
+ *
+ * @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 testPolygonRadialGradientFillColorSpectrum(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setRadialGradientFill(image, graphics, SpectrumFractions, SpectrumColors);
+ // draw the polygon
CommonShapesRenderer.drawFilledPolygon(image, graphics);
// test return value
return TestResult.PASSED;
@@ -318,7 +447,30 @@
CommonRenderingStyles.setStrokeColor(graphics);
// set fill color
CommonRenderingStyles.setRadialGradientFill(image, graphics);
- // draw the circle
+ // draw the closed path
+ CommonShapesRenderer.drawFilledClosedPath(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled closed path is rendered correctly.
+ * Radial Gradient paint is used for filling this shape using whole color
+ * spectrum.
+ *
+ * @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 testClosedPathGradientFillColorSpectrum(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setRadialGradientFill(image, graphics, SpectrumFractions, SpectrumColors);
+ // draw the closed path
CommonShapesRenderer.drawFilledClosedPath(image, graphics);
// test return value
return TestResult.PASSED;
More information about the distro-pkg-dev
mailing list