aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2009-01-11 11:31:24 +0000
committerJeremias Maerki <jeremias@apache.org>2009-01-11 11:31:24 +0000
commit25b82eeedf54b42083102ce9d4c3dad3a472d586 (patch)
tree31e89c33e88d6473d092a706c54a4851e148b112 /src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
parent04bb06d6912f18601d1623935ac0d202da372e67 (diff)
downloadxmlgraphics-fop-25b82eeedf54b42083102ce9d4c3dad3a472d586.tar.gz
xmlgraphics-fop-25b82eeedf54b42083102ce9d4c3dad3a472d586.zip
Started new IF implementation for AFP (incomplete, supporting filled rects, text and images). Work in progress!
Moved PTOCA (presentation text) command sequence production into the new "ptoca" package. The PtocaBuilder class allows more flexible command sequence production than if you have to pass in an "info object". git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@733456 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java')
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java121
1 files changed, 84 insertions, 37 deletions
diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
index 5982ae5b0..7c6ee5771 100644
--- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
@@ -25,6 +25,7 @@ import java.util.List;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.fop.afp.fonts.AFPFontCollection;
import org.apache.fop.afp.fonts.AFPFontInfo;
import org.apache.fop.afp.fonts.CharacterSet;
import org.apache.fop.afp.fonts.FopCharacterSet;
@@ -32,17 +33,23 @@ import org.apache.fop.afp.fonts.OutlineFont;
import org.apache.fop.afp.fonts.RasterFont;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fonts.FontCollection;
+import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontManager;
import org.apache.fop.fonts.FontTriplet;
import org.apache.fop.fonts.FontUtil;
import org.apache.fop.fonts.Typeface;
import org.apache.fop.render.PrintRendererConfigurator;
import org.apache.fop.render.Renderer;
+import org.apache.fop.render.intermediate.IFDocumentHandler;
+import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator;
import org.apache.fop.util.LogUtil;
/**
* AFP Renderer configurator
*/
-public class AFPRendererConfigurator extends PrintRendererConfigurator {
+public class AFPRendererConfigurator extends PrintRendererConfigurator
+ implements IFDocumentHandlerConfigurator {
/**
* Default constructor
@@ -231,6 +238,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator {
Configuration cfg = super.getRendererConfig(renderer);
if (cfg != null) {
AFPRenderer afpRenderer = (AFPRenderer)renderer;
+
try {
List/*<AFPFontInfo>*/ fontList = buildFontListFromConfiguration(cfg);
afpRenderer.setFontList(fontList);
@@ -239,49 +247,88 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator {
userAgent.getFactory().validateUserConfigStrictly());
}
- // image information
- Configuration imagesCfg = cfg.getChild("images");
+ configure(afpRenderer, cfg);
+ }
+ }
+
+ private void configure(AFPCustomizable customizable, Configuration cfg) throws FOPException {
+
+ // image information
+ Configuration imagesCfg = cfg.getChild("images");
+
+ // default to grayscale images
+ String imagesMode = imagesCfg.getAttribute("mode", IMAGES_MODE_GRAYSCALE);
+ if (IMAGES_MODE_COLOR.equals(imagesMode)) {
+ customizable.setColorImages(true);
+ } else {
+ customizable.setColorImages(false);
+ // default to 8 bits per pixel
+ int bitsPerPixel = imagesCfg.getAttributeAsInteger("bits-per-pixel", 8);
+ customizable.setBitsPerPixel(bitsPerPixel);
+ }
+
+ // native image support
+ boolean nativeImageSupport = imagesCfg.getAttributeAsBoolean("native", false);
+ customizable.setNativeImagesSupported(nativeImageSupport);
- // default to grayscale images
- String imagesMode = imagesCfg.getAttribute("mode", IMAGES_MODE_GRAYSCALE);
- if (IMAGES_MODE_COLOR.equals(imagesMode)) {
- afpRenderer.setColorImages(true);
+ // renderer resolution
+ Configuration rendererResolutionCfg = cfg.getChild("renderer-resolution", false);
+ if (rendererResolutionCfg != null) {
+ customizable.setResolution(rendererResolutionCfg.getValueAsInteger(240));
+ }
+
+ // a default external resource group file setting
+ Configuration resourceGroupFileCfg
+ = cfg.getChild("resource-group-file", false);
+ if (resourceGroupFileCfg != null) {
+ String resourceGroupDest = null;
+ try {
+ resourceGroupDest = resourceGroupFileCfg.getValue();
+ } catch (ConfigurationException e) {
+ LogUtil.handleException(log, e,
+ userAgent.getFactory().validateUserConfigStrictly());
+ }
+ File resourceGroupFile = new File(resourceGroupDest);
+ if (resourceGroupFile.canWrite()) {
+ customizable.setDefaultResourceGroupFilePath(resourceGroupDest);
} else {
- afpRenderer.setColorImages(false);
- // default to 8 bits per pixel
- int bitsPerPixel = imagesCfg.getAttributeAsInteger("bits-per-pixel", 8);
- afpRenderer.setBitsPerPixel(bitsPerPixel);
+ log.warn("Unable to write to default external resource group file '"
+ + resourceGroupDest + "'");
}
+ }
+ }
- // native image support
- boolean nativeImageSupport = imagesCfg.getAttributeAsBoolean("native", false);
- afpRenderer.setNativeImagesSupported(nativeImageSupport);
+ /** {@inheritDoc} */
+ public void configure(IFDocumentHandler documentHandler) throws FOPException {
+ Configuration cfg = super.getRendererConfig(documentHandler.getMimeType());
+ if (cfg != null) {
+ AFPDocumentHandler afpDocumentHandler = (AFPDocumentHandler)documentHandler;
+ configure(afpDocumentHandler, cfg);
+ }
+ }
- // renderer resolution
- Configuration rendererResolutionCfg = cfg.getChild("renderer-resolution", false);
- if (rendererResolutionCfg != null) {
- afpRenderer.setResolution(rendererResolutionCfg.getValueAsInteger(240));
- }
+ /** {@inheritDoc} */
+ public void setupFontInfo(IFDocumentHandler documentHandler, FontInfo fontInfo)
+ throws FOPException {
+ FontManager fontManager = userAgent.getFactory().getFontManager();
+ List fontCollections = new java.util.ArrayList();
- // a default external resource group file setting
- Configuration resourceGroupFileCfg
- = cfg.getChild("resource-group-file", false);
- if (resourceGroupFileCfg != null) {
- String resourceGroupDest = null;
- try {
- resourceGroupDest = resourceGroupFileCfg.getValue();
- } catch (ConfigurationException e) {
- LogUtil.handleException(log, e,
- userAgent.getFactory().validateUserConfigStrictly());
- }
- File resourceGroupFile = new File(resourceGroupDest);
- if (resourceGroupFile.canWrite()) {
- afpRenderer.setDefaultResourceGroupFilePath(resourceGroupDest);
- } else {
- log.warn("Unable to write to default external resource group file '"
- + resourceGroupDest + "'");
- }
+ Configuration cfg = super.getRendererConfig(documentHandler.getMimeType());
+ if (cfg != null) {
+ try {
+ List fontList = buildFontListFromConfiguration(cfg);
+ fontCollections.add(new AFPFontCollection(
+ userAgent.getEventBroadcaster(), fontList));
+ } catch (ConfigurationException e) {
+ LogUtil.handleException(log, e,
+ userAgent.getFactory().validateUserConfigStrictly());
}
+
}
+
+ fontManager.setup(fontInfo,
+ (FontCollection[])fontCollections.toArray(
+ new FontCollection[fontCollections.size()]));
+ documentHandler.setFontInfo(fontInfo);
}
}