aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/render')
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java16
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java15
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRenderer.java25
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java22
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRendererContext.java12
-rw-r--r--src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java23
6 files changed, 86 insertions, 27 deletions
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
index 0780e8a59..63e82f1ae 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
@@ -21,16 +21,17 @@ package org.apache.fop.render.afp;
import java.io.IOException;
+import org.apache.xmlgraphics.image.loader.ImageFlavor;
+import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
+import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
+import org.apache.xmlgraphics.util.MimeConstants;
+
import org.apache.fop.afp.AFPDataObjectInfo;
import org.apache.fop.afp.AFPGraphics2D;
import org.apache.fop.afp.AFPGraphicsObjectInfo;
import org.apache.fop.afp.AFPPaintingState;
import org.apache.fop.afp.AFPResourceInfo;
-import org.apache.fop.afp.AFPResourceLevel;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
-import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
-import org.apache.xmlgraphics.util.MimeConstants;
+import org.apache.fop.afp.modca.ResourceObject;
/**
* PDFImageHandler implementation which handles Graphics2D images.
@@ -65,10 +66,9 @@ public class AFPImageHandlerGraphics2D extends AFPImageHandler {
= (AFPGraphicsObjectInfo)super.generateDataObjectInfo(rendererImageInfo);
AFPResourceInfo resourceInfo = graphicsObjectInfo.getResourceInfo();
- //level not explicitly set/changed so default to inline for GOCA graphic objects
- // (due to a bug in the IBM AFP Workbench Viewer (2.04.01.07), hard copy works just fine)
if (!resourceInfo.levelChanged()) {
- resourceInfo.setLevel(new AFPResourceLevel(AFPResourceLevel.INLINE));
+ resourceInfo.setLevel(afpInfo.getResourceManager().getResourceLevelDefaults()
+ .getDefaultResourceLevel(ResourceObject.TYPE_GRAPHIC));
}
// set mime type (unsupported by MOD:CA registry)
diff --git a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
index ac3a5fe98..18f699620 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageHandlerRenderedImage.java
@@ -40,6 +40,8 @@ import org.apache.fop.afp.AFPDataObjectInfo;
import org.apache.fop.afp.AFPImageObjectInfo;
import org.apache.fop.afp.AFPObjectAreaInfo;
import org.apache.fop.afp.AFPPaintingState;
+import org.apache.fop.afp.AFPResourceInfo;
+import org.apache.fop.afp.modca.ResourceObject;
import org.apache.fop.util.bitmap.BitmapImageUtil;
/**
@@ -64,6 +66,13 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler {
AFPRendererContext rendererContext
= (AFPRendererContext)rendererImageInfo.getRendererContext();
AFPInfo afpInfo = rendererContext.getInfo();
+
+ AFPResourceInfo resourceInfo = imageObjectInfo.getResourceInfo();
+ if (!resourceInfo.levelChanged()) {
+ resourceInfo.setLevel(afpInfo.getResourceManager().getResourceLevelDefaults()
+ .getDefaultResourceLevel(ResourceObject.TYPE_IMAGE));
+ }
+
AFPPaintingState paintingState = afpInfo.getPaintingState();
int resolution = paintingState.getResolution();
int maxPixelSize = paintingState.getBitsPerPixel();
@@ -77,7 +86,8 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler {
ImageSize intrinsicSize = imageInfo.getSize();
boolean useFS10 = (maxPixelSize == 1) || BitmapImageUtil.isMonochromeImage(renderedImage);
- boolean usePageSegments = useFS10 && !imageObjectInfo.getResourceInfo().getLevel().isInline();
+ boolean usePageSegments = useFS10
+ && !resourceInfo.getLevel().isInline();
ImageSize effIntrinsicSize = intrinsicSize;
if (usePageSegments) {
@@ -99,7 +109,8 @@ public class AFPImageHandlerRenderedImage extends AFPImageHandler {
+ " to " + resampledDim);
}
renderedImage = BitmapImageUtil.convertToMonochrome(renderedImage, resampledDim);
- effIntrinsicSize = new ImageSize(resampledDim.width, resampledDim.height, resolution);
+ effIntrinsicSize = new ImageSize(
+ resampledDim.width, resampledDim.height, resolution);
}
}
if (useFS10) {
diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java
index 8035a9490..abf7dcfcc 100644
--- a/src/java/org/apache/fop/render/afp/AFPRenderer.java
+++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java
@@ -33,11 +33,20 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import org.apache.xmlgraphics.image.loader.ImageException;
+import org.apache.xmlgraphics.image.loader.ImageFlavor;
+import org.apache.xmlgraphics.image.loader.ImageInfo;
+import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+import org.apache.xmlgraphics.image.loader.util.ImageUtil;
+import org.apache.xmlgraphics.ps.ImageEncodingHelper;
+
import org.apache.fop.afp.AFPBorderPainter;
import org.apache.fop.afp.AFPDataObjectInfo;
import org.apache.fop.afp.AFPEventProducer;
import org.apache.fop.afp.AFPPaintingState;
import org.apache.fop.afp.AFPRectanglePainter;
+import org.apache.fop.afp.AFPResourceLevelDefaults;
import org.apache.fop.afp.AFPResourceManager;
import org.apache.fop.afp.AFPTextDataInfo;
import org.apache.fop.afp.AFPUnitConverter;
@@ -72,13 +81,6 @@ import org.apache.fop.render.Graphics2DAdapter;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.afp.extensions.AFPElementMapping;
import org.apache.fop.render.afp.extensions.AFPPageSetup;
-import org.apache.xmlgraphics.image.loader.ImageException;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-import org.apache.xmlgraphics.image.loader.ImageInfo;
-import org.apache.xmlgraphics.image.loader.ImageManager;
-import org.apache.xmlgraphics.image.loader.ImageSessionContext;
-import org.apache.xmlgraphics.image.loader.util.ImageUtil;
-import org.apache.xmlgraphics.ps.ImageEncodingHelper;
/**
* This is an implementation of a FOP Renderer that renders areas to AFP.
@@ -744,6 +746,15 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
resourceManager.setDefaultResourceGroupFilePath(filePath);
}
+ /**
+ * Sets the resource level defaults. The object passed in provides information which resource
+ * level shall be used by default for various kinds of resources.
+ * @param defaults the resource level defaults
+ */
+ public void setResourceLevelDefaults(AFPResourceLevelDefaults defaults) {
+ resourceManager.setResourceLevelDefaults(defaults);
+ }
+
/** {@inheritDoc} */
protected void establishTransformationMatrix(AffineTransform at) {
saveGraphicsState();
diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
index 5982ae5b0..d5ad7e580 100644
--- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
@@ -25,6 +25,8 @@ import java.util.List;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.fop.afp.AFPResourceLevel;
+import org.apache.fop.afp.AFPResourceLevelDefaults;
import org.apache.fop.afp.fonts.AFPFontInfo;
import org.apache.fop.afp.fonts.CharacterSet;
import org.apache.fop.afp.fonts.FopCharacterSet;
@@ -282,6 +284,26 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator {
+ resourceGroupDest + "'");
}
}
+
+ Configuration defaultResourceLevelCfg = cfg.getChild("default-resource-levels", false);
+ if (defaultResourceLevelCfg != null) {
+ AFPResourceLevelDefaults defaults = new AFPResourceLevelDefaults();
+ String[] types = defaultResourceLevelCfg.getAttributeNames();
+ for (int i = 0, c = types.length; i < c; i++) {
+ String type = types[i];
+ try {
+ String level = defaultResourceLevelCfg.getAttribute(type);
+ defaults.setDefaultResourceLevel(type, AFPResourceLevel.valueOf(level));
+ } catch (IllegalArgumentException iae) {
+ LogUtil.handleException(log, iae,
+ userAgent.getFactory().validateUserConfigStrictly());
+ } catch (ConfigurationException e) {
+ LogUtil.handleException(log, e,
+ userAgent.getFactory().validateUserConfigStrictly());
+ }
+ }
+ afpRenderer.setResourceLevelDefaults(defaults);
+ }
}
}
}
diff --git a/src/java/org/apache/fop/render/afp/AFPRendererContext.java b/src/java/org/apache/fop/render/afp/AFPRendererContext.java
index 8d544a7c4..6c515d4bd 100644
--- a/src/java/org/apache/fop/render/afp/AFPRendererContext.java
+++ b/src/java/org/apache/fop/render/afp/AFPRendererContext.java
@@ -22,10 +22,11 @@ package org.apache.fop.render.afp;
import java.util.Map;
import org.apache.avalon.framework.configuration.Configuration;
+
import org.apache.fop.afp.AFPPaintingState;
import org.apache.fop.afp.AFPResourceInfo;
-import org.apache.fop.afp.AFPResourceLevel;
import org.apache.fop.afp.AFPResourceManager;
+import org.apache.fop.afp.modca.ResourceObject;
import org.apache.fop.render.AbstractRenderer;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RendererContextConstants;
@@ -72,9 +73,12 @@ public class AFPRendererContext extends RendererContext {
= new AFPForeignAttributeReader();
AFPResourceInfo resourceInfo
= foreignAttributeReader.getResourceInfo(foreignAttributes);
- // default to inline level if painted as GOCA
- if (!resourceInfo.levelChanged() && !paintAsBitmap) {
- resourceInfo.setLevel(new AFPResourceLevel(AFPResourceLevel.INLINE));
+ // set default resource level if an explicit one hasn't been set
+ if (!resourceInfo.levelChanged()) {
+ byte resourceType = paintAsBitmap
+ ? ResourceObject.TYPE_IMAGE : ResourceObject.TYPE_GRAPHIC;
+ resourceInfo.setLevel(info.getResourceManager().getResourceLevelDefaults()
+ .getDefaultResourceLevel(resourceType));
}
info.setResourceInfo(resourceInfo);
}
diff --git a/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java b/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java
index ae8ac9950..ab38a5241 100644
--- a/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java
+++ b/src/java/org/apache/fop/render/afp/AbstractAFPImageHandlerRawStream.java
@@ -23,13 +23,17 @@ import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
-import org.apache.fop.afp.AFPDataObjectInfo;
-import org.apache.fop.afp.AFPObjectAreaInfo;
-import org.apache.fop.afp.AFPPaintingState;
+
import org.apache.xmlgraphics.image.loader.ImageInfo;
import org.apache.xmlgraphics.image.loader.ImageSize;
import org.apache.xmlgraphics.image.loader.impl.ImageRawStream;
+import org.apache.fop.afp.AFPDataObjectInfo;
+import org.apache.fop.afp.AFPObjectAreaInfo;
+import org.apache.fop.afp.AFPPaintingState;
+import org.apache.fop.afp.AFPResourceInfo;
+import org.apache.fop.afp.modca.ResourceObject;
+
/**
* A base abstract AFP raw stream image handler
*/
@@ -39,12 +43,22 @@ public abstract class AbstractAFPImageHandlerRawStream extends AFPImageHandler {
public AFPDataObjectInfo generateDataObjectInfo(
AFPRendererImageInfo rendererImageInfo) throws IOException {
AFPDataObjectInfo dataObjectInfo = super.generateDataObjectInfo(rendererImageInfo);
+ AFPRendererContext rendererContext
+ = (AFPRendererContext)rendererImageInfo.getRendererContext();
+ AFPInfo afpInfo = rendererContext.getInfo();
ImageInfo imageInfo = rendererImageInfo.getImageInfo();
String mimeType = imageInfo.getMimeType();
if (mimeType != null) {
dataObjectInfo.setMimeType(mimeType);
}
+
+ AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
+ if (!resourceInfo.levelChanged()) {
+ resourceInfo.setLevel(afpInfo.getResourceManager().getResourceLevelDefaults()
+ .getDefaultResourceLevel(ResourceObject.TYPE_IMAGE));
+ }
+
ImageRawStream rawStream = (ImageRawStream) rendererImageInfo.getImage();
InputStream inputStream = rawStream.createInputStream();
try {
@@ -65,9 +79,6 @@ public abstract class AbstractAFPImageHandlerRawStream extends AFPImageHandler {
// set object area info
AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();
- AFPRendererContext rendererContext
- = (AFPRendererContext)rendererImageInfo.getRendererContext();
- AFPInfo afpInfo = rendererContext.getInfo();
AFPPaintingState paintingState = afpInfo.getPaintingState();
int resolution = paintingState.getResolution();
objectAreaInfo.setWidthRes(resolution);