aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/afp
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/org/apache/fop/afp')
-rw-r--r--src/java/org/apache/fop/afp/AFPGraphics2D.java111
-rw-r--r--src/java/org/apache/fop/afp/AFPResourceInfo.java14
-rw-r--r--src/java/org/apache/fop/afp/AFPResourceLevelDefaults.java110
-rw-r--r--src/java/org/apache/fop/afp/AFPResourceManager.java18
4 files changed, 196 insertions, 57 deletions
diff --git a/src/java/org/apache/fop/afp/AFPGraphics2D.java b/src/java/org/apache/fop/afp/AFPGraphics2D.java
index 6f552ae5b..2e176e5ab 100644
--- a/src/java/org/apache/fop/afp/AFPGraphics2D.java
+++ b/src/java/org/apache/fop/afp/AFPGraphics2D.java
@@ -131,10 +131,10 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
AFPResourceManager resourceManager, AFPResourceInfo resourceInfo,
FontInfo fontInfo) {
super(textAsShapes);
- this.paintingState = paintingState;
- this.resourceManager = resourceManager;
- this.resourceInfo = resourceInfo;
- this.fontInfo = fontInfo;
+ setPaintingState(paintingState);
+ setResourceManager(resourceManager);
+ setResourceInfo(resourceInfo);
+ setFontInfo(fontInfo);
}
/**
@@ -160,7 +160,7 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
*
* @param resourceManager the AFP resource manager
*/
- public void setResourceManager(AFPResourceManager resourceManager) {
+ private void setResourceManager(AFPResourceManager resourceManager) {
this.resourceManager = resourceManager;
}
@@ -169,11 +169,65 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
*
* @param resourceInfo the AFP resource info
*/
- public void setResourceInfo(AFPResourceInfo resourceInfo) {
+ private void setResourceInfo(AFPResourceInfo resourceInfo) {
this.resourceInfo = resourceInfo;
}
/**
+ * Returns the GOCA graphics object
+ *
+ * @return the GOCA graphics object
+ */
+ public GraphicsObject getGraphicsObject() {
+ return this.graphicsObj;
+ }
+
+ /**
+ * Sets the GOCA graphics object
+ *
+ * @param obj the GOCA graphics object
+ */
+ public void setGraphicsObject(GraphicsObject obj) {
+ this.graphicsObj = obj;
+ }
+
+ /**
+ * Sets the AFP painting state
+ *
+ * @param paintingState the AFP painting state
+ */
+ private void setPaintingState(AFPPaintingState paintingState) {
+ this.paintingState = paintingState;
+ }
+
+ /**
+ * Returns the AFP painting state
+ *
+ * @return the AFP painting state
+ */
+ public AFPPaintingState getPaintingState() {
+ return this.paintingState;
+ }
+
+ /**
+ * Sets the FontInfo
+ *
+ * @param fontInfo the FontInfo
+ */
+ private void setFontInfo(FontInfo fontInfo) {
+ this.fontInfo = fontInfo;
+ }
+
+ /**
+ * Returns the FontInfo
+ *
+ * @return the FontInfo
+ */
+ public FontInfo getFontInfo() {
+ return this.fontInfo;
+ }
+
+ /**
* Sets the GraphicContext
*
* @param gc
@@ -653,51 +707,6 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
this.customTextHandler = handler;
}
- /**
- * Returns the GOCA graphics object
- *
- * @return the GOCA graphics object
- */
- public GraphicsObject getGraphicsObject() {
- return this.graphicsObj;
- }
-
- /**
- * Sets the GOCA graphics object
- *
- * @param obj the GOCA graphics object
- */
- public void setGraphicsObject(GraphicsObject obj) {
- this.graphicsObj = obj;
- }
-
- /**
- * Sets the AFP painting state
- *
- * @param paintingState the AFP painting state
- */
- public void setPaintingState(AFPPaintingState paintingState) {
- this.paintingState = paintingState;
- }
-
- /**
- * Returns the AFP painting state
- *
- * @return the AFP painting state
- */
- public AFPPaintingState getPaintingState() {
- return this.paintingState;
- }
-
- /**
- * Returns the FontInfo
- *
- * @return the FontInfo
- */
- public FontInfo getFontInfo() {
- return this.fontInfo;
- }
-
/** {@inheritDoc} */
public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
log.debug("drawRenderableImage() NYI: img=" + img + ", xform=" + xform);
diff --git a/src/java/org/apache/fop/afp/AFPResourceInfo.java b/src/java/org/apache/fop/afp/AFPResourceInfo.java
index 99b3d7417..43ba2a238 100644
--- a/src/java/org/apache/fop/afp/AFPResourceInfo.java
+++ b/src/java/org/apache/fop/afp/AFPResourceInfo.java
@@ -26,10 +26,12 @@ import java.awt.Dimension;
* The level at which a resource is to reside in the AFP output
*/
public class AFPResourceInfo {
- private static final AFPResourceLevel DEFAULT_LEVEL
+
+ /** the general default resource level */
+ public static final AFPResourceLevel DEFAULT_LEVEL
= new AFPResourceLevel(AFPResourceLevel.PRINT_FILE);
- /** the uri of this resource */
+ /** the URI of this resource */
private String uri = null;
/**
@@ -48,18 +50,18 @@ public class AFPResourceInfo {
private boolean levelChanged = false;
/**
- * Sets the data object uri
+ * Sets the data object URI.
*
- * @param uri the data object uri
+ * @param uri the data object URI
*/
public void setUri(String uri) {
this.uri = uri;
}
/**
- * Returns the uri of this data object
+ * Returns the URI of this data object.
*
- * @return the uri of this data object
+ * @return the URI of this data object
*/
public String getUri() {
return uri;
diff --git a/src/java/org/apache/fop/afp/AFPResourceLevelDefaults.java b/src/java/org/apache/fop/afp/AFPResourceLevelDefaults.java
new file mode 100644
index 000000000..8cb0ebaaf
--- /dev/null
+++ b/src/java/org/apache/fop/afp/AFPResourceLevelDefaults.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.afp;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.fop.afp.modca.ResourceObject;
+
+/**
+ * This class holds resource levels defaults for the various resource types.
+ */
+public class AFPResourceLevelDefaults {
+
+ private static final Map RESOURCE_TYPE_NAMES = new java.util.HashMap();
+
+ static {
+ //Map to be extended as need arises:
+ registerResourceTypeName("goca", ResourceObject.TYPE_GRAPHIC);
+ registerResourceTypeName("bitmap", ResourceObject.TYPE_IMAGE);
+ }
+
+ private static void registerResourceTypeName(String name, byte type) {
+ RESOURCE_TYPE_NAMES.put(name.toLowerCase(), new Byte(type));
+ }
+
+ private static byte getResourceType(String resourceTypeName) {
+ Byte result = (Byte)RESOURCE_TYPE_NAMES.get(resourceTypeName.toLowerCase());
+ if (result == null) {
+ throw new IllegalArgumentException("Unknown resource type name: " + resourceTypeName);
+ }
+ return result.byteValue();
+ }
+
+ private Map defaultResourceLevels = new java.util.HashMap();
+
+ /**
+ * Creates a new instance with default values.
+ */
+ public AFPResourceLevelDefaults() {
+ // 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)
+ setDefaultResourceLevel(ResourceObject.TYPE_GRAPHIC,
+ new AFPResourceLevel(AFPResourceLevel.INLINE));
+ }
+
+ /**
+ * Sets the default resource level for a particular resource type.
+ * @param type the resource type name
+ * @param level the resource level
+ */
+ public void setDefaultResourceLevel(String type, AFPResourceLevel level) {
+ setDefaultResourceLevel(getResourceType(type), level);
+ }
+
+ /**
+ * Sets the default resource level for a particular resource type.
+ * @param type the resource type ({@link ResourceObject}.TYPE_*)
+ * @param level the resource level
+ */
+ public void setDefaultResourceLevel(byte type, AFPResourceLevel level) {
+ this.defaultResourceLevels.put(new Byte(type), level);
+ }
+
+ /**
+ * Returns the default resource level for a particular resource type.
+ * @param type the resource type ({@link ResourceObject}.TYPE_*)
+ * @return the default resource level
+ */
+ public AFPResourceLevel getDefaultResourceLevel(byte type) {
+ AFPResourceLevel result = (AFPResourceLevel)this.defaultResourceLevels.get(new Byte(type));
+ if (result == null) {
+ result = AFPResourceInfo.DEFAULT_LEVEL;
+ }
+ return result;
+ }
+
+ /**
+ * Allows to merge the values from one instance into another. Values from the instance passed
+ * in as a parameter override values of this instance.
+ * @param other the other instance to get the defaults from
+ */
+ public void mergeFrom(AFPResourceLevelDefaults other) {
+ Iterator iter = other.defaultResourceLevels.entrySet().iterator();
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ Byte type = (Byte)entry.getKey();
+ AFPResourceLevel level = (AFPResourceLevel)entry.getValue();
+ this.defaultResourceLevels.put(type, level);
+ }
+ }
+
+}
diff --git a/src/java/org/apache/fop/afp/AFPResourceManager.java b/src/java/org/apache/fop/afp/AFPResourceManager.java
index 2e36c82a0..9218ea8e4 100644
--- a/src/java/org/apache/fop/afp/AFPResourceManager.java
+++ b/src/java/org/apache/fop/afp/AFPResourceManager.java
@@ -53,6 +53,8 @@ public class AFPResourceManager {
private Map pageSegmentMap = new java.util.HashMap();
+ private AFPResourceLevelDefaults resourceLevelDefaults = new AFPResourceLevelDefaults();
+
/**
* Main constructor
*/
@@ -218,4 +220,20 @@ public class AFPResourceManager {
currentPage.createIncludePageSegment(pageSegmentName, x, y, createHardPageSegments);
}
+ /**
+ * Sets resource level defaults. The existing defaults over merged with the ones passed in
+ * as parameter.
+ * @param defaults the new defaults
+ */
+ public void setResourceLevelDefaults(AFPResourceLevelDefaults defaults) {
+ this.resourceLevelDefaults.mergeFrom(defaults);
+ }
+
+ /**
+ * Returns the resource level defaults in use with this resource manager.
+ * @return the resource level defaults
+ */
+ public AFPResourceLevelDefaults getResourceLevelDefaults() {
+ return this.resourceLevelDefaults;
+ }
} \ No newline at end of file