/hg/gfx-test: New test case - rendering of filled arcs.
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Thu Jul 22 09:28:28 PDT 2010
changeset be2c8cfb62cd in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=be2c8cfb62cd
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Jul 22 18:15:34 2010 +0200
New test case - rendering of filled arcs.
diffstat:
8 files changed, 213 insertions(+), 111 deletions(-)
Makefile | 1
src/org/gfxtest/framework/EntityRenderingStyle.java | 56 +++++++++++-
src/org/gfxtest/framework/GfxTest.java | 68 ++++++++++----
src/org/gfxtest/testsuites/FilledArcs.java | 88 +++++++++++++++++++
src/org/gfxtest/testsuites/FilledEllipses.java | 32 +-----
src/org/gfxtest/testsuites/NormalArcs.java | 2
src/org/gfxtest/testsuites/NormalEllipses.java | 39 +-------
src/org/gfxtest/testsuites/NormalLines.java | 38 +-------
diffs (truncated from 523 to 500 lines):
diff -r e6167048456f -r be2c8cfb62cd Makefile
--- a/Makefile Thu Jul 22 16:27:18 2010 +0200
+++ b/Makefile Thu Jul 22 18:15:34 2010 +0200
@@ -77,6 +77,7 @@ TESTSUITE_CLASSES = \
$(CLASSES)/$(TESTSUITE_DIR)/NormalRectangles.class \
$(CLASSES)/$(TESTSUITE_DIR)/NormalRoundRectangles.class \
$(CLASSES)/$(TESTSUITE_DIR)/Normal3DRectangles.class \
+ $(CLASSES)/$(TESTSUITE_DIR)/FilledArcs.class \
$(CLASSES)/$(TESTSUITE_DIR)/FilledCircles.class \
$(CLASSES)/$(TESTSUITE_DIR)/FilledEllipses.class \
$(CLASSES)/$(TESTSUITE_DIR)/FilledRectangles.class \
diff -r e6167048456f -r be2c8cfb62cd src/org/gfxtest/framework/EntityRenderingStyle.java
--- a/src/org/gfxtest/framework/EntityRenderingStyle.java Thu Jul 22 16:27:18 2010 +0200
+++ b/src/org/gfxtest/framework/EntityRenderingStyle.java Thu Jul 22 18:15:34 2010 +0200
@@ -1,3 +1,43 @@ package org.gfxtest.framework;
+/*
+ Java gfx-test framework
+
+ Copyright (C) 2010 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.framework;
public class EntityRenderingStyle
@@ -8,14 +48,19 @@ public class EntityRenderingStyle
private float scale;
private int arcWidth;
private int arcHeight;
+ private boolean raised;
+ private float eccentricity;
- public EntityRenderingStyle(int cap, int join, float width, int arcWidth, int arcHeight)
+ public EntityRenderingStyle(int cap, int join, float width, float scale, int arcWidth, int arcHeight, boolean raised, float eccentricity)
{
this.cap = cap;
this.join = join;
this.width = width;
+ this.scale = scale;
this.arcWidth = arcWidth;
this.arcHeight = arcHeight;
+ this.raised = raised;
+ this.eccentricity = eccentricity;
}
public int getCap()
@@ -48,4 +93,13 @@ public class EntityRenderingStyle
return this.arcHeight;
}
+ public boolean isRaised()
+ {
+ return this.raised;
+ }
+
+ public float getEccentricity()
+ {
+ return this.eccentricity;
+ }
}
diff -r e6167048456f -r be2c8cfb62cd src/org/gfxtest/framework/GfxTest.java
--- a/src/org/gfxtest/framework/GfxTest.java Thu Jul 22 16:27:18 2010 +0200
+++ b/src/org/gfxtest/framework/GfxTest.java Thu Jul 22 18:15:34 2010 +0200
@@ -65,21 +65,14 @@ public abstract class GfxTest
protected static final int RADIUS_STEP = 30;
+ protected static final int ANGLES = 16;
+
/**
* Offset from image borders used for rendering various graphics entities, for example rectangles.
*/
protected static final int OFFSET = 80;
- /**
- * Write test suite duration to the log file.
- *
- * @param t1 time when the test suite has been started
- * @param t2 time when the test suite was completed
- */
- private void printDuration(long t1, long t2)
- {
- this.log.logSet("duration", Long.valueOf(t2-t1)); //$NON-NLS-1$
- }
+ protected static final int ARC_STEP = 10;
/**
* Default cap style.
@@ -111,7 +104,26 @@ public abstract class GfxTest
*/
protected static final float[] ALL_WIDTHS = { 1.0f, 2.0f, 5.0f, 10.0f, 20.0f, 40.0f };
- private static final int ARC_STEP = 10;
+ /**
+ * Default ellipse eccentricity.
+ */
+ protected static final float[] DEFAULT_ECCENTRICITY = { 1.0f };
+
+ /**
+ * Values used for rendering ellipses and similar geometric shapes.
+ */
+ protected static final float[] ECCENTRICITIES = {1/3.0f, 1/2.5f, 1/2.0f, 1/1.5f, 1.0f, 1.5f, 2.0f, 2.5f, 3.0f};
+
+ /**
+ * Write test suite duration to the log file.
+ *
+ * @param t1 time when the test suite has been started
+ * @param t2 time when the test suite was completed
+ */
+ private void printDuration(long t1, long t2)
+ {
+ this.log.logSet("duration", Long.valueOf(t2-t1)); //$NON-NLS-1$
+ }
/**
* Construct test suite name using full class name.
@@ -194,14 +206,25 @@ public abstract class GfxTest
protected void drawEntityWithVariousStyles(Configuration configuration, boolean changeCap, boolean changeJoin, boolean changeWidth, boolean changeScale, boolean changeDash)
{
- this.drawEntityWithVariousStyles(configuration, changeCap, changeJoin, changeWidth, changeScale, changeDash, 0, 0, 0, 0);
+ this.drawEntityWithVariousStyles(configuration, changeCap, changeJoin, changeWidth, changeScale, changeDash, 0, 0, 0, 0, false);
+ }
+
+ protected void drawEntityWithVariousStyles(Configuration configuration, boolean changeCap, boolean changeJoin, boolean changeWidth, boolean changeScale, boolean changeDash, boolean changeEccentricity)
+ {
+ this.drawEntityWithVariousStyles(configuration, changeCap, changeJoin, changeWidth, changeScale, changeDash, 0, 0, 0, 0, changeEccentricity);
}
protected void drawEntityWithVariousStyles(Configuration configuration, boolean changeCap, boolean changeJoin, boolean changeWidth, boolean changeScale, boolean changeDash, int minArcWidth, int maxArcWidth, int minArcHeight, int maxArcHeight)
{
+ this.drawEntityWithVariousStyles(configuration, changeCap, changeJoin, changeWidth, changeScale, changeDash, minArcWidth, maxArcWidth, minArcHeight, maxArcHeight, false);
+ }
+
+ protected void drawEntityWithVariousStyles(Configuration configuration, boolean changeCap, boolean changeJoin, boolean changeWidth, boolean changeScale, boolean changeDash, int minArcWidth, int maxArcWidth, int minArcHeight, int maxArcHeight, boolean changeEccentricity)
+ {
int[] caps = changeCap ? ALL_CAP_STYLES : DEFAULT_CAP_STYLE;
int[] joins = changeJoin ? ALL_JOIN_STYLES : DEFAULT_JOIN_STYLE;
float[] widths = changeWidth ? ALL_WIDTHS : DEFAULT_WIDTH;
+ float[] eccentricities = changeEccentricity ? ECCENTRICITIES : DEFAULT_ECCENTRICITY;
int testNumber = 0;
for (int cap : caps)
{
@@ -209,12 +232,20 @@ public abstract class GfxTest
{
for (float width : widths)
{
- for (int arcHeight = minArcHeight; arcHeight <= maxArcHeight; arcHeight += ARC_STEP)
+ for (float eccentricity : eccentricities)
{
- for (int arcWidth = minArcWidth; arcWidth <= maxArcWidth; arcWidth += ARC_STEP)
+ for (int arcHeight = minArcHeight; arcHeight <= maxArcHeight; arcHeight += ARC_STEP)
{
- performOneTest(configuration, testNumber, cap, join, width, arcHeight, arcWidth);
- testNumber++;
+ for (int arcWidth = minArcWidth; arcWidth <= maxArcWidth; arcWidth += ARC_STEP)
+ {
+ /*
+ * TODO: add support to various scales and dashes
+ */
+ EntityRenderingStyle entityRenderingStyle = new EntityRenderingStyle(cap, join, width,
+ 1.0f, arcHeight, arcWidth, false, eccentricity);
+ performOneTest(configuration, testNumber, entityRenderingStyle);
+ testNumber++;
+ }
}
}
}
@@ -222,15 +253,12 @@ public abstract class GfxTest
}
}
- private void performOneTest(Configuration configuration, int testNumber, int cap, int join, float width,
- int arcHeight, int arcWidth)
+ private void performOneTest(Configuration configuration, int testNumber, EntityRenderingStyle entityRenderingStyle)
{
String testName = "test" + testNumber; //$NON-NLS-1$
this.log.logBegin(testName);
TestImage image = new TestImage(configuration);
Graphics2D graphics = image.getGraphics();
- /* TODO: add support to various scales and dashes */
- EntityRenderingStyle entityRenderingStyle = new EntityRenderingStyle(cap, join, width, arcHeight, arcWidth);
logCurrentRenderingStyle(entityRenderingStyle);
drawEntity(image, graphics, testNumber, entityRenderingStyle);
graphics.dispose();
diff -r e6167048456f -r be2c8cfb62cd src/org/gfxtest/testsuites/FilledArcs.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/testsuites/FilledArcs.java Thu Jul 22 18:15:34 2010 +0200
@@ -0,0 +1,88 @@
+/*
+ Java gfx-test framework
+
+ Copyright (C) 2010 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.*;
+
+import org.gfxtest.framework.*;
+import org.gfxtest.framework.annotations.*;
+
+/**
+ * This test renders filled arcs using identity transformation matrix.
+ *
+ * @author Pavel Tisnovsky
+ */
+ at TestType(TestTypes.RENDER_TEST)
+ at GraphicsPrimitive(GraphicsPrimitives.ARC)
+ at RenderStyle(RenderStyles.FILL)
+ at Transformation(Transformations.NONE)
+public class FilledArcs extends GfxTest
+{
+
+ @Override
+ protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, EntityRenderingStyle entityRenderingStyle)
+ {
+ graphics.setStroke(new BasicStroke(entityRenderingStyle.getWidth(), entityRenderingStyle.getCap(), entityRenderingStyle.getJoin()));
+ int xc = image.getCenterX();
+ int yc = image.getCenterY();
+ int majorRadius = (xc > yc ? yc : xc) - 20;
+
+ for (int radius = majorRadius; radius >= MINOR_RADIUS; radius -= RADIUS_STEP)
+ {
+ double r = ((double) radius - MINOR_RADIUS) / (majorRadius - MINOR_RADIUS);
+ Color color = new Color(Color.HSBtoRGB((float)r, 1.0f, 1.0f));
+ graphics.setColor(color);
+ graphics.fillArc(xc - radius, yc - radius, radius << 1, radius << 1, (int) (r * 360.0), 180);
+ }
+ drawCross(graphics, xc, yc, CROSS_SIZE);
+ }
+
+ @Override
+ protected void runOtherTests(Configuration configuration)
+ {
+ drawEntityWithVariousStyles(configuration, true, true, true, false, false);
+ }
+
+ public static void main(String[] args)
+ {
+ new FilledArcs().runTestSuite(args);
+ }
+}
diff -r e6167048456f -r be2c8cfb62cd src/org/gfxtest/testsuites/FilledEllipses.java
--- a/src/org/gfxtest/testsuites/FilledEllipses.java Thu Jul 22 16:27:18 2010 +0200
+++ b/src/org/gfxtest/testsuites/FilledEllipses.java Thu Jul 22 18:15:34 2010 +0200
@@ -41,7 +41,6 @@ package org.gfxtest.testsuites;
package org.gfxtest.testsuites;
import java.awt.*;
-import java.io.IOException;
import org.gfxtest.framework.*;
import org.gfxtest.framework.annotations.*;
@@ -58,8 +57,10 @@ public class FilledEllipses extends GfxT
public class FilledEllipses extends GfxTest
{
- protected void drawFilledEllipse(TestImage image, Graphics2D graphics, float eccentricity)
+ @Override
+ protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, EntityRenderingStyle entityRenderingStyle)
{
+ graphics.setStroke(new BasicStroke(entityRenderingStyle.getWidth(), entityRenderingStyle.getCap(), entityRenderingStyle.getJoin()));
int xc = image.getCenterX();
int yc = image.getCenterY();
double rmaj = (xc > yc ? yc : xc) - (MAJOR_RADIUS - MINOR_RADIUS);
@@ -72,36 +73,17 @@ public class FilledEllipses extends GfxT
int x = (int) (xc + rmaj * Math.cos(angle));
int y = (int) (yc + rmaj * Math.sin(angle));
float radius = MINOR_RADIUS + m * (MAJOR_RADIUS - MINOR_RADIUS);
- int rx = (int)(radius * eccentricity);
- int ry = (int)(radius / eccentricity);
+ int rx = (int)(radius * entityRenderingStyle.getEccentricity());
+ int ry = (int)(radius / entityRenderingStyle.getEccentricity());
graphics.fillOval(x - rx, y - ry, rx << 1, ry << 1);
}
drawCross(graphics, xc, yc, CROSS_SIZE);
}
+ @Override
protected void runOtherTests(Configuration configuration)
{
- float[] eccentricities = {1/3.0f, 1/2.5f, 1/2.0f, 1/1.5f, 1.0f, 1.5f, 2.0f, 2.5f, 3.0f};
- int testNumber = 0;
- for (float eccentricity : eccentricities)
- {
- String testName = "test" + testNumber;
- log.logBegin(testName);
- TestImage image = new TestImage(configuration);
- Graphics2D graphics = (Graphics2D) image.getGraphics();
- drawFilledEllipse(image, graphics, eccentricity);
- graphics.dispose();
- try
- {
- image.writeImage(configuration, suiteName, testName);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- log.logEnd(testName);
- testNumber++;
- }
+ drawEntityWithVariousStyles(configuration, false, false, false, false, false, true);
}
public static void main(String[] args)
diff -r e6167048456f -r be2c8cfb62cd src/org/gfxtest/testsuites/NormalArcs.java
--- a/src/org/gfxtest/testsuites/NormalArcs.java Thu Jul 22 16:27:18 2010 +0200
+++ b/src/org/gfxtest/testsuites/NormalArcs.java Thu Jul 22 18:15:34 2010 +0200
@@ -46,7 +46,7 @@ import org.gfxtest.framework.annotations
import org.gfxtest.framework.annotations.*;
/**
- * This test renders arcs using identity transformation matrix.
+ * This test renders empty arcs using identity transformation matrix.
*
* @author Pavel Tisnovsky
*/
diff -r e6167048456f -r be2c8cfb62cd src/org/gfxtest/testsuites/NormalEllipses.java
--- a/src/org/gfxtest/testsuites/NormalEllipses.java Thu Jul 22 16:27:18 2010 +0200
+++ b/src/org/gfxtest/testsuites/NormalEllipses.java Thu Jul 22 18:15:34 2010 +0200
@@ -41,7 +41,6 @@ package org.gfxtest.testsuites;
package org.gfxtest.testsuites;
import java.awt.*;
-import java.io.IOException;
import org.gfxtest.framework.*;
import org.gfxtest.framework.annotations.*;
@@ -58,11 +57,10 @@ public class NormalEllipses extends GfxT
public class NormalEllipses extends GfxTest
{
- private void drawEllipse(TestImage image, Graphics2D graphics, float width, float eccentricity)
+ @Override
+ protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, EntityRenderingStyle entityRenderingStyle)
{
- graphics.setStroke(new BasicStroke(width, // width
- BasicStroke.JOIN_MITER, // cap
- BasicStroke.JOIN_BEVEL)); // join
+ graphics.setStroke(new BasicStroke(entityRenderingStyle.getWidth(), entityRenderingStyle.getCap(), entityRenderingStyle.getJoin()));
int xc = image.getCenterX();
int yc = image.getCenterY();
double rmaj = (xc > yc ? yc : xc) - (MAJOR_RADIUS - MINOR_RADIUS);
@@ -75,40 +73,17 @@ public class NormalEllipses extends GfxT
int x = (int) (xc + rmaj * Math.cos(angle));
int y = (int) (yc + rmaj * Math.sin(angle));
float radius = MINOR_RADIUS + m * (MAJOR_RADIUS - MINOR_RADIUS);
- int rx = (int)(radius * eccentricity);
- int ry = (int)(radius / eccentricity);
+ int rx = (int)(radius * entityRenderingStyle.getEccentricity());
+ int ry = (int)(radius / entityRenderingStyle.getEccentricity());
graphics.drawOval(x - rx, y - ry, rx << 1, ry << 1);
}
drawCross(graphics, xc, yc, CROSS_SIZE);
}
+ @Override
protected void runOtherTests(Configuration configuration)
{
- float[] eccentricities = {1/3.0f, 1/2.5f, 1/2.0f, 1/1.5f, 1.0f, 1.5f, 2.0f, 2.5f, 3.0f};
- float[] widths = { 1.0f, 2.0f, 5.0f, 10.0f, 20.0f, 40.0f };
- int testNumber = 0;
- for (float eccentricity : eccentricities)
- {
- for (float width : widths)
- {
- String testName = "test" + testNumber;
- log.logBegin(testName);
- TestImage image = new TestImage(configuration);
- Graphics2D graphics = (Graphics2D) image.getGraphics();
- drawEllipse(image, graphics, width, eccentricity);
- graphics.dispose();
- try
- {
- image.writeImage(configuration, suiteName, testName);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- log.logEnd(testName);
- testNumber++;
- }
- }
+ drawEntityWithVariousStyles(configuration, false, false, true, false, false, true);
}
public static void main(String[] args)
diff -r e6167048456f -r be2c8cfb62cd src/org/gfxtest/testsuites/NormalLines.java
--- a/src/org/gfxtest/testsuites/NormalLines.java Thu Jul 22 16:27:18 2010 +0200
+++ b/src/org/gfxtest/testsuites/NormalLines.java Thu Jul 22 18:15:34 2010 +0200
@@ -41,7 +41,6 @@ package org.gfxtest.testsuites;
package org.gfxtest.testsuites;
import java.awt.*;
-import java.io.IOException;
import org.gfxtest.framework.*;
import org.gfxtest.framework.annotations.*;
@@ -57,14 +56,12 @@ import org.gfxtest.framework.annotations
@Transformation(Transformations.NONE)
public class NormalLines extends GfxTest
{
- private static final int MINOR_RADIUS = 50;
- private static final int ANGLES = 16;
+ protected static final int LINE_MINOR_RADIUS = 50;
- private void drawLines(TestImage image, Graphics2D graphics, float width, int cap)
+ @Override
+ protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, EntityRenderingStyle entityRenderingStyle)
{
- graphics.setStroke(new BasicStroke(width, // width
- cap, // cap
- BasicStroke.JOIN_ROUND)); // join
+ graphics.setStroke(new BasicStroke(entityRenderingStyle.getWidth(), entityRenderingStyle.getCap(), entityRenderingStyle.getJoin()));
int xc = image.getCenterX();
int yc = image.getCenterY();
for (int i = 0; i < ANGLES; i++)
@@ -84,33 +81,10 @@ public class NormalLines extends GfxTest
drawCross(graphics, xc, yc, CROSS_SIZE);
}
+ @Override
protected void runOtherTests(Configuration configuration)
{
- float[] widths = { 1.0f, 10.0f, 20.0f, 40.0f, 80.0f };
- int[] caps = { BasicStroke.CAP_SQUARE, BasicStroke.CAP_BUTT, BasicStroke.CAP_ROUND };
- int testNumber = 0;
- for (int cap : caps)
- {
- for (float width : widths)
More information about the distro-pkg-dev
mailing list