aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorAdrian Cumiskey <acumiskey@apache.org>2008-09-03 16:34:56 +0000
committerAdrian Cumiskey <acumiskey@apache.org>2008-09-03 16:34:56 +0000
commit8234ed46e923e0e8029703be0c58752da7c49b45 (patch)
tree671bb2e4d0b37390a3c2ff7e96f0411717484957 /src/java
parentd0227114765d0ff051ba24d59dd62fd4a63d4e46 (diff)
downloadxmlgraphics-fop-8234ed46e923e0e8029703be0c58752da7c49b45.tar.gz
xmlgraphics-fop-8234ed46e923e0e8029703be0c58752da7c49b45.zip
Toggleable support for AFP native image flavours.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@691674 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java (renamed from src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java)23
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java2
-rw-r--r--src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java2
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java2
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRenderer.java28
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java1
-rw-r--r--src/java/org/apache/fop/render/afp/AFPState.java36
7 files changed, 66 insertions, 28 deletions
diff --git a/src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java b/src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java
index d87fabeaf..525c3487f 100644
--- a/src/java/org/apache/fop/render/afp/AFPDataObjectInfoFactory.java
+++ b/src/java/org/apache/fop/render/afp/AFPDataObjectInfoProvider.java
@@ -28,10 +28,10 @@ import org.apache.xmlgraphics.image.loader.impl.ImageRawStream;
import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
/**
- * AFP image configurator
+ * AFP data object info factory provider
*/
-public class AFPDataObjectInfoFactory {
- private final Map dataObjectInfoFactoryMap = new java.util.HashMap();
+public class AFPDataObjectInfoProvider {
+ private final Map factoryMap = new java.util.HashMap();
private final AFPState state;
/**
@@ -39,7 +39,7 @@ public class AFPDataObjectInfoFactory {
*
* @param state the AFP state
*/
- public AFPDataObjectInfoFactory(AFPState state) {
+ public AFPDataObjectInfoProvider(AFPState state) {
this.state = state;
init();
}
@@ -48,11 +48,11 @@ public class AFPDataObjectInfoFactory {
* Initialises the configurators
*/
private void init() {
- dataObjectInfoFactoryMap.put(
+ factoryMap.put(
ImageRendered.class, new AFPImageRenderedFactory(state));
- dataObjectInfoFactoryMap.put(
+ factoryMap.put(
ImageRawCCITTFax.class, new AFPRawCCITTFaxFactory(state));
- dataObjectInfoFactoryMap.put(
+ factoryMap.put(
ImageRawStream.class, new AFPImageRawStreamFactory(state));
};
@@ -62,17 +62,16 @@ public class AFPDataObjectInfoFactory {
* @param img the image
* @return the image configurator for the image
*/
- public AFPAbstractImageFactory getFactory(Image img) {
+ public AFPDataObjectInfoFactory getFactory(Image img) {
Class clazz = img.getClass();
- AFPAbstractImageFactory configurator
- = (AFPAbstractImageFactory)dataObjectInfoFactoryMap.get(clazz);
+ AFPDataObjectInfoFactory configurator = (AFPDataObjectInfoFactory)factoryMap.get(clazz);
// not directly matched so try to map ancestor
if (configurator == null) {
- Iterator it = dataObjectInfoFactoryMap.keySet().iterator();
+ Iterator it = factoryMap.keySet().iterator();
while (it.hasNext()) {
Class imageClass = (Class)it.next();
if (imageClass.isInstance(img)) {
- return (AFPAbstractImageFactory)dataObjectInfoFactoryMap.get(imageClass);
+ return (AFPDataObjectInfoFactory)factoryMap.get(imageClass);
}
}
}
diff --git a/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java b/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java
index f90024e1a..43e678aab 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageRawStreamFactory.java
@@ -27,7 +27,7 @@ import org.apache.xmlgraphics.image.loader.impl.ImageRawStream;
/**
* A raw stream image configurator
*/
-public class AFPImageRawStreamFactory extends AFPAbstractImageFactory {
+public class AFPImageRawStreamFactory extends AFPDataObjectInfoFactory {
/**
* Main constructor
diff --git a/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java b/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java
index 93a509cc0..15d7a3173 100644
--- a/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java
+++ b/src/java/org/apache/fop/render/afp/AFPImageRenderedFactory.java
@@ -30,7 +30,7 @@ import org.apache.xmlgraphics.ps.ImageEncodingHelper;
/**
* A buffered image configurator
*/
-public class AFPImageRenderedFactory extends AFPAbstractImageFactory {
+public class AFPImageRenderedFactory extends AFPDataObjectInfoFactory {
/**
* Main constructor
diff --git a/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java b/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java
index e7ef5266a..6700f263d 100644
--- a/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java
+++ b/src/java/org/apache/fop/render/afp/AFPRawCCITTFaxFactory.java
@@ -26,7 +26,7 @@ import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
/**
* An CITT fax image configurator
*/
-public class AFPRawCCITTFaxFactory extends AFPAbstractImageFactory {
+public class AFPRawCCITTFaxFactory extends AFPDataObjectInfoFactory {
/**
* Main constructor
diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java
index 0a6476af0..056792fdd 100644
--- a/src/java/org/apache/fop/render/afp/AFPRenderer.java
+++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java
@@ -155,7 +155,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
private DataStream dataStream;
/** data object information factory */
- private final AFPDataObjectInfoFactory dataObjectInfoFactory;
+ private final AFPDataObjectInfoProvider dataObjectInfoProvider;
/**
@@ -165,7 +165,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
super();
this.resourceManager = new AFPResourceManager();
this.state = new AFPState();
- this.dataObjectInfoFactory = new AFPDataObjectInfoFactory(state);
+ this.dataObjectInfoProvider = new AFPDataObjectInfoProvider(state);
this.unitConv = state.getUnitConverter();
}
@@ -376,11 +376,16 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
return context;
}
- private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
+ private static final ImageFlavor[] NATIVE_FLAVORS = new ImageFlavor[] {
+ /*ImageFlavor.RAW_PNG, */ // PNG not natively supported in AFP
ImageFlavor.RAW_JPEG, ImageFlavor.RAW_CCITTFAX, ImageFlavor.RAW_EPS,
ImageFlavor.GRAPHICS2D, ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE,
ImageFlavor.XML_DOM };
+ private static final ImageFlavor[] FLAVORS = new ImageFlavor[] {
+ ImageFlavor.GRAPHICS2D, ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE,
+ ImageFlavor.XML_DOM };
+
/** {@inheritDoc} */
public void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) {
uri = URISpecification.getURL(uri);
@@ -404,11 +409,13 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
// Only now fully load/prepare the image
Map hints = ImageUtil.getDefaultHints(sessionContext);
+
+ ImageFlavor[] flavors = state.isNativeImages() ? NATIVE_FLAVORS : FLAVORS;
org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
- info, FLAVORS, hints, sessionContext);
+ info, flavors, hints, sessionContext);
Point origin = new Point(currentIPPosition, currentBPPosition);
- AFPAbstractImageFactory factory = dataObjectInfoFactory.getFactory(img);
+ AFPDataObjectInfoFactory factory = dataObjectInfoProvider.getFactory(img);
if (factory != null) {
AFPImageInfo afpImageInfo
= new AFPImageInfo(uri, pos, origin, info, img, foreignAttributes);
@@ -563,7 +570,6 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
// Try and get the encoding to use for the font
String encoding = null;
-
try {
encoding = font.getCharacterSet(fontSize).getEncoding();
} catch (Throwable ex) {
@@ -753,6 +759,16 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
}
/**
+ * Sets whether images are supported natively or not
+ *
+ * @param nativeImages
+ * native image support
+ */
+ public void setNativeImages(boolean nativeImages) {
+ state.setNativeImages(nativeImages);
+ }
+
+ /**
* Returns the AFPDataStream
*
* @return the AFPDataStream
diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
index 95a210ce5..794f5bda8 100644
--- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
+++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
@@ -239,6 +239,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator {
} else {
afpRenderer.setColorImages(true);
}
+ afpRenderer.setNativeImages(imagesCfg.getAttributeAsBoolean("native", false));
// renderer resolution
Configuration rendererResolutionCfg = cfg.getChild("renderer-resolution", false);
diff --git a/src/java/org/apache/fop/render/afp/AFPState.java b/src/java/org/apache/fop/render/afp/AFPState.java
index 129222b6a..709e151f6 100644
--- a/src/java/org/apache/fop/render/afp/AFPState.java
+++ b/src/java/org/apache/fop/render/afp/AFPState.java
@@ -34,27 +34,31 @@ public class AFPState extends org.apache.fop.render.AbstractState implements Clo
private static Log log = LogFactory.getLog("org.apache.fop.render.afp.AFPState");
- /** The portrait rotation */
+ /** the portrait rotation */
private int portraitRotation = 0;
- /** The landscape rotation */
+ /** the landscape rotation */
private int landscapeRotation = 270;
- /** Flag to the set the output object type for images */
+ /** color image support */
private boolean colorImages = true;
- /** Default value for image depth */
+ /** images are supported in this AFP environment */
+ private boolean nativeImages;
+
+ /** default value for image depth */
private int bitsPerPixel = 8;
- /** The output resolution */
+ /** the output resolution */
private int resolution = 240; // 240 dpi
- /** The current page */
+ /** the current page */
private AFPPageState pageState = new AFPPageState();
- /** A unit converter */
+ /** a unit converter */
private final transient AFPUnitConverter unitConv = new AFPUnitConverter(this);
+
/**
* Sets the rotation to be used for portrait pages, valid values are 0
* (default), 90, 180, 270.
@@ -159,6 +163,24 @@ public class AFPState extends org.apache.fop.render.AbstractState implements Clo
}
/**
+ * Sets whether images are natively supported or not in the AFP environment
+ *
+ * @param nativeImages true if images are natively supported in this AFP environment
+ */
+ public void setNativeImages(boolean nativeImages) {
+ this.nativeImages = nativeImages;
+ }
+
+ /**
+ * Returns true if images are supported natively in this AFP environment
+ *
+ * @return true if images are supported natively in this AFP environment
+ */
+ protected boolean isNativeImages() {
+ return this.nativeImages;
+ }
+
+ /**
* Sets the output/device resolution
*
* @param resolution