/hg/gfx-test: Added new test suite - rendering of ellipses (oval...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Fri Jul 13 04:56:26 PDT 2012
changeset 0c1ceef887ca in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=0c1ceef887ca
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Jul 13 13:59:05 2012 +0200
Added new test suite - rendering of ellipses (ovals) to a PostScript file.
* src/org/gfxtest/testsuites/PrintTestEllipses.java:
* Makefile: Added new class to compile and new test to run.
diffstat:
ChangeLog | 7 +
Makefile | 2 +
src/org/gfxtest/testsuites/PrintTestEllipses.java | 1313 +++++++++++++++++++++
3 files changed, 1322 insertions(+), 0 deletions(-)
diffs (truncated from 1350 to 500 lines):
diff -r 83c95c58b0c2 -r 0c1ceef887ca ChangeLog
--- a/ChangeLog Thu Jul 12 14:05:47 2012 +0200
+++ b/ChangeLog Fri Jul 13 13:59:05 2012 +0200
@@ -1,3 +1,10 @@
+2012-07-13 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/testsuites/PrintTestEllipses.java:
+ Added new test suite - rendering of ellipses (ovals) to a PostScript
+ file.
+ * Makefile: Added new class to compile and new test to run.
+
2012-07-12 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/callbacks/CommonCircleDrawCallbacks.java:
diff -r 83c95c58b0c2 -r 0c1ceef887ca Makefile
--- a/Makefile Thu Jul 12 14:05:47 2012 +0200
+++ b/Makefile Fri Jul 13 13:59:05 2012 +0200
@@ -197,6 +197,7 @@
$(CLASSES)/$(TESTSUITE_DIR)/PrintTestQuadraticCurves.class \
$(CLASSES)/$(TESTSUITE_DIR)/PrintTestBitBlt.class \
$(CLASSES)/$(TESTSUITE_DIR)/PrintTestCircles.class \
+ $(CLASSES)/$(TESTSUITE_DIR)/PrintTestEllipses.class \
$(CLASSES)/$(TESTSUITE_DIR)/PrintTestDrawText.class \
$(CLASSES)/$(TESTSUITE_DIR)/PrintTestColorPaint.class \
$(CLASSES)/$(TESTSUITE_DIR)/PrintTestGradientPaint.class \
@@ -285,6 +286,7 @@
$(RESULTS)/PrintTestArcs \
$(RESULTS)/PrintTestBitBlt \
$(RESULTS)/PrintTestCircles \
+ $(RESULTS)/PrintTestEllipses \
$(RESULTS)/PrintTestDrawText \
$(RESULTS)/PrintTestColorPaint \
$(RESULTS)/PrintTestGradientPaint \
diff -r 83c95c58b0c2 -r 0c1ceef887ca src/org/gfxtest/testsuites/PrintTestEllipses.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/testsuites/PrintTestEllipses.java Fri Jul 13 13:59:05 2012 +0200
@@ -0,0 +1,1313 @@
+/*
+ Java gfx-test framework
+
+ Copyright (C) 2012 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.BasicStroke;
+import java.awt.Graphics2D;
+
+
+
+import org.gfxtest.callbacks.CommonEllipseDrawCallbacks;
+import org.gfxtest.framework.ColorPalette;
+import org.gfxtest.framework.GrayscalePalette;
+import org.gfxtest.framework.PrintTest;
+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;
+import org.gfxtest.framework.annotations.RenderStyles;
+import org.gfxtest.framework.annotations.TestType;
+import org.gfxtest.framework.annotations.TestTypes;
+import org.gfxtest.framework.annotations.Transformation;
+import org.gfxtest.framework.annotations.Transformations;
+import org.gfxtest.framework.annotations.Zoom;
+
+
+
+/**
+* This test suite checks rendering of various ellipses.
+*
+* @author Pavel Tisnovsky
+*/
+ at TestType(TestTypes.PRINT_TEST)
+ at GraphicsPrimitive(GraphicsPrimitives.ELLIPSE)
+ at RenderStyle(RenderStyles.NORMAL)
+ at Transformation(Transformations.NONE)
+ at Zoom(1)
+public class PrintTestEllipses extends PrintTest
+{
+
+ /**
+ * Method which renders set of ellipses using various colors and stroke
+ * styles. For each ellipse, the callback function/method is called to
+ * perform all required setup.
+ *
+ * @param image
+ * image to which ellipses are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @param radiusStep
+ * between two near ellipses
+ * @param ellipseDrawCallback
+ * class containing set of callback methods
+ */
+ private void drawEllipse(TestImage image, Graphics2D graphics2d, int radiusStep,
+ CommonEllipseDrawCallbacks ellipseDrawCallback)
+ {
+ // setup rendering
+ ellipseDrawCallback.setup(image, graphics2d);
+
+ // image width and height
+ final int width = image.getWidth();
+ final int height = image.getHeight();
+
+ // horizontal coordinates of ellipse center
+ final int xc = width >> 1;
+ final int yc = height >> 1;
+
+ // maximum radius
+ int radiusX = xc - BORDER;
+ int radiusY = yc - BORDER;
+
+ // index to color palette
+ int colorIndex = 0;
+
+ // draw all ellipses onto a paper
+ while (radiusX > MINIMUM_RADIUS && radiusY > MINIMUM_RADIUS)
+ {
+ // setup can be made for each ellipse
+ ellipseDrawCallback.iterationCallBack(xc, yc, radiusX, xc - BORDER, colorIndex++);
+ radiusX -= radiusStep;
+ radiusY -= radiusStep;
+ // render the ellipse
+ graphics2d.drawOval(xc - radiusX, yc - radiusY, radiusX << 1, radiusY << 1);
+ }
+
+ // cleanup rendering
+ ellipseDrawCallback.cleanup();
+ }
+
+ /**
+ * Test basic behavior of method Graphics.drawOval(). Color of all rendered
+ * ellipses are set to black.
+ *
+ * @param image
+ * image to which ellipses are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawEllipseBasicStyle(TestImage image, Graphics2D graphics2d)
+ {
+ drawEllipse(image, graphics2d, ELLIPSE_RADIUS_STEP, new CommonEllipseDrawCallbacks()
+ {
+ /**
+ * Callback function called before each ellipse is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x, int y, int radius, int maxRadius, int index)
+ {
+ // nothing needs to be changed or set
+ return;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test basic behavior of method Graphics.drawOval(). ellipses color are
+ * selected from a palette.
+ *
+ * @param image
+ * image to which ellipses are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawEllipseColorPalette(TestImage image, Graphics2D graphics2d)
+ {
+ drawEllipse(image, graphics2d, ELLIPSE_RADIUS_STEP, new CommonEllipseDrawCallbacks()
+ {
+ /**
+ * Callback function called before each ellipse is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x, int y, int radius, int maxRadius, int index)
+ {
+ // set new ellipse color to index
+ this.graphics.setColor(ColorPalette.getColor(index));
+ return;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test basic behavior of method Graphics.drawOval(). ellipses color are
+ * selected from a palette.
+ *
+ * @param image
+ * image to which ellipses are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawEllipseColorPaletteInv(TestImage image, Graphics2D graphics2d)
+ {
+ drawEllipse(image, graphics2d, ELLIPSE_RADIUS_STEP, new CommonEllipseDrawCallbacks()
+ {
+ /**
+ * Callback function called before each ellipse is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x, int y, int radius, int maxRadius, int index)
+ {
+ // set new ellipse color according to index
+ this.graphics.setColor(ColorPalette.getColor(MAX_COLOR_INDEX - index));
+ return;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test basic behavior of method Graphics.drawOval(). ellipses color are
+ * selected from a grayscale palette.
+ *
+ * @param image
+ * image to which ellipses are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawEllipseGrayScale(TestImage image, Graphics2D graphics2d)
+ {
+ drawEllipse(image, graphics2d, ELLIPSE_RADIUS_STEP, new CommonEllipseDrawCallbacks()
+ {
+ /**
+ * Callback function called before each ellipse is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x, int y, int radius, int maxRadius, int index)
+ {
+ // compute grayscale value
+ float gray = radius * 1.0f / maxRadius;
+ // clamp the grayscale value
+ if (gray > 1.0f)
+ {
+ gray = 1.0f;
+ }
+ // set ellipse color
+ this.graphics.setColor(GrayscalePalette.createGrayscaleColor(gray));
+ return;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test basic behavior of method Graphics.drawOval(). ellipses color are
+ * selected from a grayscale palette.
+ *
+ * @param image
+ * image to which ellipses are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawEllipseGrayScaleInv(TestImage image, Graphics2D graphics2d)
+ {
+ drawEllipse(image, graphics2d, ELLIPSE_RADIUS_STEP, new CommonEllipseDrawCallbacks()
+ {
+ /**
+ * Callback function called before each ellipse is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x, int y, int radius, int maxRadius, int index)
+ {
+ // compute grayscale value
+ float gray = 1.0f - radius * 1.0f / maxRadius;
+ // clamp the grayscale value
+ if (gray < 0.0f)
+ {
+ gray = 0.0f;
+ }
+ // set ellipse color
+ this.graphics.setColor(GrayscalePalette.createGrayscaleColor(gray));
+ return;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test basic behavior of method Graphics.drawOval(). ellipses are rendered
+ * with various width and default end caps. Color of all rendered ellipses
+ * are set to black.
+ *
+ * @param image
+ * image to which ellipses are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawEllipseChangeWidth(TestImage image, Graphics2D graphics2d)
+ {
+ drawEllipse(image, graphics2d, ELLIPSE_RADIUS_STEP << 1, new CommonEllipseDrawCallbacks()
+ {
+ /**
+ * Stroke width which is changed in each iteration.
+ */
+ private float strokeWidth = MIN_STROKE_WIDTH;
+
+ /**
+ * Callback function called before each ellipse is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x, int y, int radius, int maxRadius, int index)
+ {
+ // set stroke width
+ this.graphics.setStroke(new BasicStroke(this.strokeWidth));
+ // and change it for the next iteration
+ changeStrokeWidth();
+ return;
+ }
+
+ /**
+ * Changes stroke width.
+ */
+ private void changeStrokeWidth()
+ {
+ this.strokeWidth = this.strokeWidth < MAX_STROKE_WIDTH ? this.strokeWidth + STROKE_WIDTH_DELTA
+ : this.strokeWidth;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test basic behavior of method Graphics.drawOval(). ellipses are rendered
+ * with various width and end caps set to CAP_BUTT. Join style is set to
+ * bevel style. Color of all rendered ellipses are set to black.
+ *
+ * @param image
+ * image to which ellipses are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawEllipseChangeWidthCapButtJoinBevel(TestImage image, Graphics2D graphics2d)
+ {
+ drawEllipse(image, graphics2d, ELLIPSE_RADIUS_STEP << 1, new CommonEllipseDrawCallbacks()
+ {
+ /**
+ * Stroke width which is changed in each iteration.
+ */
+ private float strokeWidth = MIN_STROKE_WIDTH;
+
+ /**
+ * Callback function called before each ellipse is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x, int y, int radius, int maxRadius, int index)
+ {
+ // set stroke width and style
+ this.graphics
+ .setStroke(new BasicStroke(this.strokeWidth, BasicStroke.CAP_BUTT,
+ BasicStroke.JOIN_BEVEL));
+ // and change it for the next iteration
+ changeStrokeWidth();
+ return;
+ }
+
+ /**
+ * Changes stroke width.
+ */
+ private void changeStrokeWidth()
+ {
+ this.strokeWidth = this.strokeWidth < MAX_STROKE_WIDTH ? this.strokeWidth + STROKE_WIDTH_DELTA
+ : this.strokeWidth;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test basic behavior of method Graphics.drawOval(). ellipses are rendered
+ * with various width and end caps set to CAP_ROUND. Join style is set to
+ * bevel style. Color of all rendered ellipses are set to black.
+ *
+ * @param image
+ * image to which ellipses are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawEllipseChangeWidthCapRoundJoinBevel(TestImage image, Graphics2D graphics2d)
+ {
+ drawEllipse(image, graphics2d, ELLIPSE_RADIUS_STEP << 1, new CommonEllipseDrawCallbacks()
+ {
+ /**
+ * Stroke width which is changed in each iteration.
+ */
+ private float strokeWidth = MIN_STROKE_WIDTH;
+
+ /**
+ * Callback function called before each ellipse is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x, int y, int radius, int maxRadius, int index)
+ {
+ // set stroke width and style
+ this.graphics
+ .setStroke(new BasicStroke(this.strokeWidth, BasicStroke.CAP_ROUND,
+ BasicStroke.JOIN_BEVEL));
+ // and change it for the next iteration
+ changeStrokeWidth();
+ return;
+ }
+
+ /**
+ * Changes stroke width.
+ */
+ private void changeStrokeWidth()
+ {
+ this.strokeWidth = this.strokeWidth < MAX_STROKE_WIDTH ? this.strokeWidth + STROKE_WIDTH_DELTA
+ : this.strokeWidth;
+ }
+ });
+
+ // test return value
+ return TestResult.PASSED;
+ }
+
+ /**
+ * Test basic behavior of method Graphics.drawOval(). ellipses are rendered
+ * with various width and end caps set to CAP_SQUARE. Join style is set to
+ * bevel style. Color of all rendered ellipses are set to black.
+ *
+ * @param image
+ * image to which ellipses are to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testDrawEllipseChangeWidthCapSquareJoinBevel(TestImage image, Graphics2D graphics2d)
+ {
+ drawEllipse(image, graphics2d, ELLIPSE_RADIUS_STEP << 1, new CommonEllipseDrawCallbacks()
+ {
+ /**
+ * Stroke width which is changed in each iteration.
+ */
+ private float strokeWidth = MIN_STROKE_WIDTH;
+
+ /**
+ * Callback function called before each ellipse is rendered.
+ */
+ @Override
+ public void iterationCallBack(int x, int y, int radius, int maxRadius, int index)
+ {
+ // set stroke width and style
More information about the distro-pkg-dev
mailing list