From c7332c147a93181a8f7762f7425d0373810e1d21 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Thu, 10 Jul 2008 09:30:48 +0000 Subject: [PATCH] Fixed placement of bitmap images for AFP output. Made setters public for ObjectAreaInfo. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@675487 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/render/afp/ObjectAreaInfo.java | 26 +++---- .../fop/render/afp/modca/AFPDataStream.java | 78 ++++++++++--------- .../fop/render/afp/modca/ImageObject.java | 6 +- 3 files changed, 58 insertions(+), 52 deletions(-) diff --git a/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java b/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java index 85da1a8e2..49b799489 100644 --- a/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java +++ b/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java @@ -5,9 +5,9 @@ * 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. @@ -26,12 +26,12 @@ public class ObjectAreaInfo { private int widthRes; private int heightRes; private int rotation = 0; - + /** * Sets the x position of the data object * @param x the x position of the data object */ - protected void setX(int x) { + public void setX(int x) { this.x = x; } @@ -39,7 +39,7 @@ public class ObjectAreaInfo { * Sets the y position of the data object * @param y the y position of the data object */ - protected void setY(int y) { + public void setY(int y) { this.y = y; } @@ -47,7 +47,7 @@ public class ObjectAreaInfo { * Sets the data object width * @param width the width of the data object */ - protected void setWidth(int width) { + public void setWidth(int width) { this.width = width; } @@ -55,7 +55,7 @@ public class ObjectAreaInfo { * Sets the data object height * @param height the height of the data object */ - protected void setHeight(int height) { + public void setHeight(int height) { this.height = height; } @@ -63,7 +63,7 @@ public class ObjectAreaInfo { * Sets the width resolution * @param widthRes the width resolution */ - protected void setWidthRes(int widthRes) { + public void setWidthRes(int widthRes) { this.widthRes = widthRes; } @@ -71,10 +71,10 @@ public class ObjectAreaInfo { * Sets the height resolution * @param heightRes the height resolution */ - protected void setHeightRes(int heightRes) { + public void setHeightRes(int heightRes) { this.heightRes = heightRes; } - + /** * @return the x coordinate of this data object */ @@ -116,7 +116,7 @@ public class ObjectAreaInfo { public int getHeightRes() { return heightRes; } - + /** * @return the rotation of this data object */ @@ -128,10 +128,10 @@ public class ObjectAreaInfo { * Sets the data object rotation * @param rotation the data object rotation */ - protected void setRotation(int rotation) { + public void setRotation(int rotation) { this.rotation = rotation; } - + /** * {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java b/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java index c2d11bef2..bad46dd7c 100644 --- a/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java +++ b/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java @@ -28,8 +28,10 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.apache.fop.render.afp.AFPFontAttributes; import org.apache.fop.render.afp.DataObjectInfo; +import org.apache.fop.render.afp.ObjectAreaInfo; import org.apache.fop.render.afp.ResourceInfo; import org.apache.fop.render.afp.ResourceLevel; import org.apache.fop.render.afp.fonts.AFPFont; @@ -42,7 +44,7 @@ import org.apache.fop.render.afp.tools.StringUtils; * destined for a presentation service, archive library, presentation device or * another application program. The strategic presentation data stream * architectures used is Mixed Object Document Content Architecture (MO:DCA). - * + * * The MO:DCA architecture defines the data stream used by applications to * describe documents and object envelopes for interchange with other * applications and application services. Documents defined in the MO:DCA format @@ -177,7 +179,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * The document is started by invoking this method which creates an instance * of the AFP Document object. - * + * * @param name * the name of this document. */ @@ -191,7 +193,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Sets the OutputStream - * + * * @param outputStream * the AFP OutputStream */ @@ -204,7 +206,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { * instance of the AFP Document object and registers the start with a * validation map which ensures that methods are not invoked out of the * correct sequence. - * + * * @throws java.io.IOException * throws an I/O exception of some sort has occurred */ @@ -228,13 +230,13 @@ public class AFPDataStream extends AbstractResourceGroupContainer { if (interchangeSet.supportsLevel2()) { // Write out any external resource groups getExternalResourceGroupManager().writeExternalResources(); - + // Write out any print-file level resources if (hasResources()) { getResourceGroup().write(this.outputStream); } } - + // Write out document if (document != null) { document.endDocument(); @@ -253,7 +255,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Start a new page. When processing has finished on the current page, the * {@link #endPage()}method must be invoked to mark the page ending. - * + * * @param pageWidth * the width of the page * @param pageHeight @@ -281,7 +283,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { * Start a new overlay. When processing has finished on the current overlay, * the {@link #endOverlay()}method must be invoked to mark the overlay * ending. - * + * * @param x * the x position of the overlay on the page * @param y @@ -329,7 +331,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Helper method to save the current page. - * + * * @return current page object that was saved */ public PageObject savePage() { @@ -346,7 +348,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Helper method to restore the current page. - * + * * @param pageObject * page object */ @@ -373,7 +375,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Sets the offsets to be used for element positioning - * + * * @param xOff * the offset in the x direction * @param yOff @@ -389,7 +391,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Creates the given page fonts in the current page - * + * * @param pageFonts * a collection of AFP font attributes */ @@ -407,7 +409,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { * Helper method to create a map coded font object on the current page, this * method delegates the construction of the map coded font object to the * active environment group on the current page. - * + * * @param fontReference * the font number used as the resource identifier * @param font @@ -422,7 +424,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Helper method to create text on the current page, this method delegates * to the current presentation text object in order to construct the text. - * + * * @param fontReference * the font reference used as the resource identifier * @param x @@ -447,7 +449,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Creates a data object in the datastream. The data object resides * according to its type, info and MO:DCA-L (resource) support. - * + * * @param dataObjectInfo * the data object info * @return a data object @@ -465,6 +467,12 @@ public class AFPDataStream extends AbstractResourceGroupContainer { dataObjectInfo.setUri(uri); } + //Update placement with current state + ObjectAreaInfo areaInfo = dataObjectInfo.getObjectAreaInfo(); + areaInfo.setX(areaInfo.getX() + this.xOffset); + areaInfo.setY(areaInfo.getY() + this.yOffset); + areaInfo.setRotation(this.rotation); + Registry registry = Registry.getInstance(); Registry.ObjectType objectType = registry.getObjectType(dataObjectInfo); // recognised object type @@ -473,7 +481,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); ResourceLevel resourceLevel = resourceInfo.getLevel(); - + // is MO:DCA-L available? if (interchangeSet.supportsLevel2()) { // can this data object use the include object (IOB) referencing @@ -494,7 +502,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { if (resourceLevel.isExternal()) { log.warn(interchangeSet + ": not available, object " + getName() + " will reside inline"); - } + } } } // unrecognised/unsupported object type so create/embed data object @@ -506,7 +514,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { // /** // * Sets the object view port taking into account rotation. -// * +// * // * @param x // * the x position of the object // * @param y @@ -569,7 +577,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Method to create a line on the current page. - * + * * @param x1 * the first x coordinate of the line * @param y1 @@ -593,7 +601,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { * This method will create shading on the page using the specified * coordinates (the shading contrast is controlled via the red, green, blue * parameters, by converting this to grey scale). - * + * * @param x * the x coordinate of the shading * @param y @@ -613,7 +621,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Helper method which allows creation of the MPO object, via the AEG. And * the IPO via the Page. (See actual object for descriptions.) - * + * * @param name * the name of the static overlay */ @@ -624,7 +632,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Helper method which allows creation of the IMM object. - * + * * @param name * the name of the medium map */ @@ -634,7 +642,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Creates an IncludePageSegment on the current page. - * + * * @param name * the name of the include page segment * @param x @@ -668,7 +676,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Creates a TagLogicalElement on the current page. - * + * * @param attributes * the array of key value pairs. */ @@ -682,7 +690,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Creates a TagLogicalElement on the current page group. - * + * * @param attributes * the array of key value pairs. */ @@ -696,7 +704,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Creates a TagLogicalElement on the current page or page group - * + * * @param name * The tag name * @param value @@ -712,7 +720,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Creates a NoOperation item - * + * * @param content * byte data */ @@ -753,7 +761,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Sets the rotation to be used for portrait pages, valid values are 0 * (default), 90, 180, 270. - * + * * @param pageRotation * The rotation in degrees. */ @@ -770,7 +778,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Sets the rotation to be used for landscape pages, valid values are 0, 90, * 180, 270 (default). - * + * * @param pageRotation * The rotation in degrees. */ @@ -786,7 +794,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Returns the resource group for a given resource into - * + * * @param level * resource info * @return a resource group container for the given resource info @@ -810,7 +818,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Sets the default resource group file - * + * * @param resourceGroupFile * the default resource group file */ @@ -846,7 +854,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Main constructor - * + * * @param container * the container of this manager */ @@ -857,7 +865,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Sets the default resource group file - * + * * @param resourceGroupFile * the default resource group file */ @@ -901,7 +909,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { /** * Returns the corresponding resource group for the given resource level - * + * * @param level * the resource level * @return the corresponding resource group for the given resource level @@ -950,7 +958,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { } /** - * @return the MO:DCA interchange set in use + * @return the MO:DCA interchange set in use */ public InterchangeSet getInterchangeSet() { return this.interchangeSet; diff --git a/src/java/org/apache/fop/render/afp/modca/ImageObject.java b/src/java/org/apache/fop/render/afp/modca/ImageObject.java index 67c0a0858..928a9790c 100644 --- a/src/java/org/apache/fop/render/afp/modca/ImageObject.java +++ b/src/java/org/apache/fop/render/afp/modca/ImageObject.java @@ -22,6 +22,7 @@ package org.apache.fop.render.afp.modca; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; + import org.apache.fop.render.afp.tools.BinaryUtils; /** @@ -51,10 +52,7 @@ public class ImageObject extends AbstractDataObject { * @param height the image height */ public void setImageParameters(int xresol, int yresol, int width, int height) { - if (objectEnvironmentGroup == null) { - objectEnvironmentGroup = new ObjectEnvironmentGroup(); - } - objectEnvironmentGroup.setImageData(xresol, yresol, width, height); + getObjectEnvironmentGroup().setImageData(xresol, yresol, width, height); if (imageSegment == null) { imageSegment = new ImageSegment(); } -- 2.39.5