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 [5/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/MapCodedFont.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MapCodedFont.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MapCodedFont.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MapCodedFont.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,298 @@
+/*
+ * 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 java.util.ArrayList;
+
+import org.apache.fop.render.afp.exceptions.FontRuntimeException;
+import org.apache.fop.render.afp.fonts.AFPFont;
+import org.apache.fop.render.afp.fonts.CharacterSet;
+import org.apache.fop.render.afp.fonts.OutlineFont;
+import org.apache.fop.render.afp.fonts.RasterFont;
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * The Map Coded Font structured field maps a unique coded font resource local
+ * ID, which may be embedded one or more times within an object's data and
+ * descriptor, to the identifier of a coded font resource object. Additionally,
+ * the Map Coded Font structured field specifies a set of resource attributes
+ * for the coded font.
+ *
+ * @author <a href="mailto:pete@townsend.uk.com">Pete Townsend </a>
+ */
+public class MapCodedFont extends AbstractAFPObject {
+
+    /**
+     * The collection of map coded fonts (maximum of 254)
+     */
+    private ArrayList _fontlist = null;
+
+    /**
+     * Constructor for the MapCodedFont
+     */
+    public MapCodedFont() {
+
+        _fontlist = new ArrayList();
+
+    }
+
+    /**
+     * Accessor method to write the AFP datastream for the Map Coded Font
+     * @param os The stream to write to
+     * @throws java.io.IOException
+     */
+    public void writeDataStream(OutputStream os)
+        throws IOException {
+
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        baos.write(0x5A);
+        baos.write(new byte[] { 0x00, 0x00 });
+
+        // Field identifier for a MapCodedFont
+        baos.write(new byte[] { (byte) 0xD3, (byte) 0xAB, (byte) 0x8A });
+
+        // Reserved
+        baos.write(new byte[] { 0x00, 0x00, 0x00 });
+
+        for (int i = 0; i < _fontlist.size(); i++) {
+
+            FontDefinition fd = (FontDefinition) _fontlist.get(i);
+
+            // Start of repeating groups (occurs 1 to 254)
+            baos.write(0x00);
+
+            if (fd._scale == 0) {
+                // Raster Font
+                baos.write(0x22); // Length of 34
+            } else {
+                // Outline Font
+                baos.write(0x3A); // Length of 58
+            }
+
+            // Font Character Set Name Reference
+            baos.write(0x0C);
+            baos.write(0x02);
+            baos.write((byte) 0x86);
+            baos.write(0x00);
+            baos.write(fd._characterset);
+
+            // Font Code Page Name Reference
+            baos.write(0x0C);
+            baos.write(0x02);
+            baos.write((byte) 0x85);
+            baos.write(0x00);
+            baos.write(fd._codepage);
+
+            // Character Rotation
+            baos.write(0x04);
+            baos.write(0x26);
+            baos.write(fd._orientation);
+            baos.write(0x00);
+
+            // Resource Local Identifier
+            baos.write(0x04);
+            baos.write(0x24);
+            baos.write(0x05);
+            baos.write(fd._fontReferenceKey);
+
+            if (fd._scale != 0) {
+                // Outline Font (triplet '1F')
+                baos.write(0x14);
+                baos.write(0x1F);
+                baos.write(0x00);
+                baos.write(0x00);
+
+                baos.write(BinaryUtils.convert(fd._scale, 2)); // Height
+                baos.write(new byte[] { 0x00, 0x00 }); // Width
+
+                baos.write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                    0x00, 0x00, 0x00, 0x00, 0x00 });
+
+                baos.write(0x60);
+
+                // Outline Font (triplet '5D')
+                baos.write(0x04);
+                baos.write(0x5D);
+                baos.write(BinaryUtils.convert(fd._scale, 2));
+            }
+
+        }
+
+        byte[] data = baos.toByteArray();
+
+        // Set the total record length
+        byte[] rl1 = BinaryUtils.convert(data.length - 1, 2);
+        data[1] = rl1[0];
+        data[2] = rl1[1];
+
+        os.write(data);
+
+    }
+
+    /**
+     * Add a font definition on the the map coded font object.
+     *
+     * @param fontReference
+     *            the font number used as the resource identifier
+     * @param font
+     *            the font
+     * @param size
+     *            the size of the font
+     * @param orientation
+     *            the orientation of the font
+     */
+    public void addFont(byte fontReference, AFPFont font, int size, int orientation)
+        throws MaximumSizeExceededException {
+
+        FontDefinition fd = new FontDefinition();
+
+        fd._fontReferenceKey = fontReference;
+
+        switch (orientation) {
+            case 90:
+                fd._orientation = 0x2D;
+                break;
+            case 180:
+                fd._orientation = 0x5A;
+                break;
+            case 270:
+                fd._orientation = (byte) 0x87;
+                break;
+            default:
+                fd._orientation = 0x00;
+                break;
+        }
+
+        try {
+
+            if (font instanceof RasterFont) {
+
+                RasterFont raster = (RasterFont) font;
+                CharacterSet cs = raster.getCharacterSet(size);
+                if (cs == null) {
+                    String msg = "Character set not found for font "
+                        + font.getFontName() + " with point size " + size;
+                    log.error(msg);
+                    throw new FontRuntimeException(msg);
+                }
+
+                fd._characterset = cs.getNameBytes();
+
+                if (fd._characterset.length != 8) {
+                    throw new IllegalArgumentException("The character set "
+                        + new String(fd._characterset,
+                        AFPConstants.EBCIDIC_ENCODING)
+                        + " must have a fixed length of 8 characters.");
+                }
+
+                fd._codepage = cs.getCodePage().getBytes(
+                    AFPConstants.EBCIDIC_ENCODING);
+
+                if (fd._codepage.length != 8) {
+                    throw new IllegalArgumentException("The code page "
+                        + new String(fd._codepage,
+                        AFPConstants.EBCIDIC_ENCODING)
+                        + " must have a fixed length of 8 characters.");
+                }
+
+            } else if (font instanceof OutlineFont) {
+
+                OutlineFont outline = (OutlineFont) font;
+                CharacterSet cs = outline.getCharacterSet();
+                fd._characterset = cs.getNameBytes();
+
+                // There are approximately 72 points to 1 inch or 20 1440ths per point.
+
+                fd._scale = ((size / 1000) * 20);
+
+                fd._codepage = cs.getCodePage().getBytes(
+                    AFPConstants.EBCIDIC_ENCODING);
+
+                if (fd._codepage.length != 8) {
+                    throw new IllegalArgumentException("The code page "
+                        + new String(fd._codepage,
+                        AFPConstants.EBCIDIC_ENCODING)
+                        + " must have a fixed length of 8 characters.");
+                }
+
+            } else {
+                String msg = "Font of type " + font.getClass().getName()
+                    + " not recognized.";
+                log.error(msg);
+                throw new FontRuntimeException(msg);
+            }
+
+            if (_fontlist.size() > 253) {
+
+                // Throw an exception if the size is exceeded
+                throw new MaximumSizeExceededException();
+
+            } else {
+
+                _fontlist.add(fd);
+
+            }
+
+        } catch (UnsupportedEncodingException ex) {
+
+            throw new FontRuntimeException("Failed to create font "
+                + " due to a UnsupportedEncodingException", ex);
+
+        }
+
+    }
+
+    /**
+     * Private utility class used as a container for font attributes
+     */
+    private class FontDefinition {
+
+        /**
+         * The code page of the font
+         */
+        private byte[] _codepage;
+
+        /**
+         * The character set of the font
+         */
+        private byte[] _characterset;
+
+        /**
+         * The font reference key
+         */
+        private byte _fontReferenceKey;
+
+        /**
+         * The orientation of the font
+         */
+        private byte _orientation;
+
+        /**
+         * The scale (only specified for outline fonts)
+         */
+        private int _scale = 0;
+
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MapCodedFont.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MapCodedFont.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MapPageOverlay.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MapPageOverlay.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MapPageOverlay.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MapPageOverlay.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,157 @@
+/*
+ * 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 java.util.ArrayList;
+
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * The Map Page Overlay structured field maps a Resource Local ID to the name of
+ * a Begin Overlay structured field. A Map Page Overlay structured field may
+ * contain from one to 254 repeating groups.
+ *
+ */
+public class MapPageOverlay extends AbstractAFPObject {
+
+    /**
+     * The collection of overlays (maximum of 254 stored as byte[])
+     */
+    private ArrayList _overLays = new ArrayList();
+
+    /**
+     * Constructor for the Map Page Overlay
+     */
+    public MapPageOverlay() {
+
+    }
+
+    /**
+     * Add an overlay to to the map page overlay object.
+     *
+     * @param name
+     *            The name of the overlay.
+     */
+    public void addOverlay(String name) throws MaximumSizeExceededException {
+
+        if (_overLays.size() > 253) {
+            throw new MaximumSizeExceededException();
+        }
+
+        if (name.length() != 8) {
+            throw new IllegalArgumentException("The name of overlay " + name
+                + " must be 8 characters");
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("addOverlay():: adding overlay " + name);
+        }
+
+        byte[] data;
+
+        try {
+
+            data = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
+            _overLays.add(data);
+
+        } catch (UnsupportedEncodingException usee) {
+
+            log
+                .error("addOverlay():: UnsupportedEncodingException translating the name "
+                + name);
+
+        }
+
+    }
+
+    /**
+     * Accessor method to write the AFP datastream for the Map Page Overlay
+     * @param os The stream to write to
+     * @throws java.io.IOException
+     */
+    public void writeDataStream(OutputStream os)
+        throws IOException {
+
+
+        int oLayCount = _overLays.size();
+        int recordlength = oLayCount * 18;
+
+        byte[] data = new byte[recordlength + 9];
+
+        data[0] = 0x5A;
+
+        // Set the total record length
+        byte[] rl1 = BinaryUtils.convert(recordlength + 8, 2); //Ignore the
+        // first byte in
+        // the length
+        data[1] = rl1[0];
+        data[2] = rl1[1];
+
+        // Structured field ID for a MPO
+        data[3] = (byte) 0xD3;
+        data[4] = (byte) 0xAB;
+        data[5] = (byte) 0xD8;
+
+        data[6] = 0x00; // Reserved
+        data[7] = 0x00; // Reserved
+        data[8] = 0x00; // Reserved
+
+        int pos = 8;
+
+        //For each overlay
+        byte olayref = 0x00;
+
+        for (int i = 0; i < oLayCount; i++) {
+
+            olayref = (byte) (olayref + 1);
+
+            data[++pos] = 0x00;
+            data[++pos] = 0x12; //the length of repeating group
+
+            data[++pos] = 0x0C; //Fully Qualified Name
+            data[++pos] = 0x02;
+            data[++pos] = (byte) 0x84;
+            data[++pos] = 0x00;
+
+            //now add the name
+            byte[] name = (byte[]) _overLays.get(i);
+
+            for (int j = 0; j < name.length; j++) {
+
+                data[++pos] = name[j];
+
+            }
+
+            data[++pos] = 0x04; //Resource Local Identifier (RLI)
+            data[++pos] = 0x24;
+            data[++pos] = 0x02;
+
+            //now add the unique id to the RLI
+            data[++pos] = olayref;
+
+        }
+
+        os.write(data);
+
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MapPageOverlay.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MapPageOverlay.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MaximumSizeExceededException.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MaximumSizeExceededException.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MaximumSizeExceededException.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MaximumSizeExceededException.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+/**
+ * An exception to handle maximum sizes being exceeded.
+ *
+ */
+public class MaximumSizeExceededException extends Exception {
+
+    public MaximumSizeExceededException() {
+        super();
+    }
+
+}

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MaximumSizeExceededException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/MaximumSizeExceededException.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,106 @@
+/*
+ * 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 Object Area Descriptor structured field specifies the size and attributes
+ * of an object area presentation space.
+ *
+ */
+public class ObjectAreaDescriptor extends AbstractAFPObject {
+
+    private int _width = 0;
+    private int _height = 0;
+
+    /**
+     * Construct an object area descriptor for the specified object width
+     * and object height.
+     * @param width The page width.
+     * @param height The page height.
+     */
+    public ObjectAreaDescriptor(int width, int height) {
+
+        _width = width;
+        _height = height;
+
+    }
+
+    /**
+     * Accessor method to write the AFP datastream for the Object Area 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, // Length
+            0x1C, // Length
+            (byte) 0xD3,
+            (byte) 0xA6,
+            (byte) 0x6B,
+            0x00, // Flags
+            0x00, // Reserved
+            0x00, // Reserved
+            0x03, // Triplet length
+            0x43, // tid = Descriptor Position Triplet
+            0x01, // DesPosId = 1
+            0x08, // Triplet length
+            0x4B, // tid = Measurement Units Triplet
+            0x00, // XaoBase = 10 inches
+            0x00, // YaoBase = 10 inches
+            0x09, // XaoUnits = 2400
+            0x60, // XaoUnits =
+            0x09, // YaoUnits = 2400
+            0x60, // YaoUnits =
+            0x09, // Triplet length
+            0x4C, // tid = Object Area Size
+            0x02, // Size Type
+            0x00, // XoaSize
+            0x00,
+            0x00,
+            0x00, // YoaSize
+            0x00,
+            0x00,
+        };
+
+        byte[] l = BinaryUtils.convert(data.length - 1, 2);
+        data[1] = l[0];
+        data[2] = l[1];
+
+        byte[] x = BinaryUtils.convert(_width, 3);
+        data[23] = x[0];
+        data[24] = x[1];
+        data[25] = x[2];
+
+        byte[] y = BinaryUtils.convert(_height, 3);
+        data[26] = y[0];
+        data[27] = y[1];
+        data[28] = y[2];
+
+        os.write(data);
+
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectAreaPosition.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectAreaPosition.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectAreaPosition.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectAreaPosition.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,111 @@
+/*
+ * 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 Object Area Position structured field specifies the origin and
+ * orientation of the object area, and the origin and orientation of the
+ * object content within the object area.
+ */
+public class ObjectAreaPosition extends AbstractAFPObject {
+
+    private int _x = 0;
+    private int _y = 0;
+    private int _rot = 0;
+
+    /**
+     * Construct an object area position for the specified object y, y position.
+     * @param x The x coordinate.
+     * @param y The y coordinate.
+     * @param rotation The coordinate system rotation (must be 0, 90, 180, 270).
+     */
+    public ObjectAreaPosition(int x, int y, int rotation) {
+
+        _x = x;
+        _y = y;
+        _rot = rotation;
+    }
+
+    /**
+     * Accessor method to write the AFP datastream for the Object Area Position
+     * @param os The stream to write to
+     * @throws java.io.IOException
+     */
+    public void writeDataStream(OutputStream os)
+        throws IOException {
+
+        byte[] data = new byte[] {
+            0x5A,
+            0x00, // Length
+            0x20, // Length
+            (byte) 0xD3,
+            (byte) 0xAC,
+            (byte) 0x6B,
+            0x00, // Flags
+            0x00, // Reserved
+            0x00, // Reserved
+            0x01, // OAPosID = 1
+            0x17, // RGLength = 23
+            0x00, // XoaOSet
+            0x00,
+            0x00,
+            0x00, // YoaOSet
+            0x00,
+            0x00,
+            (byte)(_rot / 2), // XoaOrent
+            0x00,
+            (byte)(_rot / 2 + 45), // YoaOrent
+            0x00,
+            0x00, // Reserved
+            0x00, // XocaOSet
+            0x00,
+            0x00,
+            0x00, // YocaOSet
+            0x00,
+            0x00,
+            0x00, // XocaOrent
+            0x00,
+            0x2D, // YocaOrent
+            0x00,
+            0x01, // RefCSys
+        };
+
+        byte[] l = BinaryUtils.convert(data.length - 1, 2);
+        data[1] = l[0];
+        data[2] = l[1];
+
+        byte[] x = BinaryUtils.convert(_x, 3);
+        data[11] = x[0];
+        data[12] = x[1];
+        data[13] = x[2];
+
+        byte[] y = BinaryUtils.convert(_y, 3);
+        data[14] = y[0];
+        data[15] = y[1];
+        data[16] = y[2];
+
+        os.write(data);
+
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectAreaPosition.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectAreaPosition.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,194 @@
+/*
+ * 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 Object Environment Group (OEG) may be associated with an object and is contained
+ * within the object's begin-end envelope.
+ * The object environment group defines the object's origin and orientation on the page,
+ * and can contain font and color attribute table information. The scope of an object
+ * environment group is the scope of its containing object.
+ *
+ * An application that creates a data-stream document may omit some of the parameters
+ * normally contained in the object environment group, or it may specify that one or
+ * more default values are to be used.
+ */
+public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject {
+
+    /**
+     * Default name for the object environment group
+     */
+    private static final String DEFAULT_NAME = "OEG00001";
+
+    /**
+     * The ObjectAreaDescriptor for the object environment group
+     */
+    private ObjectAreaDescriptor _objectAreaDescriptor = null;
+
+    /**
+     * The ObjectAreaPosition for the object environment group
+     */
+    private ObjectAreaPosition _objectAreaPosition = null;
+
+    /**
+     * The ImageDataDescriptor for the object environment group
+     */
+    private ImageDataDescriptor _imageDataDescriptor = null;
+
+    /**
+     * Default constructor for the ObjectEnvironmentGroup.
+     */
+    public ObjectEnvironmentGroup() {
+
+        this(DEFAULT_NAME);
+
+    }
+
+    /**
+     * Constructor for the ObjectEnvironmentGroup, this takes a
+     * name parameter which must be 8 characters long.
+     * @param name the object environment group name
+     */
+    public ObjectEnvironmentGroup(String name) {
+
+        super(name);
+
+    }
+
+    /**
+     * Sets the object area parameters.
+     * @param x the x position of the object
+     * @param y the y position of the object
+     * @param width the object width
+     * @param height the object height
+     * @param rotation the object orientation
+     */
+    public void setObjectArea(int x, int y, int width, int height, int rotation) {
+
+        _objectAreaDescriptor = new ObjectAreaDescriptor(width, height);
+        _objectAreaPosition = new ObjectAreaPosition(x, y, rotation);
+
+    }
+
+    /**
+     * 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 setImageData(int xresol, int yresol, int width, int height) {
+        _imageDataDescriptor = new ImageDataDescriptor(xresol, yresol,  width, height);
+    }
+
+    /**
+     * Accessor method to obtain write the AFP datastream for
+     * the object environment group.
+     * @param os The stream to write to
+     * @throws java.io.IOException
+     */
+    public void writeDataStream(OutputStream os)
+        throws IOException {
+
+
+        writeStart(os);
+
+        _objectAreaDescriptor.writeDataStream(os);
+
+        _objectAreaPosition.writeDataStream(os);
+
+        if (_imageDataDescriptor != null) {
+            _imageDataDescriptor.writeDataStream(os);
+        }
+
+        writeEnd(os);
+
+    }
+
+    /**
+     * Helper method to write the start of the object environment group.
+     * @param os The stream to write to
+     */
+    private void writeStart(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) 0xA8, // Structured field id byte 2
+            (byte) 0xC7, // Structured field id byte 3
+            0x00, // Flags
+            0x00, // Reserved
+            0x00, // Reserved
+            0x00, // Name
+            0x00, //
+            0x00, //
+            0x00, //
+            0x00, //
+            0x00, //
+            0x00, //
+            0x00, //
+        };
+
+        for (int i = 0; i < _nameBytes.length; i++) {
+
+            data[9 + i] = _nameBytes[i];
+
+        }
+
+        os.write(data);
+
+    }
+
+    /**
+     * Helper method to write the end of the object environment group.
+     * @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) 0xC7; // 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);
+
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/Overlay.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/Overlay.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/Overlay.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/Overlay.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,130 @@
+/*
+ * 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.util.Iterator;
+
+/**
+ */
+public class Overlay extends AbstractPageObject{
+
+    /**
+     * Construct a new overlay object for the specified name argument, the overlay
+     * name should be an 8 character identifier.
+     *
+     * @param name
+     *            the name of the page.
+     * @param width
+     *            the width of the page.
+     * @param height
+     *            the height of the page.
+     * @param rotation
+     *            the rotation of the page.
+     */
+    public Overlay(String name, int width, int height, int rotation) {
+
+        super(name, width, height, rotation);
+
+    }
+
+    /**
+     * Accessor method to write the AFP datastream for the overlay.
+     *
+     * @param os The stream to write to
+     * @throws java.io.IOException
+     */
+    public void writeDataStream(OutputStream os)
+        throws IOException {
+
+        writeStart(os);
+
+        _activeEnvironmentGroup.writeDataStream(os);
+
+        writeObjectList(_segments, os);
+
+        writeObjectList(_tagLogicalElements, os);
+
+        writeObjectList(_objects, os);
+
+        writeEnd(os);
+
+    }
+
+    /**
+     * Helper method to write the start of the overlay.
+     * @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) 0xDF; // 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 overlay.
+     * @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) 0xDF; // 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/Overlay.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/Overlay.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageDescriptor.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageDescriptor.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageDescriptor.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageDescriptor.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,97 @@
+/*
+ * 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 Page Descriptor structured field specifies the size and attributes of
+ * a page or overlay presentation space.
+ *
+ */
+public class PageDescriptor extends AbstractAFPObject {
+
+    private int _width = 0;
+    private int _height = 0;
+
+    /**
+     * Construct a page descriptor for the specified page width
+     * and page height.
+     * @param width The page width.
+     * @param height The page height.
+     */
+    public PageDescriptor(int width, int height) {
+
+        _width = width;
+        _height = height;
+
+    }
+
+    /**
+     * Accessor method to write the AFP datastream for the Page 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,
+            0x17,
+            (byte) 0xD3,
+            (byte) 0xA6,
+            (byte) 0xAF,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+            0x09,
+            0x60,
+            0x09,
+            0x60,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+        };
+
+        byte[] x = BinaryUtils.convert(_width, 3);
+        data[15] = x[0];
+        data[16] = x[1];
+        data[17] = x[2];
+
+        byte[] y = BinaryUtils.convert(_height, 3);
+        data[18] = y[0];
+        data[19] = y[1];
+        data[20] = y[2];
+
+        os.write(data);
+
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageDescriptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageDescriptor.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageGroup.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageGroup.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageGroup.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageGroup.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 java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A page group is used in the data stream to define a named, logical grouping
+ * of sequential pages. Page groups are delimited by begin-end structured fields
+ * that carry the name of the page group. Page groups are defined so that the
+ * pages that comprise the group can be referenced or processed as a single
+ * entity. Page groups are often processed in stand-alone fashion; that is, they
+ * are indexed, retrieved, and presented outside the context of the containing
+ * document.
+ *
+ * @author <a href="mailto:pete@townsend.uk.com">Pete Townsend </a>
+ */
+public class PageGroup extends AbstractNamedAFPObject {
+
+    /**
+     * The pages contained within this group
+     */
+    private List _objects = new ArrayList();
+
+    /**
+     * The tag logical elements contained within this group
+     */
+    private List _tagLogicalElements = new ArrayList();
+
+    /**
+     * The page state
+     */
+    private boolean _complete = false;
+
+    /**
+     * Constructor for the PageGroup.
+     *
+     * @param name
+     *            the name of the page group
+     */
+    public PageGroup(String name) {
+
+        super(name);
+
+    }
+
+    /**
+     * Adds a page object to the group.
+     *
+     * @param page
+     *            the page object to add
+     */
+    public void addPage(PageObject page) {
+
+        if (!_objects.contains(page)) {
+            _objects.add(page);
+        }
+
+    }
+
+    /**
+     * @return the name of the page group
+     */
+    public String getName() {
+        return _name;
+    }
+
+    /**
+     * Creates a TagLogicalElement on the page.
+     *
+     * @param name
+     *            the name of the tag
+     * @param value
+     *            the value of the tag
+     */
+    public void createTagLogicalElement(String name, String value) {
+
+        TagLogicalElement tle = new TagLogicalElement(name, value);
+        _tagLogicalElements.add(tle);
+
+    }
+
+    /**
+     * Creates an InvokeMediaMap on the page.
+     *
+     * @param name
+     *            the name of the media map
+     */
+    public void createInvokeMediumMap(String name) {
+
+        InvokeMediumMap imm = new InvokeMediumMap(name);
+        _objects.add(imm);
+
+    }
+
+    /**
+     * Method to mark the end of the page group.
+     */
+    public void endPageGroup() {
+
+        _complete = true;
+
+    }
+
+    /**
+     * Returns an indication if the page group is complete
+     */
+    public boolean isComplete() {
+        return _complete;
+    }
+
+   /**
+     * Accessor method to write the AFP datastream for the page group.
+     * @param os The stream to write to
+     * @throws java.io.IOException
+     */
+    public void writeDataStream(OutputStream os)
+        throws IOException {
+
+        writeStart(os);
+
+        writeObjectList(_tagLogicalElements, os);
+
+        writeObjectList(_objects, os);
+
+        writeEnd(os);
+
+    }
+
+    /**
+     * Helper method to write the start of the page group.
+     * @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) 0xAD; // 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 page group.
+     * @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) 0xAD; // 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);
+
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageGroup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageGroup.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageObject.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageObject.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageObject.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageObject.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,185 @@
+/*
+ * 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;
+
+
+
+/**
+ * Pages contain the data objects that comprise a presentation document. Each
+ * page has a set of data objects associated with it. Each page within a
+ * document is independent from any other page, and each must establish its own
+ * environment parameters.
+ *
+ * The page is the level in the document component hierarchy that is used for
+ * printing or displaying a document's content. The data objects contained in
+ * the page envelope in the data stream are presented when the page is
+ * presented. Each data object has layout information associated with it that
+ * directs the placement and orientation of the data on the page. In addition,
+ * each page contains layout information that specifies the measurement units,
+ * page width, and page depth.
+ *
+ * A page is initiated by a begin page structured field and terminated by an end
+ * page structured field. Structured fields that define objects and active
+ * environment groups or that specify attributes of the page may be encountered
+ * in page state.
+ *
+ */
+public class PageObject extends AbstractPageObject {
+
+    /**
+     * The resource group object
+     */
+    private ResourceGroup _resourceGroup = null;
+
+    /**
+     * Construct a new page object for the specified name argument, the page
+     * name should be an 8 character identifier.
+     *
+     * @param name
+     *            the name of the page.
+     * @param width
+     *            the width of the page.
+     * @param height
+     *            the height of the page.
+     * @param rotation
+     *            the rotation of the page.
+     */
+    public PageObject(String name, int width, int height, int rotation) {
+
+        super(name, width, height, rotation);
+
+    }
+
+    /**
+     * Adds an overlay to the page resources
+     * @param the overlay to add
+     */
+    public void addOverlay(Overlay overlay) {
+        if (_resourceGroup == null) {
+            _resourceGroup = new ResourceGroup();
+        }
+        _resourceGroup.addOverlay(overlay);
+    }
+
+    /**
+     * Creates an IncludePageOverlay on the page.
+     *
+     * @param name
+     *            the name of the overlay
+     * @param x
+     *            the x position of the overlay
+     * @param y
+     *            the y position of the overlay
+     * @param orientation
+     *            the orientation required for the overlay
+     */
+    public void createIncludePageOverlay(String name, int x, int y, int orientation) {
+
+        IncludePageOverlay ipo = new IncludePageOverlay(name, x, y, orientation);
+        _objects.add(ipo);
+
+    }
+
+    /**
+     * Accessor method to write the AFP datastream for the page.
+     * @param os The stream to write to
+     * @throws java.io.IOException
+     */
+    public void writeDataStream(OutputStream os)
+        throws IOException {
+
+        writeStart(os);
+
+        if (_resourceGroup != null) {
+            _resourceGroup.writeDataStream(os);
+        }
+
+        _activeEnvironmentGroup.writeDataStream(os);
+
+        writeObjectList(_segments, os);
+
+        writeObjectList(_tagLogicalElements, os);
+
+        writeObjectList(_objects, os);
+
+        writeEnd(os);
+
+    }
+
+    /**
+     * Helper method to write the start of the page.
+     * @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) 0xAF; // 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 page.
+     * @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) 0xAF; // 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);
+
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageObject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PageObject.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,598 @@
+/*
+ * 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 org.apache.fop.render.afp.AFPFontColor;
+
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * Presentation text data contains the graphic characters and the control
+ * sequences necessary to position the characters within the object space. The
+ * data consists of: - graphic characters to be presented - control sequences
+ * that position them - modal control sequences that adjust the positions by
+ * small amounts - other functions causing text to be presented with differences
+ * in appearance.
+ *
+ * The graphic characters are expected to conform to a coded font representation
+ * so that they can be translated from the code point in the object data to the
+ * character in the coded font. The units of measure for linear displacements
+ * are derived from the PresentationTextDescriptor or from the hierarchical
+ * defaults.
+ *
+ * In addition to graphic character code points, Presentation Text data can
+ * contain embedded control sequences. These are strings of two or more bytes
+ * which signal an alternate mode of processing for the content of the current
+ * Presentation Text data.
+ *
+ */
+public class PresentationTextData extends AbstractAFPObject {
+
+    /**
+     * The maximum size of the presentation text data.
+     */
+    private static final int MAX_SIZE = 8192;
+
+    /**
+     * The afp data relating to this presentaion text data.
+     */
+    private ByteArrayOutputStream _baos = new ByteArrayOutputStream(1024);
+
+    /**
+     * The current x coordinate.
+     */
+    private int _currentXCoordinate = -1;
+
+    /**
+     * The current y cooridnate
+     */
+    private int _currentYCoordinate = -1;
+
+    /**
+     * The current font
+     */
+    private String _currentFont = "";
+
+    /**
+     * The current orientation
+     */
+    private int _currentOrientation = 0;
+
+    /**
+     * The current color
+     */
+    private AFPFontColor _currentColor = new AFPFontColor(0, 0, 0);
+
+    /**
+     * The current variable space increment
+     */
+    private int _currentVariableSpaceCharacterIncrement = 0;
+
+    /**
+     * The current inter character adjustment
+     */
+    private int _currentInterCharacterAdjustment = 0;
+
+    /**
+     * Default constructor for the PresentationTextData.
+     */
+    public PresentationTextData() {
+
+        this(false);
+
+    }
+
+    /**
+     * Constructor for the PresentationTextData, the boolean flag indicate
+     * whether the control sequence prefix should be set to indicate the start
+     * of a new control sequence.
+     *
+     * @param controlInd
+     *            The control sequence indicator.
+     */
+    public PresentationTextData(boolean controlInd) {
+
+        _baos.write(new byte[] { 0x5A, // Structured field identifier
+            0x00, // Record length byte 1
+            0x00, // Record length byte 2
+            (byte) 0xD3, // PresentationTextData identifier byte 1
+            (byte) 0xEE, // PresentationTextData identifier byte 2
+            (byte) 0x9B, // PresentationTextData identifier byte 3
+            0x00, // Flag
+            0x00, // Reserved
+            0x00, // Reserved
+        }, 0, 9);
+
+        if (controlInd) {
+            _baos.write(new byte[] { 0x2B, (byte) 0xD3 }, 0, 2);
+        }
+
+    }
+
+    /**
+     * The Set Coded Font Local control sequence activates a coded font and
+     * specifies the character attributes to be used. This is a modal control
+     * sequence.
+     *
+     * @param font
+     *            The font local identifier.
+     * @param afpdata
+     *            The output stream to which data should be written.
+     */
+    private void setCodedFont(byte font, ByteArrayOutputStream afpdata) {
+
+        // Avoid unnecessary specification of the font
+        if (String.valueOf(font).equals(_currentFont)) {
+            return;
+        } else {
+            _currentFont = String.valueOf(font);
+        }
+
+        afpdata.write(new byte[] { 0x03, (byte) 0xF1, font, }, 0, 3);
+
+    }
+
+    /**
+     * Establishes the current presentation position on the baseline at a new
+     * I-axis coordinate, which is a specified number of measurement units from
+     * the B-axis. There is no change to the current B-axis coordinate.
+     *
+     * @param coordinate
+     *            The coordinate for the inline move.
+     * @param afpdata
+     *            The output stream to which data should be written.
+     */
+    private void absoluteMoveInline(int coordinate,
+        ByteArrayOutputStream afpdata) {
+
+        byte[] b = BinaryUtils.convert(coordinate, 2);
+
+        afpdata.write(new byte[] { 0x04, (byte) 0xC7, b[0], b[1], }, 0, 4);
+
+        _currentXCoordinate = coordinate;
+
+    }
+
+    /**
+     * Establishes the baseline and the current presentation position at a new
+     * B-axis coordinate, which is a specified number of measurement units from
+     * the I-axis. There is no change to the current I-axis coordinate.
+     *
+     * @param coordinate
+     *            The coordinate for the baseline move.
+     * @param afpdata
+     *            The output stream to which data should be written.
+     */
+    private void absoluteMoveBaseline(int coordinate,
+        ByteArrayOutputStream afpdata) {
+
+        byte[] b = BinaryUtils.convert(coordinate, 2);
+
+        afpdata.write(new byte[] { 0x04, (byte) 0xD3, b[0], b[1], }, 0, 4);
+
+        _currentYCoordinate = coordinate;
+
+    }
+
+    /**
+     * The Transparent Data control sequence contains a sequence of code points
+     * that are presented without a scan for embedded control sequences.
+     *
+     * @param data
+     *            The text data to add.
+     * @param afpdata
+     *            The output stream to which data should be written.
+     */
+    private void addTransparentData(byte[] data, ByteArrayOutputStream afpdata) {
+
+        // Calculate the length
+        int l = data.length + 2;
+
+        if (l > 255) {
+            // Check that we are not exceeding the maximum length
+            throw new IllegalArgumentException(
+                "Transparent data is longer than 253 bytes: " + data);
+        }
+
+        afpdata.write(new byte[] { BinaryUtils.convert(l)[0], (byte) 0xDB, },
+            0, 2);
+
+        afpdata.write(data, 0, data.length);
+
+    }
+
+    /**
+     * Draws a line of specified length and specified width in the B-direction
+     * from the current presentation position. The location of the current
+     * presentation position is unchanged.
+     *
+     * @param length
+     *            The length of the rule.
+     * @param width
+     *            The width of the rule.
+     * @param afpdata
+     *            The output stream to which data should be written.
+     */
+    private void drawBaxisRule(int length, int width,
+        ByteArrayOutputStream afpdata) {
+
+        afpdata.write(new byte[] { 0x07, // Length
+            (byte) 0xE7, // Type
+        }, 0, 2);
+
+        // Rule length
+        byte[] data1 = BinaryUtils.shortToByteArray((short) length);
+        afpdata.write(data1, 0, data1.length);
+        // Rule width
+        byte[] data2 = BinaryUtils.shortToByteArray((short) width);
+        afpdata.write(data2, 0, data2.length);
+        // Rule width fraction
+        afpdata.write(0x00);
+
+    }
+
+    /**
+     * Draws a line of specified length and specified width in the I-direction
+     * from the current presentation position. The location of the current
+     * presentation position is unchanged.
+     *
+     * @param length
+     *            The length of the rule.
+     * @param width
+     *            The width of the rule.
+     * @param afpdata
+     *            The output stream to which data should be written.
+     */
+    private void drawIaxisRule(int length, int width,
+        ByteArrayOutputStream afpdata) {
+
+        afpdata.write(new byte[] { 0x07, // Length
+            (byte) 0xE5, // Type
+        }, 0, 2);
+
+        // Rule length
+        byte[] data1 = BinaryUtils.shortToByteArray((short) length);
+        afpdata.write(data1, 0, data1.length);
+        // Rule width
+        byte[] data2 = BinaryUtils.shortToByteArray((short) width);
+        afpdata.write(data2, 0, data2.length);
+        // Rule width fraction
+        afpdata.write(0x00);
+
+    }
+
+    /**
+     * Create the presentation text data for the byte array of data.
+     *
+     * @param fontNumber
+     *            The font resource identifier.
+     * @param x
+     *            The x coordinate for the text data.
+     * @param y
+     *            The y coordinate for the text data.
+     * @param orientation
+     *            The orientation of the text data.
+     * @param col
+     *            The text color.
+     * @param vsci
+     *            The variable space character increment.
+     * @param ica
+     *            The inter character adjustment.
+     * @param data
+     *            The text data to be created.
+     * @throws MaximumSizeExceededException
+     */
+    public void createTextData(int fontNumber, int x, int y, int orientation,
+        AFPFontColor col, int vsci, int ica, byte[] data)
+        throws MaximumSizeExceededException {
+
+        ByteArrayOutputStream afpdata = new ByteArrayOutputStream();
+
+        if (_currentOrientation != orientation) {
+            setTextOrientation(orientation, afpdata);
+            _currentOrientation = orientation;
+            _currentXCoordinate = -1;
+            _currentYCoordinate = -1;
+        }
+
+        // Avoid unnecessary specification of the Y co-ordinate
+        if (y != _currentYCoordinate) {
+            absoluteMoveBaseline(y, afpdata);
+            _currentXCoordinate = -1;
+        }
+
+        // Avoid unnecessary specification of the X co-ordinate
+        if (x != _currentXCoordinate) {
+            absoluteMoveInline(x, afpdata);
+        }
+
+        // Avoid unnecessary specification of the variable space increment
+        if (vsci != _currentVariableSpaceCharacterIncrement) {
+            setVariableSpaceCharacterIncrement(vsci, afpdata);
+            _currentVariableSpaceCharacterIncrement = vsci;
+        }
+
+        // Avoid unnecessary specification of the inter character adjustment
+        if (ica != _currentInterCharacterAdjustment) {
+            setInterCharacterAdjustment(ica, afpdata);
+            _currentInterCharacterAdjustment = ica;
+        }
+
+        // Avoid unnecessary specification of the text color
+        if (!col.equals(_currentColor)) {
+            setExtendedTextColor(col, afpdata);
+            _currentColor.setTo(col);
+        }
+
+        setCodedFont(BinaryUtils.convert(fontNumber)[0], afpdata);
+        addTransparentData(data, afpdata);
+        _currentXCoordinate = -1;
+
+        int s = afpdata.size();
+
+        if (_baos.size() + s > MAX_SIZE) {
+            _currentXCoordinate = -1;
+            _currentYCoordinate = -1;
+            throw new MaximumSizeExceededException();
+        }
+
+        byte[] outputdata = afpdata.toByteArray();
+        _baos.write(outputdata, 0, outputdata.length);
+
+    }
+
+    /**
+     * Drawing of lines using the starting and ending coordinates, thickness and
+     * colour arguments.
+     *
+     * @param x1
+     *            The starting X coordinate.
+     * @param y1
+     *            The starting Y coordinate.
+     * @param x2
+     *            The ending X coordinate.
+     * @param y2
+     *            The ending Y coordinate.
+     * @param thickness
+     *            The line thickness.
+     * @param orientation
+     *            The orientation of the text data.
+     * @param col
+     *            The text color.
+     */
+    public void createLineData(int x1, int y1, int x2, int y2, int thickness,
+        int orientation, AFPFontColor col) throws MaximumSizeExceededException {
+
+        ByteArrayOutputStream afpdata = new ByteArrayOutputStream();
+
+        if (_currentOrientation != orientation) {
+            setTextOrientation(orientation, afpdata);
+            _currentOrientation = orientation;
+        }
+
+        // Avoid unnecessary specification of the Y coordinate
+        if (y1 != _currentYCoordinate) {
+            absoluteMoveBaseline(y1, afpdata);
+        }
+
+        // Avoid unnecessary specification of the X coordinate
+        if (x1 != _currentXCoordinate) {
+            absoluteMoveInline(x1, afpdata);
+        }
+
+        if (!col.equals(_currentColor)) {
+            setExtendedTextColor(col, afpdata);
+            _currentColor.setTo(col);
+        }
+
+        if (y1 == y2) {
+            drawIaxisRule(x2 - x1, thickness, afpdata);
+        } else if (x1 == x2) {
+            drawBaxisRule(y2 - y1, thickness, afpdata);
+        } else {
+            return;
+        }
+
+        int s = afpdata.size();
+
+        if (_baos.size() + s > MAX_SIZE) {
+            _currentXCoordinate = -1;
+            _currentYCoordinate = -1;
+            throw new MaximumSizeExceededException();
+        }
+
+        byte[] outputdata = afpdata.toByteArray();
+        _baos.write(outputdata, 0, outputdata.length);
+
+    }
+
+    /**
+     * The Set Text Orientation control sequence establishes the I-direction and
+     * B-direction for the subsequent text. This is a modal control sequence.
+     *
+     * Semantics: This control sequence specifies the I-axis and B-axis
+     * orientations with respect to the Xp-axis for the current Presentation
+     * Text object. The orientations are rotational values expressed in degrees
+     * and minutes.
+     *
+     * @param orientation
+     *            The text orientation (0,90, 180, 270).
+     * @param afpdata
+     *            The output stream to which data should be written.
+     */
+    private void setTextOrientation(int orientation,
+        ByteArrayOutputStream afpdata) {
+
+        afpdata.write(new byte[] { 0x06, (byte) 0xF7, }, 0, 2);
+
+        switch (orientation) {
+            case 90:
+                afpdata.write(0x2D);
+                afpdata.write(0x00);
+                afpdata.write(0x5A);
+                afpdata.write(0x00);
+                break;
+            case 180:
+                afpdata.write(0x5A);
+                afpdata.write(0x00);
+                afpdata.write(0x87);
+                afpdata.write(0x00);
+                break;
+            case 270:
+                afpdata.write(0x87);
+                afpdata.write(0x00);
+                afpdata.write(0x00);
+                afpdata.write(0x00);
+                break;
+            default:
+                afpdata.write(0x00);
+                afpdata.write(0x00);
+                afpdata.write(0x2D);
+                afpdata.write(0x00);
+                break;
+        }
+
+    }
+
+    /**
+     * The Set Extended Text Color control sequence specifies a color value and
+     * defines the color space and encoding for that value.  The specified color
+     * value is applied to foreground areas of the text presentation space.
+     * This is a modal control sequence.
+     *
+     * @param col
+     *            The color to be set.
+     * @param afpdata
+     *            The output stream to which data should be written.
+     */
+    private void setExtendedTextColor(AFPFontColor col,
+        ByteArrayOutputStream afpdata) {
+
+        afpdata.write(new byte[] {
+              15		 // Control sequence length
+            , (byte)0x81         // Control sequence function type
+            , 0x00		 // Reserved; must be zero
+            , 0x01 		 // Color space - 0x01 = RGB
+            , 0x00		 // Reserved; must be zero
+            , 0x00		 // Reserved; must be zero
+            , 0x00		 // Reserved; must be zero
+            , 0x00		 // Reserved; must be zero
+            , 8			 // Number of bits in component 1
+            , 8			 // Number of bits in component 2
+            , 8			 // Number of bits in component 3
+            , 0			 // Number of bits in component 4
+            , (byte)(col.getRed())   // Red intensity
+            , (byte)(col.getGreen()) // Green intensity
+            , (byte)(col.getBlue())  // Blue intensity
+        }, 0, 15);
+
+    }
+
+    /**
+     * //TODO
+     * This is a modal control sequence.
+     *
+     * @param incr
+     *            The increment to be set.
+     * @param afpdata
+     *            The output stream to which data should be written.
+     */
+    private void setVariableSpaceCharacterIncrement(int incr,
+        ByteArrayOutputStream afpdata) {
+
+        byte[] b = BinaryUtils.convert(incr, 2);
+
+        afpdata.write(new byte[] {
+              4                  // Control sequence length
+            , (byte)0xC5         // Control sequence function type
+            , b[0]
+            , b[1]
+        }, 0, 4);
+
+    }
+
+    /**
+     * //TODO
+     * This is a modal control sequence.
+     *
+     * @param incr
+     *            The increment to be set.
+     * @param afpdata
+     *            The output stream to which data should be written.
+     */
+    private void setInterCharacterAdjustment(int incr,
+        ByteArrayOutputStream afpdata) {
+
+        byte[] b = BinaryUtils.convert(Math.abs(incr), 2);
+
+        afpdata.write(new byte[] {
+              5                  // Control sequence length
+            , (byte)0xC3         // Control sequence function type
+            , b[0]
+            , b[1]
+            , (byte)(incr >= 0 ? 0 : 1) // Direction
+        }, 0, 5);
+
+    }
+
+    /**
+     * Accessor method to write the AFP datastream for
+     * the text data.
+     * @param os The stream to write to
+     * @throws java.io.IOException
+     */
+    public void writeDataStream(OutputStream os)
+        throws IOException {
+
+        byte[] data = _baos.toByteArray();
+        byte[] size = BinaryUtils.convert(data.length - 1, 2);
+        data[1] = size[0];
+        data[2] = size[1];
+
+        os.write(data);
+
+    }
+
+    /**
+     * A control sequence is a sequence of bytes that specifies a control
+     * function. A control sequence consists of a control sequence introducer
+     * and zero or more parameters. The control sequence can extend multiple
+     * presentation text data objects, but must eventually be terminated. This
+     * method terminates the control sequence.
+     *
+     * @throws MaximumSizeExceededException
+     */
+    public void endControlSequence() throws MaximumSizeExceededException {
+
+        byte[] data = new byte[2];
+        data[0] = 0x02;
+        data[1] = (byte) 0xF8;
+
+        if (data.length + _baos.size() > MAX_SIZE) {
+            throw new MaximumSizeExceededException();
+        }
+
+        _baos.write(data, 0, data.length);
+
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextData.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,113 @@
+/*
+ * 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 Presentation Text Descriptor specifies the units of measure for the
+ * Presentation Text object space, the size of the Presentation Text object
+ * space, and the initial values for modal parameters, called initial text
+ * conditions. Initial values not provided are defaulted by the controlling
+ * environment or the receiving device.
+ *
+ * The Presentation Text Descriptor provides the following initial values:
+ * - Unit base
+ * - Xp-units per unit base
+ * - Yp-units per unit base
+ * - Xp-extent of the presentation space
+ * - Yp-extent of the presentation space
+ * - Initial text conditions.
+ *
+ * The initial text conditions are values provided by the Presentation Text
+ * Descriptor to initialize the modal parameters of the control sequences.
+ * Modal control sequences typically are characterized by the word set in
+ * the name of the control sequence. Modal parameters are identified as such
+ * in their semantic descriptions.
+ *
+ */
+public class PresentationTextDescriptor extends AbstractAFPObject {
+
+    private int _width = 0;
+    private int _height = 0;
+
+    /**
+     * Constructor a PresentationTextDescriptor for the specified
+     * width and height.
+     * @param width The width of the page.
+     * @param height The height of the page.
+     */
+    public PresentationTextDescriptor(int width, int height) {
+
+        _width = width;
+        _height = height;
+
+    }
+
+    /**
+     * Accessor method to write the AFP datastream for the Presentation Text 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,
+            0x16,
+            (byte) 0xD3,
+            (byte) 0xB1,
+            (byte) 0x9B,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+            0x09,
+            0x60,
+            0x09,
+            0x60,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+            0x00,
+        };
+
+        byte[] x = BinaryUtils.convert(_width, 3);
+        data[15] = x[0];
+        data[16] = x[1];
+        data[17] = x[2];
+
+        byte[] y = BinaryUtils.convert(_height, 3);
+        data[18] = y[0];
+        data[19] = y[1];
+        data[20] = y[2];
+
+        os.write(data);
+
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextDescriptor.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextObject.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextObject.java?rev=397562&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextObject.java (added)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextObject.java Thu Apr 27 08:08:17 2006
@@ -0,0 +1,330 @@
+/*
+ * 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 java.util.ArrayList;
+import org.apache.fop.render.afp.AFPFontColor;
+
+/**
+ * The Presentation Text object is the data object used in document processing
+ * environments for representing text which has been prepared for presentation.
+ * Text, as used here, means an ordered string of characters, such as graphic
+ * symbols, numbers, and letters, that are suitable for the specific purpose of
+ * representing coherent information. Text which has been prepared for
+ * presentation has been reduced to a primitive form through explicit
+ * specification of the characters and their placement in the presentation
+ * space. Control sequences which designate specific control functions may be
+ * embedded within the text. These functions extend the primitive form by
+ * applying specific characteristics to the text when it is presented. The
+ * collection of the graphic characters and control codes is called Presentation
+ * Text, and the object that contains the Presentation Text is called the
+ * PresentationText object.
+ *
+ */
+public class PresentationTextObject extends AbstractNamedAFPObject {
+
+    /**
+     * Default name for the presentation text object
+     */
+    private static final String DEFAULT_NAME = "PTO00001";
+
+    private PresentationTextData currentPresentationTextData = null;
+
+    private ArrayList presentationTextData = new ArrayList();
+
+    /**
+     * Default constructor for the PresentationTextObject
+     */
+    public PresentationTextObject() {
+
+        this(DEFAULT_NAME);
+
+    }
+
+    /**
+     * Construct a new PresentationTextObject for the specified name argument,
+     * the name should be an 8 character identifier.
+     */
+    public PresentationTextObject(String name) {
+
+        super(name);
+
+    }
+
+    /**
+     * Create the presentation text data for the byte array of data.
+     *
+     * @param fontNumber
+     *            The font resource identifier.
+     * @param x
+     *            The x coordinate for the text data.
+     * @param y
+     *            The y coordinate for the text data.
+     * @param col
+     *            The text color.
+     * @param vsci
+     *            The variable space character increment.
+     * @param ica
+     *            The inter character increment.
+     * @param data
+     *            The text data to be created.
+     */
+    public void createTextData(int fontNumber, int x, int y, AFPFontColor col, int vsci, int ica, byte[] data) {
+
+        // Use a default orientation of zero
+        createTextData(fontNumber, x, y, 0, col, vsci, ica, data);
+
+    }
+
+    /**
+     * Create the presentation text data for the byte array of data.
+     *
+     * @param fontNumber
+     *            The font resource identifier.
+     * @param x
+     *            The x coordinate for the text data.
+     * @param y
+     *            The y coordinate for the text data.
+     * @param orientation
+     *            The orientation of the text data.
+     * @param col
+     *            The text color.
+     * @param vsci
+     *            The variable space character increment.
+     * @param ica
+     *            The inter character adjustment.
+     * @param data
+     *            The text data to be created.
+     */
+    public void createTextData(int fontNumber, int x, int y, int orientation,
+        AFPFontColor col, int vsci, int ica, byte[] data) {
+
+        if (currentPresentationTextData == null) {
+            startPresentationTextData();
+        }
+
+        try {
+
+            currentPresentationTextData.createTextData(fontNumber, x, y,
+                orientation, col, vsci, ica, data);
+
+        } catch (MaximumSizeExceededException msee) {
+
+            endPresentationTextData();
+            createTextData(fontNumber, x, y, orientation, col, vsci, ica, data);
+
+        }
+
+    }
+
+    /**
+     * Drawing of lines using the starting and ending coordinates, thickness.
+     *
+     * @param x1
+     *            The first x coordinate of the line.
+     * @param y1
+     *            The first y coordinate of the line.
+     * @param x2
+     *            The second x coordinate of the line.
+     * @param y2
+     *            The second y coordinate of the line.
+     * @param thickness
+     *            The thickness of the line.
+     * @param col
+     *            The text color.
+     */
+    public void createLineData(int x1, int y1, int x2, int y2, int thickness, AFPFontColor col) {
+        // Default orientation
+        createLineData(x1, y1, x2, y2, thickness, 0, col);
+    }
+
+    /**
+     * Drawing of lines using the starting and ending coordinates, thickness and
+     * orientation arguments.
+     *
+     * @param x1
+     *            The first x coordinate of the line.
+     * @param y1
+     *            The first y coordinate of the line.
+     * @param x2
+     *            The second x coordinate of the line.
+     * @param y2
+     *            The second y coordinate of the line.
+     * @param thickness
+     *            The thickness of the line.
+     * @param orientation
+     *            The orientation of the line.
+     * @param col
+     *            The text color.
+     */
+    public void createLineData(int x1, int y1, int x2, int y2, int thickness,
+        int orientation, AFPFontColor col) {
+
+        if (currentPresentationTextData == null) {
+            startPresentationTextData();
+        }
+
+        try {
+
+            currentPresentationTextData.createLineData(x1, y1, x2, y2,
+                thickness, orientation, col);
+
+        } catch (MaximumSizeExceededException msee) {
+
+            endPresentationTextData();
+            createLineData(x1, y1, x2, y2, thickness, orientation, col);
+
+        }
+
+    }
+
+    /**
+     * Helper method to mark the start of the presentation text data
+     */
+    private void startPresentationTextData() {
+
+        if (presentationTextData.size() == 0) {
+            currentPresentationTextData = new PresentationTextData(true);
+        } else {
+            currentPresentationTextData = new PresentationTextData();
+        }
+
+        presentationTextData.add(currentPresentationTextData);
+
+    }
+
+    /**
+     * Helper method to mark the end of the presentation text data
+     */
+    private void endPresentationTextData() {
+
+        currentPresentationTextData = null;
+
+    }
+
+    /**
+     * Accessor method to write the AFP datastream for the PresentationTextObject.
+     * @param os The stream to write to
+     * @throws java.io.IOException
+     */
+    public void writeDataStream(OutputStream os)
+        throws IOException {
+
+        writeStart(os);
+
+        writeObjectList(presentationTextData, os);
+
+        writeEnd(os);
+
+    }
+
+    public String getName() {
+
+        return _name;
+
+    }
+
+    /**
+     * Helper method to write the start of the presenation text 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) 0x9B; // 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 presenation text 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) 0x9B; // 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);
+
+    }
+
+    /**
+     * A control sequence is a sequence of bytes that specifies a control
+     * function. A control sequence consists of a control sequence introducer
+     * and zero or more parameters. The control sequence can extend multiple
+     * presentation text data objects, but must eventually be terminated. This
+     * method terminates the control sequence.
+     */
+    public void endControlSequence() {
+
+        if (currentPresentationTextData == null) {
+            startPresentationTextData();
+        }
+
+        try {
+
+            currentPresentationTextData.endControlSequence();
+
+        } catch (MaximumSizeExceededException msee) {
+
+            endPresentationTextData();
+            endControlSequence();
+
+        }
+
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextObject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/afp/modca/PresentationTextObject.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