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 ac...@apache.org on 2008/08/27 14:35:51 UTC

svn commit: r689459 [4/7] - in /xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop: pdf/ render/ render/afp/ render/afp/goca/ render/afp/ioca/ render/afp/modca/ render/afp/modca/resource/ render/afp/modca/triplets/ render/java2d/

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsString.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsString.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsString.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsString.java Wed Aug 27 05:35:44 2008
@@ -35,17 +35,19 @@
 
     /** drawn from the current position */
     private boolean fromCurrentPosition = false;
-    
+
     /** the string to draw */
     private String str = null;
-    
+
     /** x coordinate */
     private int x;
-    
+
     /** y coordinate */
     private int y;
 
     /**
+     * Constructor
+     *
      * @param str the character string
      */
     public GraphicsString(String str) {
@@ -55,6 +57,8 @@
     }
 
     /**
+     * Constructor
+     *
      * @param str the character string
      * @param x the x coordinate
      * @param y the y coordinate
@@ -65,10 +69,8 @@
         this.y = y;
         prepareData();
     }
-    
-    /**
-     * {@inheritDoc} 
-     */
+
+    /** {@inheritDoc} */
     protected void prepareData() {
         int maxStrLen = MAX_STR_LEN - (fromCurrentPosition ? 0 : 4);
         if (str.length() > maxStrLen) {
@@ -89,7 +91,7 @@
             System.arraycopy(strData, 0, data, 2, strData.length);
         } else {
             len += 4; // x/y coordinates
-            byte[] osx = BinaryUtils.convert(x, 2);   
+            byte[] osx = BinaryUtils.convert(x, 2);
             byte[] osy = BinaryUtils.convert(y, 2);
             data = new byte[len + 2];
             data[0] = (byte)0xC3;
@@ -101,16 +103,14 @@
             System.arraycopy(strData, 0, data, 6, strData.length);
         }
     }
-    
-    /**
-     * {@inheritDoc}
-     */
+
+    /** {@inheritDoc} */
     public String toString() {
-        String string = "GraphicsString(str='" + str + "'";
+        String string = "GraphicsString{str='" + str + "'";
         if (!fromCurrentPosition) {
             string += ",x=" + x + ",y=" + y;
         }
-        string += ")";
+        string += "}";
         return string;
     }
 }
\ No newline at end of file

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageCellPosition.java (from r685891, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageCellPosition.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageCellPosition.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageCellPosition.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageCellPosition.java&r1=685891&r2=689459&rev=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageCellPosition.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageCellPosition.java Wed Aug 27 05:35:44 2008
@@ -17,10 +17,12 @@
 
 /* $Id$ */
 
-package org.apache.fop.render.afp.modca;
+package org.apache.fop.render.afp.ioca;
 
 import java.io.IOException;
 import java.io.OutputStream;
+
+import org.apache.fop.render.afp.modca.AbstractAFPObject;
 import org.apache.fop.render.afp.tools.BinaryUtils;
 
 /**
@@ -42,22 +44,22 @@
     /**
      * Size of image cell in X direction
      */
-    private byte[] xSize = new byte[] {(byte)0xFF, (byte)0xFF};
+    private final byte[] xSize = new byte[] {(byte)0xFF, (byte)0xFF};
 
     /**
      * Size of image cell in Y direction
      */
-    private byte[] ySize = new byte[] {(byte)0xFF, (byte)0xFF};
+    private final byte[] ySize = new byte[] {(byte)0xFF, (byte)0xFF};
 
     /**
      * Size of fill rectangle in X direction
      */
-    private byte[] xFillSize = new byte[] {(byte)0xFF, (byte)0xFF};
+    private final byte[] xFillSize = new byte[] {(byte)0xFF, (byte)0xFF};
 
     /**
      * Size of fill rectangle in Y direction
      */
-    private byte[] yFillSize = new byte[] {(byte)0xFF, (byte)0xFF};
+    private final byte[] yFillSize = new byte[] {(byte)0xFF, (byte)0xFF};
 
     /**
      * Constructor for the ImageCellPosition
@@ -70,10 +72,10 @@
     }
 
     /** {@inheritDoc} */
-    public void write(OutputStream os) throws IOException {
+    public void writeToStream(OutputStream os) throws IOException {
         byte[] data = new byte[21];
         copySF(data, Type.POSITION, Category.IM_IMAGE);
-        
+
         data[1] = 0x00; // length
         data[2] = 0x14;
 
@@ -113,6 +115,7 @@
      * of this image cell. A value of X'FFFF' indicates that the
      * default extent specified in bytes 28 and 29 of the Image
      * Input Descriptor (IID) is to be used.
+     *
      * @param xcSize The size to set.
      */
     public void setXSize(int xcSize) {
@@ -129,6 +132,7 @@
      * be used as the fill rectangle X-extent. The fill rectangle is
      * filled in the X direction by repeating the image cell in the
      * X direction. The image cell can be truncated to fit the rectangle.
+     *
      * @param size The size to set.
      */
     public void setXFillSize(int size) {
@@ -142,6 +146,7 @@
      * of this image cell. A value of X'FFFF' indicates that the
      * default extent specified in bytes 30 and 31 of the Image
      * Input Descriptor (IID) is to be used.
+     *
      * @param size The size to set.
      */
     public void setYSize(int size) {
@@ -158,6 +163,7 @@
      * be used as the fill rectangle Y-extent. The fill rectangle is
      * filled in the Y direction by repeating the image cell in the
      * Y direction. The image cell can be truncated to fit the rectangle.
+     *
      * @param size The size to set.
      */
     public void setYFillSize(int size) {

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageContent.java (from r685891, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageContent.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageContent.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageContent.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageContent.java&r1=685891&r2=689459&rev=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageContent.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageContent.java Wed Aug 27 05:35:44 2008
@@ -17,11 +17,12 @@
 
 /* $Id$ */
 
-package org.apache.fop.render.afp.modca;
+package org.apache.fop.render.afp.ioca;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import org.apache.fop.render.afp.tools.BinaryUtils;
+
+import org.apache.fop.render.afp.modca.AbstractStructuredAFPObject;
 
 /**
  */
@@ -34,7 +35,7 @@
      * one-dimensional compression.
      */
     public static final byte COMPID_G3_MH = (byte)0x80;
-    
+
     /**
      * The CCITT T.4 Group 3 Coding Option (G3 MR-Modified READ) is a
      * compression method standardized by the International Telegraph and
@@ -47,7 +48,7 @@
      * The CCITT T.6 Group 4 Coding Standard (G4 MMR-Modified Modified READ) is a
      * compression method standardized by the International Telegraph and
      * Telephone Consultative Committee (CCITT) for facsimile.  It enables
-     * two-dimensional compression. 
+     * two-dimensional compression.
      */
     public static final byte COMPID_G3_MMR = (byte)0x82;
 
@@ -79,7 +80,7 @@
     /**
      * The image data
      */
-    private byte[] imageData = null;
+    private byte[] data;
 
     /**
      * Constructor for the image content
@@ -90,142 +91,133 @@
     /**
      * 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.
+     * @param hresol The horizontal resolution of the image.
+     * @param vresol The vertical resolution of the image.
      */
-    public void setImageSize(int hresol, int vresol, int hsize, int vsize) {
-        imageSizeParameter = new ImageSizeParameter(hresol, vresol, hsize, vsize);
+    public void setImageSize(int hsize, int vsize, int hresol, int vresol) {
+        imageSizeParameter = new ImageSizeParameter(hsize, vsize, hresol, vresol);
     }
 
     /**
      * Sets the image encoding.
-     * 
-     * @param encoding The image encoding.
+     *
+     * @param enc The image encoding.
      */
-    public void setImageEncoding(byte encoding) {
-        this.encoding = encoding;
+    public void setImageEncoding(byte enc) {
+        this.encoding = enc;
     }
 
     /**
      * Sets the image compression.
-     * 
-     * @param compression The image compression.
+     *
+     * @param comp The image compression.
      */
-    public void setImageCompression(byte compression) {
-        this.compression = compression;
+    public void setImageCompression(byte comp) {
+        this.compression = comp;
     }
 
     /**
      * Sets the image IDE size.
-     * 
-     * @param size The IDE size.
+     *
+     * @param s The IDE size.
      */
-    public void setImageIDESize(byte size) {
-        this.size = size;
+    public void setImageIDESize(byte s) {
+        this.size = s;
     }
 
     /**
      * Sets the image IDE color model.
-     * 
-     * @param colorModel    the IDE color model.
+     *
+     * @param color    the IDE color model.
      */
-    public void setImageIDEColorModel(byte colorModel) {
-        this.colorModel = colorModel;
+    public void setImageIDEColorModel(byte color) {
+        this.colorModel = color;
     }
 
     /**
-     * Set the data of the image.
-     * 
-     * @param data the image data
+     * Set the data image store information.
+     *
+     * @param imageData the image data
      */
-    public void setImageData(byte[] data) {
-        this.imageData = data;
+    public void setImageData(byte[] imageData) {
+        this.data = imageData;
     }
 
+    private static final int MAX_DATA_LEN = 65535;
+
     /** {@inheritDoc} */
     protected void writeContent(OutputStream os) throws IOException {
         if (imageSizeParameter != null) {
-            imageSizeParameter.write(os);
+            imageSizeParameter.writeToStream(os);
         }
+
+        // TODO convert to triplet/parameter class
         os.write(getImageEncodingParameter());
+
         os.write(getImageIDESizeParameter());
+
         os.write(getIDEStructureParameter());
+
         os.write(getExternalAlgorithmParameter());
-        if (imageData != null) {
-            int off = 0;
-            while (off < imageData.length) {
-                int len = Math.min(30000, imageData.length - off);
-                os.write(getImageDataStart(len));
-                os.write(imageData, off, len);
-                off += len;
-            }
+
+        // Image Data
+        if (data != null) {
+            final byte[] dataHeader = new byte[] {
+                (byte)0xFE, // ID
+                (byte)0x92, // ID
+                0x00, // length
+                0x00  // length
+            };
+            final int lengthOffset = 2;
+            writeChunksToStream(this.data, dataHeader, lengthOffset, MAX_DATA_LEN, os);
         }
     }
 
     /** {@inheritDoc} */
     protected void writeStart(OutputStream os) throws IOException {
-        byte[] data = new byte[] {
+        final byte[] startData = new byte[] {
             (byte)0x91, // ID
             0x01, // Length
             (byte)0xff, // Object Type = IOCA Image Object
         };
-        os.write(data);
+        os.write(startData);
     }
 
     /** {@inheritDoc} */
     protected void writeEnd(OutputStream os) throws IOException {
-        byte[] data = new byte[] {
+        final byte[] endData = 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;
+        os.write(endData);
     }
 
     /**
      * Helper method to return the image encoding parameter.
-     * 
+     *
      * @return byte[] The data stream.
      */
     private byte[] getImageEncodingParameter() {
-        byte[] data = new byte[] {
+        final byte[] encodingData = new byte[] {
             (byte)0x95, // ID
             0x02, // Length
             encoding,
             0x01, // RECID
         };
-        return data;
+        return encodingData;
     }
 
     /**
      * 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[] {
+            final byte[] extAlgData = new byte[] {
                 (byte)0x95, // ID
                       0x00, // Length
                       0x10, // ALGTYPE = Compression Algorithm
@@ -239,35 +231,35 @@
                       0x00, // Reserved
                       0x00, // Reserved
             };
-            data[1] = (byte)(data.length - 2);
-            return data;
+            extAlgData[1] = (byte)(extAlgData.length - 2);
+            return extAlgData;
         }
         return new byte[0];
     }
 
     /**
      * Helper method to return the image encoding parameter.
-     * 
+     *
      * @return byte[] The data stream.
      */
     private byte[] getImageIDESizeParameter() {
-        byte[] data = new byte[] {
+        final byte[] ideSizeData = new byte[] {
             (byte)0x96, // ID
             0x01, // Length
             size,
         };
-        return data;
+        return ideSizeData;
     }
 
     /**
      * 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[] {
+            final byte bits = (byte)(size / 3);
+            final byte[] ideStructData = new byte[] {
                 (byte)0x9B, // ID
                 0x00, // Length
                 0x00, // FLAGS
@@ -280,8 +272,8 @@
                 bits,
                 bits,
             };
-            data[1] = (byte)(data.length - 2);
-            return data;
+            ideStructData[1] = (byte)(ideStructData.length - 2);
+            return ideStructData;
         }
         return new byte[0];
     }

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageInputDescriptor.java (from r685891, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageInputDescriptor.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageInputDescriptor.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageInputDescriptor.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageInputDescriptor.java&r1=685891&r2=689459&rev=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageInputDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageInputDescriptor.java Wed Aug 27 05:35:44 2008
@@ -17,10 +17,12 @@
 
 /* $Id$ */
 
-package org.apache.fop.render.afp.modca;
+package org.apache.fop.render.afp.ioca;
 
 import java.io.IOException;
 import java.io.OutputStream;
+
+import org.apache.fop.render.afp.modca.AbstractAFPObject;
 import org.apache.fop.render.afp.tools.BinaryUtils;
 
 /**
@@ -37,11 +39,11 @@
 
 
     /** {@inheritDoc} */
-    public void write(OutputStream os) throws IOException {
+    public void writeToStream(OutputStream os) throws IOException {
 
         byte[] data = new byte[45];
         copySF(data, Type.DESCRIPTOR, Category.IM_IMAGE);
-        
+
         data[1] = 0x00; // length
         data[2] = 0x2C;
 
@@ -126,7 +128,7 @@
     /**
      * 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) {

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageOutputControl.java (from r685891, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageOutputControl.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageOutputControl.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageOutputControl.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageOutputControl.java&r1=685891&r2=689459&rev=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageOutputControl.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageOutputControl.java Wed Aug 27 05:35:44 2008
@@ -17,10 +17,12 @@
 
 /* $Id$ */
 
-package org.apache.fop.render.afp.modca;
+package org.apache.fop.render.afp.ioca;
 
 import java.io.IOException;
 import java.io.OutputStream;
+
+import org.apache.fop.render.afp.modca.AbstractAFPObject;
 import org.apache.fop.render.afp.tools.BinaryUtils;
 
 /**
@@ -72,7 +74,7 @@
     }
 
     /** {@inheritDoc} */
-    public void write(OutputStream os) throws IOException {
+    public void writeToStream(OutputStream os) throws IOException {
 
         byte[] data = new byte[33];
 

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageRasterData.java (from r685891, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageRasterData.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageRasterData.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageRasterData.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageRasterData.java&r1=685891&r2=689459&rev=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageRasterData.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageRasterData.java Wed Aug 27 05:35:44 2008
@@ -17,10 +17,14 @@
 
 /* $Id$ */
 
-package org.apache.fop.render.afp.modca;
+package org.apache.fop.render.afp.ioca;
 
 import java.io.IOException;
 import java.io.OutputStream;
+
+import org.apache.fop.render.afp.modca.AbstractAFPObject;
+import org.apache.fop.render.afp.modca.AbstractAFPObject.Category;
+import org.apache.fop.render.afp.modca.AbstractAFPObject.Type;
 import org.apache.fop.render.afp.tools.BinaryUtils;
 
 /**
@@ -48,7 +52,7 @@
     /**
      * The image raster data
      */
-    private byte[] rasterData;
+    private final byte[] rasterData;
 
     /**
      * Constructor for the image raster data object
@@ -59,16 +63,15 @@
     }
 
     /** {@inheritDoc} */
-    public void write(OutputStream os) throws IOException {
+    public void writeToStream(OutputStream os) throws IOException {
         byte[] data = new byte[9];
         copySF(data, Type.DATA, Category.IM_IMAGE);
-        
         // The size of the structured field
         byte[] len = BinaryUtils.convert(rasterData.length + 8, 2);
         data[1] = len[0];
         data[2] = len[1];
-
         os.write(data);
+
         os.write(rasterData);
     }
 }
\ No newline at end of file

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageRasterPattern.java (from r685891, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageRasterPattern.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageRasterPattern.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageRasterPattern.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageRasterPattern.java&r1=685891&r2=689459&rev=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageRasterPattern.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageRasterPattern.java Wed Aug 27 05:35:44 2008
@@ -17,7 +17,7 @@
 
 /* $Id$ */
 
-package org.apache.fop.render.afp.modca;
+package org.apache.fop.render.afp.ioca;
 
 /**
  * Raster data is a grid of cells covering an area of interest.

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageSegment.java (from r685891, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageSegment.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageSegment.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageSegment.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageSegment.java&r1=685891&r2=689459&rev=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageSegment.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageSegment.java Wed Aug 27 05:35:44 2008
@@ -17,11 +17,14 @@
 
 /* $Id$ */
 
-package org.apache.fop.render.afp.modca;
+package org.apache.fop.render.afp.ioca;
 
 import java.io.IOException;
 import java.io.OutputStream;
 
+import org.apache.fop.render.afp.modca.AbstractNamedAFPObject;
+import org.apache.fop.render.afp.modca.Factory;
+
 /**
  * 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
@@ -35,119 +38,102 @@
 public class ImageSegment extends AbstractNamedAFPObject {
 
     /**
-     * Default name for the object environment group
-     */
-    private static final String DEFAULT_NAME = "IS000001";
-
-    /**
      * The ImageContent for the image segment
      */
     private ImageContent imageContent = null;
 
-    /**
-     * Default constructor for the ImageSegment.
-     */
-    public ImageSegment() {
-        this(DEFAULT_NAME);
-    }
+    private final Factory factory;
 
     /**
      * 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.
+     * @param factory the object factory
+     *
+     * @param name the name of the image.
      */
-    public ImageSegment(String name) {
+    public ImageSegment(Factory factory, String name) {
         super(name);
+        this.factory = factory;
     }
 
-    /** {@inheritDoc} */
-    protected int getNameLength() {
-        return 4;
+    private ImageContent getImageContent() {
+        if (imageContent == null) {
+            this.imageContent = factory.createImageContent();
+        }
+        return 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.
+     * @param hresol The horizontal resolution of the image.
+     * @param vresol The vertical resolution 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);
+    public void setImageSize(int hsize, int vsize, int hresol, int vresol) {
+        getImageContent().setImageSize(hsize, vsize, hresol, vresol);
     }
 
     /**
      * Sets the image encoding.
-     * 
+     *
      * @param encoding The image encoding.
      */
-    public void setImageEncoding(byte encoding) {
-        if (imageContent == null) {
-            imageContent = new ImageContent();
-        }
-        imageContent.setImageEncoding(encoding);
+    public void setEncoding(byte encoding) {
+        getImageContent().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);
+    public void setCompression(byte compression) {
+        getImageContent().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);
+    public void setIDESize(byte size) {
+        getImageContent().setImageIDESize(size);
     }
 
     /**
      * Sets the image IDE color model.
-     * 
-     * @param colorModel    the IDE color model.
+     *
+     * @param colorModel the IDE color model.
      */
-    public void setImageIDEColorModel(byte colorModel) {
-        if (imageContent == null) {
-            imageContent = new ImageContent();
-        }
-        imageContent.setImageIDEColorModel(colorModel);
+    public void setIDEColorModel(byte colorModel) {
+        getImageContent().setImageIDEColorModel(colorModel);
     }
 
     /**
-     * Set the data of the image.
-     * 
+     * Set the data image data.
+     *
      * @param data the image data
      */
-    public void setImageData(byte[] data) {
-        if (imageContent == null) {
-            imageContent = new ImageContent();
-        }
-        imageContent.setImageData(data);
+    public void setData(byte[] data) {
+        getImageContent().setImageData(data);
     }
 
     /** {@inheritDoc} */
     public void writeContent(OutputStream os) throws IOException {
         if (imageContent != null) {
-            imageContent.write(os);
+            imageContent.writeToStream(os);
         }
     }
 
+    private static final int NAME_LENGTH = 4;
+
+    /** {@inheritDoc} */
+    protected int getNameLength() {
+        return NAME_LENGTH;
+    }
+
     /** {@inheritDoc} */
     protected void writeStart(OutputStream os) throws IOException {
         byte[] nameBytes = getNameBytes();

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageSizeParameter.java (from r685891, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageSizeParameter.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageSizeParameter.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageSizeParameter.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageSizeParameter.java&r1=685891&r2=689459&rev=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageSizeParameter.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/ioca/ImageSizeParameter.java Wed Aug 27 05:35:44 2008
@@ -17,10 +17,12 @@
 
 /* $Id$ */
 
-package org.apache.fop.render.afp.modca;
+package org.apache.fop.render.afp.ioca;
 
 import java.io.IOException;
 import java.io.OutputStream;
+
+import org.apache.fop.render.afp.modca.AbstractAFPObject;
 import org.apache.fop.render.afp.tools.BinaryUtils;
 
 /**
@@ -28,28 +30,29 @@
  */
 public class ImageSizeParameter extends AbstractAFPObject {
 
-    private int hRes = 0;
-    private int vRes = 0;
     private int hSize = 0;
     private int vSize = 0;
+    private int hRes = 0;
+    private int vRes = 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 horizontal size of the image.
      * @param vsize The vertical size of the image.
+     * @param hresol The horizontal resolution of the image.
+     * @param vresol The vertical resolution of the image.
      */
-    public ImageSizeParameter(int hresol, int vresol, int hsize, int vsize) {
-        this.hRes = hresol;
-        this.vRes = vresol;
+    public ImageSizeParameter(int hsize, int vsize, int hresol, int vresol) {
         this.hSize = hsize;
         this.vSize = vsize;
+        this.hRes = hresol;
+        this.vRes = vresol;
     }
 
     /** {@inheritDoc} */
-    public void write(OutputStream os) throws IOException {
+    public void writeToStream(OutputStream os) throws IOException {
         byte[] data = new byte[] {
             (byte)0x94, // ID = Image Size Parameter
             0x09, // Length

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractAFPObject.java Wed Aug 27 05:35:44 2008
@@ -26,61 +26,62 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fop.util.store.Streamable;
 
 /**
  * This is the base class for all data stream objects. Page objects are
  * responsible for building and generating the binary datastream in an
  * AFP format.
- *
  */
-public abstract class AbstractAFPObject implements Writable {
+public abstract class AbstractAFPObject implements Streamable {
 
     /** Static logging instance */
     protected static final Log log = LogFactory.getLog("org.apache.fop.render.afp.modca");
 
+    /** the structured field class id */
     protected static final byte SF_CLASS = (byte)0xD3;
-    
-    private static final byte[] SF = new byte[] {
+
+    private static final byte[] SF_HEADER = new byte[] {
         0x5A, // Structured field identifier
         0x00, // Length byte 1
         0x10, // Length byte 2
-        (byte) SF_CLASS, // Structured field id byte 1
+        SF_CLASS, // Structured field id byte 1
         (byte) 0x00, // Structured field id byte 2
         (byte) 0x00, // Structured field id byte 3
         0x00, // Flags
         0x00, // Reserved
-        0x00, // Reserved                
-    };    
+        0x00, // Reserved
+    };
 
     /**
      * Copies the template structured field data array to the given byte array
-     * 
+     *
      * @param data the structured field data byte array
      * @param type the type code
      * @param category the category code
      */
     protected void copySF(byte[] data, byte type, byte category) {
         copySF(data, SF_CLASS, type, category);
-    }    
+    }
 
     /**
      * Copies the template structured field data array to the given byte array
-     * 
+     *
      * @param data the structured field data byte array
      * @param clazz the class code
      * @param type the type code
      * @param category the category code
      */
-    protected void copySF(byte[] data, byte clazz, byte type, byte category) {
-        System.arraycopy(SF, 0, data, 0, SF.length);
+    protected static void copySF(byte[] data, byte clazz, byte type, byte category) {
+        System.arraycopy(SF_HEADER, 0, data, 0, SF_HEADER.length);
         data[3] = clazz;
         data[4] = type;
         data[5] = category;
-    }    
+    }
 
     /**
      * Help method to write a set of AFPObjects to the AFP datastream.
-     * 
+     *
      * @param objects a list of AFPObjects
      * @param os The stream to write to
      * @throws java.io.IOException an I/O exception of some sort has occurred.
@@ -89,151 +90,153 @@
         throws IOException {
         if (objects != null) {
             for (Iterator it = objects.iterator(); it.hasNext();) {
-                AbstractAFPObject obj = (AbstractAFPObject)it.next(); 
-                obj.write(os);
+                Object object = it.next();
+                if (object instanceof Streamable) {
+                    ((Streamable)object).writeToStream(os);
+                }
             }
         }
     }
-    
+
     /** structured field type codes */
-    interface Type {
-            
-        // Attribute
+    public interface Type {
+
+        /** Attribute */
         byte ATTRIBUTE = (byte)0x0A;
-        
-        // Copy Count
+
+        /** Copy Count */
         byte COPY_COUNT = (byte)0xA2;
-        
-        // Descriptor
+
+        /** Descriptor */
         byte DESCRIPTOR = (byte)0xA6;
-        
-        // Control
+
+        /** Control */
         byte CONTROL = (byte)0xA7;
-        
-        // Begin
+
+        /** Begin */
         byte BEGIN = (byte)0xA8;
-        
-        // End
+
+        /** End */
         byte END = (byte)0xA9;
-        
-        // Map
+
+        /** Map */
         byte MAP = (byte)0xAB;
-        
-        // Position
+
+        /** Position */
         byte POSITION = (byte)0xAC;
-        
-        // Process
+
+        /** Process */
         byte PROCESS = (byte)0xAD;
-        
-        // Include
+
+        /** Include */
         byte INCLUDE = (byte)0xAF;
-        
-        // Table
+
+        /** Table */
         byte TABLE = (byte)0xB0;
-        
-        // Migration
+
+        /** Migration */
         byte MIGRATION = (byte)0xB1;
-        
-        // Variable
+
+        /** Variable */
         byte VARIABLE = (byte)0xB2;
-        
-        // Link
+
+        /** Link */
         byte LINK = (byte)0xB4;
-        
-        // Data
+
+        /** Data */
         byte DATA = (byte)0xEE;
     }
-        
+
     /** structured field category codes */
-    interface Category {
-        
-        // Page Segment
+    public interface Category {
+
+        /** Page Segment */
         byte PAGE_SEGMENT = (byte)0x5F;
 
-        // Object Area
+        /** Object Area */
         byte OBJECT_AREA = (byte)0x6B;
-        
-        // Color Attribute Table
+
+        /** Color Attribute Table */
         byte COLOR_ATTRIBUTE_TABLE = (byte)0x77;
 
-        // IM Image
+        /** IM Image */
         byte IM_IMAGE = (byte)0x7B;
-        
-        // Medium
+
+        /** Medium */
         byte MEDIUM = (byte)0x88;
-        
-        // Coded Font
+
+        /** Coded Font */
         byte CODED_FONT = (byte)0x8A;
-        
-        // Process Element
+
+        /** Process Element */
         byte PROCESS_ELEMENT = (byte)0x90;
 
-        // Object Container
+        /** Object Container */
         byte OBJECT_CONTAINER = (byte)0x92;
 
-        // Presentation Text
+        /** Presentation Text */
         byte PRESENTATION_TEXT = (byte)0x9B;
 
-        // Index
+        /** Index */
         byte INDEX = (byte)0xA7;
-        
-        // Document
+
+        /** Document */
         byte DOCUMENT = (byte)0xA8;
-        
-        // Page Group
+
+        /** Page Group */
         byte PAGE_GROUP = (byte)0xAD;
-        
-        // Page
+
+        /** Page */
         byte PAGE = (byte)0xAF;
-        
-        // Graphics
+
+        /** Graphics */
         byte GRAPHICS = (byte)0xBB;
-        
-        // Data Resource
+
+        /** Data Resource */
         byte DATA_RESOURCE = (byte)0xC3;
-        
-        // Document Environment Group (DEG)
+
+        /** Document Environment Group (DEG) */
         byte DOCUMENT_ENVIRONMENT_GROUP = (byte)0xC4;
-        
-        // Resource Group
+
+        /** Resource Group */
         byte RESOURCE_GROUP = (byte)0xC6;
 
-        // Object Environment Group (OEG)
+        /** Object Environment Group (OEG) */
         byte OBJECT_ENVIRONMENT_GROUP = (byte)0xC7;
-        
-        // Active Environment Group (AEG)
+
+        /** Active Environment Group (AEG) */
         byte ACTIVE_ENVIRONMENT_GROUP = (byte)0xC9;
-        
-        // Medium Map
+
+        /** Medium Map */
         byte MEDIUM_MAP = (byte)0xCC;
-        
-        // Form Map
+
+        /** Form Map */
         byte FORM_MAP = (byte)0xCD;
-        
-        // Name Resource
+
+        /** Name Resource */
         byte NAME_RESOURCE = (byte)0xCE;
-        
-        // Page Overlay
+
+        /** Page Overlay */
         byte PAGE_OVERLAY = (byte)0xD8;
-        
-        // Resource Environment Group (REG)
+
+        /** Resource Environment Group (REG) */
         byte RESOURCE_ENVIROMENT_GROUP = (byte)0xD9;
-        
-        // Overlay
+
+        /** Overlay */
         byte OVERLAY = (byte)0xDF;
-        
-        // Data Suppression
+
+        /** Data Suppression */
         byte DATA_SUPRESSION = (byte)0xEA;
-        
-        // Bar Code
+
+        /** Bar Code */
         byte BARCODE = (byte)0xEB;
-        
-        // No Operation
+
+        /** No Operation */
         byte NO_OPERATION = (byte)0xEE;
-        
-        // Image
+
+        /** Image */
         byte IMAGE = (byte)0xFB;
     }
-    
+
 }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDataObject.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,62 +22,60 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.render.afp.ObjectAreaInfo;
+import org.apache.fop.render.afp.AFPDataObjectInfo;
+import org.apache.fop.render.afp.AFPObjectAreaInfo;
 
 /**
  * Abstract base class used by the ImageObject and GraphicsObject which both
  * have define an ObjectEnvironmentGroup
  */
-public abstract class AbstractDataObject extends AbstractPreparedObjectContainer {
+public abstract class AbstractDataObject extends AbstractNamedAFPObject {
 
-    /** The object environment group */
+    /** the object environment group */
     protected ObjectEnvironmentGroup objectEnvironmentGroup = null;
 
+    /** the object factory */
+    protected final Factory factory;
+
     /**
      * Named constructor
-     * 
+     *
+     * @param factory the object factory
      * @param name data object name
      */
-    public AbstractDataObject(String name) {
+    public AbstractDataObject(Factory factory, String name) {
         super(name);
+        this.factory = factory;
     }
-    
+
     /**
-     * Sets the object display area position and size.
+     * Sets the object view port (area position and size).
      *
-     * @param objectAreaInfo
+     * @param dataObjectInfo
      *            the object area info
      */
-    public void setViewport(ObjectAreaInfo objectAreaInfo) {
+    public void setViewport(AFPDataObjectInfo dataObjectInfo) {
+        AFPObjectAreaInfo objectAreaInfo = dataObjectInfo.getObjectAreaInfo();
         getObjectEnvironmentGroup().setObjectArea(objectAreaInfo);
     }
-    
+
     /**
      * Gets the ObjectEnvironmentGroup
-     * 
+     *
      * @return the object environment group
      */
     protected ObjectEnvironmentGroup getObjectEnvironmentGroup() {
         if (objectEnvironmentGroup == null) {
-            objectEnvironmentGroup = new ObjectEnvironmentGroup();
+            this.objectEnvironmentGroup = factory.createObjectEnvironmentGroup();
         }
         return objectEnvironmentGroup;
     }
-    
-    /**
-     * Sets the ObjectEnvironmentGroup.
-     * 
-     * @param objectEnvironmentGroup The objectEnvironmentGroup to set
-     */
-    public void setObjectEnvironmentGroup(ObjectEnvironmentGroup objectEnvironmentGroup) {
-        this.objectEnvironmentGroup = objectEnvironmentGroup;
-    }
 
     /** {@inheritDoc} */
     protected void writeContent(OutputStream os) throws IOException {
+        super.writeContent(os);
         if (objectEnvironmentGroup != null) {
-            objectEnvironmentGroup.write(os);
+            objectEnvironmentGroup.writeToStream(os);
         }
-        super.writeContent(os);
     }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractDescriptor.java Wed Aug 27 05:35:44 2008
@@ -33,9 +33,15 @@
     protected int heightRes = 0;
 
     /**
+     * Default constructor
+     */
+    public AbstractDescriptor() {
+    }
+
+    /**
      * Constructor a PresentationTextDescriptor for the specified
      * width and height.
-     * 
+     *
      * @param width The width of the page.
      * @param height The height of the page.
      * @param widthRes The width resolution of the page.
@@ -47,4 +53,12 @@
         this.widthRes = widthRes;
         this.heightRes = heightRes;
     }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return "width=" + width
+        + ", height=" + height
+        + ", widthRes=" + widthRes
+        + ", heightRes=" + heightRes;
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractNamedAFPObject.java Wed Aug 27 05:35:44 2008
@@ -45,24 +45,34 @@
     /**
      * Constructor for the ActiveEnvironmentGroup, this takes a
      * name parameter which should be 8 characters long.
-     * 
+     *
      * @param name the object name
      */
     protected AbstractNamedAFPObject(String name) {
         this.name = name;
     }
-    
+
+    /**
+     * Returns the name length
+     *
+     * @return the name length
+     */
+    protected int getNameLength() {
+        return DEFAULT_NAME_LENGTH;
+    }
+
     /**
      * Returns the name as a byte array in EBCIDIC encoding
-     * 
+     *
      * @return the name as a byte array in EBCIDIC encoding
      */
     protected byte[] getNameBytes() {
-        if (name.length() < DEFAULT_NAME_LENGTH) {
-            name = (name + "       ").substring(0, DEFAULT_NAME_LENGTH);
-        } else if (name.length() > DEFAULT_NAME_LENGTH) {
-            log.warn("Constructor:: name truncated to " + DEFAULT_NAME_LENGTH + " chars" + name);
-            name = name.substring(0, DEFAULT_NAME_LENGTH);
+        int nameLen = getNameLength();
+        if (name.length() < nameLen) {
+            name = (name + "       ").substring(0, nameLen);
+        } else if (name.length() > nameLen) {
+            log.warn("Constructor:: name truncated to " + nameLen + " chars" + name);
+            name = name.substring(0, nameLen);
         }
         byte[] nameBytes = null;
         try {
@@ -85,7 +95,7 @@
 
     /**
      * Returns the name of this object
-     * 
+     *
      * @return the name of this object
      */
     public String getName() {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPageObject.java Wed Aug 27 05:35:44 2008
@@ -21,15 +21,11 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.fop.render.afp.LineDataInfo;
 import org.apache.fop.render.afp.TextDataInfo;
 import org.apache.fop.render.afp.fonts.AFPFont;
-import org.apache.fop.render.afp.modca.resource.ResourceManager;
-import org.apache.fop.render.afp.modca.resource.ResourceStore;
-import org.apache.fop.render.afp.modca.resource.StoreInfo;
 
 /**
  * Pages contain the data objects that comprise a presentation document. Each
@@ -53,9 +49,6 @@
  */
 public abstract class AbstractPageObject extends AbstractNamedAFPObject {
 
-    /** The resource manager */
-    protected ResourceManager resourceManager;
-
     /** The active environment group for the page */
     protected ActiveEnvironmentGroup activeEnvironmentGroup = null;
 
@@ -66,10 +59,11 @@
     protected List/*<TagLogicalElement>*/ tagLogicalElements = null;
 
     /** The list of the include page segments */
-    protected List/*<IncludePageSegment>*/ includePageSegments = null;
+    protected List/*<IncludePageSegment>*/ includePageSegments
+        = new java.util.ArrayList/*<IncludePageSegment>*/();
 
     /** The list of objects within this resource container */
-    protected List/*<AbstractStructuredAFPObject>*/ objects = null;
+    protected List/*<AbstractStructuredAFPObject>*/ objects = new java.util.ArrayList();
 
     /** The page width */
     private int width;
@@ -81,7 +75,7 @@
     protected int rotation = 0;
 
     /** The page state */
-    private boolean complete = false;
+    protected boolean complete = false;
 
     /** The width resolution */
     private int widthRes;
@@ -89,27 +83,35 @@
     /** The height resolution */
     private int heightRes;
 
-    /** Default constructor */
-    public AbstractPageObject() {
+    /** the object factory */
+    protected final Factory factory;
+
+    /**
+     * Default constructor
+     *
+     * @param factory the object factory
+     */
+    public AbstractPageObject(Factory factory) {
+        this.factory = factory;
     }
 
     /**
      * Main constructor
-     * 
-     * @param resourceManager the resource manager 
+     *
+     * @param factory the object factory
      * @param name the name of this page object
      */
-    public AbstractPageObject(ResourceManager resourceManager, String name) {
+    public AbstractPageObject(Factory factory, String name) {
         super(name);
-        this.resourceManager = resourceManager;
+        this.factory = factory;
     }
 
     /**
      * Construct a new page object for the specified name argument, the page
      * name should be an 8 character identifier.
-     * 
-     * @param resourceManager the resource manager
      *
+     * @param factory
+     *            the object factory.
      * @param name
      *            the name of the page.
      * @param width
@@ -123,10 +125,11 @@
      * @param heightRes
      *            the height resolution of the page.
      */
-    public AbstractPageObject(ResourceManager resourceManager,
+    public AbstractPageObject(Factory factory,
             String name, int width, int height, int rotation,
             int widthRes, int heightRes) {
-        this(resourceManager, name);
+        super(name);
+        this.factory = factory;
         this.width = width;
         this.height = height;
         this.rotation = rotation;
@@ -153,7 +156,7 @@
     /**
      * Helper method to create a line on the current page, this method delegates
      * to the presentation text object in order to construct the line.
-     * 
+     *
      * @param lineDataInfo the line data information.
      */
     public void createLine(LineDataInfo lineDataInfo) {
@@ -182,28 +185,32 @@
         complete = true;
     }
 
-    private void endPresentationObject() {
+    /**
+     * Ends the presentation text object
+     */
+    protected void endPresentationObject() {
         if (currentPresentationTextObject != null) {
             currentPresentationTextObject.endControlSequence();
             currentPresentationTextObject = null;
         }
     }
-        
+
     /**
      * Helper method to create a presentation text object
      * on the current page and to return the object.
-     * 
+     *
      * @return the presentation text object
      */
     private PresentationTextObject getPresentationTextObject() {
         if (currentPresentationTextObject == null) {
-            PresentationTextObject presentationTextObject = new PresentationTextObject();
+            PresentationTextObject presentationTextObject
+                = factory.createPresentationTextObject();
             addObject(presentationTextObject);
             this.currentPresentationTextObject = presentationTextObject;
         }
         return currentPresentationTextObject;
     }
-    
+
     /**
      * Creates a TagLogicalElement on the page.
      *
@@ -234,16 +241,13 @@
      *
      * @param name
      *            the name of the page segment
-     * @param xCoor
+     * @param x
      *            the x coordinate of the page segment.
-     * @param yCoor
+     * @param y
      *            the y coordinate of the page segment.
      */
-    public void createIncludePageSegment(String name, int xCoor, int yCoor) {
-        IncludePageSegment ips = new IncludePageSegment(name, xCoor, yCoor);
-        if (includePageSegments == null) {
-            includePageSegments = new java.util.ArrayList/*<IncludePageSegment>*/();
-        }
+    public void createIncludePageSegment(String name, int x, int y) {
+        IncludePageSegment ips = factory.createIncludePageSegment(name, x, y);
         includePageSegments.add(ips);
     }
 
@@ -257,8 +261,8 @@
             /**
              * Every page object must have an ActiveEnvironmentGroup
              */
-            this.activeEnvironmentGroup = new ActiveEnvironmentGroup(
-                    width, height, widthRes, heightRes);
+            this.activeEnvironmentGroup
+                = factory.createActiveEnvironmentGroup(width, height, widthRes, heightRes);
 
             if (rotation != 0) {
                 switch (rotation) {
@@ -280,7 +284,7 @@
 
     /**
      * Returns an indication if the page is complete
-     * 
+     *
      * @return whether this page is complete
      */
     public boolean isComplete() {
@@ -289,7 +293,7 @@
 
     /**
      * Returns the height of the page
-     * 
+     *
      * @return the height of the page
      */
     public int getHeight() {
@@ -298,7 +302,7 @@
 
     /**
      * Returns the width of the page
-     * 
+     *
      * @return the width of the page
      */
     public int getWidth() {
@@ -307,48 +311,30 @@
 
     /**
      * Returns the rotation of the page
-     * 
+     *
      * @return the rotation of the page
      */
     public int getRotation() {
         return rotation;
     }
-    
+
     /** {@inheritDoc} */
     protected void writeContent(OutputStream os) throws IOException {
         super.writeContent(os);
         if (this instanceof PageObject || this instanceof Overlay) {
-            getActiveEnvironmentGroup().write(os);
+            getActiveEnvironmentGroup().writeToStream(os);
         }
         writeObjects(this.includePageSegments, os);
         writeObjects(this.tagLogicalElements, os);
-        
-        // Write objects from cache
-        Iterator it = objects.iterator();
-        if (it.hasNext()) {
-            ResourceStore store = resourceManager.getStore();
-            do {
-                Object obj = it.next();
-                if (obj instanceof Writable) {
-                    Writable writableObject = (Writable)obj;
-                    writableObject.write(os);
-                } else if (obj instanceof StoreInfo) {
-                    StoreInfo storeInfo = (StoreInfo)obj;
-                    store.writeToStream(storeInfo, os);
-                }
-            } while (it.hasNext());
-        }
+        writeObjects(this.objects, os);
     }
-    
+
     /**
      * Adds an AFP object reference to this page
-     * 
+     *
      * @param obj an AFP object
      */
-    protected void addObject(Object obj) {
-        if (objects == null) {
-            this.objects = new java.util.ArrayList();
-        }
+    public void addObject(Object obj) {
         objects.add(obj);
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractPreparedObjectContainer.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,7 +29,7 @@
  */
 public abstract class AbstractPreparedObjectContainer extends AbstractNamedAFPObject
 implements PreparedAFPObject {
-    
+
     /** list of objects contained within this container */
     protected List/*<PreparedAFPObject>*/ objects = null;
 
@@ -41,18 +41,16 @@
 
     /**
      * Named constructor
-     * 
+     *
      * @param name the name of the container
      */
     protected AbstractPreparedObjectContainer(String name) {
         super(name);
     }
-    
+
     /** {@inheritDoc} */
     protected void writeContent(OutputStream os) throws IOException {
-        if (objects != null) {
-            super.writeObjects(objects, os);
-        }
+        super.writeObjects(objects, os);
     }
 
     private List/*<PreparedAFPObject>*/ getObjects() {
@@ -61,10 +59,10 @@
         }
         return this.objects;
     }
-    
+
     /**
      * Adds a given prepared object to this container
-     * 
+     *
      * @param preparedObject the prepared object
      * @return the drawingOrder if it was added, null otherwise
      */
@@ -72,10 +70,10 @@
         getObjects().add(preparedObject);
         return preparedObject;
     }
-    
+
     /**
      * Returns the current data length
-     * 
+     *
      * @return the current data length of this container including
      * all enclosed objects (and their containers)
      */
@@ -91,5 +89,5 @@
             }
         }
         return dataLen;
-    } 
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceEnvironmentGroupContainer.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,11 +22,10 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.render.afp.modca.resource.ResourceManager;
 
 /**
- * An abstract class which encapsulates the common features of 
- * Document and PageGroup resource containers 
+ * An abstract class which encapsulates the common features of
+ * Document and PageGroup resource containers
  */
 public abstract class AbstractResourceEnvironmentGroupContainer
     extends AbstractResourceGroupContainer {
@@ -38,17 +37,18 @@
 
     /**
      * Main constructor
-     * 
-     * @param resourceManager the resource manager 
+     *
+     * @param factory the object factory
      * @param name the name of this resource container
      */
-    public AbstractResourceEnvironmentGroupContainer(ResourceManager resourceManager, String name) {
-        super(resourceManager, name);
+    public AbstractResourceEnvironmentGroupContainer(
+            Factory factory, String name) {
+        super(factory, name);
     }
 
     /**
      * Adds a page to the resource container.
-     * 
+     *
      * @param page - the Page object
      */
     public void addPage(PageObject page) {
@@ -57,7 +57,7 @@
 
     /**
      * Adds a PageGroup to the resource container.
-     * 
+     *
      * @param pageGroup the PageGroup object
      */
     public void addPageGroup(PageGroup pageGroup) {
@@ -78,13 +78,13 @@
     protected void writeContent(OutputStream os) throws IOException {
         super.writeContent(os);
         if (resourceEnvironmentGroup != null) {
-            resourceEnvironmentGroup.write(os);
+            resourceEnvironmentGroup.writeToStream(os);
         }
     }
-    
+
     /**
      * Returns the resource environment group
-     * 
+     *
      * @return the resource environment group
      */
     protected ResourceEnvironmentGroup getResourceEnvironmentGroup() {
@@ -92,5 +92,5 @@
             this.resourceEnvironmentGroup = new ResourceEnvironmentGroup();
         }
         return this.resourceEnvironmentGroup;
-    }    
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractResourceGroupContainer.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,41 +22,40 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.render.afp.modca.resource.ResourceManager;
 
 /**
  * An abstract container of resource objects
  */
 public abstract class AbstractResourceGroupContainer extends AbstractPageObject {
 
-    /**
-     * The resource group object
-     */
+    /** the resource group object */
     private ResourceGroup resourceGroup = null;
 
     /**
      * Default constructor
+     *
+     * @param factory the object factory
      */
-    public AbstractResourceGroupContainer() {
-        super();
+    public AbstractResourceGroupContainer(Factory factory) {
+        super(factory);
     }
 
     /**
      * Named constructor
-     * 
-     * @param resourceManager the resource manager
+     *
+     * @param factory the object factory
      * @param name the name of this resource container
      */
-    public AbstractResourceGroupContainer(ResourceManager resourceManager, String name) {
-        super(resourceManager, name);
+    public AbstractResourceGroupContainer(Factory factory, String name) {
+        super(factory, name);
     }
 
     /**
      * Construct a new page object for the specified name argument, the page
      * name should be an 8 character identifier.
-     * 
-     * @param resourceManager
-     *            the resource manager
+     *
+     * @param factory
+     *            the object factory
      * @param name
      *            the name of the page.
      * @param width
@@ -70,14 +69,14 @@
      * @param heightRes
      *            the height resolution of the page.
      */
-    public AbstractResourceGroupContainer(ResourceManager resourceManager, String name, int width, int height,
-            int rotation, int widthRes, int heightRes) {
-        super(resourceManager, name, width, height, rotation, widthRes, heightRes);
+    public AbstractResourceGroupContainer(Factory factory,
+            String name, int width, int height, int rotation, int widthRes, int heightRes) {
+        super(factory, name, width, height, rotation, widthRes, heightRes);
     }
 
     /**
      * Return the number of resources in this container
-     * 
+     *
      * @return the number of resources in this container
      */
     protected int getResourceCount() {
@@ -86,30 +85,32 @@
         }
         return 0;
     }
-    
+
     /**
      * Returns true if this resource group container contains resources
-     * 
+     *
      * @return true if this resource group container contains resources
      */
     protected boolean hasResources() {
         return resourceGroup != null && resourceGroup.getResourceCount() > 0;
     }
-    
+
     /**
+     * Returns the resource group in this resource group container
+     *
      * @return the resource group in this resource group container
      */
     protected ResourceGroup getResourceGroup() {
         if (resourceGroup == null) {
-            resourceGroup = resourceManager.getFactory().createResourceGroup();
+            resourceGroup = factory.createResourceGroup();
         }
         return resourceGroup;
     }
-    
+
     /** {@inheritDoc} */
     protected void writeContent(OutputStream os) throws IOException {
         if (resourceGroup != null) {
-            resourceGroup.write(os);
+            resourceGroup.writeToStream(os);
         }
         super.writeContent(os);
     }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AbstractStructuredAFPObject.java Wed Aug 27 05:35:44 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,7 +19,6 @@
 
 package org.apache.fop.render.afp.modca;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
@@ -27,6 +26,7 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet;
 import org.apache.fop.render.afp.modca.triplets.MappingOptionTriplet;
 import org.apache.fop.render.afp.modca.triplets.MeasurementUnitsTriplet;
@@ -34,16 +34,17 @@
 import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet;
 import org.apache.fop.render.afp.modca.triplets.StrucFlgs;
 import org.apache.fop.render.afp.modca.triplets.Triplet;
+import org.apache.fop.render.afp.tools.BinaryUtils;
 
 /**
  * An abstract class encapsulating an MODCA structured object
  */
-public abstract class AbstractStructuredAFPObject extends AbstractAFPObject {    
+public abstract class AbstractStructuredAFPObject extends AbstractAFPObject {
     /**
      * list of object triplets
      */
     protected List/*<Triplet>*/ triplets = null;
-    
+
     /**
      * triplet data created from triplet list
      */
@@ -54,10 +55,10 @@
      */
     protected AbstractStructuredAFPObject() {
     }
-    
+
     /**
      * Returns the triplet data length
-     * 
+     *
      * @return the triplet data length
      */
     protected int getTripletDataLength() {
@@ -73,10 +74,10 @@
         }
         return 0;
     }
-    
+
     /**
      * Returns the triplet data
-     * 
+     *
      * @return the triplet data
      * @throws IOException throws an I/O exception if one occurred
      */
@@ -88,10 +89,10 @@
         }
         return this.tripletData;
     }
-    
+
     /**
      * Writes any triplet data
-     * 
+     *
      * @param os The stream to write to
      * @throws IOException The stream to write to
      */
@@ -100,12 +101,12 @@
             os.write(tripletData);
         } else if (triplets != null) {
             writeObjects(triplets, os);
-        }        
+        }
     }
 
     /**
      * Helper method to write the start of the Object.
-     * 
+     *
      * @param os The stream to write to
      * @throws IOException throws an I/O exception if one occurred
      */
@@ -115,7 +116,7 @@
 
     /**
      * Helper method to write the end of the Object.
-     * 
+     *
      * @param os The stream to write to
      * @throws IOException an I/O exception if one occurred
      */
@@ -124,21 +125,16 @@
 
     /**
      * Helper method to write the contents of the Object.
-     * 
+     *
      * @param os The stream to write to
      * @throws IOException throws an I/O exception if one occurred
      */
     protected void writeContent(OutputStream os) throws IOException {
         writeTriplets(os);
     }
-    
-    /**
-     * Accessor method to write the AFP datastream for this structure field object
-     * 
-     * @param os The stream to write to
-     * @throws IOException in the event that an I/O exception occurred
-     */
-    public void write(OutputStream os) throws IOException {
+
+    /** {@inheritDoc} */
+    public void writeToStream(OutputStream os) throws IOException {
         writeStart(os);
         writeContent(os);
         writeEnd(os);
@@ -146,7 +142,7 @@
 
     /**
      * Returns the first matching triplet found in the structured field triplet list
-     *  
+     *
      * @param tripletId the triplet identifier
      */
     private Triplet getTriplet(byte tripletId) {
@@ -159,20 +155,20 @@
         }
         return null;
     }
-    
+
     /**
      * Returns true of this structured field has the given triplet
-     * 
+     *
      * @param tripletId the triplet identifier
      * @return true if the structured field has the given triplet
      */
-    private boolean hasTriplet(byte tripletId) {
+    public boolean hasTriplet(byte tripletId) {
         return getTriplet(tripletId) != null;
     }
 
     /**
      * Adds a triplet to this structured object
-     * 
+     *
      * @param triplet the triplet to add
      */
     private void addTriplet(Triplet triplet) {
@@ -181,10 +177,10 @@
 
     /**
      * Adds a list of triplets to the triplets contained within this structured field
-     * 
+     *
      * @param tripletCollection a collection of triplets
      */
-    private void addTriplets(Collection/*<Triplet>*/ tripletCollection) {
+    public void addTriplets(Collection/*<Triplet>*/ tripletCollection) {
         if (tripletCollection != null) {
             getTriplets().addAll(tripletCollection);
         }
@@ -197,10 +193,10 @@
         }
         return triplets;
     }
-        
+
     /**
      * Sets the fully qualified name of this resource
-     * 
+     *
      * @param fqnType the fully qualified name type of this resource
      * @param fqnFormat the fully qualified name format of this resource
      * @param fqName the fully qualified name of this resource
@@ -219,10 +215,10 @@
         log.warn(this + " has no fully qualified name");
         return null;
     }
-    
+
     /**
      * Sets the objects classification
-     * 
+     *
      * @param objectClass the classification of the object
      * @param objectType the MOD:CA registry object type entry for the given
      *        object/component type of the object
@@ -235,18 +231,18 @@
 
     /**
      * Sets the objects classification with the default structure flags
-     * 
+     *
      * @param objectClass the classification of the object
      * @param objectType the MOD:CA registry object type entry for the given
      *        object/component type of the object
      */
     public void setObjectClassification(byte objectClass, Registry.ObjectType objectType) {
-        setObjectClassification(objectClass, objectType, StrucFlgs.getDefault());
+        setObjectClassification(objectClass, objectType, StrucFlgs.DEFAULT);
     }
-        
+
     /**
      * Sets the extent of an object area in the X and Y directions
-     * 
+     *
      * @param x the x direction extent
      * @param y the y direction extent
      */
@@ -256,7 +252,7 @@
 
     /**
      * Sets the measurement units used to specify the units of measure
-     * 
+     *
      * @param xRes units per base on the x-axis
      * @param yRes units per base on the y-axis
      */
@@ -266,16 +262,16 @@
 
     /**
      * Sets the mapping option
-     * 
+     *
      * @param optionValue the mapping option value
      */
     public void setMappingOption(byte optionValue) {
         addTriplet(new MappingOptionTriplet(optionValue));
     }
-    
+
     /**
      * Sets a comment on this resource
-     * 
+     *
      * @param comment a comment string
      */
     public void setComment(String comment) {
@@ -285,4 +281,49 @@
             log.error(e.getMessage());
         }
     }
+
+    /**
+     * Writes data chunks to a given outputstream
+     *
+     * @param data the data
+     * @param dataHeader the header data
+     * @param lengthOffset offset of length field in data chunk
+     * @param maxChunkLength the maximum chunk length
+     * @param os the outputstream to write to
+     * @throws IOException thrown if an I/O exception of some sort has occurred.
+     */
+    protected static void writeChunksToStream(byte[] data, byte[] dataHeader,
+            int lengthOffset, int maxChunkLength, OutputStream os) throws IOException {
+        int dataLength = data.length;
+        int numFullChunks = dataLength / maxChunkLength;
+        int lastChunkLength = dataLength % maxChunkLength;
+
+        int headerLen = dataHeader.length - lengthOffset;
+        // length field is just before data so do not include in data length
+        if (headerLen == 2) {
+            headerLen = 0;
+        }
+
+        byte[] len;
+        int off = 0;
+        if (numFullChunks > 0) {
+            // write out full data chunks
+            len = BinaryUtils.convert(headerLen + maxChunkLength, 2);
+            dataHeader[lengthOffset] = len[0]; // Length byte 1
+            dataHeader[lengthOffset + 1] = len[1]; // Length byte 2
+            for (int i = 0; i < numFullChunks; i++, off += maxChunkLength) {
+                os.write(dataHeader);
+                os.write(data, off, maxChunkLength);
+            }
+        }
+
+        if (lastChunkLength > 0) {
+            // write last data chunk
+            len = BinaryUtils.convert(headerLen + lastChunkLength, 2);
+            dataHeader[lengthOffset] = len[0]; // Length byte 1
+            dataHeader[lengthOffset + 1] = len[1]; // Length byte 2
+            os.write(dataHeader);
+            os.write(data, off, lastChunkLength);
+        }
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java?rev=689459&r1=689458&r2=689459&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ActiveEnvironmentGroup.java Wed Aug 27 05:35:44 2008
@@ -40,66 +40,44 @@
  */
 public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup {
 
-    /**
-     * Default name for the active environment group
-     */
-    private static final String DEFAULT_NAME = "AEG00001";
-
-    /**
-     * The collection of MapCodedFont objects
-     */
-    private List mapCodedFonts = null;
+    /** The collection of MapCodedFont objects */
+    private List/*<MapCodedFonts>*/ mapCodedFonts = null;
 
-    /**
-     * The collection of MapDataResource objects
-     */
-    private List mapDataResources = null;
+    /** the collection of MapDataResource objects */
+    private final List mapDataResources = null;
 
-    /**
-     * The Object Area Descriptor for the active environment group
-     */
+    /** the Object Area Descriptor for the active environment group */
     private ObjectAreaDescriptor objectAreaDescriptor = null;
 
-    /**
-     * The Object Area Position for the active environment group
-     */
+    /** the Object Area Position for the active environment group */
     private ObjectAreaPosition objectAreaPosition = null;
 
-    /**
-     * The PresentationTextDescriptor for the active environment group
-     */
+    /** the PresentationTextDescriptor for the active environment group */
     private PresentationTextDescriptor presentationTextDataDescriptor = null;
 
-    /**
-     * The PageDescriptor for the active environment group
-     */
+    /** the PageDescriptor for the active environment group */
     private PageDescriptor pageDescriptor = null;
 
-    /**
-     * Default constructor for the ActiveEnvironmentGroup.
-     * 
-     * @param width the page width
-     * @param height the page height
-     * @param widthRes the page width resolution
-     * @param heightRes the page height resolution
-     */
-    public ActiveEnvironmentGroup(int width, int height, int widthRes, int heightRes) {
-        this(DEFAULT_NAME, width, height, widthRes, heightRes);
-    }
+    /** the resource manager */
+    private final Factory factory;
 
     /**
      * Constructor for the ActiveEnvironmentGroup, this takes a
      * name parameter which must be 8 characters long.
-     * 
+     *
+     * @param factory the object factory
      * @param name the active environment group name
      * @param width the page width
      * @param height the page height
      * @param widthRes the page width resolution
      * @param heightRes the page height resolution
      */
-    public ActiveEnvironmentGroup(String name, int width, int height, int widthRes, int heightRes) {
+    public ActiveEnvironmentGroup(Factory factory,
+            String name, int width, int height, int widthRes, int heightRes) {
         super(name);
 
+        this.factory = factory;
+
         // Create PageDescriptor
         pageDescriptor = new PageDescriptor(width, height, widthRes, heightRes);
 
@@ -114,7 +92,7 @@
 
     /**
      * Set the position of the object area
-     * 
+     *
      * @param x the x offset
      * @param y the y offset
      * @param rotation the rotation
@@ -127,7 +105,7 @@
     /**
      * Accessor method to obtain the PageDescriptor object of the
      * active environment group.
-     * 
+     *
      * @return the page descriptor object
      */
     public PageDescriptor getPageDescriptor() {
@@ -137,7 +115,7 @@
     /**
      * Accessor method to obtain the PresentationTextDataDescriptor object of
      * the active environment group.
-     * 
+     *
      * @return the presentation text descriptor
      */
     public PresentationTextDescriptor getPresentationTextDataDescriptor() {
@@ -147,20 +125,20 @@
     /** {@inheritDoc} */
     public void writeContent(OutputStream os) throws IOException {
         super.writeTriplets(os);
-        
+
         writeObjects(mapCodedFonts, os);
         writeObjects(mapDataResources, os);
         writeObjects(mapPageOverlays, os);
-        
+
         if (pageDescriptor != null) {
-            pageDescriptor.write(os);            
+            pageDescriptor.writeToStream(os);
         }
         if (objectAreaDescriptor != null && objectAreaPosition != null) {
-            objectAreaDescriptor.write(os);
-            objectAreaPosition.write(os);
+            objectAreaDescriptor.writeToStream(os);
+            objectAreaPosition.writeToStream(os);
         }
         if (presentationTextDataDescriptor != null) {
-            presentationTextDataDescriptor.write(os);
+            presentationTextDataDescriptor.writeToStream(os);
         }
     }
 
@@ -185,16 +163,9 @@
         return mapCodedFonts;
     }
 
-//    private List getMapDataResources() {
-//        if (mapDataResources == null) {
-//            mapDataResources = new java.util.ArrayList();
-//        }
-//        return mapDataResources;
-//    }
-
     /**
      * Method to create a map coded font object
-     * 
+     *
      * @param fontRef the font number used as the resource identifier
      * @param font the font
      * @param size the point size of the font
@@ -203,14 +174,14 @@
     public void createFont(int fontRef, AFPFont font, int size, int orientation) {
         MapCodedFont mcf = getCurrentMapCodedFont();
         if (mcf == null) {
-            mcf = new MapCodedFont();
+            mcf = factory.createMapCodedFont();
             getMapCodedFonts().add(mcf);
         }
 
         try {
             mcf.addFont(fontRef, font, size, orientation);
         } catch (MaximumSizeExceededException msee) {
-            mcf = new MapCodedFont();
+            mcf = factory.createMapCodedFont();
             getMapCodedFonts().add(mcf);
 
             try {
@@ -225,7 +196,7 @@
     /**
      * Getter method for the most recent MapCodedFont added to the
      * Active Environment Group (returns null if no MapCodedFonts exist)
-     * 
+     *
      * @return the most recent Map Coded Font.
      */
     private MapCodedFont getCurrentMapCodedFont() {
@@ -236,7 +207,14 @@
             return null;
         }
     }
-    
+
+//  private List getMapDataResources() {
+//  if (mapDataResources == null) {
+//      mapDataResources = new java.util.ArrayList();
+//  }
+//  return mapDataResources;
+//}
+
 //    /**
 //     * Method to create a map data resource object
 //     * @param dataObjectAccessor a data object accessor

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ContainerDataDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ContainerDataDescriptor.java?rev=689459&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ContainerDataDescriptor.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ContainerDataDescriptor.java Wed Aug 27 05:35:44 2008
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render.afp.modca;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * Container data descriptor (to maintain compatibility with pre-year 2000 applications)
+ */
+public class ContainerDataDescriptor extends AbstractDescriptor {
+
+    /**
+     * Main constructor
+     *
+     * @param width the container data width
+     * @param height  the container data height
+     * @param widthRes the container width resolution
+     * @param heightRes the container height resolution
+     */
+    public ContainerDataDescriptor(int width, int height, int widthRes,
+            int heightRes) {
+        super(width, height, widthRes, heightRes);
+    }
+
+    /** {@inheritDoc} */
+    public void writeToStream(OutputStream os) throws IOException {
+        byte[] data = new byte[21];
+        copySF(data, Type.DESCRIPTOR, Category.IMAGE);
+
+        // SF length
+        byte[] len = BinaryUtils.convert(data.length - 1, 2);
+        data[1] = len[0];
+        data[2] = len[1];
+
+        data[9] = 0x00; // XocBase = 10 inches
+        data[10] = 0x00; // YocBase = 10 inches
+
+        // XocUnits
+        byte[] xdpi = BinaryUtils.convert(widthRes * 10, 2);
+        data[11] = xdpi[0];
+        data[12] = xdpi[1];
+
+        // YocUnits
+        byte[] ydpi = BinaryUtils.convert(heightRes * 10, 2);
+        data[13] = ydpi[0];
+        data[14] = ydpi[1];
+
+        // XocSize
+        byte[] x = BinaryUtils.convert(width, 3);
+        data[15] = x[0];
+        data[16] = x[1];
+        data[17] = x[2];
+
+        // YocSize
+        byte[] y = BinaryUtils.convert(height, 3);
+        data[18] = y[0];
+        data[19] = y[1];
+        data[20] = y[2];
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ContainerDataDescriptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ContainerDataDescriptor.java
------------------------------------------------------------------------------
    svn:keywords = Revision Id



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org