diff options
author | Adrian Cumiskey <acumiskey@apache.org> | 2008-06-09 11:19:44 +0000 |
---|---|---|
committer | Adrian Cumiskey <acumiskey@apache.org> | 2008-06-09 11:19:44 +0000 |
commit | 1dbe17e5b2edc0639f92cbb7644107dae8f6ad7e (patch) | |
tree | db41dd50af80e9fa35cef7f2e2f26fb36756bb03 /src/java/org/apache/fop | |
parent | 2665e6b83c40656cc728ef356bb932387ca9207e (diff) | |
download | xmlgraphics-fop-1dbe17e5b2edc0639f92cbb7644107dae8f6ad7e.tar.gz xmlgraphics-fop-1dbe17e5b2edc0639f92cbb7644107dae8f6ad7e.zip |
* Created new AreaObjectInfo class POJO to cleanup all this long parameter passingthat seems to be going on.
* convertToGrayscale() method changed so that it is performing an atomic function, again simplified/cleaned up parameter passing.
* Fixed bug with handling TIFF images.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@664679 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop')
12 files changed, 348 insertions, 282 deletions
diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index 763f9dafb..bfdf56d2b 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -923,8 +923,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { getAFPDataStream().createIncludePageSegment(name, mpts2units(x), mpts2units(y)); } else { - ImageManager manager = getUserAgent().getFactory() - .getImageManager(); + ImageManager manager = getUserAgent().getFactory().getImageManager(); ImageInfo info = null; InputStream in = null; try { @@ -967,12 +966,16 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { ImageObjectInfo imageObjectInfo = new ImageObjectInfo(); imageObjectInfo.setUri(uri); imageObjectInfo.setMimeType(mimeType); - imageObjectInfo.setX(afpx); - imageObjectInfo.setY(afpy); - imageObjectInfo.setWidth(afpw); - imageObjectInfo.setHeight(afph); - imageObjectInfo.setWidthRes(afpres); - imageObjectInfo.setHeightRes(afpres); + + ObjectAreaInfo objectAreaInfo = new ObjectAreaInfo(); + objectAreaInfo.setX(afpx); + objectAreaInfo.setY(afpy); + objectAreaInfo.setWidth(afpw); + objectAreaInfo.setHeight(afph); + objectAreaInfo.setWidthRes(afpres); + objectAreaInfo.setHeightRes(afpres); + imageObjectInfo.setObjectAreaInfo(objectAreaInfo); + imageObjectInfo.setData(buf); imageObjectInfo.setDataHeight(ccitt.getSize().getHeightPx()); imageObjectInfo.setDataWidth(ccitt.getSize().getWidthPx()); @@ -1068,23 +1071,27 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { // create image object parameters ImageObjectInfo imageObjectInfo = new ImageObjectInfo(); + imageObjectInfo.setBuffered(true); if (imageInfo != null) { imageObjectInfo.setUri(imageInfo.getOriginalURI()); imageObjectInfo.setMimeType(imageInfo.getMimeType()); } - imageObjectInfo.setX(mpts2units(x)); - imageObjectInfo.setY(mpts2units(y)); - imageObjectInfo.setWidth(mpts2units(w)); - imageObjectInfo.setHeight(mpts2units(h)); - imageObjectInfo.setWidthRes(imageRes); - imageObjectInfo.setHeightRes(imageRes); + + ObjectAreaInfo objectAreaInfo = new ObjectAreaInfo(); + objectAreaInfo.setX(mpts2units(x)); + objectAreaInfo.setY(mpts2units(y)); + objectAreaInfo.setWidth(mpts2units(w)); + objectAreaInfo.setHeight(mpts2units(h)); + objectAreaInfo.setWidthRes(imageRes); + objectAreaInfo.setHeightRes(imageRes); + imageObjectInfo.setObjectAreaInfo(objectAreaInfo); + imageObjectInfo.setData(baout.toByteArray()); imageObjectInfo.setDataHeight(image.getHeight()); imageObjectInfo.setDataWidth(image.getWidth()); imageObjectInfo.setColor(colorImages); imageObjectInfo.setBitsPerPixel(bitsPerPixel); imageObjectInfo.setResourceInfoFromForeignAttributes(foreignAttributes); - getAFPDataStream().createObject(imageObjectInfo); } diff --git a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java index 8277418d4..660ac4332 100644 --- a/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java +++ b/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java @@ -274,7 +274,7 @@ public class AFPRendererConfigurator extends PrintRendererConfigurator { afpRenderer.getAFPDataStream().setDefaultResourceGroupFile(resourceGroupFile); } else { log.warn("Unable to write to default external resource group file '" - + resourceGroupDest); + + resourceGroupDest + "'"); } } } diff --git a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java index 86c26d74f..b0d155cd9 100644 --- a/src/java/org/apache/fop/render/afp/AFPSVGHandler.java +++ b/src/java/org/apache/fop/render/afp/AFPSVGHandler.java @@ -153,23 +153,28 @@ public class AFPSVGHandler extends AbstractGenericSVGHandler { int height = (int)Math.round((afpInfo.getHeight() * res) / 72000f); // set the data object parameters - DataObjectInfo info = new DataObjectInfo(); + DataObjectInfo dataObjectInfo = new DataObjectInfo(); String docUri = ((AbstractDocument)doc).getDocumentURI(); - info.setUri(docUri); - info.setX(x); - info.setY(y); - info.setWidth(width); - info.setHeight(height); - info.setWidthRes(res); - info.setHeightRes(res); + dataObjectInfo.setUri(docUri); + + ObjectAreaInfo objectAreaInfo = new ObjectAreaInfo(); + objectAreaInfo.setX(x); + objectAreaInfo.setY(y); + objectAreaInfo.setWidth(width); + objectAreaInfo.setHeight(height); + objectAreaInfo.setWidthRes(res); + objectAreaInfo.setHeightRes(res); + + dataObjectInfo.setObjectAreaInfo(objectAreaInfo); + Map/*<QName, String>*/ foreignAttributes = (Map/*<QName, String>*/)context.getProperty( RendererContextConstants.FOREIGN_ATTRIBUTES); - info.setResourceInfoFromForeignAttributes(foreignAttributes); + dataObjectInfo.setResourceInfoFromForeignAttributes(foreignAttributes); AFPDataStream afpDataStream = afpInfo.getAFPDataStream(); - GraphicsObject graphicsObj = (GraphicsObject)afpDataStream.createObject(info); + GraphicsObject graphicsObj = (GraphicsObject)afpDataStream.createObject(dataObjectInfo); graphics.setGraphicsObject(graphicsObj); try { diff --git a/src/java/org/apache/fop/render/afp/DataObjectInfo.java b/src/java/org/apache/fop/render/afp/DataObjectInfo.java index 00044da96..b25470551 100644 --- a/src/java/org/apache/fop/render/afp/DataObjectInfo.java +++ b/src/java/org/apache/fop/render/afp/DataObjectInfo.java @@ -42,13 +42,9 @@ public class DataObjectInfo { private static final ResourceInfo DEFAULT_RESOURCE_INFO = new ResourceInfo(); private String uri; - private int x; - private int y; - private int width; - private int height; - private int widthRes; - private int heightRes; - private int rotation = 0; + + /** the object area info */ + private ObjectAreaInfo objectAreaInfo; /** object type entry */ private ObjectType objectType; @@ -70,53 +66,6 @@ public class DataObjectInfo { this.uri = uri; } - /** - * Sets the x position of the data object - * @param x the x position of the data object - */ - protected void setX(int x) { - this.x = x; - } - - /** - * Sets the y position of the data object - * @param y the y position of the data object - */ - protected void setY(int y) { - this.y = y; - } - - /** - * Sets the data object width - * @param width the width of the data object - */ - protected void setWidth(int width) { - this.width = width; - } - - /** - * Sets the data object height - * @param height the height of the data object - */ - protected void setHeight(int height) { - this.height = height; - } - - /** - * Sets the width resolution - * @param widthRes the width resolution - */ - protected void setWidthRes(int widthRes) { - this.widthRes = widthRes; - } - - /** - * Sets the height resolution - * @param heightRes the height resolution - */ - protected void setHeightRes(int heightRes) { - this.heightRes = heightRes; - } /** * @return the uri of this data object @@ -126,63 +75,6 @@ public class DataObjectInfo { } /** - * @return the x coordinate of this data object - */ - public int getX() { - return x; - } - - /** - * @return the y coordinate of this data object - */ - public int getY() { - return y; - } - - /** - * @return the width of this data object - */ - public int getWidth() { - return width; - } - - /** - * @return the height of this data object - */ - public int getHeight() { - return height; - } - - /** - * @return the width resolution of this data object - */ - public int getWidthRes() { - return widthRes; - } - - /** - * @return the height resolution of this data object - */ - public int getHeightRes() { - return heightRes; - } - - /** - * @return the rotation of this data object - */ - public int getRotation() { - return rotation; - } - - /** - * Sets the data object rotation - * @param rotation the data object rotation - */ - protected void setRotation(int rotation) { - this.rotation = rotation; - } - - /** * Sets the object type * @param objectType the object type */ @@ -213,6 +105,21 @@ public class DataObjectInfo { } /** + * Sets the object area info + * @param objectAreaInfo the object area info + */ + public void setObjectAreaInfo(ObjectAreaInfo objectAreaInfo) { + this.objectAreaInfo = objectAreaInfo; + } + + /** + * @return the object area info + */ + public ObjectAreaInfo getObjectAreaInfo() { + return this.objectAreaInfo; + } + + /** * Sets the resource group settings using the given foreign attributes * @param foreignAttributes a mapping of element attributes names to values */ @@ -278,14 +185,8 @@ public class DataObjectInfo { */ public String toString() { return "uri=" + uri - + ", x=" + x - + ", y=" + y - + ", width=" + width - + ", height=" + height - + ", widthRes=" + widthRes - + ", heightRes=" + heightRes - + ", rotation=" + rotation - + (resourceInfo != null ? ", resourceInfo=" + resourceInfo : "") - + (objectType != null ? ", objectTypeEntry=" + objectType : ""); + + (objectAreaInfo != null ? "objectAreaInfo=" + objectAreaInfo : "") + + (objectType != null ? ", objectType=" + objectType : "") + + (resourceInfo != null ? ", resourceInfo=" + resourceInfo : ""); } } diff --git a/src/java/org/apache/fop/render/afp/ImageObjectInfo.java b/src/java/org/apache/fop/render/afp/ImageObjectInfo.java index cf5e7f951..f9bbc82cf 100644 --- a/src/java/org/apache/fop/render/afp/ImageObjectInfo.java +++ b/src/java/org/apache/fop/render/afp/ImageObjectInfo.java @@ -29,7 +29,8 @@ public class ImageObjectInfo extends DataObjectInfo { private byte[] data; private int dataWidth; private int dataHeight; - private String mimeType; + private String mimeType; + private boolean buffered; /** * Default constructor @@ -151,6 +152,21 @@ public class ImageObjectInfo extends DataObjectInfo { } /** + * Sets whether or not this is info about a buffered image + * @param buffered true if this is info about a buffered image + */ + public void setBuffered(boolean buffered) { + this.buffered = buffered; + } + + /** + * @return true if this image info is about a buffered image + */ + public boolean isBuffered() { + return this.buffered; + } + + /** * {@inheritDoc} */ public String toString() { @@ -161,4 +177,5 @@ public class ImageObjectInfo extends DataObjectInfo { + ", color=" + color + ", bitPerPixel=" + bitsPerPixel; } + }
\ No newline at end of file diff --git a/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java b/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java new file mode 100644 index 000000000..85da1a8e2 --- /dev/null +++ b/src/java/org/apache/fop/render/afp/ObjectAreaInfo.java @@ -0,0 +1,147 @@ +/* + * 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.render.afp; + +public class ObjectAreaInfo { + private int x; + private int y; + private int width; + private int height; + 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) { + this.x = x; + } + + /** + * Sets the y position of the data object + * @param y the y position of the data object + */ + protected void setY(int y) { + this.y = y; + } + + /** + * Sets the data object width + * @param width the width of the data object + */ + protected void setWidth(int width) { + this.width = width; + } + + /** + * Sets the data object height + * @param height the height of the data object + */ + protected void setHeight(int height) { + this.height = height; + } + + /** + * Sets the width resolution + * @param widthRes the width resolution + */ + protected void setWidthRes(int widthRes) { + this.widthRes = widthRes; + } + + /** + * Sets the height resolution + * @param heightRes the height resolution + */ + protected void setHeightRes(int heightRes) { + this.heightRes = heightRes; + } + + /** + * @return the x coordinate of this data object + */ + public int getX() { + return x; + } + + /** + * @return the y coordinate of this data object + */ + public int getY() { + return y; + } + + /** + * @return the width of this data object + */ + public int getWidth() { + return width; + } + + /** + * @return the height of this data object + */ + public int getHeight() { + return height; + } + + /** + * @return the width resolution of this data object + */ + public int getWidthRes() { + return widthRes; + } + + /** + * @return the height resolution of this data object + */ + public int getHeightRes() { + return heightRes; + } + + /** + * @return the rotation of this data object + */ + public int getRotation() { + return rotation; + } + + /** + * Sets the data object rotation + * @param rotation the data object rotation + */ + protected void setRotation(int rotation) { + this.rotation = rotation; + } + + /** + * {@inheritDoc} + */ + public String toString() { + return "x=" + x + + ", y=" + y + + ", width=" + width + + ", height=" + height + + ", widthRes=" + widthRes + + ", heightRes=" + heightRes + + ", rotation=" + rotation; + } +}
\ No newline at end of file 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 92a5b99f2..c2d11bef2 100644 --- a/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java +++ b/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java @@ -492,7 +492,7 @@ public class AFPDataStream extends AbstractResourceGroupContainer { } } else { if (resourceLevel.isExternal()) { - log.warn( interchangeSet + log.warn(interchangeSet + ": not available, object " + getName() + " will reside inline"); } } @@ -504,68 +504,68 @@ public class AFPDataStream extends AbstractResourceGroupContainer { return dataObj; } - /** - * Sets the object view port taking into account rotation. - * - * @param x - * the x position of the object - * @param y - * the y position of the object - * @param w - * the width of the object - * @param h - * the height of the object - * @param wr - * the resolution width of the object - * @param hr - * the resolution height of the object - * @return a new graphics object - */ - private void setObjectViewPort(AbstractDataObject dataObj, int x, int y, - int w, int h, int wr, int hr) { - int xOrigin; - int yOrigin; - int width; - int height; - int widthRes; - int heightRes; - switch (this.rotation) { - case 90: - xOrigin = getCurrentPage().getWidth() - y - yOffset; - yOrigin = x + xOffset; - width = h; - height = w; - widthRes = hr; - heightRes = wr; - break; - case 180: - xOrigin = getCurrentPage().getWidth() - x - xOffset; - yOrigin = getCurrentPage().getHeight() - y - yOffset; - width = w; - height = h; - widthRes = wr; - heightRes = hr; - break; - case 270: - xOrigin = y + yOffset; - yOrigin = getCurrentPage().getHeight() - x - xOffset; - width = h; - height = w; - widthRes = hr; - heightRes = wr; - break; - default: - xOrigin = x + xOffset; - yOrigin = y + yOffset; - width = w; - height = h; - widthRes = wr; - heightRes = hr; - break; - } - dataObj.setViewport(xOrigin, yOrigin, width, height, widthRes, - heightRes, rotation); - } +// /** +// * Sets the object view port taking into account rotation. +// * +// * @param x +// * the x position of the object +// * @param y +// * the y position of the object +// * @param w +// * the width of the object +// * @param h +// * the height of the object +// * @param wr +// * the resolution width of the object +// * @param hr +// * the resolution height of the object +// * @return a new graphics object +// */ +// private void setObjectViewPort(AbstractDataObject dataObj, int x, int y, +// int w, int h, int wr, int hr) { +// int xOrigin; +// int yOrigin; +// int width; +// int height; +// int widthRes; +// int heightRes; +// switch (this.rotation) { +// case 90: +// xOrigin = getCurrentPage().getWidth() - y - yOffset; +// yOrigin = x + xOffset; +// width = h; +// height = w; +// widthRes = hr; +// heightRes = wr; +// break; +// case 180: +// xOrigin = getCurrentPage().getWidth() - x - xOffset; +// yOrigin = getCurrentPage().getHeight() - y - yOffset; +// width = w; +// height = h; +// widthRes = wr; +// heightRes = hr; +// break; +// case 270: +// xOrigin = y + yOffset; +// yOrigin = getCurrentPage().getHeight() - x - xOffset; +// width = h; +// height = w; +// widthRes = hr; +// heightRes = wr; +// break; +// default: +// xOrigin = x + xOffset; +// yOrigin = y + yOffset; +// width = w; +// height = h; +// widthRes = wr; +// heightRes = hr; +// break; +// } +// dataObj.setViewport(xOrigin, yOrigin, width, height, widthRes, +// heightRes, rotation); +// } /** * Method to create a line on the current page. diff --git a/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java b/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java index 9bf713127..f52047b62 100644 --- a/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java +++ b/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java @@ -22,6 +22,8 @@ package org.apache.fop.render.afp.modca; import java.io.IOException; import java.io.OutputStream; +import org.apache.fop.render.afp.ObjectAreaInfo; + /** * Abstract base class used by the ImageObject and GraphicsObject which both @@ -45,25 +47,11 @@ public abstract class AbstractDataObject extends AbstractPreparedObjectContainer /** * Sets the object display area position and size. * - * @param x - * the x position of the object - * @param y - * the y position of the object - * @param width - * the width of the object - * @param height - * the height of the object - * @param widthRes - * the resolution width - * @param heightRes - * the resolution height - * @param rotation - * the rotation of the object + * @param objectAreaInfo + * the object area info */ - public void setViewport(int x, int y, int width, int height, - int widthRes, int heightRes, int rotation) { - getObjectEnvironmentGroup().setObjectArea(x, y, width, height, - widthRes, heightRes, rotation); + public void setViewport(ObjectAreaInfo objectAreaInfo) { + getObjectEnvironmentGroup().setObjectArea(objectAreaInfo); } /** diff --git a/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java b/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java index bcb506dee..7e3f41a53 100644 --- a/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java +++ b/src/java/org/apache/fop/render/afp/modca/DataObjectFactory.java @@ -21,6 +21,7 @@ package org.apache.fop.render.afp.modca; import org.apache.fop.render.afp.DataObjectInfo; import org.apache.fop.render.afp.ImageObjectInfo; +import org.apache.fop.render.afp.ObjectAreaInfo; import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet; import org.apache.fop.render.afp.tools.StringUtils; import org.apache.xmlgraphics.image.codec.tiff.TIFFImage; @@ -43,25 +44,23 @@ public class DataObjectFactory { * * @param io * the target image object - * @param raw - * the buffer containing the RGB image data - * @param width - * the width of the image in pixels - * @param height - * the height of the image in pixels - * @param bitsPerPixel - * the number of bits to use per pixel - * - * TODO: move this method somewhere appropriate in commons + * @param info + * the image object info + * + * @return the converted image data */ - private static void convertToGrayScaleImage(ImageObject io, byte[] raw, int width, - int height, int bitsPerPixel) { + private static byte[] convertToGrayScaleImage(ImageObject io, ImageObjectInfo info) { + byte[] raw = info.getData(); + int width = info.getDataWidth(); + int height = info.getDataHeight(); + int bitsPerPixel = info.getBitsPerPixel(); + int pixelsPerByte = 8 / bitsPerPixel; int bytewidth = (width / pixelsPerByte); if ((width % pixelsPerByte) != 0) { bytewidth++; } - byte[] bw = new byte[height * bytewidth]; + byte[] data = new byte[height * bytewidth]; byte ib; for (int y = 0; y < height; y++) { ib = 0; @@ -92,27 +91,26 @@ public class DataObjectFactory { if ((x % pixelsPerByte) == (pixelsPerByte - 1) || ((x + 1) == width)) { - bw[(y * bytewidth) + (x / pixelsPerByte)] = ib; + data[(y * bytewidth) + (x / pixelsPerByte)] = ib; ib = 0; } } } - io.setImageIDESize((byte) bitsPerPixel); - io.setImageData(bw); + return data; } /** * Helper method to create an image on the current container and to return * the object. - * @param info the image object info + * @param imageObjectInfo the image object info * @return a newly created image object */ - protected ImageObject createImage(ImageObjectInfo info) { + protected ImageObject createImage(ImageObjectInfo imageObjectInfo) { String name = IMAGE_NAME_PREFIX + StringUtils.lpad(String.valueOf(++imageCount), '0', 5); ImageObject imageObj = new ImageObject(name); - if (info.hasCompression()) { - int compression = info.getCompression(); + if (imageObjectInfo.hasCompression()) { + int compression = imageObjectInfo.getCompression(); switch (compression) { case TIFFImage.COMP_FAX_G3_1D: imageObj.setImageEncoding(ImageContent.COMPID_G3_MH); @@ -128,15 +126,19 @@ public class DataObjectFactory { "Invalid compression scheme: " + compression); } } - imageObj.setImageParameters(info.getWidthRes(), info.getHeightRes(), - info.getDataWidth(), info.getDataHeight()); - if (info.isColor()) { - imageObj.setImageIDESize((byte)24); - imageObj.setImageData(info.getData()); - } else { - convertToGrayScaleImage(imageObj, info.getData(), - info.getDataWidth(), info.getDataHeight(), - info.getBitsPerPixel()); + ObjectAreaInfo objectAreaInfo = imageObjectInfo.getObjectAreaInfo(); + imageObj.setImageParameters(objectAreaInfo.getWidthRes(), objectAreaInfo.getHeightRes(), + imageObjectInfo.getDataWidth(), imageObjectInfo.getDataHeight()); + if (imageObjectInfo.isBuffered()) { + if (imageObjectInfo.isColor()) { + imageObj.setImageIDESize((byte)24); + imageObj.setImageData(imageObjectInfo.getData()); + } else { + int bitsPerPixel = imageObjectInfo.getBitsPerPixel(); + imageObj.setImageIDESize((byte)bitsPerPixel); + byte[] data = convertToGrayScaleImage(imageObj, imageObjectInfo); + imageObj.setImageData(data); + } } return imageObj; } @@ -166,10 +168,7 @@ public class DataObjectFactory { } else { dataObject = createGraphic(dataObjectInfo); } - dataObject.setViewport(dataObjectInfo.getX(), dataObjectInfo.getY(), - dataObjectInfo.getWidth(), dataObjectInfo.getHeight(), - dataObjectInfo.getWidthRes(), dataObjectInfo.getHeightRes(), - dataObjectInfo.getRotation()); + dataObject.setViewport(dataObjectInfo.getObjectAreaInfo()); dataObject.setFullyQualifiedName( FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_INTERNAL_RESOURCE_REF, diff --git a/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java b/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java index 0c260db90..a73c9fc70 100644 --- a/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java +++ b/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java @@ -23,6 +23,7 @@ import java.awt.Color; import java.io.IOException; import java.io.OutputStream; +import org.apache.fop.render.afp.ObjectAreaInfo; import org.apache.fop.render.afp.goca.GraphicsBox; import org.apache.fop.render.afp.goca.GraphicsData; import org.apache.fop.render.afp.goca.GraphicsFillet; @@ -64,11 +65,15 @@ public class GraphicsObject extends AbstractDataObject { /** * {@inheritDoc} */ - public void setViewport(int x, int y, int width, int height, - int widthRes, int heightRes, int rotation) { - super.setViewport(x, y, width, height, widthRes, heightRes, rotation); + public void setViewport(ObjectAreaInfo objectAreaInfo) { + super.setViewport(objectAreaInfo); getObjectEnvironmentGroup().setGraphicsData( - widthRes, heightRes, 0, x + width, 0, y + height); + objectAreaInfo.getWidthRes(), + objectAreaInfo.getHeightRes(), + 0, + objectAreaInfo.getX() + objectAreaInfo.getWidth(), + 0, + objectAreaInfo.getY() + objectAreaInfo.getHeight()); } /** diff --git a/src/java/org/apache/fop/render/afp/modca/IncludeObject.java b/src/java/org/apache/fop/render/afp/modca/IncludeObject.java index 188664264..85cb283a8 100644 --- a/src/java/org/apache/fop/render/afp/modca/IncludeObject.java +++ b/src/java/org/apache/fop/render/afp/modca/IncludeObject.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.OutputStream; import org.apache.fop.render.afp.DataObjectInfo; +import org.apache.fop.render.afp.ObjectAreaInfo; import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet; import org.apache.fop.render.afp.modca.triplets.MappingOptionTriplet; import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet; @@ -133,8 +134,8 @@ public class IncludeObject extends AbstractNamedAFPObject implements DataObjectA } DataObjectInfo dataObjectInfo = dataObjectAccessor.getDataObjectInfo(); - - setObjectArea(dataObjectInfo.getX(), dataObjectInfo.getY()); + ObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo(); + setObjectArea(objectAreaInfo.getX(), objectAreaInfo.getY()); super.setFullyQualifiedName( FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME, @@ -147,11 +148,11 @@ public class IncludeObject extends AbstractNamedAFPObject implements DataObjectA ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT, objectType); - super.setMeasurementUnits(dataObjectInfo.getWidthRes(), dataObjectInfo.getHeightRes()); + super.setMeasurementUnits(objectAreaInfo.getWidthRes(), objectAreaInfo.getHeightRes()); super.setMappingOption(MappingOptionTriplet.SCALE_TO_FIT); - super.setObjectAreaSize(dataObjectInfo.getWidth(), dataObjectInfo.getHeight()); + super.setObjectAreaSize(objectAreaInfo.getWidth(), objectAreaInfo.getHeight()); } /** diff --git a/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java b/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java index b673dec46..4b31da1f1 100644 --- a/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java +++ b/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java @@ -22,6 +22,8 @@ package org.apache.fop.render.afp.modca; import java.io.IOException; import java.io.OutputStream; +import org.apache.fop.render.afp.ObjectAreaInfo; + /** * An Object Environment Group (OEG) may be associated with an object and is contained @@ -79,20 +81,14 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject { /** * Sets the object area parameters. - * @param x the x position of the object - * @param y the y position of the object - * @param width the object width - * @param height the object height - * @param rotation the object orientation - * @param widthRes the object resolution width - * @param heightRes the object resolution height + * @param info the object area info */ - public void setObjectArea(int x, int y, int width, int height, - int widthRes, int heightRes, int rotation) { - this.objectAreaDescriptor = new ObjectAreaDescriptor(width, height, - widthRes, heightRes); - this.objectAreaPosition = new ObjectAreaPosition(x, y, rotation); - + public void setObjectArea(ObjectAreaInfo info) { + this.objectAreaDescriptor = new ObjectAreaDescriptor( + info.getWidth(), info.getHeight(), + info.getWidthRes(), info.getHeightRes()); + this.objectAreaPosition = new ObjectAreaPosition( + info.getX(), info.getY(), info.getRotation()); } /** |