diff options
Diffstat (limited to 'test/java/org/apache/fop/visual')
14 files changed, 75 insertions, 75 deletions
diff --git a/test/java/org/apache/fop/visual/AbstractBitmapProducer.java b/test/java/org/apache/fop/visual/AbstractBitmapProducer.java index 4093f4d94..44061e082 100644 --- a/test/java/org/apache/fop/visual/AbstractBitmapProducer.java +++ b/test/java/org/apache/fop/visual/AbstractBitmapProducer.java @@ -32,14 +32,14 @@ public abstract class AbstractBitmapProducer implements BitmapProducer { /** Logger */ protected static Log log = LogFactory.getLog(AbstractBitmapProducer.class); - + /** * Returns a new JAXP Transformer based on information in the ProducerContext. * @param context context information for the process * @return a new Transformer instance (identity or set up with a stylesheet) * @throws TransformerConfigurationException in case creating the Transformer fails. */ - protected Transformer getTransformer(ProducerContext context) + protected Transformer getTransformer(ProducerContext context) throws TransformerConfigurationException { if (context.getTemplates() != null) { return context.getTemplates().newTransformer(); @@ -47,5 +47,5 @@ public abstract class AbstractBitmapProducer implements BitmapProducer { return context.getTransformerFactory().newTransformer(); } } - + } diff --git a/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java b/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java index 216a4466e..0f842468f 100644 --- a/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java +++ b/test/java/org/apache/fop/visual/AbstractPSPDFBitmapProducer.java @@ -40,7 +40,7 @@ import org.apache.fop.apps.Fop; import org.apache.fop.apps.FopFactory; /** - * BitmapProducer implementation that uses the PS or PDF renderer and an external converter + * BitmapProducer implementation that uses the PS or PDF renderer and an external converter * to create bitmaps. * <p> * Here's what the configuration element looks like for the class: @@ -52,7 +52,7 @@ import org.apache.fop.apps.FopFactory; * </producer> * </pre> * <p> - * You will notice the three parameters in curly braces (java.util.MessageFormat style) to the + * You will notice the three parameters in curly braces (java.util.MessageFormat style) to the * converter call: * <ul> * <li>0: the input file @@ -62,15 +62,15 @@ import org.apache.fop.apps.FopFactory; * <p> * The "delete-temp-files" element is optional and defaults to true. */ -public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer +public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer implements Configurable { // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - + private String converter; private boolean deleteTempFiles; - + /** @see org.apache.avalon.framework.configuration.Configurable */ public void configure(Configuration cfg) throws ConfigurationException { this.converter = cfg.getChild("converter").getValue(); @@ -86,9 +86,9 @@ public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer */ public void convert(File inFile, File outFile, ProducerContext context) throws IOException { outFile.delete(); - + //Build command-line - String cmd = MessageFormat.format(converter, + String cmd = MessageFormat.format(converter, new Object[] {inFile.toString(), outFile.toString(), Integer.toString(context.getTargetResolution())}); ConvertUtils.convert(cmd, null, null, log); @@ -97,17 +97,17 @@ public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer throw new IOException("The target file has not been generated"); } } - + /** - * @return the native extension generated by the output format, ex. "ps" or "pdf". + * @return the native extension generated by the output format, ex. "ps" or "pdf". */ protected abstract String getTargetExtension(); - + /** * @return the output format for the FOP renderer, i.e. a MIME type. */ protected abstract String getTargetFormat(); - + /** @see org.apache.fop.visual.BitmapProducer */ public BufferedImage produce(File src, ProducerContext context) { try { @@ -115,9 +115,9 @@ public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer userAgent.setTargetResolution(context.getTargetResolution()); userAgent.setBaseURL(src.getParentFile().toURL().toString()); - File tempOut = new File(context.getTargetDir(), + File tempOut = new File(context.getTargetDir(), src.getName() + "." + getTargetExtension()); - File tempPNG = new File(context.getTargetDir(), + File tempPNG = new File(context.getTargetDir(), src.getName() + "." + getTargetExtension() + ".png"); try { OutputStream out = new FileOutputStream(tempOut); @@ -125,13 +125,13 @@ public abstract class AbstractPSPDFBitmapProducer extends AbstractBitmapProducer try { Fop fop = fopFactory.newFop(getTargetFormat(), userAgent, out); SAXResult res = new SAXResult(fop.getDefaultHandler()); - + Transformer transformer = getTransformer(context); transformer.transform(new StreamSource(src), res); } finally { IOUtils.closeQuietly(out); } - + convert(tempOut, tempPNG, context); BufferedImage img = BitmapComparator.getImage(tempPNG); return img; diff --git a/test/java/org/apache/fop/visual/AbstractRedirectorLineHandler.java b/test/java/org/apache/fop/visual/AbstractRedirectorLineHandler.java index 5b397c5f9..344d3199e 100644 --- a/test/java/org/apache/fop/visual/AbstractRedirectorLineHandler.java +++ b/test/java/org/apache/fop/visual/AbstractRedirectorLineHandler.java @@ -23,7 +23,7 @@ package org.apache.fop.visual; * Abstract base implementation for a RedirectorLineHandler which provides empty notifyStart() * and notifyEnd() methods. */ -public abstract class AbstractRedirectorLineHandler +public abstract class AbstractRedirectorLineHandler implements RedirectorLineHandler { /** @see org.apache.fop.visual.RedirectorLineHandler#notifyStart() */ diff --git a/test/java/org/apache/fop/visual/BatchDiffer.java b/test/java/org/apache/fop/visual/BatchDiffer.java index c2faba37b..e0c78135e 100644 --- a/test/java/org/apache/fop/visual/BatchDiffer.java +++ b/test/java/org/apache/fop/visual/BatchDiffer.java @@ -89,7 +89,7 @@ import org.apache.fop.layoutengine.LayoutEngineTestSuite; * source files with. Default: no stylesheet, identity transform. * <p> * The "producers" element contains a list of producer implementations with configuration. - * The "classname" attribute specifies the fully qualified class name for the implementation. + * The "classname" attribute specifies the fully qualified class name for the implementation. */ public class BatchDiffer { @@ -114,7 +114,7 @@ public class BatchDiffer { * @throws SAXException In case of a problem during SAX processing * @throws IOException In case of a I/O problem */ - public void runBatch(File cfgFile) + public void runBatch(File cfgFile) throws ConfigurationException, SAXException, IOException { DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder(); Configuration cfg = cfgBuilder.buildFromFile(cfgFile); @@ -141,7 +141,7 @@ public class BatchDiffer { } } BitmapProducer[] producers = getProducers(cfg.getChild("producers")); - + //Set up directories File srcDir = new File(cfg.getChild("source-directory").getValue()); if (!srcDir.exists()) { @@ -153,12 +153,12 @@ public class BatchDiffer { throw new RuntimeException("target-directory is invalid: " + targetDir); } context.setTargetDir(targetDir); - + boolean stopOnException = cfg.getChild("stop-on-exception").getValueAsBoolean(true); final boolean createDiffs = cfg.getChild("create-diffs").getValueAsBoolean(true); - + //RUN! - + IOFileFilter filter = new SuffixFileFilter(new String[] {".xml", ".fo"}); //Same filtering as in layout engine tests if (cfg.getChild("filter-disabled").getValueAsBoolean(true)) { @@ -191,10 +191,10 @@ public class BatchDiffer { } //Create combined image if (bitmaps[0] == null) { - throw new RuntimeException("First producer didn't return a bitmap for " + throw new RuntimeException("First producer didn't return a bitmap for " + f + ". Cannot continue."); } - + Runnable runnable = new Runnable() { public void run() { try { @@ -226,11 +226,11 @@ public class BatchDiffer { throw new RuntimeException("Error while configuring BatchDiffer: " + e.getMessage()); } } - + private void saveBitmaps(File targetDir, File srcFile, boolean createDiffs, BufferedImage[] bitmaps) throws IOException { BufferedImage combined = BitmapComparator.buildCompareImage(bitmaps); - + //Save combined bitmap as PNG file File outputFile = new File(targetDir, srcFile.getName() + "._combined.png"); ImageWriterUtil.saveAsPNG(combined, outputFile); @@ -244,7 +244,7 @@ public class BatchDiffer { } } } - + private BitmapProducer[] getProducers(Configuration cfg) { Configuration[] children = cfg.getChildren("producer"); BitmapProducer[] producers = new BitmapProducer[children.length]; @@ -260,7 +260,7 @@ public class BatchDiffer { } return producers; } - + /** * Main method. * @param args command-line arguments @@ -278,16 +278,16 @@ public class BatchDiffer { printUsage(); System.exit(-1); } - + Thread.currentThread().setPriority(Thread.MIN_PRIORITY); BatchDiffer differ = new BatchDiffer(); differ.runBatch(cfgFile); - + System.out.println("Regular exit..."); } catch (Exception e) { System.out.println("Exception caught..."); e.printStackTrace(); } } - + } diff --git a/test/java/org/apache/fop/visual/BitmapComparator.java b/test/java/org/apache/fop/visual/BitmapComparator.java index 70a627d7e..650554f37 100644 --- a/test/java/org/apache/fop/visual/BitmapComparator.java +++ b/test/java/org/apache/fop/visual/BitmapComparator.java @@ -39,8 +39,8 @@ import org.apache.commons.io.IOUtils; /** * Helper class to visually compare two bitmap images. * <p> - * This class was created by extracting reusable code from - * org.apache.batik.test.util.ImageCompareText (Apache Batik) + * This class was created by extracting reusable code from + * org.apache.batik.test.util.ImageCompareText (Apache Batik) * into this separate class. * <p> * TODO Move as utility class to XML Graphics Commons when possible @@ -51,7 +51,7 @@ public class BitmapComparator { * Builds a new BufferedImage that is the difference between the two input images * @param ref the reference bitmap * @param gen the newly generated bitmap - * @return the diff bitmap + * @return the diff bitmap */ public static BufferedImage buildDiffImage(BufferedImage ref, BufferedImage gen) { @@ -104,7 +104,7 @@ public class BitmapComparator { ColorModel cm = gen.getColorModel(); cm = GraphicsUtil.coerceData(genWR, cm, false); } - + if (!refPre) { ColorModel cm = ref.getColorModel(); cm = GraphicsUtil.coerceData(refWR, cm, false); @@ -114,14 +114,14 @@ public class BitmapComparator { } /** - * Builds a combined image that places a number of images next to each other for - * manual, visual comparison. + * Builds a combined image that places a number of images next to each other for + * manual, visual comparison. * @param images the array of bitmaps * @return the combined image */ public static BufferedImage buildCompareImage(BufferedImage[] images) { BufferedImage cmp = new BufferedImage( - images[0].getWidth() * images.length, + images[0].getWidth() * images.length, images[0].getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g = cmp.createGraphics(); @@ -145,8 +145,8 @@ public class BitmapComparator { } /** - * Builds a combined image that places two images next to each other for - * manual, visual comparison. + * Builds a combined image that places two images next to each other for + * manual, visual comparison. * @param ref the reference image * @param gen the actual image * @return the combined image @@ -155,7 +155,7 @@ public class BitmapComparator { BufferedImage gen) { return buildCompareImage(new BufferedImage[] {ref, gen}); } - + /** * Loads an image from a URL * @param url the URL to the image @@ -173,7 +173,7 @@ public class BitmapComparator { if (red == null) { return null; } - + BufferedImage img = new BufferedImage(red.getWidth(), red.getHeight(), BufferedImage.TYPE_INT_ARGB); @@ -192,7 +192,7 @@ public class BitmapComparator { InputStream in = new java.io.FileInputStream(bitmapFile); try { in = new java.io.BufferedInputStream(in); - + ImageTagRegistry reg = ImageTagRegistry.getRegistry(); Filter filt = reg.readStream(in); if (filt == null) { @@ -203,7 +203,7 @@ public class BitmapComparator { if (red == null) { return null; } - + BufferedImage img = new BufferedImage(red.getWidth(), red.getHeight(), BufferedImage.TYPE_INT_ARGB); diff --git a/test/java/org/apache/fop/visual/BitmapProducer.java b/test/java/org/apache/fop/visual/BitmapProducer.java index 4a16bd276..6aba0296a 100644 --- a/test/java/org/apache/fop/visual/BitmapProducer.java +++ b/test/java/org/apache/fop/visual/BitmapProducer.java @@ -35,5 +35,5 @@ public interface BitmapProducer { * @return the generated BufferedImage */ BufferedImage produce(File src, ProducerContext context); - + } diff --git a/test/java/org/apache/fop/visual/BitmapProducerJava2D.java b/test/java/org/apache/fop/visual/BitmapProducerJava2D.java index c445fe078..13f26e022 100644 --- a/test/java/org/apache/fop/visual/BitmapProducerJava2D.java +++ b/test/java/org/apache/fop/visual/BitmapProducerJava2D.java @@ -55,7 +55,7 @@ public class BitmapProducerJava2D extends AbstractBitmapProducer implements Conf // configure fopFactory as desired private FopFactory fopFactory = FopFactory.newInstance(); - + private boolean deleteTempFiles; /** @see org.apache.avalon.framework.configuration.Configurable */ @@ -69,20 +69,20 @@ public class BitmapProducerJava2D extends AbstractBitmapProducer implements Conf FOUserAgent userAgent = fopFactory.newFOUserAgent(); userAgent.setTargetResolution(context.getTargetResolution()); userAgent.setBaseURL(src.getParentFile().toURL().toString()); - + File outputFile = new File(context.getTargetDir(), src.getName() + ".java2d.png"); OutputStream out = new FileOutputStream(outputFile); out = new BufferedOutputStream(out); try { Fop fop = fopFactory.newFop(MimeConstants.MIME_PNG, userAgent, out); SAXResult res = new SAXResult(fop.getDefaultHandler()); - + Transformer transformer = getTransformer(context); transformer.transform(new StreamSource(src), res); } finally { IOUtils.closeQuietly(out); } - + BufferedImage img = BitmapComparator.getImage(outputFile); if (deleteTempFiles) { if (!outputFile.delete()) { diff --git a/test/java/org/apache/fop/visual/BitmapProducerPDF.java b/test/java/org/apache/fop/visual/BitmapProducerPDF.java index a7f2f1849..a6f667f80 100644 --- a/test/java/org/apache/fop/visual/BitmapProducerPDF.java +++ b/test/java/org/apache/fop/visual/BitmapProducerPDF.java @@ -22,7 +22,7 @@ package org.apache.fop.visual; import org.apache.fop.apps.MimeConstants; /** - * BitmapProducer implementation that uses the PDFRenderer and an external converter + * BitmapProducer implementation that uses the PDFRenderer and an external converter * to create bitmaps. * <p> * See the superclass' javadoc for info on the configuration format. @@ -33,10 +33,10 @@ public class BitmapProducerPDF extends AbstractPSPDFBitmapProducer { protected String getTargetExtension() { return "pdf"; } - + /** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetFormat() */ protected String getTargetFormat() { return MimeConstants.MIME_PDF; } - + } diff --git a/test/java/org/apache/fop/visual/BitmapProducerPS.java b/test/java/org/apache/fop/visual/BitmapProducerPS.java index a60346254..704cfb950 100644 --- a/test/java/org/apache/fop/visual/BitmapProducerPS.java +++ b/test/java/org/apache/fop/visual/BitmapProducerPS.java @@ -22,7 +22,7 @@ package org.apache.fop.visual; import org.apache.fop.apps.MimeConstants; /** - * BitmapProducer implementation that uses the PSRenderer and an external converter + * BitmapProducer implementation that uses the PSRenderer and an external converter * to create bitmaps. * <p> * See the superclass' javadoc for info on the configuration format. @@ -33,11 +33,11 @@ public class BitmapProducerPS extends AbstractPSPDFBitmapProducer { protected String getTargetExtension() { return "ps"; } - + /** @see org.apache.fop.visual.AbstractPSPDFBitmapProducer#getTargetFormat() */ protected String getTargetFormat() { return MimeConstants.MIME_POSTSCRIPT; } - + } diff --git a/test/java/org/apache/fop/visual/ConvertUtils.java b/test/java/org/apache/fop/visual/ConvertUtils.java index cdfa0efb1..e83322f90 100644 --- a/test/java/org/apache/fop/visual/ConvertUtils.java +++ b/test/java/org/apache/fop/visual/ConvertUtils.java @@ -32,14 +32,14 @@ public class ConvertUtils { /** * Calls an external converter application (GhostScript, for example). * @param cmd the full command - * @param envp array of strings, each element of which has environment variable settings + * @param envp array of strings, each element of which has environment variable settings * in format name=value. - * @param workDir the working directory of the subprocess, or null if the subprocess should + * @param workDir the working directory of the subprocess, or null if the subprocess should * inherit the working directory of the current process. * @param log the logger to log output by the external application to * @throws IOException in case the external call fails */ - public static void convert(String cmd, String[] envp, File workDir, final Log log) + public static void convert(String cmd, String[] envp, File workDir, final Log log) throws IOException { log.debug(cmd); @@ -53,7 +53,7 @@ public class ConvertUtils { log.error("ERR> " + line); } }; - StreamRedirector errorRedirector + StreamRedirector errorRedirector = new StreamRedirector(process.getErrorStream(), errorHandler); //Redirect stdout output @@ -62,11 +62,11 @@ public class ConvertUtils { log.debug("OUT> " + line); } }; - StreamRedirector outputRedirector + StreamRedirector outputRedirector = new StreamRedirector(process.getInputStream(), outputHandler); new Thread(errorRedirector).start(); new Thread(outputRedirector).start(); - + process.waitFor(); } catch (java.lang.InterruptedException ie) { throw new IOException("The call to the external converter failed: " + ie.getMessage()); @@ -76,11 +76,11 @@ public class ConvertUtils { int exitValue = process.exitValue(); if (exitValue != 0) { - throw new IOException("The call to the external converter failed. Result: " + throw new IOException("The call to the external converter failed. Result: " + exitValue); } } - - + + } diff --git a/test/java/org/apache/fop/visual/ProducerContext.java b/test/java/org/apache/fop/visual/ProducerContext.java index 11e103a73..214820c82 100644 --- a/test/java/org/apache/fop/visual/ProducerContext.java +++ b/test/java/org/apache/fop/visual/ProducerContext.java @@ -33,7 +33,7 @@ public class ProducerContext { private Templates templates; private int targetResolution; private File targetDir; - + /** * @return the TransformerFactory to be used. */ @@ -43,7 +43,7 @@ public class ProducerContext { } return tFactory; } - + /** * @return the requested bitmap resolution in dpi for all bitmaps. */ @@ -73,14 +73,14 @@ public class ProducerContext { public void setTemplates(Templates templates) { this.templates = templates; } - + /** * @return the target directory for all produced bitmaps */ public File getTargetDir() { return targetDir; } - + /** * Sets the target directory for all produced bitmaps. * @param targetDir the target directory diff --git a/test/java/org/apache/fop/visual/RedirectorLineHandler.java b/test/java/org/apache/fop/visual/RedirectorLineHandler.java index d77870397..017dcbe5b 100644 --- a/test/java/org/apache/fop/visual/RedirectorLineHandler.java +++ b/test/java/org/apache/fop/visual/RedirectorLineHandler.java @@ -34,7 +34,7 @@ public interface RedirectorLineHandler { * @param line a line of application output */ void handleLine(String line); - + /** * Called after the last handleLine() call. */ diff --git a/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java b/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java index 1d03e0f95..07db62fc9 100644 --- a/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java +++ b/test/java/org/apache/fop/visual/ReferenceBitmapLoader.java @@ -41,7 +41,7 @@ import org.apache.avalon.framework.configuration.ConfigurationException; public class ReferenceBitmapLoader extends AbstractBitmapProducer implements Configurable { private File bitmapDirectory; - + /** @see org.apache.avalon.framework.configuration.Configurable */ public void configure(Configuration cfg) throws ConfigurationException { this.bitmapDirectory = new File(cfg.getChild("directory").getValue(null)); diff --git a/test/java/org/apache/fop/visual/StreamRedirector.java b/test/java/org/apache/fop/visual/StreamRedirector.java index c96cf6c42..918f5bf5c 100644 --- a/test/java/org/apache/fop/visual/StreamRedirector.java +++ b/test/java/org/apache/fop/visual/StreamRedirector.java @@ -42,14 +42,14 @@ public class StreamRedirector implements Runnable { this.in = in; this.handler = handler; } - + /** * @return true if the run() method was terminated by an exception. */ public boolean hasFailed() { return (this.exception != null); } - + /** * @return the exception if the run() method was terminated by an exception, or null */ |