You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2008/08/15 16:20:47 UTC

svn commit: r686229 - /xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/

Author: jeremias
Date: Fri Aug 15 07:20:47 2008
New Revision: 686229

URL: http://svn.apache.org/viewvc?rev=686229&view=rev
Log:
Extended to allow generating the renderer and painter PDF alongside each other for visual inspection.

Modified:
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BatchDiffer.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducer.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerJava2D.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerPDF.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerPS.java
    xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java?rev=686229&r1=686228&r2=686229&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java Fri Aug 15 07:20:47 2008
@@ -35,6 +35,7 @@
 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 @@
 
     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 @@
     /**
      * @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);

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BatchDiffer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BatchDiffer.java?rev=686229&r1=686228&r2=686229&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BatchDiffer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BatchDiffer.java Fri Aug 15 07:20:47 2008
@@ -176,7 +176,7 @@
                     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()) {

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducer.java?rev=686229&r1=686228&r2=686229&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducer.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducer.java Fri Aug 15 07:20:47 2008
@@ -31,9 +31,10 @@
      * 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);
 
 }

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerJava2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerJava2D.java?rev=686229&r1=686228&r2=686229&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerJava2D.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerJava2D.java Fri Aug 15 07:20:47 2008
@@ -33,6 +33,7 @@
 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 @@
     }
 
     /** @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 {

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerPDF.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerPDF.java?rev=686229&r1=686228&r2=686229&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerPDF.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerPDF.java Fri Aug 15 07:20:47 2008
@@ -29,14 +29,16 @@
  */
 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";
     }
 
 }

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerPS.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerPS.java?rev=686229&r1=686228&r2=686229&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerPS.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/BitmapProducerPS.java Fri Aug 15 07:20:47 2008
@@ -29,15 +29,16 @@
  */
 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";
     }
 
-
 }

Modified: xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java?rev=686229&r1=686228&r2=686229&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java Fri Aug 15 07:20:47 2008
@@ -51,7 +51,7 @@
     }
 
     /** @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()) {



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org