aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/bitmap
diff options
context:
space:
mode:
authorPeter Hancock <phancock@apache.org>2012-06-29 11:22:42 +0000
committerPeter Hancock <phancock@apache.org>2012-06-29 11:22:42 +0000
commit3e31e071ea47f37ef7f8749b324dfdfe76745d18 (patch)
tree7d3b646c521349634592b62556a8832ec082cc9c /src/java/org/apache/fop/render/bitmap
parentae8a5035235e1262e412e1eacd0eb3adfaef83ef (diff)
parent015538e0f11f031e3d7bd05db8c29e2a40365678 (diff)
downloadxmlgraphics-fop-3e31e071ea47f37ef7f8749b324dfdfe76745d18.tar.gz
xmlgraphics-fop-3e31e071ea47f37ef7f8749b324dfdfe76745d18.zip
Merged trunk@1354651
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_RoundedCorners@1355321 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/bitmap')
-rw-r--r--src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java4
-rw-r--r--src/java/org/apache/fop/render/bitmap/BitmapRendererConfigurator.java14
-rw-r--r--src/java/org/apache/fop/render/bitmap/PNGDocumentHandler.java4
-rw-r--r--src/java/org/apache/fop/render/bitmap/PNGRenderer.java8
-rw-r--r--src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java2
-rw-r--r--src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java4
-rw-r--r--src/java/org/apache/fop/render/bitmap/TIFFRenderer.java28
-rw-r--r--src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java2
8 files changed, 37 insertions, 29 deletions
diff --git a/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java b/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java
index 0577a737a..0c6ebde56 100644
--- a/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java
+++ b/src/java/org/apache/fop/render/bitmap/AbstractBitmapDocumentHandler.java
@@ -40,7 +40,6 @@ import org.apache.fop.apps.FopFactoryConfigurator;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.render.intermediate.AbstractBinaryWritingIFDocumentHandler;
import org.apache.fop.render.intermediate.IFContext;
-import org.apache.fop.render.intermediate.IFDocumentHandler;
import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator;
import org.apache.fop.render.intermediate.IFException;
import org.apache.fop.render.intermediate.IFPainter;
@@ -48,7 +47,8 @@ import org.apache.fop.render.java2d.Java2DPainter;
import org.apache.fop.render.java2d.Java2DUtil;
/**
- * Abstract {@link IFDocumentHandler} implementation for producing bitmap images.
+ * Abstract {@link org.apache.fop.render.intermediate.IFDocumentHandler} implementation
+ * for producing bitmap images.
*/
public abstract class AbstractBitmapDocumentHandler extends AbstractBinaryWritingIFDocumentHandler {
diff --git a/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigurator.java b/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigurator.java
index 1b6c43700..2ca0a172b 100644
--- a/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/bitmap/BitmapRendererConfigurator.java
@@ -19,7 +19,6 @@
package org.apache.fop.render.bitmap;
-import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.List;
@@ -115,13 +114,13 @@ public class BitmapRendererConfigurator extends Java2DRendererConfigurator
/** {@inheritDoc} */
public void setupFontInfo(IFDocumentHandler documentHandler, FontInfo fontInfo)
throws FOPException {
- FontManager fontManager = userAgent.getFactory().getFontManager();
+ final FontManager fontManager = userAgent.getFactory().getFontManager();
- Graphics2D graphics2D = Java2DFontMetrics.createFontMetricsGraphics2D();
+ final Java2DFontMetrics java2DFontMetrics = new Java2DFontMetrics();
- List fontCollections = new java.util.ArrayList();
- fontCollections.add(new Base14FontCollection(graphics2D));
- fontCollections.add(new InstalledFontCollection(graphics2D));
+ final List fontCollections = new java.util.ArrayList();
+ fontCollections.add(new Base14FontCollection(java2DFontMetrics));
+ fontCollections.add(new InstalledFontCollection(java2DFontMetrics));
Configuration cfg = super.getRendererConfig(documentHandler.getMimeType());
if (cfg != null) {
@@ -129,7 +128,8 @@ public class BitmapRendererConfigurator extends Java2DRendererConfigurator
FontEventListener listener = new FontEventAdapter(
userAgent.getEventBroadcaster());
List fontList = buildFontList(cfg, fontResolver, listener);
- fontCollections.add(new ConfiguredFontCollection(fontResolver, fontList));
+ fontCollections.add(new ConfiguredFontCollection(fontResolver, fontList,
+ userAgent.isComplexScriptFeaturesEnabled()));
}
fontManager.setup(fontInfo,
diff --git a/src/java/org/apache/fop/render/bitmap/PNGDocumentHandler.java b/src/java/org/apache/fop/render/bitmap/PNGDocumentHandler.java
index 77a024436..ed92b852f 100644
--- a/src/java/org/apache/fop/render/bitmap/PNGDocumentHandler.java
+++ b/src/java/org/apache/fop/render/bitmap/PNGDocumentHandler.java
@@ -20,11 +20,11 @@
package org.apache.fop.render.bitmap;
import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.intermediate.IFDocumentHandler;
import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator;
/**
- * {@link IFDocumentHandler} implementation that produces PNG files.
+ * {@link org.apache.fop.render.intermediate.IFDocumentHandler} implementation
+ * that produces PNG files.
*/
public class PNGDocumentHandler extends AbstractBitmapDocumentHandler {
diff --git a/src/java/org/apache/fop/render/bitmap/PNGRenderer.java b/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
index 3733bf2f2..6f45d18ca 100644
--- a/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
+++ b/src/java/org/apache/fop/render/bitmap/PNGRenderer.java
@@ -29,6 +29,7 @@ import org.apache.xmlgraphics.image.writer.ImageWriter;
import org.apache.xmlgraphics.image.writer.ImageWriterParams;
import org.apache.xmlgraphics.image.writer.ImageWriterRegistry;
+import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.area.PageViewport;
import org.apache.fop.render.java2d.Java2DRenderer;
@@ -40,6 +41,13 @@ import org.apache.fop.render.java2d.Java2DRenderer;
*/
public class PNGRenderer extends Java2DRenderer {
+ /**
+ * @param userAgent the user agent that contains configuration details. This cannot be null.
+ */
+ public PNGRenderer(FOUserAgent userAgent) {
+ super(userAgent);
+ }
+
/** The MIME type for png-Rendering */
public static final String MIME_TYPE = MimeConstants.MIME_PNG;
diff --git a/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java b/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java
index 7d321791a..da19b2986 100644
--- a/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java
+++ b/src/java/org/apache/fop/render/bitmap/PNGRendererMaker.java
@@ -36,7 +36,7 @@ public class PNGRendererMaker extends AbstractRendererMaker {
/** {@inheritDoc} */
public Renderer makeRenderer(FOUserAgent ua) {
- return new PNGRenderer();
+ return new PNGRenderer(ua);
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java b/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java
index a212d0e9e..1c9a39bbe 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFDocumentHandler.java
@@ -20,11 +20,11 @@
package org.apache.fop.render.bitmap;
import org.apache.fop.apps.MimeConstants;
-import org.apache.fop.render.intermediate.IFDocumentHandler;
import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator;
/**
- * {@link IFDocumentHandler} implementation that produces TIFF files.
+ * {@link org.apache.fop.render.intermediate.IFDocumentHandler} implementation
+ * that produces TIFF files.
*/
public class TIFFDocumentHandler extends AbstractBitmapDocumentHandler {
diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java b/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
index 7dd3bcd95..3cdcf2cdc 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
@@ -31,6 +31,7 @@ import java.awt.image.SinglePixelPackedSampleModel;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Iterator;
+import java.util.NoSuchElementException;
import org.apache.commons.logging.Log;
@@ -81,20 +82,16 @@ public class TIFFRenderer extends Java2DRenderer implements TIFFConstants {
return MIME_TYPE;
}
- /** Creates TIFF renderer. */
- public TIFFRenderer() {
- writerParams = new ImageWriterParams();
- writerParams.setCompressionMethod(COMPRESSION_PACKBITS);
- }
-
/**
- * {@inheritDoc}
- * org.apache.fop.apps.FOUserAgent)
+ * Creates TIFF renderer.
+ *
+ * @param userAgent the user agent that contains configuration details. This cannot be null.
*/
- public void setUserAgent(FOUserAgent foUserAgent) {
- super.setUserAgent(foUserAgent);
+ public TIFFRenderer(FOUserAgent userAgent) {
+ super(userAgent);
+ writerParams = new ImageWriterParams();
+ writerParams.setCompressionMethod(COMPRESSION_PACKBITS);
- //Set target resolution
int dpi = Math.round(userAgent.getTargetResolution());
writerParams.setResolution(dpi);
}
@@ -133,7 +130,11 @@ public class TIFFRenderer extends Java2DRenderer implements TIFFConstants {
multiWriter.close();
}
} else {
- writer.writeImage((RenderedImage) pageImagesItr.next(), outputStream, writerParams);
+ RenderedImage renderedImage = null;
+ if (pageImagesItr.hasNext()) {
+ renderedImage = (RenderedImage) pageImagesItr.next();
+ }
+ writer.writeImage(renderedImage, outputStream, writerParams);
if (pageImagesItr.hasNext()) {
BitmapRendererEventProducer eventProducer
= BitmapRendererEventProducer.Provider.get(
@@ -186,8 +187,7 @@ public class TIFFRenderer extends Java2DRenderer implements TIFFConstants {
try {
pageImage = getPageImage(current++);
} catch (FOPException e) {
- log.error(e);
- return null;
+ throw new NoSuchElementException(e.getMessage());
}
if (COMPRESSION_CCITT_T4.equalsIgnoreCase(writerParams.getCompressionMethod())
diff --git a/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java b/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java
index e3c567995..852e6ba04 100644
--- a/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java
+++ b/src/java/org/apache/fop/render/bitmap/TIFFRendererMaker.java
@@ -34,7 +34,7 @@ public class TIFFRendererMaker extends AbstractRendererMaker {
/** {@inheritDoc} */
public Renderer makeRenderer(FOUserAgent userAgent) {
- return new TIFFRenderer();
+ return new TIFFRenderer(userAgent);
}
/** {@inheritDoc} */