/hg/gfx-test: * src/org/gfxtest/testsuites/LinearGradientPaint.j...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Tue Sep 6 02:37:23 PDT 2011
changeset b92ad5c954c0 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=b92ad5c954c0
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Tue Sep 06 11:39:17 2011 +0200
* src/org/gfxtest/testsuites/LinearGradientPaint.java: Added 22 new
gfx. tests.
* src/org/gfxtest/framework/CommonShapesRenderer.java: Added method
for rendering empty rectangle.
* src/org/gfxtest/framework/CommonRenderingStyles.java: Added methods
supporting rendering shapes filled by gradient with various color
bands.
diffstat:
ChangeLog | 37 +
src/org/gfxtest/framework/CommonRenderingStyles.java | 115 ++++
src/org/gfxtest/framework/CommonShapesRenderer.java | 24 +
src/org/gfxtest/testsuites/LinearGradientPaint.java | 501 +++++++++++++++++++
4 files changed, 677 insertions(+), 0 deletions(-)
diffs (truncated from 921 to 500 lines):
diff -r 49478d158096 -r b92ad5c954c0 ChangeLog
--- a/ChangeLog Mon Sep 05 11:28:26 2011 +0200
+++ b/ChangeLog Tue Sep 06 11:39:17 2011 +0200
@@ -1,4 +1,15 @@
+2011-09-06 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/testsuites/LinearGradientPaint.java:
+ Added 22 new tests.
+ * src/org/gfxtest/framework/CommonShapesRenderer.java:
+ Added method for rendering empty rectangle.
+ * src/org/gfxtest/framework/CommonRenderingStyles.java:
+ Added methods supporting rendering shapes filled by gradient
+ with various color bands.
+
2011-09-05 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* Makefile: added new classes to compile
* src/org/gfxtest/framework/CommonRenderingStyles.java:
Added methods supporting rendering shapes filled by linear gradient
@@ -7,10 +18,12 @@
Added new test suite containing 16 new gfx.tests.
2011-09-02 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/testsuites/SpecialCases.java:
Added 6 new test cases, added JavaDoc to existing test cases.
2011-08-19 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/framework/CommonRenderingStyles.java:
Added methods supporting rendering shapes filled by radial gradient
paint.
@@ -20,6 +33,7 @@
Created new test suite containing 12 new gfx.tests.
2011-08-18 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/testsuites/GradientPaint.java:
Created new test suite containing 16 new gfx.tests.
* src/org/gfxtest/common/CommonShapesRenderer.java:
@@ -28,6 +42,7 @@
Added methods supporting rendering shapes filled by gradient paint.
2011-08-17 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/common/Configuration.java:
Added JavaDoc.
* src/org/gfxtest/framework/CommonRenderingStyles.java:
@@ -39,11 +54,13 @@
Added new test cases.
2011-08-16 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/testsuites/BlankImage.java:
Added new test cases (rendering using transparency etc.), added
JavaDoc.
2011-08-12 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/testsuites/NormalQuadraticCurves.java:
* src/org/gfxtest/testsuites/NormalQuadraticCurvesAsPaths.java:
* src/org/gfxtest/testsuites/NormalCubicCurves.java:
@@ -51,6 +68,7 @@
Refactored, added new test cases (rendering using transparency etc.)
2011-08-11 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* Makefile: added new classes to compile
* src/org/gfxtest/framework/CommonRenderingStyles.java:
Added class containing static methods for setting various rendering
@@ -62,16 +80,19 @@
Javadoc.
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.
* src/org/gfxtest/testsuites/NormalCubicCurvesAsPaths.java:
Created new test suite containing 12 gfx.tests.
2011-08-05 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/framework/CubicCurvePointSet.java:
Added new methods for fetching points arrays.
* src/org/gfxtest/framework/GfxTest.java:
@@ -85,31 +106,37 @@
Added new test cases.
2011-08-04 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/framework/CubicCurvePointSet.java: added
* src/org/gfxtest/testsuites/NormalCubicCurves.java:
Refactoring, added more test cases including special cases (multiple
control points).
2011-08-04 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* diff.diff: removed as it's just a garbage.
* src/org/gfxtest/testsuites/NormalQuadraticCurves.java:
Added new tests - drawing curves using extra width stroke.
2011-08-03 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* diff.diff: removed as it's just a garbage.
* src/org/gfxtest/testsuites/NormalQuadraticCurves.java:
Added tests for special cases - multiple control points.
2011-08-03 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/testsuites/ColorPalette.java: added new method
* src/org/gfxtest/testsuites/NormalQuadraticCurves.java:
Refactoring, added new test cases.
2011-08-02 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/testsuites/PathsFromLines.java: created new test
cases.
2011-08-01 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/harness/ExternalCommands.java:
* src/org/gfxtest/framework/GfxTestConfiguration.java:
Fixed issue: each test suite can be called from command line without
@@ -117,21 +144,26 @@
are used instead. Code refactoring, added missing JavaDoc.
2011-08-01 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/harness/ExternalCommands.java:
Code refactoring and added missing JavaDoc.
2011-07-29 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/testsuites/AALines.java: improved JavaDoc.
2011-07-29 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* Makefile: added new class to compile & run: PathsFromLines.java
* src/org/gfxtest/testsuites/PathsFromLines.java: created new test
suite containing test using Path2D class for rendering lines.
2011-07-28 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/testsuites/NormalLines.java: added new tests
2011-07-27 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* Makefile:
Added new build targets - doc and clean-doc
* src/org/gfxtest/framework/GfxTest.java:
@@ -140,22 +172,26 @@
Fixed javadoc tool warnings, added doc to all methods and attributes.
2011-07-27 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* Makefile: added new class to compile & run: NormalCubicCurves.java
* src/org/gfxtest/testsuites/NormalCubicCurves.java: created
Added new test suite - drawing of normal cubic curves.
2011-07-26 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/testsuites/NormalQuadraticCurve.java: renamed
* src/org/gfxtest/testsuites/NormalQuadraticCurves.java: renamed
* src/org/gfxtest/testsuites/NormalQuadraticCurvesAsPaths.java: created
Added new test suite - drawing of normal quadratic curves using Path2D.
2011-07-26 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* Makefile: added new class to compile & run: NormalQuadraticCurve.java
* src/org/gfxtest/testsuites/NormalQuadraticCurve.java: created
Added new test suite - drawing of normal quadratic curves.
2011-07-22 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/harness/PixelPanel.java: created
* src/org/gfxtest/harness/MainWindow.java:
Add capability of showing values of selected pixels from
@@ -163,6 +199,7 @@
the selected pixel.
2011-07-21 Pavel Tisnovsky <ptisnovs at redhat.com>
+
* src/org/gfxtest/ImageDiffer/ImageUtils.java:
* src/org/gfxtest/harness/MainWindow.java:
Add image zooming capability into gfx-test harness.
diff -r 49478d158096 -r b92ad5c954c0 src/org/gfxtest/framework/CommonRenderingStyles.java
--- a/src/org/gfxtest/framework/CommonRenderingStyles.java Mon Sep 05 11:28:26 2011 +0200
+++ b/src/org/gfxtest/framework/CommonRenderingStyles.java Tue Sep 06 11:39:17 2011 +0200
@@ -518,10 +518,45 @@
// calculate radius of circle
int radius = CommonShapesRenderer.calculateRadius(image);
+ // numbers ranging from 0.0 to 1.0 specifying the distribution of colors along the gradient
float[] fractions = { 0.0f, 0.5f, 1.0f };
+
+ // array of colors corresponding to each fractional value
Color[] colors = { color1, color2, color3 };
+ // create linear gradient object
LinearGradientPaint linearGradientPaint = new LinearGradientPaint(xc - radius + offset, yc, xc + radius - offset, yc, fractions, colors);
+
+ // set fill style
+ graphics.setPaint(linearGradientPaint);
+ }
+
+ /**
+ * Set horizontal linear 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 setHorizontalLinearGradientFill(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);
+
+ // create linear gradient object
+ LinearGradientPaint linearGradientPaint = new LinearGradientPaint(xc - radius, yc, xc + radius, yc, fractions, colors);
+
+ // set fill style
graphics.setPaint(linearGradientPaint);
}
@@ -599,10 +634,45 @@
// calculate radius of circle
int radius = CommonShapesRenderer.calculateRadius(image);
+ // numbers ranging from 0.0 to 1.0 specifying the distribution of colors along the gradient
float[] fractions = { 0.0f, 0.5f, 1.0f };
+
+ // array of colors corresponding to each fractional value
Color[] colors = { color1, color2, color3 };
+ // create linear gradient object
LinearGradientPaint linearGradientPaint = new LinearGradientPaint(xc, yc - radius + offset, xc, yc + radius - offset, fractions, colors);
+
+ // set fill style
+ graphics.setPaint(linearGradientPaint);
+ }
+
+ /**
+ * Set vertical linear 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 setVerticalLinearGradientFill(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);
+
+ // create linear gradient object
+ LinearGradientPaint linearGradientPaint = new LinearGradientPaint(xc, yc - radius, xc, yc + radius, fractions, colors);
+
+ // set fill style
graphics.setPaint(linearGradientPaint);
}
@@ -691,10 +761,55 @@
int x2 = xc + r2 - delta;
int y2 = yc + r2 - delta;
+ // numbers ranging from 0.0 to 1.0 specifying the distribution of colors along the gradient
float[] fractions = { 0.0f, 0.5f, 1.0f };
+
+ // array of colors corresponding to each fractional value
Color[] colors = { color1, color2, color3 };
+ // create linear gradient object
LinearGradientPaint linearGradientPaint = new LinearGradientPaint(x1, y1, x2, y2, fractions, colors);
+
+ // set fill style
+ graphics.setPaint(linearGradientPaint);
+ }
+
+ /**
+ * Set diagonal linear 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 setDiagonalLinearGradientFill(TestImage image, Graphics2D graphics, float[] fractions, Color[] colors)
+ {
+ // sin 45 = cos 45 = 0.707f
+ final double SIN_COS_45 = Math.cos(Math.PI / 4);
+
+ // calculate center of the image
+ int xc = image.getCenterX();
+ int yc = image.getCenterY();
+
+ // calculate radius of circle
+ int radius = CommonShapesRenderer.calculateRadius(image);
+ int r2 = (int)(radius * SIN_COS_45 );
+
+ // compute end points used for diagonal fill
+ int x1 = xc - r2;
+ int y1 = yc - r2;
+ int x2 = xc + r2;
+ int y2 = yc + r2;
+
+ // create linear gradient object
+ LinearGradientPaint linearGradientPaint = new LinearGradientPaint(x1, y1, x2, y2, fractions, colors);
+
+ // set fill style
graphics.setPaint(linearGradientPaint);
}
diff -r 49478d158096 -r b92ad5c954c0 src/org/gfxtest/framework/CommonShapesRenderer.java
--- a/src/org/gfxtest/framework/CommonShapesRenderer.java Mon Sep 05 11:28:26 2011 +0200
+++ b/src/org/gfxtest/framework/CommonShapesRenderer.java Tue Sep 06 11:39:17 2011 +0200
@@ -155,6 +155,30 @@
}
/**
+ * Draw rectangle onto the graphics canvas.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics context for image
+ */
+ public static void drawRectangle(TestImage image, Graphics2D graphics)
+ {
+ // calculate center of the image
+ int xc = image.getCenterX();
+ int yc = image.getCenterY();
+
+ // calculate size of the rectangle
+ int size = calculateRadius(image);
+
+ // draw the rectangle
+ graphics.drawRect(xc - size, yc - size, size << 1, size << 1);
+
+ // draw crosses at interesting points of image
+ drawCrossesForBasicShapes(graphics, xc, yc, size);
+ }
+
+ /**
* Draw filled circle onto the graphics canvas.
*
* @param image
diff -r 49478d158096 -r b92ad5c954c0 src/org/gfxtest/testsuites/LinearGradientPaint.java
--- a/src/org/gfxtest/testsuites/LinearGradientPaint.java Mon Sep 05 11:28:26 2011 +0200
+++ b/src/org/gfxtest/testsuites/LinearGradientPaint.java Tue Sep 06 11:39:17 2011 +0200
@@ -40,6 +40,7 @@
package org.gfxtest.testsuites;
+import java.awt.Color;
import java.awt.Graphics2D;
@@ -58,6 +59,20 @@
@Zoom(1)
public class LinearGradientPaint 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 circle drawn by graphics.drawOval() is rendered correctly.
*
@@ -78,6 +93,25 @@
}
/**
+ * Test if rectangle 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 testRectangleLinearGradientEmptyFill(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // draw the rectangle
+ CommonShapesRenderer.drawRectangle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
* Test if filled circle drawn by graphics.fillOval() is rendered correctly.
* Horizontal gradient paint is used for filling this circle.
*
@@ -189,6 +223,29 @@
/**
* Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+ * Horizontal linear 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 testCircleHorizontalColorSpectrum(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setHorizontalLinearGradientFill(image, graphics, SpectrumFractions, SpectrumColors);
+ // draw the circle
+ CommonShapesRenderer.drawFilledCircle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
* Vertical gradient paint is used for filling this circle.
*
* @param image
@@ -299,6 +356,29 @@
/**
* Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+ * Vertical linear 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 testCircleVerticalColorSpectrum(TestImage image, Graphics2D graphics)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics);
+ // set fill color
+ CommonRenderingStyles.setVerticalLinearGradientFill(image, graphics, SpectrumFractions, SpectrumColors);
+ // draw the circle
+ CommonShapesRenderer.drawFilledCircle(image, graphics);
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
* Diagonal gradient paint is used for filling this circle.
*
* @param image
@@ -408,6 +488,427 @@
}
/**
+ * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+ * Diagonal linear gradient paint is used for filling this circle using
+ * whole color spectrum.
More information about the distro-pkg-dev
mailing list