aboutsummaryrefslogtreecommitdiffstats
path: root/test/java
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-08-15 14:20:47 +0000
committerJeremias Maerki <jeremias@apache.org>2008-08-15 14:20:47 +0000
commitd18265be9c211b0f4898f983fd41d1da769a7638 (patch)
tree151ead9cf0ef8a2d52662e41aa6109d22153402f /test/java
parenta9507e95620a50c591d2af0aa660c889904a2af8 (diff)
downloadxmlgraphics-fop-d18265be9c211b0f4898f983fd41d1da769a7638.tar.gz
xmlgraphics-fop-d18265be9c211b0f4898f983fd41d1da769a7638.zip
Extended to allow generating the renderer and painter PDF alongside each other for visual inspection.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@686229 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/java')
-rw-r--r--test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java20
-rw-r--r--test/java/org/apache/fop/visual/BatchDiffer.java2
-rw-r--r--test/java/org/apache/fop/visual/BitmapProducer.java3
-rw-r--r--test/java/org/apache/fop/visual/BitmapProducerJava2D.java6
-rw-r--r--test/java/org/apache/fop/visual/BitmapProducerPDF.java14
-rw-r--r--test/java/org/apache/fop/visual/BitmapProducerPS.java15
-rw-r--r--test/java/org/apache/fop/visual/ReferenceBitmapLoader.java2
7 files changed, 38 insertions, 24 deletions
diff --git a/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java b/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java
index 0f842468f..9afe66f9b 100644
--- a/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java
+++ b/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java
@@ -35,6 +35,7 @@ import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.commons.io.IOUtils;
+
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
@@ -70,11 +71,16 @@ public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer
private String converter;
private boolean deleteTempFiles;
+ /** the bitmap producer's target format */
+ protected String targetFormat;
- /** @see org.apache.avalon.framework.configuration.Configurable */
+ /** {@inheritDoc} */
public void configure(Configuration cfg) throws ConfigurationException {
this.converter = cfg.getChild("converter").getValue();
this.deleteTempFiles = cfg.getChild("delete-temp-files").getValueAsBoolean(true);
+ if (cfg.getChild("target-format", false) != null) {
+ this.targetFormat = cfg.getChild("target-format").getValue();
+ }
}
/**
@@ -106,19 +112,21 @@ public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer
/**
* @return the output format for the FOP renderer, i.e. a MIME type.
*/
- protected abstract String getTargetFormat();
+ protected String getTargetFormat() {
+ return this.targetFormat;
+ }
- /** @see org.apache.fop.visual.BitmapProducer */
- public BufferedImage produce(File src, ProducerContext context) {
+ /** {@inheritDoc} */
+ public BufferedImage produce(File src, int index, ProducerContext context) {
try {
FOUserAgent userAgent = fopFactory.newFOUserAgent();
userAgent.setTargetResolution(context.getTargetResolution());
userAgent.setBaseURL(src.getParentFile().toURL().toString());
File tempOut = new File(context.getTargetDir(),
- src.getName() + "." + getTargetExtension());
+ src.getName() + "." + index + "." + getTargetExtension());
File tempPNG = new File(context.getTargetDir(),
- src.getName() + "." + getTargetExtension() + ".png");
+ src.getName() + "." + index + "." + getTargetExtension() + ".png");
try {
OutputStream out = new FileOutputStream(tempOut);
out = new BufferedOutputStream(out);
diff --git a/test/java/org/apache/fop/visual/BatchDiffer.java b/test/java/org/apache/fop/visual/BatchDiffer.java
index e0c78135e..396657bee 100644
--- a/test/java/org/apache/fop/visual/BatchDiffer.java
+++ b/test/java/org/apache/fop/visual/BatchDiffer.java
@@ -176,7 +176,7 @@ public class BatchDiffer {
final BufferedImage[] bitmaps = new BufferedImage[producers.length];
for (int j = 0; j < producers.length; j++) {
times[j] = System.currentTimeMillis();
- bitmaps[j] = producers[j].produce(f, context);
+ bitmaps[j] = producers[j].produce(f, j, context);
times[j] = System.currentTimeMillis() - times[j];
}
if (log.isDebugEnabled()) {
diff --git a/test/java/org/apache/fop/visual/BitmapProducer.java b/test/java/org/apache/fop/visual/BitmapProducer.java
index 6aba0296a..9326656f4 100644
--- a/test/java/org/apache/fop/visual/BitmapProducer.java
+++ b/test/java/org/apache/fop/visual/BitmapProducer.java
@@ -31,9 +31,10 @@ public interface BitmapProducer {
* Produces a BufferedImage from the source file by invoking the FO processor and
* converting the generated output file to a bitmap image if necessary.
* @param src the source FO or XML file
+ * @param index the index of the producer inside the test set
* @param context context information for the conversion
* @return the generated BufferedImage
*/
- BufferedImage produce(File src, ProducerContext context);
+ BufferedImage produce(File src, int index, ProducerContext context);
}
diff --git a/test/java/org/apache/fop/visual/BitmapProducerJava2D.java b/test/java/org/apache/fop/visual/BitmapProducerJava2D.java
index 13f26e022..9d4db6391 100644
--- a/test/java/org/apache/fop/visual/BitmapProducerJava2D.java
+++ b/test/java/org/apache/fop/visual/BitmapProducerJava2D.java
@@ -33,6 +33,7 @@ import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.commons.io.IOUtils;
+
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
@@ -64,13 +65,14 @@ public class BitmapProducerJava2D extends AbstractBitmapProducer implements Conf
}
/** @see org.apache.fop.visual.BitmapProducer */
- public BufferedImage produce(File src, ProducerContext context) {
+ public BufferedImage produce(File src, int index, ProducerContext context) {
try {
FOUserAgent userAgent = fopFactory.newFOUserAgent();
userAgent.setTargetResolution(context.getTargetResolution());
userAgent.setBaseURL(src.getParentFile().toURL().toString());
- File outputFile = new File(context.getTargetDir(), src.getName() + ".java2d.png");
+ File outputFile = new File(context.getTargetDir(),
+ src.getName() + "." + index + ".java2d.png");
OutputStream out = new FileOutputStream(outputFile);
out = new BufferedOutputStream(out);
try {
diff --git a/test/java/org/apache/fop/visual/BitmapProducerPDF.java b/test/java/org/apache/fop/visual/BitmapProducerPDF.java
index a6f667f80..ceede38d2 100644
--- a/test/java/org/apache/fop/visual/BitmapProducerPDF.java
+++ b/test/java/org/apache/fop/visual/BitmapProducerPDF.java
@@ -29,14 +29,16 @@ import org.apache.fop.apps.MimeConstants;
*/
public class BitmapProducerPDF extends AbstractPSPDFBitmapProducer {
- /** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetExtension() */
- protected String getTargetExtension() {
- return "pdf";
+ /**
+ * Default constructor.
+ */
+ public BitmapProducerPDF() {
+ this.targetFormat = MimeConstants.MIME_PDF;
}
- /** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetFormat() */
- protected String getTargetFormat() {
- return MimeConstants.MIME_PDF;
+ /** {@inheritDoc} */
+ protected String getTargetExtension() {
+ return "pdf";
}
}
diff --git a/test/java/org/apache/fop/visual/BitmapProducerPS.java b/test/java/org/apache/fop/visual/BitmapProducerPS.java
index 704cfb950..d711dad16 100644
--- a/test/java/org/apache/fop/visual/BitmapProducerPS.java
+++ b/test/java/org/apache/fop/visual/BitmapProducerPS.java
@@ -29,15 +29,16 @@ import org.apache.fop.apps.MimeConstants;
*/
public class BitmapProducerPS extends AbstractPSPDFBitmapProducer {
- /** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetExtension() */
- protected String getTargetExtension() {
- return "ps";
+ /**
+ * Default constructor.
+ */
+ public BitmapProducerPS() {
+ this.targetFormat = MimeConstants.MIME_POSTSCRIPT;
}
- /** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetFormat() */
- protected String getTargetFormat() {
- return MimeConstants.MIME_POSTSCRIPT;
+ /** {@inheritDoc} */
+ protected String getTargetExtension() {
+ return "ps";
}
-
}
diff --git a/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java b/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java
index 07db62fc9..3955b3425 100644
--- a/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java
+++ b/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java
@@ -51,7 +51,7 @@ public class ReferenceBitmapLoader extends AbstractBitmapProducer implements Con
}
/** @see org.apache.fop.visual.BitmapProducer */
- public BufferedImage produce(File src, ProducerContext context) {
+ public BufferedImage produce(File src, int index, ProducerContext context) {
try {
File bitmap = new File(bitmapDirectory, src.getName() + ".png");
if (bitmap.exists()) {