import org.apache.fop.render.afp.modca.GraphicsObject;
import org.apache.fop.render.afp.modca.ImageObject;
import org.apache.fop.render.afp.modca.IncludeObject;
+import org.apache.fop.render.afp.modca.MapDataResource;
import org.apache.fop.render.afp.modca.ObjectContainer;
import org.apache.fop.render.afp.modca.Overlay;
import org.apache.fop.render.afp.modca.PageSegment;
import org.apache.fop.render.afp.modca.Registry;
import org.apache.fop.render.afp.modca.ResourceObject;
+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;
import org.apache.xmlgraphics.image.codec.tiff.TIFFImage;
* @return a newly created image object
*/
public AbstractDataObject createImage(AFPImageObjectInfo imageObjectInfo) {
- AbstractDataObject dataObj;
- Registry.ObjectType objectType = imageObjectInfo.getObjectType();
-
- // A known object type so place in container
- if (objectType != null) {
- ObjectContainer objectContainer = factory.createObjectContainer();
-
- objectContainer.setObjectClassification(
- ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT,
- objectType);
-
- objectContainer.setData(imageObjectInfo.getData());
-
- dataObj = objectContainer;
- } else {
+ AbstractDataObject dataObj = null;
+ // A known object type so place in an object container
+ if (imageObjectInfo.isBuffered()) {
+ // IOCA bitmap image
ImageObject imageObj = factory.createImageObject();
if (imageObjectInfo.hasCompression()) {
int compression = imageObjectInfo.getCompression();
}
}
-// imageObjectInfo.getDataWidth(), imageObjectInfo.getDataHeight(),
-// objectAreaInfo.getWidthRes(), objectAreaInfo.getHeightRes());
-
- if (imageObjectInfo.isBuffered()) {
- if (imageObjectInfo.isColor()) {
- imageObj.setIDESize((byte) 24);
- } else {
- imageObj.setIDESize((byte) imageObjectInfo.getBitsPerPixel());
- }
- imageObj.setData(imageObjectInfo.getData());
+ if (imageObjectInfo.isColor()) {
+ imageObj.setIDESize((byte) 24);
+ } else {
+ imageObj.setIDESize((byte) imageObjectInfo.getBitsPerPixel());
}
+ imageObj.setData(imageObjectInfo.getData());
+
dataObj = imageObj;
+
+ } else {
+ ObjectContainer objectContainer = factory.createObjectContainer();
+
+ Registry.ObjectType objectType = imageObjectInfo.getObjectType();
+
+ objectContainer.setObjectClassification(
+ ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT,
+ objectType);
+
+ objectContainer.setInputStream(imageObjectInfo.getInputStream());
+
+ dataObj = objectContainer;
}
return dataObj;
}
* @return a new graphics object
*/
public GraphicsObject createGraphic(AFPGraphicsObjectInfo graphicsObjectInfo) {
- // paint the graphic using batik
GraphicsObject graphicsObj = factory.createGraphic();
+ // paint the graphic using batik
graphicsObjectInfo.getPainter().paint(graphicsObj);
return graphicsObj;
}
Registry.ObjectType objectType = dataObjectInfo.getObjectType();
if (objectType != null) {
includeObj.setObjectClassification(
+ // object scope not defined
ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT,
objectType);
}
includeObj.setMeasurementUnits(
objectAreaInfo.getWidthRes(), objectAreaInfo.getHeightRes());
-// includeObj.setMappingOption(MappingOptionTriplet.SCALE_TO_FIT);
+ includeObj.setMappingOption(MappingOptionTriplet.SCALE_TO_FIT);
return includeObj;
}
/**
* Creates a resource object wrapper for named includable data objects
*
- * @param dataObj an named object
+ * @param namedObj an named object
* @param resourceInfo resource information
* @param objectType the object type
* @return a new resource object wrapper
*/
- public ResourceObject createResource(AbstractNamedAFPObject dataObj,
+ public ResourceObject createResource(AbstractNamedAFPObject namedObj,
AFPResourceInfo resourceInfo, Registry.ObjectType objectType) {
ResourceObject resourceObj = null;
String resourceName = resourceInfo.getName();
} else {
resourceObj = factory.createResource();
}
- if (dataObj instanceof ObjectContainer) {
- resourceObj.setType(ResourceObject.TYPE_OBJECT_CONTAINER);
-
- // mandatory triplet for object container
- resourceObj.setObjectClassification(
- ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT,
- objectType);
- } else if (dataObj instanceof ImageObject) {
- resourceObj.setType(ResourceObject.TYPE_IMAGE);
- } else if (dataObj instanceof GraphicsObject) {
- resourceObj.setType(ResourceObject.TYPE_GRAPHIC);
- } else if (dataObj instanceof Document) {
+ if (namedObj instanceof Document) {
resourceObj.setType(ResourceObject.TYPE_DOCUMENT);
- } else if (dataObj instanceof PageSegment) {
+ } else if (namedObj instanceof PageSegment) {
resourceObj.setType(ResourceObject.TYPE_PAGE_SEGMENT);
- } else if (dataObj instanceof Overlay) {
+ } else if (namedObj instanceof Overlay) {
resourceObj.setType(ResourceObject.TYPE_OVERLAY_OBJECT);
+ } else if (namedObj instanceof AbstractDataObject) {
+ AbstractDataObject dataObj = (AbstractDataObject)namedObj;
+
+ // other type by default
+ byte fqnType = FullyQualifiedNameTriplet.TYPE_OTHER_OBJECT_DATA_REF;
+ if (namedObj instanceof ObjectContainer) {
+ resourceObj.setType(ResourceObject.TYPE_OBJECT_CONTAINER);
+
+ // mandatory triplet for object container
+ resourceObj.setObjectClassification(
+ ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT,
+ objectType);
+ } else if (namedObj instanceof ImageObject) {
+ resourceObj.setType(ResourceObject.TYPE_IMAGE);
+ // ioca image type
+ fqnType = FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF;
+ } else if (namedObj instanceof GraphicsObject) {
+ resourceObj.setType(ResourceObject.TYPE_GRAPHIC);
+ } else {
+ throw new UnsupportedOperationException(
+ "Unsupported resource object for data object type " + dataObj);
+ }
+
+ // set the map data resource
+ MapDataResource mapDataResource = factory.createMapDataResource();
+ mapDataResource.setFullyQualifiedName(
+ fqnType,
+ FullyQualifiedNameTriplet.FORMAT_CHARSTR,
+ resourceObj.getName());
+ dataObj.getObjectEnvironmentGroup().setMapDataResource(mapDataResource);
+
} else {
throw new UnsupportedOperationException(
- "Unsupported resource object type " + dataObj);
+ "Unsupported resource object type " + namedObj);
}
- resourceObj.setDataObject(dataObj);
+ // set the resource information/classification on the data object
+ resourceObj.setDataObject(namedObj);
return resourceObj;
}
/** resource info */
private AFPResourceInfo resourceInfo;
- private byte[] data;
+ /** the data object width */
+ private int dataWidth;
+
+ /** the data object height */
+ private int dataHeight;
/**
* Default constructor
/** {@inheritDoc} */
public String toString() {
return "mimeType=" + getMimeType()
+ + ", dataWidth=" + dataWidth
+ + ", dataHeight=" + dataHeight
+ (objectAreaInfo != null ? ", objectAreaInfo=" + objectAreaInfo : "")
+ (resourceInfo != null ? ", resourceInfo=" + resourceInfo : "");
}
}
/**
- * Sets the object data
+ * Returns the image data width
+ *
+ * @return the image data width
+ */
+ public int getDataWidth() {
+ return dataWidth;
+ }
+
+ /**
+ * Sets the image data width
+ *
+ * @param imageDataWidth the image data width
+ */
+ public void setDataWidth(int imageDataWidth) {
+ this.dataWidth = imageDataWidth;
+ }
+
+ /**
+ * Returns the image data height
*
- * @param data a data byte array
+ * @return the image data height
*/
- public void setData(byte[] data) {
- this.data = data;
+ public int getDataHeight() {
+ return dataHeight;
}
/**
- * Returns the object data
+ * Sets the image data height
*
- * @return the object data as byte array
+ * @param imageDataHeight the image data height
*/
- public byte[] getData() {
- return this.data;
+ public void setDataHeight(int imageDataHeight) {
+ this.dataHeight = imageDataHeight;
}
/**
/** {@inheritDoc} */
public void draw(Shape shape) {
- log.debug("draw() shape=" + shape);
+// log.debug("draw() shape=" + shape);
doDrawing(shape, false);
}
/** {@inheritDoc} */
public void fill(Shape shape) {
- log.debug("fill() shape=" + shape);
+// log.debug("fill() shape=" + shape);
doDrawing(shape, true);
}
AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo();
-// float[] srcPts = new float[] {x, y};
-// int[] coords = unitConv.mpts2units(srcPts);
-// objectAreaInfo.setX(coords[X]);
-// objectAreaInfo.setY(coords[Y]);
AffineTransform at = gc.getTransform();
float[] srcPts = new float[] {x, y};
float[] dstPts = new float[2];
package org.apache.fop.render.afp;
+import java.io.InputStream;
/**
* A list of parameters associated with an image
*/
public class AFPImageObjectInfo extends AFPDataObjectInfo {
+ /** number of bits per pixel used */
private int bitsPerPixel;
+
+ /** is this a color image? */
private boolean color;
+
+ /** compression type if any */
private int compression = -1;
- private int dataWidth;
- private int dataHeight;
+
+ /** the image mimetype */
private String mimeType;
+
+ /** is this a buffered image? */
private boolean buffered;
+ /** the object data in a byte array */
+ private byte[] data;
+
+ /** the object data in an inputstream */
+ private InputStream inputStream;
+
/**
* Default constructor
*/
this.compression = compression;
}
+ /** {@inheritDoc} */
+ public String getMimeType() {
+ return mimeType;
+ }
+
/**
- * Returns the image data width
+ * Sets whether or not this is info about a buffered image
*
- * @return the image data width
+ * @param buffered true if this is info about a buffered image
*/
- public int getDataWidth() {
- return dataWidth;
+ public void setBuffered(boolean buffered) {
+ this.buffered = buffered;
}
/**
- * Sets the image data width
+ * Returns true if this image info is about a buffered image
*
- * @param imageDataWidth the image data width
+ * @return true if this image info is about a buffered image
*/
- public void setDataWidth(int imageDataWidth) {
- this.dataWidth = imageDataWidth;
+ public boolean isBuffered() {
+ return this.buffered;
}
/**
- * Returns the image data height
+ * Sets the object data
*
- * @return the image data height
+ * @param data the object data
*/
- public int getDataHeight() {
- return dataHeight;
+ public void setData(byte[] data) {
+ this.data = data;
}
/**
- * Sets the image data height
+ * Returns the object data
*
- * @param imageDataHeight the image data height
+ * @return the object data
*/
- public void setDataHeight(int imageDataHeight) {
- this.dataHeight = imageDataHeight;
- }
-
- /** {@inheritDoc} */
- public String getMimeType() {
- return mimeType;
+ public byte[] getData() {
+ return this.data;
}
/**
- * Sets whether or not this is info about a buffered image
+ * Sets the object data inputstream
*
- * @param buffered true if this is info about a buffered image
+ * @param inputStream the object data inputstream
*/
- public void setBuffered(boolean buffered) {
- this.buffered = buffered;
+ public void setInputStream(InputStream inputStream) {
+ this.inputStream = inputStream;
}
/**
- * Returns true if this image info is about a buffered image
+ * Returns the object data inputstream
*
- * @return true if this image info is about a buffered image
+ * @return the object data inputstream
*/
- public boolean isBuffered() {
- return this.buffered;
+ public InputStream getInputStream() {
+ return this.inputStream;
}
/** {@inheritDoc} */
public String toString() {
return "AFPImageObjectInfo{" + super.toString()
- + ", dataWidth=" + dataWidth
- + ", dataHeight=" + dataHeight
+ + ", mimeType=" + mimeType
+ + ", buffered=" + buffered
+ + ", compression=" + compression
+ ", color=" + color
- + ", bitPerPixel=" + bitsPerPixel
+ + ", bitsPerPixel=" + bitsPerPixel
+ "}";
}
org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
info, FLAVORS, hints, sessionContext);
- if (/*img instanceof ImageRawJPEG || */img instanceof ImageRawStream
- || img instanceof ImageRendered) {
+ if (img instanceof ImageRendered || img instanceof ImageRawStream) {
AFPImageObjectInfo imageObjectInfo
= getImageObjectInfo(uri, info, pos, origin, img);
resourceManager.createObject(imageObjectInfo);
} else {
imageObjectInfo.setBuffered(false);
-// int resolution = state.getResolution();
-// objectAreaInfo.setWidthRes(resolution);
-// objectAreaInfo.setHeightRes(resolution);
-
ImageRawStream rawStream = (ImageRawStream) img;
+ if (img instanceof ImageRawCCITTFax) {
+ ImageRawCCITTFax ccitt = (ImageRawCCITTFax) img;
+ imageObjectInfo.setCompression(ccitt.getCompression());
- int xresol = (int) (rawStream.getSize().getDpiHorizontal() * 10);
- objectAreaInfo.setWidthRes(xresol);
+ int xresol = (int) (rawStream.getSize().getDpiHorizontal() * 10);
+ objectAreaInfo.setWidthRes(xresol);
- int yresol = (int) (rawStream.getSize().getDpiVertical() * 10);
- objectAreaInfo.setHeightRes(yresol);
+ int yresol = (int) (rawStream.getSize().getDpiVertical() * 10);
+ objectAreaInfo.setHeightRes(yresol);
+ } else {
+ int resolution = state.getResolution();
+ objectAreaInfo.setWidthRes(resolution);
+ objectAreaInfo.setHeightRes(resolution);
+ }
InputStream inputStream = rawStream.createInputStream();
- byte[] buf = IOUtils.toByteArray(inputStream);
- imageObjectInfo.setData(buf);
+ imageObjectInfo.setInputStream(inputStream);
int dataHeight = rawStream.getSize().getHeightPx();
imageObjectInfo.setDataHeight(dataHeight);
int dataWidth = rawStream.getSize().getWidthPx();
imageObjectInfo.setDataWidth(dataWidth);
- if (img instanceof ImageRawCCITTFax) {
- ImageRawCCITTFax ccitt = (ImageRawCCITTFax) img;
- imageObjectInfo.setCompression(ccitt.getCompression());
- }
}
return imageObjectInfo;
}
/** {@inheritDoc} */
public void renderText(TextArea text) {
-// log.debug(text.getText());
renderInlineAreaBackAndBorders(text);
String name = getInternalFontNameForArea(text);
int interCharacterAdjustment
= Math.round(unitConv.mpt2units(text.getTextLetterSpaceAdjust()));
- TextDataInfo textDataInfo = new TextDataInfo();
+ AFPTextDataInfo textDataInfo = new AFPTextDataInfo();
textDataInfo.setFontReference(fontReference);
textDataInfo.setX(coords[X]);
textDataInfo.setY(coords[Y]);
*/
public class AFPResourceLevel {
+ /** directly in page **/
+ public static final int INLINE = 0;
+
/** page level **/
- public static final int PAGE = 0;
+ public static final int PAGE = 1;
/** page group level **/
- public static final int PAGE_GROUP = 1;
+ public static final int PAGE_GROUP = 2;
/** document level **/
- public static final int DOCUMENT = 2;
+ public static final int DOCUMENT = 3;
/** print file level **/
- public static final int PRINT_FILE = 3;
+ public static final int PRINT_FILE = 4;
/** external level **/
- public static final int EXTERNAL = 4;
+ public static final int EXTERNAL = 5;
+ private static final String NAME_INLINE = "inline";
private static final String NAME_PAGE = "page";
private static final String NAME_PAGE_GROUP = "page-group";
private static final String NAME_DOCUMENT = "document";
private static final String NAME_PRINT_FILE = "print-file";
private static final String NAME_EXTERNAL = "external";
- private static final String[] NAMES
- = new String[] {NAME_PAGE, NAME_PAGE_GROUP, NAME_DOCUMENT, NAME_PRINT_FILE, NAME_EXTERNAL};
-
+ private static final String[] NAMES = new String[] {
+ NAME_INLINE, NAME_PAGE, NAME_PAGE_GROUP,
+ NAME_DOCUMENT, NAME_PRINT_FILE, NAME_EXTERNAL
+ };
/** where the resource will reside in the AFP output */
}
/**
- * Returns true if this is a page level
+ * Returns true if this is at page level
*
- * @return true if this is a page level
+ * @return true if this is at page level
*/
public boolean isPage() {
return level == PAGE;
}
/**
- * Returns true if this is page group level
+ * Returns true if this is at page group level
*
- * @return true if this is page group level
+ * @return true if this is at page group level
*/
public boolean isPageGroup() {
return level == PAGE_GROUP;
}
/**
- * Returns true if this is document level
+ * Returns true if this is at document level
*
- * @return true if this is document level
+ * @return true if this is at document level
*/
public boolean isDocument() {
return level == DOCUMENT;
}
/**
- * Returns true if this is external level
+ * Returns true if this is at external level
*
- * @return true if this is external level
+ * @return true if this is at external level
*/
public boolean isExternal() {
return level == EXTERNAL;
}
/**
- * Returns true if this is print-file level
+ * Returns true if this is at print-file level
*
- * @return true if this is print-file level
+ * @return true if this is at print-file level
*/
public boolean isPrintFile() {
return level == PRINT_FILE;
}
/**
- * Returns true if this resource level is inlined
+ * Returns true if this resource level is inline
*
- * @return true if this resource level is inlined
+ * @return true if this resource level is inline
*/
- public boolean isInlined() {
- return isPage() || isPageGroup() || isDocument();
+ public boolean isInline() {
+ return level == INLINE;
}
/**
throw new IllegalArgumentException("Unknown data object type: " + dataObjectInfo);
}
+ // set data object viewport (i.e. position, rotation, dimension, resolution)
if (namedObj instanceof AbstractDataObject) {
AbstractDataObject dataObj = (AbstractDataObject)namedObj;
dataObj.setViewport(dataObjectInfo);
AFPResourceLevel resourceLevel = resourceInfo.getLevel();
Registry.ObjectType objectType = dataObjectInfo.getObjectType();
- boolean canInclude = (namedObj instanceof ImageObject
+
+ ResourceGroup resourceGroup = streamer.getResourceGroup(resourceLevel);
+
+ boolean canInclude = (resourceGroup != null) && (namedObj instanceof ImageObject
|| objectType != null && objectType.isIncludable());
+
if (canInclude) {
+
// if it is to reside within a resource group at print-file or external level
if (resourceLevel.isPrintFile() || resourceLevel.isExternal()) {
+
// wrap newly created data object in a resource object
namedObj = dataObjectFactory.createResource(namedObj, resourceInfo, objectType);
}
// add data object into its resource group destination
- ResourceGroup resourceGroup = streamer.getResourceGroup(resourceLevel);
resourceGroup.addObject(namedObj);
// add an include to the current page
// record name of data object for the resource
includeNameMap.put(resourceInfo, namedObj.getName());
} else {
- // add data object directly into the current page
+ // not to be included so inline data object directly into the current page
dataStream.getCurrentPage().addObject(namedObj);
}
} else {
- // existing resource so reference by adding an include to the current page
+ // an existing data resource so reference it by adding an include to the current page
IncludeObject includeObject
= dataObjectFactory.createInclude(includeName, dataObjectInfo);
dataStream.getCurrentPage().addObject(includeObject);
import org.apache.fop.render.Renderer;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RendererContextConstants;
+import org.apache.fop.render.RendererContext.RendererContextWrapper;
import org.apache.fop.svg.SVGEventProducer;
import org.apache.fop.svg.SVGUserAgent;
import org.apache.xmlgraphics.util.QName;
return afpi;
}
+ private static final int X = 0;
+ private static final int Y = 1;
+
/**
* Render the SVG document.
*
AFPUnitConverter unitConv = state.getUnitConverter();
-// RendererContextWrapper rctx = RendererContext.wrapRendererContext(context);
-// int currx = rctx.getCurrentXPosition();
-// int curry = rctx.getCurrentYPosition();
-// int afpx = Math.round(unitConv.mpt2units(currx));
-// int afpy = Math.round(unitConv.mpt2units(curry));
-// objectAreaInfo.setOffsetX(afpx);
-// objectAreaInfo.setOffsetY(afpy);
-
- AffineTransform at = state.getData().getTransform();
- float transX = (float)at.getTranslateX();
- float transY = (float)at.getTranslateY();
-// int afpx = Math.round(unitConv.mpt2units(currx));
-// objectAreaInfo.setX(afpx);
-// int afpy = Math.round(unitConv.mpt2units(curry));
-// objectAreaInfo.setY(afpy);
-// objectAreaInfo.setX(coords[0]);
-// objectAreaInfo.setY(coords[1]);
- objectAreaInfo.setX(Math.round(transX));
- objectAreaInfo.setY(Math.round(transY));
-
-// AffineTransform at = currentState.getData().getTransform();
-// int x = (int)Math.round(at.getTranslateX());
-// objectAreaInfo.setX(x);
-//
-// int y = (int)Math.round(at.getTranslateY());
-// objectAreaInfo.setY(y);
+ RendererContextWrapper rctx = RendererContext.wrapRendererContext(context);
+ int currx = rctx.getCurrentXPosition();
+ int curry = rctx.getCurrentYPosition();
+ float[] srcPts = {currx, curry};
+ int[] coords = unitConv.mpts2units(srcPts);
+ objectAreaInfo.setX(coords[X]);
+ objectAreaInfo.setY(coords[Y]);
int resolution = afpInfo.getResolution();
objectAreaInfo.setWidthRes(resolution);
--- /dev/null
+/*
+ * 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;
+
+import java.awt.Color;
+
+/**
+ * Text data information
+ */
+public class AFPTextDataInfo {
+
+ private int fontReference;
+
+ private int x;
+
+ private int y;
+
+ private Color color;
+
+ private int variableSpaceCharacterIncrement;
+
+ private int interCharacterAdjustment;
+
+ private byte[] data;
+
+ private int orientation;
+
+ /**
+ * Returns the font reference
+ *
+ * @return the font reference
+ */
+ public int getFontReference() {
+ return fontReference;
+ }
+
+ /**
+ * Sets the font reference
+ *
+ * @param fontReference the font reference
+ */
+ protected void setFontReference(int fontReference) {
+ this.fontReference = fontReference;
+ }
+
+ /**
+ * Returns the x coordinate
+ *
+ * @return the x coordinate
+ */
+ public int getX() {
+ return x;
+ }
+
+ /**
+ * Sets the X coordinate
+ *
+ * @param x the X coordinate
+ */
+ protected void setX(int x) {
+ this.x = x;
+ }
+
+ /**
+ * Returns the y coordinate
+ *
+ * @return the y coordinate
+ */
+ public int getY() {
+ return y;
+ }
+
+ /**
+ * Sets the Y coordinate
+ *
+ * @param y the Y coordinate
+ */
+ protected void setY(int y) {
+ this.y = y;
+ }
+
+ /**
+ * Returns the color
+ *
+ * @return the color
+ */
+ public Color getColor() {
+ return color;
+ }
+
+ /**
+ * Sets the color
+ *
+ * @param color the color
+ */
+ protected void setColor(Color color) {
+ this.color = color;
+ }
+
+ /**
+ * Return the variable space character increment
+ *
+ * @return the variable space character increment
+ */
+ public int getVariableSpaceCharacterIncrement() {
+ return variableSpaceCharacterIncrement;
+ }
+
+ /**
+ * Sets the variable space character increment
+ *
+ * @param variableSpaceCharacterIncrement the variable space character increment
+ */
+ protected void setVariableSpaceCharacterIncrement(
+ int variableSpaceCharacterIncrement) {
+ this.variableSpaceCharacterIncrement = variableSpaceCharacterIncrement;
+ }
+
+ /**
+ * Return the inter character adjustment
+ *
+ * @return the inter character adjustment
+ */
+ public int getInterCharacterAdjustment() {
+ return interCharacterAdjustment;
+ }
+
+ /**
+ * Sets the inter character adjustment
+ *
+ * @param interCharacterAdjustment the inter character adjustment
+ */
+ protected void setInterCharacterAdjustment(int interCharacterAdjustment) {
+ this.interCharacterAdjustment = interCharacterAdjustment;
+ }
+
+ /**
+ * Return the text data
+ *
+ * @return the text data
+ */
+ public byte[] getData() {
+ return data;
+ }
+
+ /**
+ * Sets the text data
+ *
+ * @param data the text orientation
+ */
+ protected void setData(byte[] data) {
+ this.data = data;
+ }
+
+ /**
+ * Sets the text orientation
+ *
+ * @param orientation the text orientation
+ */
+ public void setOrientation(int orientation) {
+ this.orientation = orientation;
+ }
+
+ /**
+ * Returns the text orientation
+ *
+ * @return the text orientation
+ */
+ public int getOrientation() {
+ return this.orientation;
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return "TextDataInfo{fontReference=" + fontReference
+ + ", x=" + x
+ + ", y=" + y
+ + ", color=" + color
+ + ", vsci=" + variableSpaceCharacterIncrement
+ + ", ica=" + interCharacterAdjustment
+ + ", orientation=" + orientation
+ + ", data=" + data
+ + "}";
+ }
+}
\ No newline at end of file
+++ /dev/null
-/*
- * 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;
-
-import java.awt.Color;
-
-/**
- * Text data information
- */
-public class TextDataInfo {
-
- private int fontReference;
-
- private int x;
-
- private int y;
-
- private Color color;
-
- private int variableSpaceCharacterIncrement;
-
- private int interCharacterAdjustment;
-
- private byte[] data;
-
- private int orientation;
-
- /**
- * Returns the font reference
- *
- * @return the font reference
- */
- public int getFontReference() {
- return fontReference;
- }
-
- /**
- * Sets the font reference
- *
- * @param fontReference the font reference
- */
- protected void setFontReference(int fontReference) {
- this.fontReference = fontReference;
- }
-
- /**
- * Returns the x coordinate
- *
- * @return the x coordinate
- */
- public int getX() {
- return x;
- }
-
- /**
- * Sets the X coordinate
- *
- * @param x the X coordinate
- */
- protected void setX(int x) {
- this.x = x;
- }
-
- /**
- * Returns the y coordinate
- *
- * @return the y coordinate
- */
- public int getY() {
- return y;
- }
-
- /**
- * Sets the Y coordinate
- *
- * @param y the Y coordinate
- */
- protected void setY(int y) {
- this.y = y;
- }
-
- /**
- * Returns the color
- *
- * @return the color
- */
- public Color getColor() {
- return color;
- }
-
- /**
- * Sets the color
- *
- * @param color the color
- */
- protected void setColor(Color color) {
- this.color = color;
- }
-
- /**
- * Return the variable space character increment
- *
- * @return the variable space character increment
- */
- public int getVariableSpaceCharacterIncrement() {
- return variableSpaceCharacterIncrement;
- }
-
- /**
- * Sets the variable space character increment
- *
- * @param variableSpaceCharacterIncrement the variable space character increment
- */
- protected void setVariableSpaceCharacterIncrement(
- int variableSpaceCharacterIncrement) {
- this.variableSpaceCharacterIncrement = variableSpaceCharacterIncrement;
- }
-
- /**
- * Return the inter character adjustment
- *
- * @return the inter character adjustment
- */
- public int getInterCharacterAdjustment() {
- return interCharacterAdjustment;
- }
-
- /**
- * Sets the inter character adjustment
- *
- * @param interCharacterAdjustment the inter character adjustment
- */
- protected void setInterCharacterAdjustment(int interCharacterAdjustment) {
- this.interCharacterAdjustment = interCharacterAdjustment;
- }
-
- /**
- * Return the text data
- *
- * @return the text data
- */
- public byte[] getData() {
- return data;
- }
-
- /**
- * Sets the text data
- *
- * @param data the text orientation
- */
- protected void setData(byte[] data) {
- this.data = data;
- }
-
- /**
- * Sets the text orientation
- *
- * @param orientation the text orientation
- */
- public void setOrientation(int orientation) {
- this.orientation = orientation;
- }
-
- /**
- * Returns the text orientation
- *
- * @return the text orientation
- */
- public int getOrientation() {
- return this.orientation;
- }
-
- /** {@inheritDoc} */
- public String toString() {
- return "TextDataInfo{fontReference=" + fontReference
- + ", x=" + x
- + ", y=" + y
- + ", color=" + color
- + ", vsci=" + variableSpaceCharacterIncrement
- + ", ica=" + interCharacterAdjustment
- + ", orientation=" + orientation
- + ", data=" + data
- + "}";
- }
-}
\ No newline at end of file
import org.apache.fop.render.afp.AFPDataObjectInfo;
import org.apache.fop.render.afp.AFPObjectAreaInfo;
+import org.apache.fop.render.afp.AFPResourceInfo;
+import org.apache.fop.render.afp.AFPResourceLevel;
/**
* Abstract base class used by the ImageObject and GraphicsObject which both
* the object area info
*/
public void setViewport(AFPDataObjectInfo dataObjectInfo) {
- AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();
- getObjectEnvironmentGroup().setObjectArea(objectAreaInfo);
+ AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
+ AFPResourceLevel resourceLevel = resourceInfo.getLevel();
+
+ // only need to set OAD and OAP inlined (pre-2000 apps)
+ if (resourceLevel.isInline()) {
+ AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();
+ getObjectEnvironmentGroup().setObjectArea(objectAreaInfo);
+ }
}
/**
*
* @return the object environment group
*/
- protected ObjectEnvironmentGroup getObjectEnvironmentGroup() {
+ public ObjectEnvironmentGroup getObjectEnvironmentGroup() {
if (objectEnvironmentGroup == null) {
this.objectEnvironmentGroup = factory.createObjectEnvironmentGroup();
}
/** {@inheritDoc} */
protected void writeContent(OutputStream os) throws IOException {
- super.writeContent(os);
+ super.writeContent(os); // write triplets
if (objectEnvironmentGroup != null) {
objectEnvironmentGroup.writeToStream(os);
}
}
+
}
import java.util.List;
import org.apache.fop.render.afp.LineDataInfo;
-import org.apache.fop.render.afp.TextDataInfo;
+import org.apache.fop.render.afp.AFPTextDataInfo;
import org.apache.fop.render.afp.fonts.AFPFont;
/**
* @param textDataInfo
* the afp text data
*/
- public void createText(TextDataInfo textDataInfo) {
+ public void createText(AFPTextDataInfo textDataInfo) {
getPresentationTextObject().createTextData(textDataInfo);
}
package org.apache.fop.render.afp.modca;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.Collection;
import org.apache.commons.io.output.ByteArrayOutputStream;
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.MeasurementUnitsTriplet;
import org.apache.fop.render.afp.modca.triplets.ObjectAreaSizeTriplet;
import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet;
*
* @param triplet the triplet to add
*/
- private void addTriplet(Triplet triplet) {
+ protected void addTriplet(Triplet triplet) {
getTriplets().add(triplet);
}
addTriplet(new MeasurementUnitsTriplet(xRes, xRes));
}
- /**
- * Sets the mapping option
- *
- * @param optionValue the mapping option value
- */
- public void setMappingOption(byte optionValue) {
- addTriplet(new MappingOptionTriplet(optionValue));
- }
-
/**
* Sets a comment on this resource
*
}
}
+ /**
+ * Reads data chunks from an inputstream
+ * and then formats them with a structured header to a given outputstream
+ *
+ * @param dataHeader the header data
+ * @param lengthOffset offset of length field in data chunk
+ * @param maxChunkLength the maximum chunk length
+ * @param inputStream the inputstream to read from
+ * @param outputStream the outputstream to write to
+ * @throws IOException thrown if an I/O exception of some sort has occurred.
+ */
+ protected static void copyChunks(byte[] dataHeader, int lengthOffset,
+ int maxChunkLength, InputStream inputStream, OutputStream outputStream)
+ throws IOException {
+ int headerLen = dataHeader.length - lengthOffset;
+ // length field is just before data so do not include in data length
+ if (headerLen == 2) {
+ headerLen = 0;
+ }
+ byte[] data = new byte[maxChunkLength];
+ int numBytesRead = 0;
+ while ((numBytesRead = inputStream.read(data, 0, maxChunkLength)) > 0) {
+ byte[] len = BinaryUtils.convert(headerLen + numBytesRead, 2);
+ dataHeader[lengthOffset] = len[0]; // Length byte 1
+ dataHeader[lengthOffset + 1] = len[1]; // Length byte 2
+ outputStream.write(dataHeader);
+ outputStream.write(data, 0, numBytesRead);
+ }
+ }
+
/**
* Writes data chunks to a given outputstream
*
- * @param data the data
+ * @param data the data byte array
* @param dataHeader the header data
* @param lengthOffset offset of length field in data chunk
* @param maxChunkLength the maximum chunk length
/** {@inheritDoc} */
public void writeToStream(OutputStream os) throws IOException {
byte[] data = new byte[21];
- copySF(data, Type.DESCRIPTOR, Category.IMAGE);
+ copySF(data, Type.DESCRIPTOR, Category.OBJECT_CONTAINER);
// SF length
byte[] len = BinaryUtils.convert(data.length - 1, 2);
data[1] = len[0];
data[2] = len[1];
- data[9] = 0x00; // XocBase = 10 inches
- data[10] = 0x00; // YocBase = 10 inches
+ // XocBase = 10 inches
+ data[9] = 0x00;
+
+ // YocBase = 10 inches
+ data[10] = 0x00;
// XocUnits
byte[] xdpi = BinaryUtils.convert(widthRes * 10, 2);
data[14] = ydpi[1];
// XocSize
- byte[] x = BinaryUtils.convert(width, 3);
- data[15] = x[0];
- data[16] = x[1];
- data[17] = x[2];
+ byte[] xsize = BinaryUtils.convert(width, 3);
+ data[15] = xsize[0];
+ data[16] = xsize[1];
+ data[17] = xsize[2];
// YocSize
- byte[] y = BinaryUtils.convert(height, 3);
- data[18] = y[0];
- data[19] = y[1];
- data[20] = y[2];
+ byte[] ysize = BinaryUtils.convert(height, 3);
+ data[18] = ysize[0];
+ data[19] = ysize[1];
+ data[20] = ysize[2];
}
}
import org.apache.fop.render.afp.AFPFontAttributes;
import org.apache.fop.render.afp.AFPResourceLevel;
import org.apache.fop.render.afp.LineDataInfo;
-import org.apache.fop.render.afp.TextDataInfo;
+import org.apache.fop.render.afp.AFPTextDataInfo;
import org.apache.fop.render.afp.fonts.AFPFont;
import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet;
* @param textDataInfo
* the afp text data
*/
- public void createText(TextDataInfo textDataInfo) {
+ public void createText(AFPTextDataInfo textDataInfo) {
textDataInfo.setOrientation(orientation);
currentPage.createText(textDataInfo);
}
/**
* Creates a new MO:DCA {@link ContainerDataDescriptor}
*
- * @param width the container data width
- * @param height the container data height
+ * @param dataWidth the container data width
+ * @param dataHeight the container data height
* @param widthRes the container data width resolution
* @param heightRes the container data height resolution
* @return a new {@link ContainerDataDescriptor}
*/
public ContainerDataDescriptor createContainerDataDescriptor(
- int width, int height, int widthRes, int heightRes) {
+ int dataWidth, int dataHeight, int widthRes, int heightRes) {
ContainerDataDescriptor containerDataDescriptor
- = new ContainerDataDescriptor(width, height, widthRes, heightRes);
+ = new ContainerDataDescriptor(dataWidth, dataHeight, widthRes, heightRes);
return containerDataDescriptor;
}
+ /**
+ * Creates a new MO:DCA {@link MapContainerData}
+ *
+ * @param optionValue the option value
+ * @return a new {@link MapContainerData}
+ */
+ public MapContainerData createMapContainerData(byte optionValue) {
+ MapContainerData mapContainerData = new MapContainerData(optionValue);
+ return mapContainerData;
+ }
+
+ /**
+ * Creates a new MO:DCA {@link MapDataResource}
+ *
+ * @return a new {@link MapDataResource}
+ */
+ public MapDataResource createMapDataResource() {
+ MapDataResource mapDataResource = new MapDataResource();
+ return mapDataResource;
+ }
+
+ /**
+ * Creates a new MO:DCA {@link PresentationEnvironmentControl}
+ *
+ * @return a new {@link PresentationEnvironmentControl}
+ */
+ public PresentationEnvironmentControl createPresentationEnvironmentControl() {
+ PresentationEnvironmentControl presentationEnvironmentControl
+ = new PresentationEnvironmentControl();
+ return presentationEnvironmentControl;
+ }
+
/**
* Creates a new IOCA {@link ImageSegment}
*
return imageContent;
}
-
/**
* Creates a new IOCA {@link ImageRasterData}
*
public void writeToStream(OutputStream os) throws IOException {
byte[] headerData = new byte[9];
copySF(headerData, Type.DESCRIPTOR, Category.GRAPHICS);
+
byte[] drawingOrderSubsetData = getDrawingOrderSubset();
+
byte[] windowSpecificationData = getWindowSpecification();
- byte[] len = BinaryUtils.convert(
- 8 + drawingOrderSubsetData.length + windowSpecificationData.length, 2);
+
+ byte[] len = BinaryUtils.convert(headerData.length
+ + drawingOrderSubsetData.length
+ + windowSpecificationData.length - 1, 2);
headerData[1] = len[0];
headerData[2] = len[1];
+
os.write(headerData);
os.write(drawingOrderSubsetData);
os.write(windowSpecificationData);
byte[] yResol = BinaryUtils.convert(heightRes * 10, 2);
byte[] imxyres = xResol;
- final byte[] data = new byte[] {
// Window specification
- (byte) 0xF6, 18, // LENGTH
+ final byte[] data = new byte[] {
+ (byte) 0xF6,
+ 18, // LENGTH
(ABS + IMGRES), // FLAGS (ABS)
0x00, // reserved (must be zero)
0x00, // CFORMAT (coordinate format - 16bit high byte first signed)
0x00, // UBASE (unit base - ten inches)
+
xResol[0], // XRESOL
xResol[1],
yResol[0], // YRESOL
yResol[1],
+
imxyres[0], // IMXYRES (Number of image points per ten inches
imxyres[1], // in X and Y directions)
+
xlcoord[0], // XLWIND
xlcoord[1],
xrcoord[0], // XRWIND
super.writeContent(os);
if (imageSegment != null) {
+ final byte[] dataHeader = new byte[9];
+ copySF(dataHeader, SF_CLASS, Type.DATA, Category.IMAGE);
+ final int lengthOffset = 1;
+
// TODO save memory!
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imageSegment.writeToStream(baos);
byte[] data = baos.toByteArray();
-
- final byte[] dataHeader = new byte[9];
- copySF(dataHeader, SF_CLASS, Type.DATA, Category.IMAGE);
- final int lengthOffset = 1;
writeChunksToStream(data, dataHeader, lengthOffset, MAX_DATA_LEN, os);
}
}
import java.io.IOException;
import java.io.OutputStream;
+import org.apache.fop.render.afp.modca.triplets.MappingOptionTriplet;
import org.apache.fop.render.afp.tools.BinaryUtils;
/**
public String toString() {
return "IOB: " + this.getName();
}
+
+ /**
+ * Sets the mapping option
+ *
+ * @param optionValue the mapping option value
+ */
+ public void setMappingOption(byte optionValue) {
+ addTriplet(new MappingOptionTriplet(optionValue));
+ }
}
\ No newline at end of file
*/
public class MapDataResource extends AbstractStructuredAFPObject {
- /**
- * Static default generated name reference
- */
- private static final String DEFAULT_NAME = "MDR00001";
-
/**
* Main constructor
- *
- * @param dataObjectAccessor a data object accessor
*/
public MapDataResource() {
-// AbstractNamedAFPObject namedDataObject = dataObjectAccessor.getDataObject();
-// DataObjectInfo dataObjectInfo = dataObjectAccessor.getDataObjectInfo();
-// AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
-// AFPResourceLevel resourceLevel = resourceInfo.getLevel();
-// if (resourceLevel.isExternal()) {
-// String url = resourceLevel.getExternalFilePath();
-// if (url != null) {
-// super.setFullyQualifiedName(
-// FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_EXTERNAL_RESOURCE_REF,
-// FullyQualifiedNameTriplet.FORMAT_CHARSTR, url);
-// }
-// } else {
-// String fqName = namedDataObject.getFullyQualifiedName();
-// super.setFullyQualifiedName(
-// FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF,
-// FullyQualifiedNameTriplet.FORMAT_CHARSTR, fqName);
-// }
-//
-// // Set object classification
-// Registry.ObjectType objectType = dataObjectInfo.getObjectType();
-// super.setObjectClassification(
-// ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT,
-// objectType);
}
/** {@inheritDoc} */
- public void writeStart(OutputStream os) throws IOException {
+ public void writeToStream(OutputStream os) throws IOException {
super.writeStart(os);
- byte[] data = new byte[9];
+ byte[] data = new byte[11];
copySF(data, Type.MAP, Category.DATA_RESOURCE);
- byte[] len = BinaryUtils.convert(10 + getTripletDataLength(), 2);
+ int tripletDataLen = getTripletDataLength();
+
+ byte[] len = BinaryUtils.convert(10 + tripletDataLen, 2);
data[1] = len[0];
data[2] = len[1];
- os.write(data);
- }
-
- /** {@inheritDoc} */
- public void writeContent(OutputStream os) throws IOException {
- // RGLength
- byte[] len = BinaryUtils.convert(2 + getTripletDataLength(), 2);
- os.write(len);
+ len = BinaryUtils.convert(2 + tripletDataLen, 2);
+ data[9] = len[0];
+ data[10] = len[1];
- super.writeTriplets(os);
+ os.write(data);
+ os.write(tripletData);
}
}
package org.apache.fop.render.afp.modca;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import org.apache.fop.render.afp.AFPDataObjectInfo;
+import org.apache.fop.render.afp.AFPObjectAreaInfo;
+import org.apache.fop.render.afp.AFPResourceInfo;
+import org.apache.fop.render.afp.AFPResourceLevel;
+import org.apache.fop.render.afp.modca.triplets.MappingOptionTriplet;
import org.apache.fop.render.afp.tools.BinaryUtils;
/**
/** the object container data maximum length */
private static final int MAX_DATA_LEN = 32759;
- /** the object data */
- protected byte[] objectData;
+ private InputStream inputStream;
/**
* Main constructor
*/
public ObjectContainer(Factory factory, String name) {
super(factory, name);
+
+// PresentationEnvironmentControl presentationEnvironmentControl
+// = factory.createPresentationEnvironmentControl();
+// getObjectEnvironmentGroup().setPresentationEnvironmentControl(
+// presentationEnvironmentControl);
+
}
/** {@inheritDoc} */
copySF(headerData, Type.BEGIN, Category.OBJECT_CONTAINER);
// Set the total record length
- byte[] len = BinaryUtils.convert(16 + getTripletDataLength(), 2);
+ int containerLen = headerData.length + getTripletDataLength() - 1;
+ byte[] len = BinaryUtils.convert(containerLen, 2);
headerData[1] = len[0]; // Length byte 1
headerData[2] = len[1]; // Length byte 2
/** {@inheritDoc} */
protected void writeContent(OutputStream os) throws IOException {
- super.writeContent(os); // write OEG
+ super.writeContent(os); // write triplets and OEG
- // write OCD
+ // write OCDs
byte[] dataHeader = new byte[9];
copySF(dataHeader, SF_CLASS, Type.DATA, Category.OBJECT_CONTAINER);
final int lengthOffset = 1;
- writeChunksToStream(objectData, dataHeader, lengthOffset,
- MAX_DATA_LEN, os);
+
+ copyChunks(dataHeader, lengthOffset, MAX_DATA_LEN, inputStream, os);
}
/** {@inheritDoc} */
/** {@inheritDoc} */
public void setViewport(AFPDataObjectInfo dataObjectInfo) {
super.setViewport(dataObjectInfo);
-// AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();
-//
-// int width = objectAreaInfo.getWidth();
-// int height = objectAreaInfo.getHeight();
-// int widthRes = objectAreaInfo.getWidthRes();
-// int heightRes = objectAreaInfo.getHeightRes();
-// ContainerDataDescriptor containerDataDescriptor
-// = factory.createContainerDataDescriptor(width, height, widthRes, heightRes);
-// getObjectEnvironmentGroup().setDataDescriptor(containerDataDescriptor);
+
+ AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();
+
+ AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
+ AFPResourceLevel resourceLevel = resourceInfo.getLevel();
+
+ // only need to set MCD and CDD when OC is inljned (pre-2000 apps)
+ if (resourceLevel.isInline()) {
+ MapContainerData mapContainerData
+ = factory.createMapContainerData(MappingOptionTriplet.SCALE_TO_FIT);
+ getObjectEnvironmentGroup().setMapContainerData(mapContainerData);
+
+ int dataWidth = dataObjectInfo.getDataWidth();
+ int dataHeight = dataObjectInfo.getDataHeight();
+ int widthRes = objectAreaInfo.getWidthRes();
+ int heightRes = objectAreaInfo.getHeightRes();
+ ContainerDataDescriptor containerDataDescriptor
+ = factory.createContainerDataDescriptor(
+ dataWidth, dataHeight, widthRes, heightRes);
+ getObjectEnvironmentGroup().setDataDescriptor(containerDataDescriptor);
+ }
}
/**
- * Sets the object container data
+ * Sets the inputstream for the the object container data
*
- * @param data the object container data
+ * @param inputStream the inputstream for the object container data
*/
- public void setData(byte[] data) {
- this.objectData = data;
+ public void setInputStream(InputStream inputStream) {
+ this.inputStream = inputStream;
}
}
import java.io.OutputStream;
import org.apache.fop.render.afp.AFPObjectAreaInfo;
+import org.apache.fop.render.afp.tools.BinaryUtils;
/**
* An Object Environment Group (OEG) may be associated with an object and is contained
private final Factory factory;
+ /** the PresentationEnvironmentControl for the object environment group */
+ private PresentationEnvironmentControl presentationEnvironmentControl = null;
+
/** the ObjectAreaDescriptor for the object environment group */
private ObjectAreaDescriptor objectAreaDescriptor = null;
/** the ObjectAreaPosition for the object environment group */
private ObjectAreaPosition objectAreaPosition = null;
- /** the DataDescritpor for the object environment group */
+ /** the DataDescriptor for the object environment group */
private AbstractDescriptor dataDescriptor;
+ /** the MapDataResource for the object environment group */
+ private MapDataResource mapDataResource;
+
+ /** the MapContainerData for the object environment group */
+ private MapContainerData mapContainerData;
+
/**
* Constructor for the ObjectEnvironmentGroup, this takes a
* name parameter which must be 8 characters long.
protected void writeStart(OutputStream os) throws IOException {
byte[] data = new byte[17];
copySF(data, Type.BEGIN, Category.OBJECT_ENVIRONMENT_GROUP);
+
+ int sfLen = data.length + getTripletDataLength() - 1;
+ byte[] len = BinaryUtils.convert(sfLen, 2);
+ data[1] = len[0];
+ data[2] = len[1];
+
os.write(data);
}
protected void writeContent(OutputStream os) throws IOException {
super.writeContent(os);
+ if (presentationEnvironmentControl != null) {
+ presentationEnvironmentControl.writeToStream(os);
+ }
+
if (objectAreaDescriptor != null) {
objectAreaDescriptor.writeToStream(os);
}
objectAreaPosition.writeToStream(os);
}
+ if (mapContainerData != null) {
+ mapContainerData.writeToStream(os);
+ }
+
+ if (mapDataResource != null) {
+ mapDataResource.writeToStream(os);
+ }
+
if (dataDescriptor != null) {
dataDescriptor.writeToStream(os);
}
os.write(data);
}
+ /**
+ * Sets the presentation environment control
+ *
+ * @param presentationEnvironmentControl the presentation environment control
+ */
+ public void setPresentationEnvironmentControl(
+ PresentationEnvironmentControl presentationEnvironmentControl) {
+ this.presentationEnvironmentControl = presentationEnvironmentControl;
+ }
+
/**
* Sets the data descriptor
*
public void setDataDescriptor(AbstractDescriptor dataDescriptor) {
this.dataDescriptor = dataDescriptor;
}
+
+ /**
+ * Sets the map data resource
+ *
+ * @param mapDataResource the map data resource
+ */
+ public void setMapDataResource(MapDataResource mapDataResource) {
+ this.mapDataResource = mapDataResource;
+ }
+
+ /**
+ * Sets the map container data
+ *
+ * @param mapContainerData the map container data
+ */
+ public void setMapContainerData(MapContainerData mapContainerData) {
+ this.mapContainerData = mapContainerData;
+ }
}
*
* @param width The page width.
* @param height The page height.
- * @param widthResolution The page width resolution
- * @param heightResolution The page height resolution
+ * @param widthRes The page width resolution
+ * @param heightRes The page height resolution
*/
- public PageDescriptor(int width, int height, int widthResolution, int heightResolution) {
- super(width, height, widthResolution, heightResolution);
+ public PageDescriptor(int width, int height, int widthRes, int heightRes) {
+ super(width, height, widthRes, heightRes);
}
/** {@inheritDoc} */
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.fop.render.afp.LineDataInfo;
-import org.apache.fop.render.afp.TextDataInfo;
+import org.apache.fop.render.afp.AFPTextDataInfo;
import org.apache.fop.render.afp.tools.BinaryUtils;
/**
* @throws MaximumSizeExceededException
* thrown if the maximum number of text data is exceeded
*/
- public void createTextData(TextDataInfo textDataInfo)
+ public void createTextData(AFPTextDataInfo textDataInfo)
throws MaximumSizeExceededException {
ByteArrayOutputStream afpdata = new ByteArrayOutputStream();
/**
* Constructor a PresentationTextDescriptor for the specified
* width and height.
- *
+ *
* @param width The width of the page.
* @param height The height of the page.
- * @param widthResolution The width resolution of the page.
- * @param heightResolution The height resolution of the page.
+ * @param widthRes The width resolution of the page.
+ * @param heightRes The height resolution of the page.
*/
public PresentationTextDescriptor(int width, int height,
- int widthResolution, int heightResolution) {
- super(width, height, widthResolution, heightResolution);
+ int widthRes, int heightRes) {
+ super(width, height, widthRes, heightRes);
}
/** {@inheritDoc} */
public void writeToStream(OutputStream os) throws IOException {
byte[] data = new byte[23];
-
+
copySF(data, Type.MIGRATION, Category.PRESENTATION_TEXT);
data[1] = 0x00; // length
import java.util.List;
import org.apache.fop.render.afp.LineDataInfo;
-import org.apache.fop.render.afp.TextDataInfo;
+import org.apache.fop.render.afp.AFPTextDataInfo;
/**
* The Presentation Text object is the data object used in document processing
* @param textDataInfo
* The afp text data
*/
- public void createTextData(TextDataInfo textDataInfo) {
+ public void createTextData(AFPTextDataInfo textDataInfo) {
if (currentPresentationTextData == null) {
startPresentationTextData();
}
this.namedObject = obj;
}
+ /**
+ * Returns the data object referenced by this resource object
+ *
+ * @return the data object referenced by this resource object
+ */
+ public AbstractNamedAFPObject getDataObject() {
+ return namedObject;
+ }
+
/** {@inheritDoc} */
protected void writeStart(OutputStream os) throws IOException {
super.writeStart(os);
public static final byte TYPE_IMAGE = 0x06;
// private static final byte FONT_CHARACTER_SET = 0x40;
+
// private static final byte CODE_PAGE = 0x41;
+
// private static final byte CODED_FONT = 0x42;
/** object container type */
public static final byte TYPE_OVERLAY_OBJECT = (byte) 0xFC;
// private static final byte PAGEDEF = (byte) 0xFD;
+
// private static final byte FORMDEF = (byte) 0xFE;
private class ResourceObjectTypeTriplet extends Triplet {
/**
* Main constructor
*
- * @param type
- * the resource objec type
+ * @param type the resource object type
*/
public ResourceObjectTypeTriplet(byte type) {
super(RESOURCE_OBJECT,
--- /dev/null
+/*
+ * 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.modca.triplets;
+
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * The Extended Resource Local Identifier triplet specifies a resource type and a
+ * four byte local identifier or LID. The LID usually is associated with a specific
+ * resource name by a map structured field, such as a Map Data Resource structured
+ * field, or a Map Media Type structured field.
+ */
+public class ExtendedResourceLocalIdentifierTriplet extends Triplet {
+
+ /** the image resource type */
+ public static final byte TYPE_IMAGE_RESOURCE = 0x10;
+
+ /** the retired value type */
+ public static final byte TYPE_RETIRED_VALUE = 0x30;
+
+ /** the retired value type */
+ public static final byte TYPE_MEDIA_RESOURCE = 0x40;
+
+ /**
+ * Main constructor
+ *
+ * @param type the resource type
+ * @param localId the resource local id
+ */
+ public ExtendedResourceLocalIdentifierTriplet(byte type, int localId) {
+ super(Triplet.EXTENDED_RESOURCE_LOCAL_IDENTIFIER);
+ byte[] data = new byte[5];
+ data[0] = type;
+ byte[] resLID = BinaryUtils.convert(localId, 4);
+ System.arraycopy(resLID, 0, data, 1, resLID.length);
+ super.setData(data);
+ }
+}
--- /dev/null
+/*
+ * 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.modca.triplets;
+
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * The Object Byte Extent triplet is used to specify the number of bytes contained in an object
+ */
+public class ObjectByteExtentTriplet extends Triplet {
+
+ /**
+ * Main constructor
+ *
+ * @param byteExt the number of bytes contained in the object
+ */
+ public ObjectByteExtentTriplet(int byteExt) {
+ super(OBJECT_BYTE_EXTENT);
+ byte[] data = BinaryUtils.convert(byteExt, 4);
+ super.setData(data);
+ }
+}
*/
public class StrucFlgs {
-// private static final int OBJECT_DATA_NOT_CARRIED_IN_OBJECT_CONTAINER = 1;
-// private static final int OBJECT_DATA_OBJECT_CONTAINER_STRUCTURE_UNKNOWN = 2;
-// private static final int OBJECT_DATA_CARRIED_IN_OBJECT_CONTAINER = 3;
-//
-// private static final int OBJECT_CONTAINER_NOT_INCLUDE_OBJECT_ENVIRONMENT_GROUP = 4;
-// private static final int OBJECT_CONTAINER_OBJECT_ENVIRONMENT_GROUP_CONTAINMENT_UNKNOWN = 8;
-// private static final int OBJECT_CONTAINER_INCLUDES_OBJECT_ENVIRONMENT_GROUP = 12;
-//
-// private static final int OBJECT_CONTAINER_DATA_NOT_CARRIED_IN_OBJECT_DATA = 16;
-// private static final int OBJECT_CONTAINER_DATA_OBJECT_DATA_CONTAINMENT_UNKNOWN = 32;
-// private static final int OBJECT_CONTAINER_DATA_CARRIES_OBJECT_DATA = 48;
-
- private static final int OBJECT_DATA_NOT_CARRIED_IN_OBJECT_CONTAINER = 48;
- private static final int OBJECT_DATA_OBJECT_CONTAINER_STRUCTURE_UNKNOWN = 32;
- private static final int OBJECT_DATA_CARRIED_IN_OBJECT_CONTAINER = 16;
+ private static final int OBJECT_DATA_NOT_CARRIED_IN_OBJECT_CONTAINER = 1;
+ private static final int OBJECT_DATA_OBJECT_CONTAINER_STRUCTURE_UNKNOWN = 2;
+ private static final int OBJECT_DATA_CARRIED_IN_OBJECT_CONTAINER = 3;
- private static final int OBJECT_CONTAINER_NOT_INCLUDE_OBJECT_ENVIRONMENT_GROUP = 12;
+ private static final int OBJECT_CONTAINER_NOT_INCLUDE_OBJECT_ENVIRONMENT_GROUP = 4;
private static final int OBJECT_CONTAINER_OBJECT_ENVIRONMENT_GROUP_CONTAINMENT_UNKNOWN = 8;
- private static final int OBJECT_CONTAINER_INCLUDES_OBJECT_ENVIRONMENT_GROUP = 4;
+ private static final int OBJECT_CONTAINER_INCLUDES_OBJECT_ENVIRONMENT_GROUP = 12;
- private static final int OBJECT_CONTAINER_DATA_NOT_CARRIED_IN_OBJECT_DATA = 3;
- private static final int OBJECT_CONTAINER_DATA_OBJECT_DATA_CONTAINMENT_UNKNOWN = 2;
- private static final int OBJECT_CONTAINER_DATA_CARRIES_OBJECT_DATA = 1;
+ private static final int OBJECT_CONTAINER_DATA_NOT_CARRIED_IN_OBJECT_DATA = 16;
+ private static final int OBJECT_CONTAINER_DATA_OBJECT_DATA_CONTAINMENT_UNKNOWN = 32;
+ private static final int OBJECT_CONTAINER_DATA_CARRIES_OBJECT_DATA = 48;
+
+// private static final int OBJECT_DATA_NOT_CARRIED_IN_OBJECT_CONTAINER = 48;
+// private static final int OBJECT_DATA_OBJECT_CONTAINER_STRUCTURE_UNKNOWN = 32;
+// private static final int OBJECT_DATA_CARRIED_IN_OBJECT_CONTAINER = 16;
+//
+// private static final int OBJECT_CONTAINER_NOT_INCLUDE_OBJECT_ENVIRONMENT_GROUP = 12;
+// private static final int OBJECT_CONTAINER_OBJECT_ENVIRONMENT_GROUP_CONTAINMENT_UNKNOWN = 8;
+// private static final int OBJECT_CONTAINER_INCLUDES_OBJECT_ENVIRONMENT_GROUP = 4;
+//
+// private static final int OBJECT_CONTAINER_DATA_NOT_CARRIED_IN_OBJECT_DATA = 3;
+// private static final int OBJECT_CONTAINER_DATA_OBJECT_DATA_CONTAINMENT_UNKNOWN = 2;
+// private static final int OBJECT_CONTAINER_DATA_CARRIES_OBJECT_DATA = 1;
/**
* the default structured flags setting