/**
* Sets the image size parameters
* resolution, hsize and vsize.
+ *
* @param hresol The horizontal resolution of the image.
* @param vresol The vertical resolution of the image.
* @param hsize The horizontal size of the image.
/**
* Sets the image encoding.
+ *
* @param encoding The image encoding.
*/
public void setImageEncoding(byte encoding) {
/**
* Sets the image compression.
+ *
* @param compression The image compression.
*/
public void setImageCompression(byte compression) {
/**
* Sets the image IDE size.
+ *
* @param size The IDE size.
*/
public void setImageIDESize(byte size) {
/**
* Sets the image IDE color model.
+ *
* @param colorModel the IDE color model.
*/
public void setImageIDEColorModel(byte colorModel) {
/**
* Set the data of the image.
+ *
* @param data the image data
*/
public void setImageData(byte[] data) {
this.imageData = data;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void writeContent(OutputStream os) throws IOException {
if (imageSizeParameter != null) {
imageSizeParameter.write(os);
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void writeStart(OutputStream os) throws IOException {
byte[] data = new byte[] {
(byte)0x91, // ID
os.write(data);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
protected void writeEnd(OutputStream os) throws IOException {
byte[] data = new byte[] {
(byte)0x93, // ID
/**
* Helper method to return the start of the image segment.
+ *
* @return byte[] The data stream.
*/
private byte[] getImageDataStart(int len) {
-
byte[] data = new byte[] {
(byte)0xFE, // ID
(byte)0x92, // ID
0x00, // Length
0x00, // Length
};
-
byte[] l = BinaryUtils.convert(len, 2);
data[2] = l[0];
data[3] = l[1];
/**
* Helper method to return the image encoding parameter.
+ *
* @return byte[] The data stream.
*/
private byte[] getImageEncodingParameter() {
/**
* Helper method to return the external algorithm parameter.
+ *
* @return byte[] The data stream.
*/
private byte[] getExternalAlgorithmParameter() {
/**
* Helper method to return the image encoding parameter.
+ *
* @return byte[] The data stream.
*/
private byte[] getImageIDESizeParameter() {
/**
* Helper method to return the external algorithm parameter.
+ *
* @return byte[] The data stream.
*/
private byte[] getIDEStructureParameter() {
public void write(OutputStream os) throws IOException {
byte[] data = new byte[45];
-
- data[0] = 0x5A;
- data[1] = 0x00;
+ copySF(data, Type.DESCRIPTOR, Category.IM_IMAGE);
+
+ data[1] = 0x00; // length
data[2] = 0x2C;
- data[3] = (byte) 0xD3;
- data[4] = (byte) 0xA6;
- data[5] = (byte) 0x7B;
- data[6] = 0x00;
- data[7] = 0x00;
- data[8] = 0x00;
// Constant data.
data[9] = 0x00;
data[44] = (byte)0xFF;
os.write(data);
-
}
/**
* Sets the resolution information for the raster image
* the default value is a resolution of 240 dpi.
+ *
* @param resolution The resolution value
*/
public void setResolution(int resolution) {
/** {@inheritDoc} */
public void write(OutputStream os) throws IOException {
-
byte[] data = new byte[9];
-
- data[0] = 0x5A;
-
+ copySF(data, Type.DATA, Category.IM_IMAGE);
+
// The size of the structured field
- byte[] x = BinaryUtils.convert(rasterData.length + 8, 2);
- data[1] = x[0];
- data[2] = x[1];
-
- data[3] = (byte) 0xD3;
- data[4] = (byte) 0xEE;
- data[5] = (byte) 0x7B;
- data[6] = 0x00;
- data[7] = 0x00;
- data[8] = 0x00;
+ byte[] len = BinaryUtils.convert(rasterData.length + 8, 2);
+ data[1] = len[0];
+ data[2] = len[1];
os.write(data);
os.write(rasterData);
/**
* Constructor for the image segment with the specified name,
* the name must be a fixed length of eight characters.
+ *
* @param name The name of the image.
*/
public ImageSegment(String name) {
/**
* The collection of map coded fonts (maximum of 254)
*/
- private List fontList = null;
+ private List/*<FontDefinition>*/ fontList = new java.util.ArrayList();
/**
* Constructor for the MapCodedFont
*/
public MapCodedFont() {
- fontList = new java.util.ArrayList();
}
/** {@inheritDoc} */
public void write(OutputStream os) throws IOException {
- byte[] startData = new byte[] {
- 0x5A,
- 0x00, // Reserved
- 0x00, // Reserved
- (byte)0xD3,
- (byte)0xAB, // Format 2
- (byte)0x8A,
- 0x00, // Reserved
- 0x00, // Reserved
- 0x00, // Reserved
- };
-
ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ byte[] startData = new byte[9];
+ copySF(startData, Type.MAP, Category.CODED_FONT);
baos.write(startData);
Iterator iter = fontList.iterator();
}
}
- /**
- * Accessor method to write the AFP datastream for the Map Page Overlay
- * @param os The stream to write to
- * @throws java.io.IOException if an I/O exception occurred
- */
+ /** {@inheritDoc} */
public void write(OutputStream os) throws IOException {
int oLayCount = getOverlays().size();
int recordlength = oLayCount * 18;
// Structured field ID for a MPO
data[3] = (byte) 0xD3;
- data[4] = (byte) 0xAB;
- data[5] = (byte) 0xD8;
+ data[4] = (byte) Type.MAP;
+ data[5] = (byte) Category.PAGE_OVERLAY;
data[6] = 0x00; // Reserved
data[7] = 0x00; // Reserved
/**
* The Object Area Descriptor structured field specifies the size and attributes
* of an object area presentation space.
- *
*/
public class ObjectAreaDescriptor extends AbstractDescriptor {
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.fop.render.afp.DataObjectInfo;
-import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet;
-import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet;
import org.apache.fop.render.afp.tools.BinaryUtils;
/**
/** the object data */
private byte[] objectData = null;
-// /** the data object info */
-// private DataObjectInfo dataObjectInfo;
-
/**
* Default constructor
*/
this.dataObj = dataObj;
}
-// /** {@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} */
protected void writeStart(OutputStream os) throws IOException {
// create object data from data object
// write out object data in chunks of object container data
for (int i = 0; i <= objectData.length; i += ObjectContainerData.MAX_DATA_LEN) {
- ObjectContainerData objectContainerData = new ObjectContainerData(objectData, i);
- objectContainerData.write(os);
+ new ObjectContainerData(objectData, i).write(os);
}
}
/** The maximum object container data length */
private static final int MAX_DATA_LEN = 32759;
+ private byte[] objData = null;
+
+ private int startIndex;
+
/**
* Main constructor
*
* @param objData the object data
*/
public ObjectContainerData(byte[] objData, int startIndex) {
+ this.objData = objData;
+ this.startIndex = startIndex;
+ }
+
+ /** {@inheritDoc} */
+ public void write(OutputStream os) throws IOException {
int dataLen = MAX_DATA_LEN;
if (startIndex + MAX_DATA_LEN >= objData.length) {
dataLen = objData.length - startIndex - 1;
}
- byte[] len = BinaryUtils.convert(8 + dataLen, 2);
byte[] data = new byte[9 + dataLen];
- data[0] = 0x5A; // Structured field identifier
+ copySF(data, Type.DATA, Category.OBJECT_CONTAINER);
+
+ byte[] len = BinaryUtils.convert(8 + dataLen, 2);
data[1] = len[0]; // Length byte 1
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] = getCategoryCode(); // Structured field id byte 3
- data[6] = 0x00; // Flags
- data[7] = 0x00; // Reserved
- data[8] = 0x00; // Reserved
// copy object data chunk
System.arraycopy(objData, startIndex, data, 9, dataLen);
-
- super.setData(data);
+ os.write(data);
}
/** {@inheritDoc} */
+ ")";
}
- /** {@inheritDoc} */
- protected byte getCategoryCode() {
- return (byte)0x92;
- }
- }
-
- /** {@inheritDoc} */
- protected byte getCategoryCode() {
- return (byte)0x92;
}
}
addObject(ipo);
}
-// /**
-// * @return a new page segment object
-// */
-// private PageSegment createPageSegment() {
-// String name = PAGE_SEGMENT_NAME_PREFIX
-// + StringUtils.lpad(String.valueOf(++pageSegmentCount), '0', 5);
-// PageSegment pageSegment = new PageSegment(name);
-// return pageSegment;
-// }
-
-// /**
-// * @return the current page segment
-// */
-// private PageSegment getCurrentPageSegment() {
-// if (currentPageSegment == null) {
-// this.currentPageSegment = createPageSegment();
-// super.addObject(currentPageSegment);
-// }
-// return this.currentPageSegment;
-// }
-//
-// private static final String PAGE_SEGMENT_NAME_PREFIX = "PSG";
-
-// /**
-// * Starts a new page segment and makes it current.
-// */
-// public void startPageSegment() {
-// getCurrentPageSegment();
-// }
-//
-// /**
-// * Ends the current page segment.
-// */
-// public void endPageSegment() {
-// this.currentPageSegment = null;
-// }
-
-// /**
-// * {@inheritDoc}
-// */
-// protected void addObject(AbstractAFPObject obj) {
-//// if (currentPageSegment != null) {
-//// getCurrentPageSegment().addObject(obj);
-//// } else {
-// super.addObject(obj);
-//// }
-// }
-
/**
* This method will create shading on the page using the specified
* coordinates (the shading contrast is controlled via the red, green blue
public void writeStart(OutputStream os) throws IOException {
super.writeStart(os);
- byte[] l = BinaryUtils.convert(19 + getTripletDataLength(), 2);
byte[] data = new byte[9];
- data[0] = 0x5A; // Structured field identifier
+ copySF(data, Type.PROCESS, Category.DATA_RESOURCE);
+
+ byte[] l = BinaryUtils.convert(19 + getTripletDataLength(), 2);
data[1] = l[0]; // Length byte 1
data[2] = l[1]; // Length byte 1
- data[3] = (byte)0xD3; // Structured field id byte 1
- data[4] = (byte)0xAD; // Structured field id byte 2
- data[5] = (byte)0xC3; // Structured field id byte 3
- data[6] = 0x00; // Flags
- data[7] = 0x00; // Reserved
- data[8] = 0x00; // Reserved
-
+
os.write(data);
}
super.writeContent(os);
}
- /** {@inheritDoc} */
- protected byte getCategoryCode() {
- return (byte)0xC3;
- }
}
/** {@inheritDoc} */
public void write(OutputStream os) throws IOException {
-
byte[] data = new byte[23];
- data[0] = 0x5A;
- data[1] = 0x00;
+
+ copySF(data, Type.MIGRATION, Category.PRESENTATION_TEXT);
+
+ data[1] = 0x00; // length
data[2] = 0x16;
- data[3] = (byte) 0xD3;
- data[4] = (byte) 0xB1;
- data[5] = (byte) 0x9B;
- data[6] = 0x00;
- data[7] = 0x00;
- data[8] = 0x00;
+
data[9] = 0x00;
data[10] = 0x00;
data[22] = 0x00;
os.write(data);
-
}
}
\ No newline at end of file
import java.io.IOException;
import java.io.OutputStream;
-import java.util.Collection;
import java.util.Iterator;
-import java.util.Map;
import java.util.Set;
import org.apache.fop.render.afp.DataObjectCache;
-import org.apache.fop.render.afp.DataObjectInfo;
import org.apache.fop.render.afp.ResourceInfo;
-import org.apache.fop.render.afp.ResourceLevel;
-import org.apache.fop.render.afp.tools.StringUtils;
/**
* A Resource Group contains a set of overlays.
// return includeObj;
// }
- /**
- * Checks if a named object is of a valid type to be added to a resource group
- *
- * @param namedObj a named object
- * @return true if the named object is of a valid type to be added to a resource group
- */
- private boolean isValidObjectType(AbstractNamedAFPObject namedObj) {
- return (namedObj instanceof Overlay
- || namedObj instanceof ResourceObject
- || namedObj instanceof PageSegment
- || namedObj instanceof GraphicsObject
- || namedObj instanceof ImageObject
- || namedObj instanceof ObjectContainer
- || namedObj instanceof Document
- // || namedObj instanceof FormMap
- // || namedObj instanceof BarcodeObject
- );
- }
+// /**
+// * Checks if a named object is of a valid type to be added to a resource group
+// *
+// * @param namedObj a named object
+// * @return true if the named object is of a valid type to be added to a resource group
+// */
+// private boolean isValidObjectType(AbstractNamedAFPObject namedObj) {
+// return (namedObj instanceof Overlay
+// || namedObj instanceof ResourceObject
+// || namedObj instanceof PageSegment
+// || namedObj instanceof GraphicsObject
+// || namedObj instanceof ImageObject
+// || namedObj instanceof ObjectContainer
+// || namedObj instanceof Document
+// // || namedObj instanceof FormMap
+// // || namedObj instanceof BarcodeObject
+// );
+// }
/**
* Add this object cache resource info to this resource group
*/
public void setDataObject(AbstractNamedAFPObject obj) {
this.namedObject = obj;
-//
-// String fqn = obj.getFullyQualifiedName();
-// if (fqn != null) {
-// super.setFullyQualifiedName(
-// FullyQualifiedNameTriplet.TYPE_REPLACE_FIRST_GID_NAME,
-// FullyQualifiedNameTriplet.FORMAT_CHARSTR,
-// fqn);
-// }
-//
-// byte type;
-// if (obj instanceof ObjectContainer) {
-// type = ResourceObjectTypeTriplet.OBJECT_CONTAINER;
-// } else if (obj instanceof ImageObject) {
-// type = ResourceObjectTypeTriplet.IMAGE_OBJECT;
-// } else if (obj instanceof GraphicsObject) {
-// type = ResourceObjectTypeTriplet.GRAPHICS_OBJECT;
-// } else if (obj instanceof Document) {
-// type = ResourceObjectTypeTriplet.DOCUMENT_OBJECT;
-// } else if (obj instanceof PageSegment) {
-// type = ResourceObjectTypeTriplet.PAGE_SEGMENT_OBJECT;
-// } else if (obj instanceof Overlay) {
-// type = ResourceObjectTypeTriplet.OVERLAY_OBJECT;
-// } else {
-// throw new UnsupportedOperationException(
-// "Unsupported resource object type " + obj);
-// }
-// getTriplets().add(new ResourceObjectTypeTriplet(type));
}
-
-// /** {@inheritDoc} */
-// public void setDataObjectInfo(DataObjectInfo dataObjectInfo) {
-// this.dataObjectInfo = dataObjectInfo;
-//
-// if (namedObject instanceof ObjectContainer) {
-// Registry.ObjectType objectType = dataObjectInfo.getObjectType();
-// super.setObjectClassification(
-// ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT,
-// objectType);
-// }
-// }
/** {@inheritDoc} */
protected void writeStart(OutputStream os) throws IOException {
/**
* Name of the key, used within the TLE
*/
- private String tleName = null;
+ private String name = null;
/**
* Value returned by the key
*/
- private String tleValue = null;
-
- /**
- * Byte representaion of the name
- */
- private byte[] tleByteName = null;
-
- /**
- * Byte representaion of the value
- */
- private byte[] tleByteValue = null;
+ private String value = null;
/**
* Construct a tag logical element with the name and value specified.
+ *
* @param name the name of the tag logical element
* @param value the value of the tag logical element
*/
public TagLogicalElement(String name, String value) {
-
- this.tleName = name;
- this.tleValue = value;
-
- try {
-
- this.tleByteName = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
- this.tleByteValue = value.getBytes(AFPConstants.EBCIDIC_ENCODING);
-
- } catch (UnsupportedEncodingException usee) {
-
- this.tleByteName = name.getBytes();
- this.tleByteValue = value.getBytes();
- log.warn(
- "Constructor:: UnsupportedEncodingException translating the name "
- + name);
-
- }
-
+ this.name = name;
+ this.value = value;
}
- /**
- * Accessor method to obtain the byte array AFP datastream for the
- * TagLogicalElement.
- * @param os The outputsteam stream
- * @throws java.io.IOException if an I/O exception occurred
- */
+ /** {@inheritDoc} */
public void write(OutputStream os) throws IOException {
- byte[] data = new byte[17 + tleName.length() + tleValue.length()];
+ byte[] data = new byte[17 + name.length() + value.length()];
data[0] = 0x5A;
// Set the total record length
byte[] rl1
- = BinaryUtils.convert(16 + tleName.length() + tleValue.length(), 2);
+ = BinaryUtils.convert(16 + name.length() + value.length(), 2);
//Ignore first byte
data[1] = rl1[0];
data[2] = rl1[1];
// Structured field ID for a TLE
data[3] = (byte) 0xD3;
- data[4] = (byte) 0xA0;
- data[5] = (byte) 0x90;
+ data[4] = (byte) Type.ATTRIBUTE;
+ data[5] = (byte) Category.PROCESS_ELEMENT;
data[6] = 0x00; // Reserved
data[7] = 0x00; // Reserved
//Use 2 triplets, attrubute name and value (the key for indexing)
- byte[] rl2 = BinaryUtils.convert(tleName.length() + 4, 1);
+ byte[] rl2 = BinaryUtils.convert(name.length() + 4, 1);
data[9] = rl2[0]; // length of the triplet, including this field
data[10] = 0x02; //Identifies it as a FQN triplet
data[11] = 0x0B; // GID format
data[12] = 0x00;
+ byte[] tleByteName = null;
+ byte[] tleByteValue = null;
+ try {
+ tleByteName = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
+ tleByteValue = value.getBytes(AFPConstants.EBCIDIC_ENCODING);
+ } catch (UnsupportedEncodingException usee) {
+ tleByteName = name.getBytes();
+ tleByteValue = value.getBytes();
+ log.warn(
+ "Constructor:: UnsupportedEncodingException translating the name "
+ + name);
+ }
+
int pos = 13;
for (int i = 0; i < tleByteName.length; i++) {
data[pos++] = tleByteName[i];
/**
* Constructor for the TagLogicalElementBean.
+ *
* @param key the key attribute
* @param value the value attribute
*/
/**
* Getter for the key attribute.
+ *
* @return the key
*/
public String getKey() {
/**
* Getter for the value attribute.
+ *
* @return the value
*/
public String getValue() {