diff options
author | Adrian Cumiskey <acumiskey@apache.org> | 2008-07-17 19:13:56 +0000 |
---|---|---|
committer | Adrian Cumiskey <acumiskey@apache.org> | 2008-07-17 19:13:56 +0000 |
commit | 030cd56ed235409e5fe6d2914d7224d9a58380c1 (patch) | |
tree | 0cb3bd47be75f861e3653f871dbc3888fc0ef39a /src/java/org/apache/fop/render/afp/modca/ObjectContainer.java | |
parent | e8d3199b5154012c1109085741b53f36b3a59282 (diff) | |
download | xmlgraphics-fop-030cd56ed235409e5fe6d2914d7224d9a58380c1.tar.gz xmlgraphics-fop-030cd56ed235409e5fe6d2914d7224d9a58380c1.zip |
* Added new DataObjectFactory to take care of MO:DCA DataObject creation/instantiation.
* Created a DataObjectCache which is now used to cache all resource objects such as images to a RandomAccessFile so all the memory isn't eaten by them during rendering.
* Added new GraphicsObjectPainter class invoked by DataObjectFactory on creation of GraphicsObject.
* Added Category and Type inner interfaces and handy copySF() to base AbstractAFPObject with more code reuse, simplifications/optimizations of writeStart() and writeEnd().
* SVG entry and isImage() isGraphic() convenience methods added to MO:DCA Registry.
* Updated AFPSVGHandler to use similar fox:conversion-mode foreign attribute mechanism for bitmap painting fallback used by PCLRenderer and PDFRenderer.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@677689 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/afp/modca/ObjectContainer.java')
-rw-r--r-- | src/java/org/apache/fop/render/afp/modca/ObjectContainer.java | 159 |
1 files changed, 59 insertions, 100 deletions
diff --git a/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java b/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java index 599cb0b40..fc9edc4b7 100644 --- a/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java +++ b/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java @@ -31,24 +31,18 @@ import org.apache.fop.render.afp.tools.BinaryUtils; /** * Object containers are MO:DCA objects that envelop and carry object data. */ -public class ObjectContainer extends AbstractNamedAFPObject implements DataObjectAccessor { +public class ObjectContainer extends AbstractNamedAFPObject /*implements DataObjectAccessor*/ { private static final String DEFAULT_NAME = "OC000001"; - /** - * the data object - */ + /** the data object */ private AbstractDataObject dataObj = null; - /** - * the object data - */ + /** the object data */ private byte[] objectData = null; - /** - * the data object info - */ - private DataObjectInfo dataObjectInfo; +// /** the data object info */ +// private DataObjectInfo dataObjectInfo; /** * Default constructor @@ -59,6 +53,7 @@ public class ObjectContainer extends AbstractNamedAFPObject implements DataObjec /** * Main constructor + * * @param name the name of this object container */ public ObjectContainer(String name) { @@ -67,85 +62,61 @@ public class ObjectContainer extends AbstractNamedAFPObject implements DataObjec /** * Sets the data object for this object container + * * @param dataObj the data object to reside within this object container */ public void setDataObject(AbstractDataObject dataObj) { this.dataObj = dataObj; } - /** - * {@inheritDoc} - */ - public AbstractNamedAFPObject getDataObject() { - return this.dataObj; - } - - /** - * {@inheritDoc} - */ - public DataObjectInfo getDataObjectInfo() { - return this.dataObjectInfo; - } +// /** {@inheritDoc} */ +// public AbstractNamedAFPObject getDataObject() { +// return this.dataObj; +// } +// +// /** {@inheritDoc} */ +// public DataObjectInfo getDataObjectInfo() { +// return this.dataObjectInfo; +// } - /** - * {@inheritDoc} - */ - public void setDataObjectInfo(DataObjectInfo dataObjectInfo) { - this.dataObjectInfo = dataObjectInfo; - - Registry registry = Registry.getInstance(); - Registry.ObjectType objectType = registry.getObjectType(dataObjectInfo); - if (objectType != null) { - super.setObjectClassification( - ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT, - objectType); - } else { - log.warn("no object type for " + dataObjectInfo.getUri()); - } - super.setFullyQualifiedName( - FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME, - FullyQualifiedNameTriplet.FORMAT_CHARSTR, - dataObjectInfo.getUri()); - } +// /** {@inheritDoc} */ +// public void setDataObjectInfo(DataObjectInfo dataObjectInfo) { +// this.dataObjectInfo = dataObjectInfo; +// +// Registry registry = Registry.getInstance(); +// Registry.ObjectType objectType = registry.getObjectType(dataObjectInfo); +// if (objectType != null) { +// super.setObjectClassification( +// ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT, +// objectType); +// } else { +// log.warn("no object type for " + dataObjectInfo.getUri()); +// } +// super.setFullyQualifiedName( +// FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME, +// FullyQualifiedNameTriplet.FORMAT_CHARSTR, +// dataObjectInfo.getUri()); +// } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeStart(OutputStream os) throws IOException { - super.writeStart(os); - // create object data from data object ByteArrayOutputStream bos = new ByteArrayOutputStream(); dataObj.write(bos); this.objectData = bos.toByteArray(); + byte[] data = new byte[17]; + copySF(data, Type.BEGIN, Category.OBJECT_CONTAINER); + // Set the total record length byte[] len = BinaryUtils.convert(16 + getTripletDataLength(), 2); - byte[] data = new byte[] { - 0x5A, // Structured field identifier - len[0], // Length byte 1 - len[1], // Length byte 2 - (byte)0xD3, // Structured field id byte 1 - (byte)0xA8, // Structured field id byte 2 - (byte)0x92, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - nameBytes[0], - nameBytes[1], - nameBytes[2], - nameBytes[3], - nameBytes[4], - nameBytes[5], - nameBytes[6], - nameBytes[7] - }; + data[1] = len[0]; // Length byte 1 + data[2] = len[1]; // Length byte 2 + os.write(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeContent(OutputStream os) throws IOException { super.writeContent(os); @@ -156,29 +127,10 @@ public class ObjectContainer extends AbstractNamedAFPObject implements DataObjec } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ protected void writeEnd(OutputStream os) throws IOException { - byte[] data = new byte[] { - 0x5A, // Structured field identifier - 0x00, // Length byte 1 - 0x10, // Length byte 2 - (byte)0xD3, // Structured field id byte 1 - (byte)0xA9, // Structured field id byte 2 - (byte)0x92, // Structured field id byte 3 - 0x00, // Flags - 0x00, // Reserved - 0x00, // Reserved - nameBytes[0], - nameBytes[1], - nameBytes[2], - nameBytes[3], - nameBytes[4], - nameBytes[5], - nameBytes[6], - nameBytes[7], - }; + byte[] data = new byte[17]; + copySF(data, Type.END, Category.OBJECT_CONTAINER); os.write(data); } @@ -187,13 +139,12 @@ public class ObjectContainer extends AbstractNamedAFPObject implements DataObjec */ private class ObjectContainerData extends AbstractPreparedAFPObject { - /** - * The maximum object container data length - */ + /** The maximum object container data length */ private static final int MAX_DATA_LEN = 32759; /** * Main constructor + * * @param objData the object data */ public ObjectContainerData(byte[] objData, int startIndex) { @@ -208,7 +159,7 @@ public class ObjectContainer extends AbstractNamedAFPObject implements DataObjec data[2] = len[1]; // Length byte 2 data[3] = (byte)0xD3; // Structured field id byte 1 data[4] = (byte)0xEE; // Structured field id byte 2 - data[5] = (byte)0x92; // Structured field id byte 3 + data[5] = getCategoryCode(); // Structured field id byte 3 data[6] = 0x00; // Flags data[7] = 0x00; // Reserved data[8] = 0x00; // Reserved @@ -219,13 +170,21 @@ public class ObjectContainer extends AbstractNamedAFPObject implements DataObjec super.setData(data); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public String toString() { return "ObjectContainerData(" + (data != null ? "" + (data.length - 2) : "null") + ")"; } + + /** {@inheritDoc} */ + protected byte getCategoryCode() { + return (byte)0x92; + } + } + + /** {@inheritDoc} */ + protected byte getCategoryCode() { + return (byte)0x92; } } |