You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ma...@apache.org on 2006/04/27 17:08:24 UTC
svn commit: r397562 [4/6] - in /xmlgraphics/fop/trunk/src/sandbox:
META-INF/services/ org/apache/fop/render/afp/
org/apache/fop/render/afp/apps/ org/apache/fop/render/afp/exceptions/
org/apache/fop/render/afp/extensions/ org/apache/fop/render/afp/fonts...
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageContent.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageContent.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageContent.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageContent.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,294 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+import java.io.IOException;
+import java.io.OutputStream;
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ */
+public class ImageContent extends AbstractAFPObject {
+
+ /**
+ * The image size parameter
+ */
+ private ImageSizeParameter _imageSizeParameter = null;
+
+ /**
+ * The image encoding
+ */
+ private byte _encoding = 0x03;
+
+ /**
+ * The image ide size
+ */
+ private byte _size = 1;
+
+ /**
+ * The image compression
+ */
+ private byte _compression = (byte)0xC0;
+
+ /**
+ * The image color model
+ */
+ private byte _colorModel = 0x01;
+
+ /**
+ * The image data
+ */
+ private byte _data[] = null;
+
+ /**
+ * Constructor for the image content
+ */
+ public ImageContent() {
+
+ }
+
+ /**
+ * 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.
+ * @param vsize The vertival size of the image.
+ */
+ public void setImageSize(int hresol, int vresol, int hsize, int vsize) {
+ _imageSizeParameter = new ImageSizeParameter(hresol, vresol, hsize, vsize);
+ }
+
+ /**
+ * Sets the image encoding.
+ * @param encoding The image encoding.
+ */
+ public void setImageEncoding(byte encoding) {
+ _encoding = encoding;
+ }
+
+ /**
+ * Sets the image compression.
+ * @param compression The image compression.
+ */
+ public void setImageCompression(byte compression) {
+ _compression = compression;
+ }
+
+ /**
+ * Sets the image IDE size.
+ * @param size The IDE size.
+ */
+ public void setImageIDESize(byte size) {
+ _size = size;
+ }
+
+ /**
+ * Sets the image IDE color model.
+ * @param size The IDE color model.
+ */
+ public void setImageIDEColorModel(byte colorModel) {
+ _colorModel = colorModel;
+ }
+
+ /**
+ * Set the data of the image.
+ */
+ public void setImageData(byte data[]) {
+ _data = data;
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the Image Content
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ writeStart(os);
+
+ if (_imageSizeParameter != null) {
+ _imageSizeParameter.writeDataStream(os);
+ }
+
+ os.write(getImageEncodingParameter());
+
+ os.write(getImageIDESizeParameter());
+
+ os.write(getIDEStructureParameter());
+
+ os.write(getExternalAlgorithmParameter());
+
+ if (_data != null) {
+ int off = 0;
+ while (off < _data.length) {
+ int len = Math.min(30000, _data.length - off);
+ os.write(getImageDataStart(len));
+ os.write(_data, off, len);
+ off += len;
+ }
+ }
+
+ writeEnd(os);
+
+ }
+
+ /**
+ * Helper method to write the start of the Image Content.
+ * @param os The stream to write to
+ */
+ private void writeStart(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[] {
+ (byte)0x91, // ID
+ 0x01, // Length
+ (byte)0xff, // Object Type = IOCA Image Object
+ };
+
+ os.write(data);
+
+ }
+
+ /**
+ * Helper method to write the end of the Image Content.
+ * @param os The stream to write to
+ */
+ private void writeEnd(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[] {
+ (byte)0x93, // ID
+ 0x00, // Length
+ };
+
+ os.write(data);
+
+ }
+
+ /**
+ * 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];
+
+
+ return data;
+
+ }
+
+ /**
+ * Helper method to return the image encoding parameter.
+ * @return byte[] The data stream.
+ */
+ private byte[] getImageEncodingParameter() {
+
+ byte[] data = new byte[] {
+ (byte)0x95, // ID
+ 0x02, // Length
+ _encoding,
+ 0x01, // RECID
+ };
+
+ return data;
+
+ }
+
+ /**
+ * Helper method to return the external algorithm parameter.
+ * @return byte[] The data stream.
+ */
+ private byte[] getExternalAlgorithmParameter() {
+
+ if (_encoding == (byte)0x83 && _compression != 0) {
+ byte[] data = new byte[] {
+ (byte)0x95, // ID
+ 0x00, // Length
+ 0x10, // ALGTYPE = Compression Algorithm
+ 0x00, // Reserved
+ (byte)0x83, // COMPRID = JPEG
+ 0x00, // Reserved
+ 0x00, // Reserved
+ 0x00, // Reserved
+ _compression, // MARKER
+ 0x00, // Reserved
+ 0x00, // Reserved
+ 0x00, // Reserved
+ };
+ data[1] = (byte)(data.length - 2);
+ return data;
+ }
+ return new byte[0];
+ }
+
+ /**
+ * Helper method to return the image encoding parameter.
+ * @return byte[] The data stream.
+ */
+ private byte[] getImageIDESizeParameter() {
+
+ byte[] data = new byte[] {
+ (byte)0x96, // ID
+ 0x01, // Length
+ _size,
+ };
+
+ return data;
+
+ }
+
+ /**
+ * Helper method to return the external algorithm parameter.
+ * @return byte[] The data stream.
+ */
+ private byte[] getIDEStructureParameter() {
+
+ if (_colorModel != 0 && _size == 24) {
+ byte bits = (byte)(_size / 3);
+ byte[] data = new byte[] {
+ (byte)0x9B, // ID
+ 0x00, // Length
+ 0x00, // FLAGS
+ 0x00, // Reserved
+ _colorModel, // COLOR MODEL
+ 0x00, // Reserved
+ 0x00, // Reserved
+ 0x00, // Reserved
+ bits,
+ bits,
+ bits,
+ };
+ data[1] = (byte)(data.length - 2);
+ return data;
+ }
+ return new byte[0];
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageContent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageContent.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageDataDescriptor.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageDataDescriptor.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageDataDescriptor.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageDataDescriptor.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ */
+public class ImageDataDescriptor extends AbstractAFPObject {
+
+ private int _xresol = 0;
+ private int _yresol = 0;
+ private int _width = 0;
+ private int _height = 0;
+
+ /**
+ * Constructor for a ImageDataDescriptor for the specified
+ * resolution, width and height.
+ * @param xresol The horizontal resolution of the image.
+ * @param yresol The vertical resolution of the image.
+ * @param width The width of the image.
+ * @param height The height of the height.
+ */
+ public ImageDataDescriptor(int xresol, int yresol, int width, int height) {
+
+ _xresol = xresol;
+ _yresol = yresol;
+ _width = width;
+ _height = height;
+
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the Image Data Descriptor
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[] {
+ 0x5A,
+ 0x00,
+ 0x20,
+ (byte) 0xD3,
+ (byte) 0xA6,
+ (byte) 0xFB,
+ 0x00, // Flags
+ 0x00, // Reserved
+ 0x00, // Reserved
+ 0x00, // Unit base - 10 Inches
+ 0x00, // XRESOL
+ 0x00, //
+ 0x00, // YRESOL
+ 0x00, //
+ 0x00, // XSIZE
+ 0x00, //
+ 0x00, // YSIZE
+ 0x00, //
+ (byte)0xF7, // ID = Set IOCA Function Set
+ 0x02, // Length
+ 0x01, // Category = Function set identifier
+ 0x0B, // FCNSET = IOCA FS 11
+ };
+
+ byte[] l = BinaryUtils.convert(data.length - 1, 2);
+ data[1] = l[0];
+ data[2] = l[1];
+
+ byte[] x = BinaryUtils.convert(_xresol, 2);
+ data[10] = x[0];
+ data[11] = x[1];
+
+ byte[] y = BinaryUtils.convert(_yresol, 2);
+ data[12] = y[0];
+ data[13] = y[1];
+
+ byte[] w = BinaryUtils.convert(_width, 2);
+ data[14] = w[0];
+ data[15] = w[1];
+
+ byte[] h = BinaryUtils.convert(_height, 2);
+ data[16] = h[0];
+ data[17] = h[1];
+
+ os.write(data);
+
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageDataDescriptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageDataDescriptor.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageInputDescriptor.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageInputDescriptor.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageInputDescriptor.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageInputDescriptor.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * The IM Image Input Descriptor structured field contains the
+ * descriptor data for an IM image data object. This data specifies
+ * the resolution, size, and color of the IM image.
+ */
+public class ImageInputDescriptor extends AbstractAFPObject {
+
+ /**
+ * The resolution of the raster image (default 240)
+ */
+ private int _resolution = 240;
+
+
+ /**
+ * Accessor method to write the AFP datastream for the Image Input Descriptor
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[45];
+
+ data[0] = 0x5A;
+ data[1] = 0x00;
+ 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[10] = 0x00;
+ data[11] = 0x09;
+ data[12] = 0x60;
+ data[13] = 0x09;
+ data[14] = 0x60;
+ data[15] = 0x00;
+ data[16] = 0x00;
+ data[17] = 0x00;
+ data[18] = 0x00;
+ data[19] = 0x00;
+ data[20] = 0x00;
+
+ // X Base (Fixed x00)
+ data[21] = 0x00;
+ // Y Base (Fixed x00)
+ data[22] = 0x00;
+
+ byte[] imagepoints = BinaryUtils.convert(_resolution * 10, 2);
+
+ /**
+ * Specifies the number of image points per unit base for the X axis
+ * of the image. This value is ten times the resolution of the image
+ * in the X direction.
+ */
+ data[23] = imagepoints[0];
+ data[24] = imagepoints[1];
+
+ /**
+ * Specifies the number of image points per unit base for the Y axis
+ * of the image. This value is ten times the resolution of the image
+ * in the Y direction.
+ */
+ data[25] = imagepoints[0];
+ data[26] = imagepoints[1];
+
+ /**
+ * Specifies the extent in the X direction, in image points, of an
+ * non-celled (simple) image.
+ */
+ data[27] = 0x00;
+ data[28] = 0x01;
+
+ /**
+ * Specifies the extent in the Y direction, in image points, of an
+ * non-celled (simple) image.
+ */
+ data[29] = 0x00;
+ data[30] = 0x01;
+
+ // Constant Data
+ data[31] = 0x00;
+ data[32] = 0x00;
+ data[33] = 0x00;
+ data[34] = 0x00;
+ data[35] = 0x2D;
+ data[36] = 0x00;
+
+ // Default size of image cell in X direction
+ data[37] = 0x00;
+ data[38] = 0x01;
+
+ // Default size of image cell in Y direction
+ data[39] = 0x00;
+ data[40] = 0x01;
+
+ // Constant Data
+ data[41] = 0x00;
+ data[42] = 0x01;
+
+ // Image Color
+ data[43] = (byte)0xFF;
+ 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) {
+ _resolution = resolution;
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageInputDescriptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageInputDescriptor.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageObject.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageObject.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageObject.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageObject.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,271 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * An IOCA Image Data Object
+ */
+public class ImageObject extends AbstractNamedAFPObject {
+
+ /**
+ * The object environment group
+ */
+ private ObjectEnvironmentGroup _objectEnvironmentGroup = null;
+
+ /**
+ * The image segment
+ */
+ private ImageSegment _imageSegment = null;
+
+ /**
+ * Constructor for the image object with the specified name,
+ * the name must be a fixed length of eight characters.
+ * @param name The name of the image.
+ */
+ public ImageObject(String name) {
+
+ super(name);
+
+ }
+
+ /**
+ * Sets the image display area position and size.
+ *
+ * @param x
+ * the x position of the image
+ * @param y
+ * the y position of the image
+ * @param w
+ * the width of the image
+ * @param h
+ * the height of the image
+ * @param r
+ * the rotation of the image
+ */
+ public void setImageViewport(int x, int y, int w, int h, int r) {
+ if (_objectEnvironmentGroup == null) {
+ _objectEnvironmentGroup = new ObjectEnvironmentGroup();
+ }
+ _objectEnvironmentGroup.setObjectArea(x, y, w, h, r);
+ }
+
+ /**
+ * Set the dimensions of the image.
+ * @param xresol the x resolution of the image
+ * @param yresol the y resolution of the image
+ * @param width the image width
+ * @param height the image height
+ */
+ public void setImageParameters(int xresol, int yresol, int width, int height) {
+ if (_objectEnvironmentGroup == null) {
+ _objectEnvironmentGroup = new ObjectEnvironmentGroup();
+ }
+ _objectEnvironmentGroup.setImageData(xresol, yresol, width, height);
+ if (_imageSegment == null) {
+ _imageSegment = new ImageSegment();
+ }
+ _imageSegment.setImageSize(xresol, yresol, width, height);
+ }
+
+ /**
+ * Sets the image encoding.
+ * @param encoding The image encoding.
+ */
+ public void setImageEncoding(byte encoding) {
+ if (_imageSegment == null) {
+ _imageSegment = new ImageSegment();
+ }
+ _imageSegment.setImageEncoding(encoding);
+ }
+
+ /**
+ * Sets the image compression.
+ * @param compression The image compression.
+ */
+ public void setImageCompression(byte compression) {
+ if (_imageSegment == null) {
+ _imageSegment = new ImageSegment();
+ }
+ _imageSegment.setImageCompression(compression);
+ }
+
+ /**
+ * Sets the image IDE size.
+ * @param size The IDE size.
+ */
+ public void setImageIDESize(byte size) {
+ if (_imageSegment == null) {
+ _imageSegment = new ImageSegment();
+ }
+ _imageSegment.setImageIDESize(size);
+ }
+
+ /**
+ * Sets the image IDE color model.
+ * @param size The IDE color model.
+ */
+ public void setImageIDEColorModel(byte colorModel) {
+ if (_imageSegment == null) {
+ _imageSegment = new ImageSegment();
+ }
+ _imageSegment.setImageIDEColorModel(colorModel);
+ }
+
+ /**
+ * Set the data of the image.
+ * @param data The image data
+ */
+ public void setImageData(byte data[]) {
+ if (_imageSegment == null) {
+ _imageSegment = new ImageSegment();
+ }
+ _imageSegment.setImageData(data);
+ }
+
+ /**
+ * Sets the ObjectEnvironmentGroup.
+ * @param objectEnvironmentGroup The objectEnvironmentGroup to set
+ */
+ public void setObjectEnvironmentGroup(ObjectEnvironmentGroup objectEnvironmentGroup) {
+ _objectEnvironmentGroup = objectEnvironmentGroup;
+ }
+
+ /**
+ * Helper method to return the start of the image object.
+ * @return byte[] The data stream.
+ */
+ private byte[] getIPDStart(int len) {
+
+ byte[] data = new byte[] {
+
+ 0x5A, // Structured field identifier
+ 0x00, // Length byte 1
+ 0x10, // Length byte 2
+ (byte) 0xD3, // Structured field id byte 1
+ (byte) 0xEE, // Structured field id byte 2
+ (byte) 0xFB, // Structured field id byte 3
+ 0x00, // Flags
+ 0x00, // Reserved
+ 0x00, // Reserved
+ };
+
+ byte[] l = BinaryUtils.convert(len + 8, 2);
+ data[1] = l[0];
+ data[2] = l[1];
+
+ return data;
+
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the Image Object
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ writeStart(os);
+
+ if (_objectEnvironmentGroup != null) {
+ _objectEnvironmentGroup.writeDataStream(os);
+ }
+
+ if (_imageSegment != null) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ _imageSegment.writeDataStream(baos);
+ byte b[] = baos.toByteArray();
+ int off = 0;
+ while (off < b.length) {
+ int len = Math.min(30000, b.length - off);
+ os.write(getIPDStart(len));
+ os.write(b, off, len);
+ off += len;
+ }
+ }
+
+ writeEnd(os);
+
+ }
+
+ /**
+ * Helper method to write the start of the Image Object.
+ * @param os The stream to write to
+ */
+ private void writeStart(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[17];
+
+ data[0] = 0x5A; // Structured field identifier
+ data[1] = 0x00; // Length byte 1
+ data[2] = 0x10; // Length byte 2
+ data[3] = (byte) 0xD3; // Structured field id byte 1
+ data[4] = (byte) 0xA8; // Structured field id byte 2
+ data[5] = (byte) 0xFB; // Structured field id byte 3
+ data[6] = 0x00; // Flags
+ data[7] = 0x00; // Reserved
+ data[8] = 0x00; // Reserved
+
+ for (int i = 0; i < _nameBytes.length; i++) {
+
+ data[9 + i] = _nameBytes[i];
+
+ }
+
+ os.write(data);
+
+ }
+
+ /**
+ * Helper method to write the end of the Image Object.
+ * @param os The stream to write to
+ */
+ private void writeEnd(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[17];
+
+ data[0] = 0x5A; // Structured field identifier
+ data[1] = 0x00; // Length byte 1
+ data[2] = 0x10; // Length byte 2
+ data[3] = (byte) 0xD3; // Structured field id byte 1
+ data[4] = (byte) 0xA9; // Structured field id byte 2
+ data[5] = (byte) 0xFB; // Structured field id byte 3
+ data[6] = 0x00; // Flags
+ data[7] = 0x00; // Reserved
+ data[8] = 0x00; // Reserved
+
+ for (int i = 0; i < _nameBytes.length; i++) {
+
+ data[9 + i] = _nameBytes[i];
+
+ }
+
+ os.write(data);
+
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageObject.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageObject.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageOutputControl.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageOutputControl.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageOutputControl.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageOutputControl.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,207 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * The IM Image Output Control structured field specifies the position and
+ * orientation of the IM image object area and the mapping of the image points
+ * to presentation device pels.
+ *
+ */
+public class ImageOutputControl extends AbstractAFPObject {
+
+ /**
+ * The orientation of the image
+ */
+ private int _orientation = 0;
+
+ /**
+ * Specifies the offset, along the X-axis, of the IM image object area
+ * origin to the origin of the including page
+ */
+ private int _Xcoordinate = 0;
+
+ /**
+ * Specifies the offset, along the Y-axis, of the IM image object area
+ * origin to the origin of the including page
+ */
+ private int _Ycoordinate = 0;
+
+ /**
+ * Map an image point to a single presentation device pel
+ */
+ private boolean _singlepoint = true;
+
+ /**
+ * Constructor for the ImageOutputControl The x parameter specifies the
+ * offset, along the X-axis, of the IM image object area origin to the
+ * origin of the including page and the y parameter specifies the offset
+ * along the Y-axis. The offset is specified in image points and is resolved
+ * using the units of measure specified for the image in the IID structured
+ * field.
+ *
+ * @param x
+ * The X-axis offset.
+ * @param y
+ * The Y-axis offset.
+ */
+ public ImageOutputControl(int x, int y) {
+
+ _Xcoordinate = x;
+ _Ycoordinate = y;
+
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the Image Output Control
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[33];
+
+ data[0] = 0x5A;
+ data[1] = 0x00;
+ data[2] = 0x20;
+ data[3] = (byte) 0xD3;
+ data[4] = (byte) 0xA7;
+ data[5] = (byte) 0x7B;
+ data[6] = 0x00;
+ data[7] = 0x00;
+ data[8] = 0x00;
+
+ // XoaOset
+ byte[] x1 = BinaryUtils.convert(_Xcoordinate, 3);
+ data[9] = x1[0];
+ data[10] = x1[1];
+ data[11] = x1[2];
+
+ // YoaOset
+ byte[] x2 = BinaryUtils.convert(_Ycoordinate, 3);
+ data[12] = x2[0];
+ data[13] = x2[1];
+ data[14] = x2[2];
+
+ switch (_orientation) {
+ case 0:
+ // 0 and 90 degrees respectively
+ data[15] = 0x00;
+ data[16] = 0x00;
+ data[17] = 0x2D;
+ data[18] = 0x00;
+ break;
+ case 90:
+ // 90 and 180 degrees respectively
+ data[15] = 0x2D;
+ data[16] = 0x00;
+ data[17] = 0x5A;
+ data[18] = 0x00;
+ break;
+ case 180:
+ // 180 and 270 degrees respectively
+ data[15] = 0x5A;
+ data[16] = 0x00;
+ data[17] = (byte) 0x87;
+ data[18] = 0x00;
+ break;
+ case 270:
+ // 270 and 0 degrees respectively
+ data[15] = (byte) 0x87;
+ data[16] = 0x00;
+ data[17] = 0x00;
+ data[18] = 0x00;
+ break;
+ default:
+ // 0 and 90 degrees respectively
+ data[15] = 0x00;
+ data[16] = 0x00;
+ data[17] = 0x2D;
+ data[18] = 0x00;
+ break;
+
+ }
+
+ // Constant Data
+ data[19] = 0x00;
+ data[20] = 0x00;
+ data[21] = 0x00;
+ data[22] = 0x00;
+ data[23] = 0x00;
+ data[24] = 0x00;
+ data[25] = 0x00;
+ data[26] = 0x00;
+
+ if (_singlepoint) {
+ data[27] = 0x03;
+ data[28] = (byte) 0xE8;
+ data[29] = 0x03;
+ data[30] = (byte) 0xE8;
+ } else {
+ data[27] = 0x07;
+ data[28] = (byte) 0xD0;
+ data[29] = 0x07;
+ data[30] = (byte) 0xD0;
+ }
+
+ // Constant Data
+ data[31] = (byte) 0xFF;
+ data[32] = (byte) 0xFF;
+
+ os.write(data);
+
+ }
+
+ /**
+ * Sets the orientation which specifies the amount of clockwise rotation of
+ * the IM image object area.
+ *
+ * @param orientation
+ * The orientation to set.
+ */
+ public void setOrientation(int orientation) {
+
+ if (orientation == 0 || orientation == 90 || orientation == 180
+ || orientation == 270) {
+ _orientation = orientation;
+ } else {
+ throw new IllegalArgumentException(
+ "The orientation must be one of the values 0, 90, 180, 270");
+ }
+
+ }
+
+ /**
+ * Sets the singlepoint, if true map an image point to a single presentation
+ * device pel in the IM image object area. If false map an image point to
+ * two presentation device pels in the IM image object area (double-dot)
+ *
+ * @param singlepoint
+ * Use the singlepoint basis when true.
+ */
+ public void setSinglepoint(boolean singlepoint) {
+ _singlepoint = singlepoint;
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageOutputControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageOutputControl.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterData.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterData.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterData.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterData.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * Contains the image points that define the IM image raster pattern.
+ *
+ * A raster pattern is the array of presentation device pels that forms
+ * the image. The image data is uncompressed. Bits are grouped into
+ * bytes and are ordered from left to right within each byte. Each bit
+ * in the image data represents an image point and is mapped to
+ * presentation device pels as specified in the IOC structured field.
+ * A bit with value B'1' indicates a significant image point; a bit
+ * with value B'0' indicates an insignificant image point.
+ * Image points are recorded from left to right in rows that represents
+ * scan lines (X direction), and rows representing scan lines are
+ * recorded from top to bottom (Y direction). When the image is
+ * presented, all image points in a row are presented before any
+ * image points in the next sequential row are presented, and all rows
+ * have the same number of image points. If the total number of image
+ * points is not a multiple of 8, the last byte of the image data is
+ * padded to a byte boundary. The padding bits do not represent image
+ * points and are ignored by presentation devices.
+ */
+public class ImageRasterData extends AbstractAFPObject {
+
+ /**
+ * The image raster data
+ */
+ private byte[] _rasterdata;
+
+ /**
+ * Constructor for the image raster data object
+ * @param rasterdata The raster image data
+ */
+ public ImageRasterData(byte[] rasterdata) {
+
+ _rasterdata = rasterdata;
+
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the Image Raster Data
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[9];
+
+ data[0] = 0x5A;
+
+ // 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;
+
+ os.write(data);
+ os.write(_rasterdata);
+
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterData.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterData.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterPattern.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterPattern.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterPattern.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterPattern.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,762 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+/**
+ * Raster data is a grid of cells covering an area of interest.
+ * Each pixel, the smallest unit of information in the grid, displays
+ * a unique attribute. This static class generates raster data for different
+ * shades of grey (betweeen 0 and 16) the lower the number being the
+ * darker the shade. The image data dimensions are 64 x 8.
+ */
+public class ImageRasterPattern {
+
+ /**
+ * The Raster Pattern for Greyscale 16
+ */
+ private static final byte[] GREYSCALE16 = new byte[] {
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ };
+
+ /**
+ * The Raster Pattern for Greyscale 15
+ */
+ private static final byte[] GREYSCALE15 = new byte[] {
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ };
+
+ /**
+ * The Raster Pattern for Greyscale 14
+ */
+ private static final byte[] GREYSCALE14 = new byte[] {
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ };
+
+
+ /**
+ * The Raster Pattern for Greyscale 13
+ */
+ private static final byte[] GREYSCALE13 = new byte[] {
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ };
+
+ /**
+ * The Raster Pattern for Greyscale 12
+ */
+ private static final byte[] GREYSCALE12 = new byte[] {
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ };
+
+ /**
+ * The Raster Pattern for Greyscale 11
+ */
+ private static final byte[] GREYSCALE11 = new byte[] {
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ };
+
+ /**
+ * The Raster Pattern for Greyscale 10
+ */
+ private static final byte[] GREYSCALE10 = new byte[] {
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ 0x44,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ };
+
+ /**
+ * The Raster Pattern for Greyscale 9
+ */
+ private static final byte[] GREYSCALE09 = new byte[] {
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ 0x11,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ };
+
+ /**
+ * The Raster Pattern for Greyscale 8
+ */
+ private static final byte[] GREYSCALE08 = new byte[] {
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ };
+
+
+ /**
+ * The Raster Pattern for Greyscale 7
+ */
+ private static final byte[] GREYSCALE07 = new byte[] {
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ };
+
+
+ /**
+ * The Raster Pattern for Greyscale 6
+ */
+ private static final byte[] GREYSCALE06 = new byte[] {
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ (byte)0xEE,
+ (byte)0xEE,
+ (byte)0xEE,
+ (byte)0xEE,
+ (byte)0xEE,
+ (byte)0xEE,
+ (byte)0xEE,
+ (byte)0xEE,
+ };
+
+ /**
+ * The Raster Pattern for Greyscale 5
+ */
+ private static final byte[] GREYSCALE05 = new byte[] {
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xEE,
+ (byte)0xEE,
+ (byte)0xEE,
+ (byte)0xEE,
+ (byte)0xEE,
+ (byte)0xEE,
+ (byte)0xEE,
+ (byte)0xEE,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ };
+
+
+ /**
+ * The Raster Pattern for Greyscale 4
+ */
+ private static final byte[] GREYSCALE04 = new byte[] {
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xAA,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ };
+
+ /**
+ * The Raster Pattern for Greyscale 3
+ */
+ private static final byte[] GREYSCALE03 = new byte[] {
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ 0x55,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xBB,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ };
+
+ /**
+ * The Raster Pattern for Greyscale 2
+ */
+ private static final byte[] GREYSCALE02 = new byte[] {
+ 0x77,
+ 0x77,
+ 0x77,
+ 0x77,
+ 0x77,
+ 0x77,
+ 0x77,
+ 0x77,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xDD,
+ (byte)0xDD,
+ (byte)0xDD,
+ (byte)0xDD,
+ (byte)0xDD,
+ (byte)0xDD,
+ (byte)0xDD,
+ (byte)0xDD,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ };
+
+
+ /**
+ * The Raster Pattern for Greyscale 1
+ */
+ private static final byte[] GREYSCALE01 = new byte[] {
+ 0x77,
+ 0x77,
+ 0x77,
+ 0x77,
+ 0x77,
+ 0x77,
+ 0x77,
+ 0x77,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ };
+
+
+ /**
+ * The Raster Pattern for Greyscale 00
+ */
+ private static final byte[] GREYSCALE00 = new byte[] {
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ (byte)0xFF,
+ };
+
+ /**
+ * Static method to return the raster image data for the
+ * grey scale specified. The scale should be between 0 (darkest)
+ * and 16 (lightest).
+ * @param greyscale The grey scale value (0 - 16)
+ */
+ public static byte[] getRasterData(int greyscale) {
+
+ int repeat = 16;
+
+ byte[] greypattern = new byte[32];
+ byte[] rasterdata = new byte[32 * repeat];
+
+ switch (greyscale) {
+ case 0:
+ System.arraycopy(GREYSCALE00, 0, greypattern, 0, 32);
+ break;
+ case 1:
+ System.arraycopy(GREYSCALE01, 0, greypattern, 0, 32);
+ break;
+ case 2:
+ System.arraycopy(GREYSCALE02, 0, greypattern, 0, 32);
+ break;
+ case 3:
+ System.arraycopy(GREYSCALE03, 0, greypattern, 0, 32);
+ break;
+ case 4:
+ System.arraycopy(GREYSCALE04, 0, greypattern, 0, 32);
+ break;
+ case 5:
+ System.arraycopy(GREYSCALE05, 0, greypattern, 0, 32);
+ break;
+ case 6:
+ System.arraycopy(GREYSCALE06, 0, greypattern, 0, 32);
+ break;
+ case 7:
+ System.arraycopy(GREYSCALE07, 0, greypattern, 0, 32);
+ break;
+ case 8:
+ System.arraycopy(GREYSCALE08, 0, greypattern, 0, 32);
+ break;
+ case 9:
+ System.arraycopy(GREYSCALE09, 0, greypattern, 0, 32);
+ break;
+ case 10:
+ System.arraycopy(GREYSCALE10, 0, greypattern, 0, 32);
+ break;
+ case 11:
+ System.arraycopy(GREYSCALE11, 0, greypattern, 0, 32);
+ break;
+ case 12:
+ System.arraycopy(GREYSCALE12, 0, greypattern, 0, 32);
+ break;
+ case 13:
+ System.arraycopy(GREYSCALE13, 0, greypattern, 0, 32);
+ break;
+ case 14:
+ System.arraycopy(GREYSCALE14, 0, greypattern, 0, 32);
+ break;
+ case 15:
+ System.arraycopy(GREYSCALE15, 0, greypattern, 0, 32);
+ break;
+ case 16:
+ System.arraycopy(GREYSCALE16, 0, greypattern, 0, 32);
+ break;
+ default :
+ System.arraycopy(GREYSCALE00, 0, greypattern, 0, 32);
+ break;
+ }
+
+ for(int i = 0; i < repeat; i++) {
+
+ System.arraycopy(greypattern, 0, rasterdata, i * 32, 32);
+
+ }
+
+ return rasterdata;
+
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterPattern.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageRasterPattern.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageSegment.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageSegment.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageSegment.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageSegment.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,225 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * An Image Segment is represented by a set of self-defining fields, fields
+ * that describe their own contents. It starts with a Begin Segment, and
+ * ends with an End Segment.
+ *
+ * Between the Begin Segment and End Segment is the image information to
+ * be processed, called the Image Content.
+ *
+ * Only one Image Content can exist within a single IOCA Image Segment.
+ */
+public class ImageSegment extends AbstractAFPObject {
+
+ /**
+ * Default name for the object environment group
+ */
+ private static final String DEFAULT_NAME = "IS01";
+
+ /**
+ * The name of the image segment
+ */
+ private String _name;
+
+ /**
+ * The name of the image segment as EBCIDIC bytes
+ */
+ private byte[] _nameBytes;
+
+ /**
+ * The ImageContent for the image segment
+ */
+ private ImageContent _imageContent = null;
+
+ /**
+ * Default constructor for the ImageSegment.
+ */
+ public ImageSegment() {
+
+ this(DEFAULT_NAME);
+
+ }
+
+ /**
+ * 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) {
+
+ if (name.length() != 4) {
+ String msg = "Image segment name must be 4 characters long " + name;
+ log.error("Constructor:: " + msg);
+ throw new IllegalArgumentException(msg);
+ }
+
+ _name = name;
+
+ try {
+
+ _nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
+
+ } catch (UnsupportedEncodingException usee) {
+
+ _nameBytes = name.getBytes();
+ log.warn(
+ "Constructor:: UnsupportedEncodingException translating the name "
+ + name);
+
+ }
+
+ }
+
+ /**
+ * 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.
+ * @param vsize The vertival size of the image.
+ */
+ public void setImageSize(int hresol, int vresol, int hsize, int vsize) {
+ if (_imageContent == null) {
+ _imageContent = new ImageContent();
+ }
+ _imageContent.setImageSize(hresol, vresol, hsize, vsize);
+ }
+
+ /**
+ * Sets the image encoding.
+ * @param encoding The image encoding.
+ */
+ public void setImageEncoding(byte encoding) {
+ if (_imageContent == null) {
+ _imageContent = new ImageContent();
+ }
+ _imageContent.setImageEncoding(encoding);
+ }
+
+ /**
+ * Sets the image compression.
+ * @param compression The image compression.
+ */
+ public void setImageCompression(byte compression) {
+ if (_imageContent == null) {
+ _imageContent = new ImageContent();
+ }
+ _imageContent.setImageCompression(compression);
+ }
+
+ /**
+ * Sets the image IDE size.
+ * @param size The IDE size.
+ */
+ public void setImageIDESize(byte size) {
+ if (_imageContent == null) {
+ _imageContent = new ImageContent();
+ }
+ _imageContent.setImageIDESize(size);
+ }
+
+ /**
+ * Sets the image IDE color model.
+ * @param size The IDE color model.
+ */
+ public void setImageIDEColorModel(byte colorModel) {
+ if (_imageContent == null) {
+ _imageContent = new ImageContent();
+ }
+ _imageContent.setImageIDEColorModel(colorModel);
+ }
+
+ /**
+ * Set the data of the image.
+ * @param data the image data
+ */
+ public void setImageData(byte data[]) {
+ if (_imageContent == null) {
+ _imageContent = new ImageContent();
+ }
+ _imageContent.setImageData(data);
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the Image Segment
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ writeStart(os);
+
+ if (_imageContent != null) {
+ _imageContent.writeDataStream(os);
+ }
+
+ writeEnd(os);
+
+ }
+
+ /**
+ * Helper method to write the start of the Image Segment.
+ * @param os The stream to write to
+ */
+ private void writeStart(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[] {
+ 0x70, // ID
+ 0x04, // Length
+ 0x00, // Name byte 1
+ 0x00, // Name byte 2
+ 0x00, // Name byte 3
+ 0x00, // Name byte 4
+ };
+
+ for (int i = 0; i < _nameBytes.length; i++) {
+
+ data[2 + i] = _nameBytes[i];
+
+ }
+
+ os.write(data);
+
+ }
+
+ /**
+ * Helper method to write the end of the Image Segment.
+ * @param os The stream to write to
+ */
+ private void writeEnd(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[] {
+ 0x71, // ID
+ 0x00, // Length
+ };
+
+ os.write(data);
+
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageSegment.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageSegment.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageSizeParameter.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageSizeParameter.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageSizeParameter.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageSizeParameter.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * Describes the measurement characteristics of the image when it is created.
+ */
+public class ImageSizeParameter extends AbstractAFPObject {
+
+ private int _hresol = 0;
+ private int _vresol = 0;
+ private int _hsize = 0;
+ private int _vsize = 0;
+
+ /**
+ * Constructor for a ImageSizeParameter for the specified
+ * resolution, hsize and vsize.
+ * @param hresol The horizontal resolution of the image.
+ * @param vresol The vertical resolution of the image.
+ * @param hsize The hsize of the image.
+ * @param vsize The vsize of the vsize.
+ */
+ public ImageSizeParameter(int hresol, int vresol, int hsize, int vsize) {
+
+ _hresol = hresol;
+ _vresol = vresol;
+ _hsize = hsize;
+ _vsize = vsize;
+
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the Image Size Parameter
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[] {
+ (byte)0x94, // ID = Image Size Parameter
+ 0x09, // Length
+ 0x00, // Unit base - 10 Inches
+ 0x00, // HRESOL
+ 0x00, //
+ 0x00, // VRESOL
+ 0x00, //
+ 0x00, // HSIZE
+ 0x00, //
+ 0x00, // VSIZE
+ 0x00, //
+ };
+
+ byte[] x = BinaryUtils.convert(_hresol, 2);
+ data[3] = x[0];
+ data[4] = x[1];
+
+ byte[] y = BinaryUtils.convert(_vresol, 2);
+ data[5] = y[0];
+ data[6] = y[1];
+
+ byte[] w = BinaryUtils.convert(_hsize, 2);
+ data[7] = w[0];
+ data[8] = w[1];
+
+ byte[] h = BinaryUtils.convert(_vsize, 2);
+ data[9] = h[0];
+ data[10] = h[1];
+
+ os.write(data);
+
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageSizeParameter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ImageSizeParameter.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludeObject.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludeObject.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludeObject.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludeObject.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * An Include Object structured field references an object on a page or overlay.
+ * It optionally contains parameters that identify the object and that specify
+ * presentation parameters such as object position, size, orientation, mapping,
+ * and default color.
+ * <p>
+ * Where the presentation parameters conflict with parameters specified in the
+ * object's environment group (OEG), the parameters in the Include Object
+ * structured field override. If the referenced object is a page segment, the
+ * IOB parameters override the corresponding environment group parameters on all
+ * data objects in the page segment.
+ * </p>
+ */
+public class IncludeObject extends AbstractNamedAFPObject {
+
+ /**
+ * The object type
+ */
+ private byte _objectType = (byte) 0x92;
+
+ /**
+ * The orientation on the include object
+ */
+ private int _orientation = 0;
+
+ /**
+ * Constructor for the include object with the specified name, the name must
+ * be a fixed length of eight characters and is the name of the referenced
+ * object.
+ *
+ * @param name
+ * the name of the image
+ */
+ public IncludeObject(String name) {
+
+ super(name);
+ _objectType = (byte) 0xFB;
+
+ }
+
+ /**
+ * Sets the orienation to use for the Include Object.
+ *
+ * @param orientation
+ * The orientation (0,90, 180, 270)
+ */
+ public void setOrientation(int orientation) {
+
+ if (orientation == 0 || orientation == 90 || orientation == 180
+ || orientation == 270) {
+ _orientation = orientation;
+ } else {
+ throw new IllegalArgumentException(
+ "The orientation must be one of the values 0, 90, 180, 270");
+ }
+
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the Include Object
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[37];
+
+ data[0] = 0x5A;
+
+ // Set the total record length
+ byte[] rl1 = BinaryUtils.convert(36, 2); //Ignore first byte
+ data[1] = rl1[0];
+ data[2] = rl1[1];
+
+ // Structured field ID for a IOB
+ data[3] = (byte) 0xD3;
+ data[4] = (byte) 0xAF;
+ data[5] = (byte) 0xC3;
+
+ data[6] = 0x00; // Reserved
+ data[7] = 0x00; // Reserved
+ data[8] = 0x00; // Reserved
+
+ for (int i = 0; i < _nameBytes.length; i++) {
+ data[9 + i] = _nameBytes[i];
+ }
+
+ data[17] = 0x00;
+ data[18] = _objectType;
+
+ // XoaOset
+ data[20] = (byte) 0xFF;
+ data[21] = (byte) 0xFF;
+ data[22] = (byte) 0xFF;
+
+ // YoaOset
+ data[23] = (byte) 0xFF;
+ data[24] = (byte) 0xFF;
+ data[25] = (byte) 0xFF;
+
+ switch (_orientation) {
+ case 90:
+ data[26] = 0x2D;
+ data[27] = 0x00;
+ data[28] = 0x5A;
+ data[29] = 0x00;
+ break;
+ case 180:
+ data[26] = 0x5A;
+ data[27] = 0x00;
+ data[28] = (byte) 0x87;
+ data[29] = 0x00;
+ break;
+ case 270:
+ data[26] = (byte) 0x87;
+ data[27] = 0x00;
+ data[28] = 0x00;
+ data[29] = 0x00;
+ break;
+ default:
+ data[26] = 0x00;
+ data[27] = 0x00;
+ data[28] = 0x2D;
+ data[29] = 0x00;
+ break;
+ }
+
+ // XocaOset
+ data[30] = (byte) 0xFF;
+ data[31] = (byte) 0xFF;
+ data[32] = (byte) 0xFF;
+
+ // YocaOset
+ data[33] = (byte) 0xFF;
+ data[34] = (byte) 0xFF;
+ data[35] = (byte) 0xFF;
+
+ data[36] = 0x01;
+
+ os.write(data);
+
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludeObject.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludeObject.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludePageOverlay.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludePageOverlay.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludePageOverlay.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludePageOverlay.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ *
+ * The Include Page Overlay structured field references an overlay resource
+ * definition that is to be positioned on the page. A page overlay can be
+ * referenced at any time during the page state, but not during an object state.
+ * The overlay contains its own active environment group definition.
+ *
+ * Note: There is no need for the triplets, so I have ignored them.
+ *
+ * A real example of where this will be used is for static overlays, such as an
+ * address on the page.
+ *
+ */
+public class IncludePageOverlay extends AbstractNamedAFPObject {
+
+ /**
+ * The x coordinate
+ */
+ private int _xCoor = 0;
+
+ /**
+ * The y coordinate
+ */
+ private int _yCoor = 0;
+
+ /**
+ * The orientation
+ */
+ private int _orientation = 0;
+
+ /**
+ * Constructor for the Include Page Overlay
+ * @param overlayName Name of the page segment
+ * @param x The x position
+ * @param y The y position
+ * @param orientation The orientation
+ */
+ public IncludePageOverlay(String overlayName, int x, int y, int orientation) {
+
+ super(overlayName);
+
+ _xCoor = x;
+ _yCoor = y;
+ setOrientation(orientation);
+ }
+
+ /**
+ * Sets the orienation to use for the overlay.
+ *
+ * @param orientation
+ * The orientation (0,90, 180, 270)
+ */
+ public void setOrientation(int orientation) {
+
+ if (orientation == 0 || orientation == 90 || orientation == 180
+ || orientation == 270) {
+ _orientation = orientation;
+ } else {
+ throw new IllegalArgumentException(
+ "The orientation must be one of the values 0, 90, 180, 270");
+ }
+
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the Include Page Overlay
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[25]; //(9 +16)
+
+ data[0] = 0x5A;
+
+ // Set the total record length
+ byte[] rl1 = BinaryUtils.convert(24, 2); //Ignore first byte
+ data[1] = rl1[0];
+ data[2] = rl1[1];
+
+ // Structured field ID for a IPO
+ data[3] = (byte) 0xD3;
+ data[4] = (byte) 0xAF;
+ data[5] = (byte) 0xD8;
+
+ data[6] = 0x00; // Reserved
+ data[7] = 0x00; // Reserved
+ data[8] = 0x00; // Reserved
+
+ for (int i = 0; i < _nameBytes.length; i++) {
+
+ data[9 + i] = _nameBytes[i];
+
+ }
+
+ byte[] r2 = BinaryUtils.convert(_xCoor, 3);
+ data[17] = r2[0]; // x coordinate
+ data[18] = r2[1];
+ data[19] = r2[2];
+
+ byte[] r3 = BinaryUtils.convert(_yCoor, 3);
+ data[20] = r3[0]; // y coordinate
+ data[21] = r3[1];
+ data[22] = r3[2];
+
+ switch (_orientation) {
+ case 90:
+ data[23] = 0x2D;
+ data[24] = 0x00;
+ break;
+ case 180:
+ data[23] = 0x5A;
+ data[24] = 0x00;
+ break;
+ case 270:
+ data[23] = (byte) 0x87;
+ data[24] = 0x00;
+ break;
+ default:
+ data[23] = 0x00;
+ data[24] = 0x00;
+ break;
+ }
+
+ os.write(data);
+
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludePageOverlay.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludePageOverlay.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludePageSegment.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludePageSegment.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludePageSegment.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludePageSegment.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * The Include Page Segment structured field references a page segment resource
+ * object that is to be presented on the page or overlay presentation space. The IPS
+ * specifies a reference point on the including page or overlay coordinate system that
+ * may be used to position objects contained in the page segment. A page segment
+ * can be referenced at any time during page or overlay state, but not during an
+ * object state. The page segment inherits the active environment group definition of
+ * the including page or overlay.
+ *
+ * Note : No use for Triplets.
+ *
+ * A 'real' example for where this will be used is for
+ * the dynamic placing of overlay objects, such as signatures
+ * that may have to be placed at different positions on a document.
+ *
+ */
+public class IncludePageSegment extends AbstractNamedAFPObject{
+
+ /**
+ * The x position where we need to put this object on the page
+ */
+ private byte [] _xCoor;
+
+ /**
+ * The y position where we need to put this object on the page
+ */
+ private byte [] _yCoor;
+
+ /**
+ * Constructor for the Include Page Segment
+ * @param name Name of the page segment
+ * @param xVal The x position
+ * @param yVal The y position
+ */
+ public IncludePageSegment(String name, int xVal, int yVal){
+
+ super(name);
+ _xCoor = BinaryUtils.convert(xVal, 3);
+ _yCoor = BinaryUtils.convert(yVal, 3);
+
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the Include Page Segment
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[23]; //(9 +14)
+
+ data[0] = 0x5A;
+
+ // Set the total record length
+ byte[] rl1 = BinaryUtils.convert(22, 2); //Ignore first byte
+ data[1] = rl1[0];
+ data[2] = rl1[1];
+
+ // Structured field ID for a IPS
+ data[3] = (byte) 0xD3;
+ data[4] = (byte) 0xAF;
+ data[5] = (byte) 0x5F;
+
+ data[6] = 0x00; // Reserved
+ data[7] = 0x00; // Reserved
+ data[8] = 0x00; // Reserved
+
+ for (int i = 0; i < _nameBytes.length; i++) {
+
+ data[9 + i] = _nameBytes[i];
+
+ }
+
+ data[17] = _xCoor[0]; // x coordinate
+ data[18] = _xCoor[1];
+ data[19] = _xCoor[2];
+
+ data[20] = _yCoor[0]; // y coordinate
+ data[21] = _yCoor[1];
+ data[22] = _yCoor[2];
+
+ os.write(data);
+
+ }
+
+
+}
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludePageSegment.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/IncludePageSegment.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/InvokeMediumMap.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/InvokeMediumMap.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/InvokeMediumMap.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/InvokeMediumMap.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * The Invoke Medium Map structured field identifies the Medium Map that is to
+ * become active for the document. An Invoke Medium Map structured field affects
+ * the document's current environment. The Medium Map's effect on current environment
+ * parameter values lasts until a new Medium Map is invoked.
+ */
+public class InvokeMediumMap extends AbstractNamedAFPObject {
+
+ /**
+ * Constructor for the Invoke Medium Map
+ * @param mediumMapName Name of the medium map
+ */
+ public InvokeMediumMap(String mediumMapName) {
+
+ super(mediumMapName);
+
+ }
+
+ /**
+ * Accessor method to write the AFP datastream for the Invoke Medium Map
+ * @param os The stream to write to
+ * @throws java.io.IOException
+ */
+ public void writeDataStream(OutputStream os)
+ throws IOException {
+
+ byte[] data = new byte[17];
+
+ data[0] = 0x5A;
+
+ // Set the total record length
+ byte[] rl1 = BinaryUtils.convert(16, 2); //Ignore first byte
+ data[1] = rl1[0];
+ data[2] = rl1[1];
+
+ // Structured field ID for a IPO
+ data[3] = (byte) 0xD3;
+ data[4] = (byte) 0xAB;
+ data[5] = (byte) 0xCC;
+
+ data[6] = 0x00; // Reserved
+ data[7] = 0x00; // Reserved
+ data[8] = 0x00; // Reserved
+
+ for (int i = 0; i < _nameBytes.length; i++) {
+
+ data[9 + i] = _nameBytes[i];
+
+ }
+
+ os.write(data);
+
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/InvokeMediumMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/InvokeMediumMap.java
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org