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/04/11 19:17:29 UTC

svn commit: r647228 [2/2] - in /xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp: ./ extensions/ modca/ modca/triplets/

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java?rev=647228&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectContainer.java Fri Apr 11 10:17:14 2008
@@ -0,0 +1,171 @@
+/*
+ * 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.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.fop.render.afp.DataObjectInfo;
+import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet;
+import org.apache.fop.render.afp.modca.triplets.StrucFlgs;
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * Object containers are MO:DCA objects that envelop and carry object data.
+ */
+public class ObjectContainer extends AbstractNamedAFPObject {
+    
+    /**
+     * the object container data
+     */
+    private ObjectContainerData objectContainerData;
+
+    /**
+     * Main constructor
+     * @param name the name of this object container
+     * @param dataObj the data object to reside within this object container
+     * @param info the data object info about the data object
+     */
+    public ObjectContainer(String name, AbstractDataObject dataObj, DataObjectInfo info) {
+        super(name);
+        
+        final boolean dataInContainer = true;
+        final boolean containerHasOEG = false;
+        final boolean dataInOCD = true;
+        StrucFlgs strucFlgs = new StrucFlgs(
+            dataInContainer, containerHasOEG, dataInOCD
+        );
+        ObjectTypeRegistry registry = ObjectTypeRegistry.getInstance();
+        ObjectTypeRegistry.ObjectType entry = registry.getObjectType(info);
+        super.setObjectClassification(
+            ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT,
+            entry, strucFlgs
+        );
+        
+        // write data object to object container data
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        // TODO: AC - fix
+//        dataObj.writeDataStream(bos);
+        this.objectContainerData = new ObjectContainerData(bos.toByteArray());
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    protected void writeStart(OutputStream os) throws IOException {
+        super.writeStart(os);
+        
+        // Set the total record length
+        byte[] len = BinaryUtils.convert(18 + getTripletDataLength(), 2);
+        byte[] data = new byte[] {
+            0x5A, // Structured field identifier
+            len[0], // Length byte 1
+            len[1], // Length byte 2
+            (byte)0xD3, // Structured field id byte 1
+            (byte)0xA8, // Structured field id byte 2
+            (byte)0x92, // Structured field id byte 3
+            0x00, // Flags
+            0x00, // Reserved
+            0x00, // Reserved
+            nameBytes[0],            
+            nameBytes[1],
+            nameBytes[2],
+            nameBytes[3],
+            nameBytes[4],
+            nameBytes[5],
+            nameBytes[6],
+            nameBytes[7],
+            0x00, // Reserved
+            0x00, // Reserved
+        };
+        os.write(data);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void writeContent(OutputStream os) throws IOException {
+        super.writeContent(os); // write triplets
+        if (objectContainerData != null) {
+            objectContainerData.writeDataStream(os);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void writeEnd(OutputStream os) throws IOException {
+        byte[] data = new byte[] {
+           0x5A, // Structured field identifier
+           0x00, // Length byte 1
+           0x10, // Length byte 2
+           (byte)0xD3, // Structured field id byte 1
+           (byte)0xA9, // Structured field id byte 2
+           (byte)0x92, // Structured field id byte 3
+           0x00, // Flags
+           0x00, // Reserved
+           0x00, // Reserved
+           nameBytes[0],            
+           nameBytes[1],
+           nameBytes[2],
+           nameBytes[3],
+           nameBytes[4],
+           nameBytes[5],
+           nameBytes[6],
+           nameBytes[7],
+        };
+        os.write(data);
+    }
+    
+    private class ObjectContainerData extends AbstractStructuredAFPObject {
+        /** the object data */
+        private byte[] objData = null;
+        
+        /**
+         * Main constructor
+         * @param objData the object data
+         */
+        public ObjectContainerData(byte[] objData) {
+            this.objData = objData;
+        }
+        
+        /**
+         * {@inheritDoc}
+         */
+        public void writeDataStream(OutputStream os) throws IOException {
+            // Set the total record length
+            byte[] len = BinaryUtils.convert(8 + objData.length, 2);
+            byte[] data = new byte[] {
+                0x5A, // Structured field identifier
+                len[0], // Length byte 1
+                len[1], // Length byte 2
+                (byte)0xD3, // Structured field id byte 1
+                (byte)0xEE, // Structured field id byte 2
+                (byte)0x92, // Structured field id byte 3
+                0x00, // Flags
+                0x00, // Reserved
+                0x00, // Reserved
+            };
+
+            os.write(data);
+        }
+    }
+}

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectTypeRegistry.java (from r644335, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Registry.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectTypeRegistry.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectTypeRegistry.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Registry.java&r1=644335&r2=647228&rev=647228&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Registry.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectTypeRegistry.java Fri Apr 11 10:17:14 2008
@@ -20,334 +20,185 @@
 package org.apache.fop.render.afp.modca;
 
 import java.io.UnsupportedEncodingException;
+import java.util.Collections;
 
 import org.apache.commons.logging.LogFactory;
+import org.apache.fop.render.afp.DataObjectInfo;
+import org.apache.fop.render.afp.ImageObjectInfo;
+import org.apache.xmlgraphics.util.MimeConstants;
 
 /**
  * MOD:CA object type registry
  */
-public final class Registry {
-    
-    /** IOB supported object types */
-    public static final byte IOCA_FS10 = 5;
-    public static final byte IOCA_FS11 = 11;
-    public static final byte IOCA_FS45 = 12;
-    public static final byte DIB_WIN = 17; //device independent bitmap
-    public static final byte DIB_OS2 = 18;
-    public static final byte PCX = 19;
-    public static final byte GIF = 22;
-    public static final byte JFIF = 23; // jpeg file interchange format 
-    public static final byte PDF_SINGLE_PAGE = 25; 
-    public static final byte PCL_PAGE_OBJECT = 34; 
-    public static final byte EPS_TRANS = 48;
-    public static final byte PDF_SINGLE_PAGE_TRANS = 49;
-    public static final byte JPEG2000 = 58;
+public final class ObjectTypeRegistry {
+    /** IOB supported object types */    
+    private static final byte COMPID_GIF = 22;
+    private static final byte COMPID_JFIF = 23; // jpeg file interchange format 
+    private static final byte COMPID_PDF_SINGLE_PAGE = 25; 
+    private static final byte COMPID_PCL_PAGE_OBJECT = 34; 
     
     /** IOB unsupported object types */
-    public static final byte EPS = 13;
-    public static final byte TIFF = 14;
-    public static final byte COM_SETUP_FILE = 15;
-    public static final byte TAPE_LABEL_SETUP_FILE = 16;
-    public static final byte CMT = 20; // color mapping table
-    public static final byte ANACOMP_CONTROL_RECORD = 24; 
-    public static final byte PDF_RESOURCE_OBJECT = 26; 
-    public static final byte IOCA_FS42 = 45;
-    public static final byte RESIDENT_COLOR_PROFILE = 46;
-    public static final byte IOCA_FS45_TILE_RESOURCE = 47;
-    public static final byte FONT = 51;
-    public static final byte FONT_COLLECTION = 53;
-    public static final byte RESOURCE_ACCESS_TABLE = 54; 
-    public static final byte IOCA_FS40 = 55;
-    public static final byte UP3I_PRINT_DATA = 56;
-    public static final byte COLOR_MANAGEMENT_RESOURCE = 57;
-
-    
-    /** internal mapping array references */
-    private static final int COMPONENT_ID = 0;
-    private static final int OBJECT_TYPE_NAME = 1;
-    private static final int OBJECT_ID = 2;
-    private static final int CAN_BE_INCLUDED = 3;
+    private static final byte COMPID_EPS = 13;
+    private static final byte COMPID_TIFF = 14;
 
-    private byte[][][] componentIdMap;
+    /** mime type entry mapping */
+    private java.util.Map/*<String, ObjectTypeRegistry.Entry>*/ mimeEntryMap
+        = Collections.synchronizedMap(
+                Collections.unmodifiableMap(
+                        new java.util.HashMap/*<String, ObjectTypeRegistry.Entry>*/()));
 
-    private static Registry instance = null;
+    private static ObjectTypeRegistry instance = null;
 
     /**
      * @return a single instance of Registry
      */
-    public static Registry getInstance() {
+    public static ObjectTypeRegistry getInstance() {
         synchronized (instance) {
             if (instance == null) {
-                instance = new Registry();
+                instance = new ObjectTypeRegistry();
             }            
         }
         return instance;
     }
     
-    private Registry() {
+    private ObjectTypeRegistry() {
         init();
     }
     
     private void init() {
-        try {
-            componentIdMap = new byte[][][] {
-            /* object type id (OID), object type name, compontent Id, can be included with IOB?, */ 
-            {
-                {IOCA_FS10},
-                "IOCA FS10".getBytes(AFPConstants.EBCIDIC_ENCODING),
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x05},
-                {1}
-            },
-            {
-                {IOCA_FS11},
-                "IOCA FS11".getBytes(AFPConstants.EBCIDIC_ENCODING),
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x0B},
-                {1}
-            },
-            {
-                {IOCA_FS45},
-                "IOCA FS45".getBytes(AFPConstants.EBCIDIC_ENCODING),
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x0C},
-                {1}
-            },
-            {
-                {EPS},
-                "Encapsulated Postscript".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x0D},
-                {0}
-            },
-            {
-                {TIFF},
-                "TIFF".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x0E},
-                {0}
-            },
-            {
-                {COM_SETUP_FILE},
-                "COM setup".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x0F},
-                {0}
-            },
-            {
-                {TAPE_LABEL_SETUP_FILE},
-                "Tape Label setup".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x10},
-                {0}
-            },
-            {
-                {DIB_WIN},
-                "DIB, Windows Version".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x11},
-                {1}
-            },
-            {
-                {DIB_OS2},
-                "DIB, OS/2 PM Version".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x12},
-                {1}
-            },
-            {
-                {PCX},
-                "PCX".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x13},
-                {1}
-            },
-            {
-                {CMT},
-                "Color Mapping Table (CMT)".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x14},
-                {0}
-            },
-            {
-                {GIF},
-                "GIF".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x16},
-                {1}
-            },
-            {
-                {JFIF},
-                "JFIF".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x17},
-                {1}
-            },
-            {
-                {ANACOMP_CONTROL_RECORD},
-                "AnaStak Control Record".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x18},
-                {0}
-            },
-            {
-                {PDF_SINGLE_PAGE},
-                "PDF Single-page Object".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x19},
-                {1}
-            },
-            {
-                {PDF_RESOURCE_OBJECT},
-                "PDF Resource Object".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x1A},
-                {0}
-            },
-            {
-                {PCL_PAGE_OBJECT},
-                "PCL Page Object".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x22},
-                {1}
-            },
-            {
-                {IOCA_FS42},
-                "IOCA FS42".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x2D},
-                {0}
-            },
-            {
-                {RESIDENT_COLOR_PROFILE},
-                "Resident Color Profile".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x2E},
-                {0}
-            },
-            {
-                {IOCA_FS45_TILE_RESOURCE},
-                "IOCA FS45".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x2E},
-                {0}
-            },
-            {
-                {EPS_TRANS},
-                "EPS with Transparency".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x30},
-                {1}
-            },
-            {
-                {PDF_SINGLE_PAGE_TRANS},
-                "PDF with Transparency".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x31},
-                {1}
-            },
-            {
-                {FONT},
-                "TrueType/OpenType Font".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x33},
-                {0}
-            },
-            {
-                {FONT_COLLECTION},
-                "TrueType/OpenType Font Collection".getBytes(
-                        AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x35},
-                {0}
-            },
-            {
-                {RESOURCE_ACCESS_TABLE},
-                "Resource Access Table".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x36},
-                {0}
-            },
-            {
-                {IOCA_FS40},
-                "IOCA FS40".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x37},
-                {0}
-            },
-            {
-                {UP3I_PRINT_DATA},
-                "IP3i Print Data".getBytes(AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x38},
-                {0}
-            },
-            {
-                {COLOR_MANAGEMENT_RESOURCE},
-                "Color Management Resource (CMR)".getBytes(
-                        AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x39},
-                {0}
-            },
-            {
-                {JPEG2000},
-                "JPEG2000 (JP2) File Format".getBytes(
-                        AFPConstants.EBCIDIC_ENCODING),                
-                {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x3A},
-                {1}
-            }
-            };
-        } catch (UnsupportedEncodingException e) {
-            // should never happen!
-            LogFactory.getLog("org.apache.fop.render.afp.modca.Registry").error(e.getMessage());
-        }        
-    }
-
-    private byte[][][] getComponentIdMap() {
-        if (componentIdMap == null) {
-            init();
-        }
-        return componentIdMap;
-    }
-
-    private byte[][] getMapData(byte compontentId) {
-        getComponentIdMap();
-        for (int i = 0; i < componentIdMap.length; i++) {
-            if (compontentId == componentIdMap[i][0][0]) {
-                return componentIdMap[i];
-            }
-        }
-        return null;
+        mimeEntryMap.put(
+                MimeConstants.MIME_EPS,
+                new ObjectType(
+                        COMPID_EPS,
+                        new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x0D},
+                        "Encapsulated Postscript",
+                        false
+                )
+        );
+        mimeEntryMap.put(
+                MimeConstants.MIME_TIFF,
+                new ObjectType(
+                        COMPID_TIFF,
+                        new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x0E},
+                        "TIFF",
+                        false
+                )
+        );
+        mimeEntryMap.put(
+                MimeConstants.MIME_GIF,
+                new ObjectType(
+                        COMPID_GIF,
+                        new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x16},
+                        "GIF",
+                        true
+                )
+        );
+        mimeEntryMap.put(
+                MimeConstants.MIME_JPEG,
+                new ObjectType(
+                        COMPID_JFIF,
+                        new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x17},
+                        "JFIF",
+                        true
+                )
+        );
+        mimeEntryMap.put(MimeConstants.MIME_PDF,
+                new ObjectType(
+                        COMPID_PDF_SINGLE_PAGE,
+                        new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x19},
+                        "PDF Single-page Object",
+                        true
+                )
+        );         
+        mimeEntryMap.put(
+                MimeConstants.MIME_PCL,
+                new ObjectType(
+                        COMPID_PCL_PAGE_OBJECT,
+                        new byte[] {0x06, 0x07, 0x2B, 0x12, 0x00, 0x04, 0x01, 0x01, 0x22},
+                        "PCL Page Object",
+                        true
+                )
+        );
     }
 
     /**
-     * Returns a registry Entry for a given componentId
-     * @param compontentId a compontent id
-     * @return the registry entry for a give componentId
+     * Returns the registry Entry for a given data object info
+     * 
+     * @param info
+     *            the data object info
+     * @return the registry Entry for a given data object info
      */
-    public Entry getEntry(byte compontentId) {
-        byte[][] data = getMapData(compontentId);
-        if (data != null) {
-            return new Registry.Entry(data);
+    public ObjectType getObjectType(DataObjectInfo info) {
+        ObjectType entry = null;
+        if (info instanceof ImageObjectInfo) {
+            ImageObjectInfo imageInfo = (ImageObjectInfo)info;
+            String mimeType = imageInfo.getMimeType();
+            entry = (ObjectType)mimeEntryMap.get(mimeType);
         }
-        return null;
+        return entry;
     }
-
+    
     /**
-     * Encapsulates a MOD:CA Registry Entry
+     * Encapsulates a MOD:CA Registry Object Type entry
      */
-    public final class Entry {
-        private byte[][] data;
-
+    public class ObjectType {
+        private byte componentId; 
+        private byte[] oid;
+        private byte[] name;
+        private boolean canBeIncluded;
+        
         /**
          * Main constructor
-         * @param the map data structure array
+         * @param componentId the component id of this object type
+         * @param oid the object id of this object type
+         * @param objectTypeName the object type name
+         * @param canBeIncluded true if this object can be included with an IOB structured field
          */
-        private Entry(byte[][] data) {
-            this.data = data;
+        public ObjectType(byte componentId, byte[] oid, String objectTypeName,
+                boolean canBeIncluded) {
+            this.componentId = componentId;
+            this.oid = oid;
+            try {
+                this.name = objectTypeName.getBytes(AFPConstants.EBCIDIC_ENCODING);
+            } catch (UnsupportedEncodingException e) {
+                // should never happen!
+                LogFactory.getLog("org.apache.fop.render.afp.modca.Registry.Entry").error(
+                        "character encoding error occurred on componentId "
+                        + componentId
+                        + " : "
+                        + e.getMessage());
+            }
+            this.canBeIncluded = canBeIncluded;
         }
-        
+                
         /**
          * Returns a MOD:CA object type OID from a given a componentId
          * @return the corresponding object type id for a given component id
          * or null if the component id is unknown and the object type OID was not found.
          */
         public byte[] getOID() {
-            return data[OBJECT_ID];
+            return this.oid;
         }
 
         /**
          * @return the object type name for the given componentId 
          */
-        public byte[] getObjectTypeName() {
-            return data[OBJECT_TYPE_NAME];
+        public byte[] getName() {
+            return this.name;
         }
 
         /**
          * @return the compontentId for this entry
          */
-        public byte[] getComponentId() {
-            return data[COMPONENT_ID];
+        public byte getComponentId() {
+            return this.componentId;
         }
 
         /**
          * @return true if this component can be included with an IOB structured field
          */
         public boolean canBeIncluded() {
-            return data[CAN_BE_INCLUDED][0] == 1;
+            return this.canBeIncluded;
         }
     }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageSegment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageSegment.java?rev=647228&r1=647227&r2=647228&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageSegment.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageSegment.java Fri Apr 11 10:17:14 2008
@@ -31,7 +31,7 @@
  */
 public class PageSegment extends AbstractNamedAFPObject {
 
-    private List objects = null;
+    private List/*<AbstractAFPObject>*/ objects = null;
     
     /**
      * Main constructor
@@ -42,14 +42,21 @@
     }
 
     /**
-     * Adds a resource object (image/graphic) to this page segment
-     * @param object the resource objec to add to this page segment
+     * @return a list of objects contained within this page segment
      */
-    public void addObject(AbstractAFPObject object) {
+    public List/*<AbstractAFPObject>*/ getObjects() {
         if (objects == null) {
             objects = new java.util.ArrayList();
         }
-        objects.add(object);
+        return objects;
+    }
+
+    /**
+     * Adds a resource object (image/graphic) to this page segment
+     * @param object the resource objec to add to this page segment
+     */
+    public void addObject(AbstractAFPObject object) {
+        getObjects().add(object);
     }
     
     /**
@@ -75,6 +82,14 @@
     /**
      * {@inheritDoc}
      */
+    protected void writeContent(OutputStream os) throws IOException {
+        super.writeContent(os);
+        writeObjects(objects, os);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     protected void writeEnd(OutputStream os) throws IOException {
         byte[] data = new byte[17];
         data[0] = 0x5A; // Structured field identifier
@@ -90,13 +105,5 @@
             data[9 + i] = nameBytes[i];
         }
         os.write(data);
-    }
-    
-    /**
-     * {@inheritDoc}
-     */
-    protected void writeContent(OutputStream os) throws IOException {
-        super.writeContent(os);
-        writeObjects(objects, os);
-    }
+    }    
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java?rev=647228&r1=647227&r2=647228&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PresentationTextData.java Fri Apr 11 10:17:14 2008
@@ -54,52 +54,50 @@
     private static final int MAX_SIZE = 8192;
 
     /**
-     * The afp data relating to this presentaion text data.
+     * The afp data relating to this presentation text data.
      */
-    private ByteArrayOutputStream _baos = new ByteArrayOutputStream(1024);
+    private ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
 
     /**
      * The current x coordinate.
      */
-    private int _currentXCoordinate = -1;
+    private int currentXCoordinate = -1;
 
     /**
      * The current y cooridnate
      */
-    private int _currentYCoordinate = -1;
+    private int currentYCoordinate = -1;
 
     /**
      * The current font
      */
-    private String _currentFont = "";
+    private String currentFont = "";
 
     /**
      * The current orientation
      */
-    private int _currentOrientation = 0;
+    private int currentOrientation = 0;
 
     /**
      * The current color
      */
-    private Color _currentColor = new Color(0, 0, 0);
+    private Color currentColor = new Color(0, 0, 0);
 
     /**
      * The current variable space increment
      */
-    private int _currentVariableSpaceCharacterIncrement = 0;
+    private int currentVariableSpaceCharacterIncrement = 0;
 
     /**
      * The current inter character adjustment
      */
-    private int _currentInterCharacterAdjustment = 0;
+    private int currentInterCharacterAdjustment = 0;
 
     /**
      * Default constructor for the PresentationTextData.
      */
     public PresentationTextData() {
-
         this(false);
-
     }
 
     /**
@@ -111,8 +109,7 @@
      *            The control sequence indicator.
      */
     public PresentationTextData(boolean controlInd) {
-
-        _baos.write(new byte[] { 0x5A, // Structured field identifier
+        baos.write(new byte[] { 0x5A, // Structured field identifier
             0x00, // Record length byte 1
             0x00, // Record length byte 2
             (byte) 0xD3, // PresentationTextData identifier byte 1
@@ -124,9 +121,8 @@
         }, 0, 9);
 
         if (controlInd) {
-            _baos.write(new byte[] { 0x2B, (byte) 0xD3 }, 0, 2);
+            baos.write(new byte[] { 0x2B, (byte) 0xD3 }, 0, 2);
         }
-
     }
 
     /**
@@ -140,16 +136,14 @@
      *            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)) {
+        if (String.valueOf(font).equals(currentFont)) {
             return;
         } else {
-            _currentFont = String.valueOf(font);
+            currentFont = String.valueOf(font);
         }
 
         afpdata.write(new byte[] { 0x03, (byte) 0xF1, font, }, 0, 3);
-
     }
 
     /**
@@ -162,15 +156,10 @@
      * @param afpdata
      *            The output stream to which data should be written.
      */
-    private void absoluteMoveInline(int coordinate,
-        ByteArrayOutputStream afpdata) {
-
+    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;
-
+        currentXCoordinate = coordinate;
     }
 
     /**
@@ -183,15 +172,10 @@
      * @param afpdata
      *            The output stream to which data should be written.
      */
-    private void absoluteMoveBaseline(int coordinate,
-        ByteArrayOutputStream afpdata) {
-
+    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;
-
+        currentYCoordinate = coordinate;
     }
 
     /**
@@ -204,21 +188,16 @@
      *            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);
-
     }
 
     /**
@@ -233,13 +212,10 @@
      * @param afpdata
      *            The output stream to which data should be written.
      */
-    private void drawBaxisRule(int length, int width,
-        ByteArrayOutputStream afpdata) {
-
+    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);
@@ -248,7 +224,6 @@
         afpdata.write(data2, 0, data2.length);
         // Rule width fraction
         afpdata.write(0x00);
-
     }
 
     /**
@@ -263,13 +238,10 @@
      * @param afpdata
      *            The output stream to which data should be written.
      */
-    private void drawIaxisRule(int length, int width,
-        ByteArrayOutputStream afpdata) {
-
+    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);
@@ -278,7 +250,6 @@
         afpdata.write(data2, 0, data2.length);
         // Rule width fraction
         afpdata.write(0x00);
-
     }
 
     /**
@@ -303,62 +274,60 @@
      * @throws MaximumSizeExceededException
      */
     public void createTextData(int fontNumber, int x, int y, int orientation,
-        Color col, int vsci, int ica, byte[] data)
-        throws MaximumSizeExceededException {
+        Color col, int vsci, int ica, byte[] data) throws MaximumSizeExceededException {
 
         ByteArrayOutputStream afpdata = new ByteArrayOutputStream();
 
-        if (_currentOrientation != orientation) {
+        if (currentOrientation != orientation) {
             setTextOrientation(orientation, afpdata);
-            _currentOrientation = orientation;
-            _currentXCoordinate = -1;
-            _currentYCoordinate = -1;
+            currentOrientation = orientation;
+            currentXCoordinate = -1;
+            currentYCoordinate = -1;
         }
 
         // Avoid unnecessary specification of the Y co-ordinate
-        if (y != _currentYCoordinate) {
+        if (y != currentYCoordinate) {
             absoluteMoveBaseline(y, afpdata);
-            _currentXCoordinate = -1;
+            currentXCoordinate = -1;
         }
 
         // Avoid unnecessary specification of the X co-ordinate
-        if (x != _currentXCoordinate) {
+        if (x != currentXCoordinate) {
             absoluteMoveInline(x, afpdata);
         }
 
         // Avoid unnecessary specification of the variable space increment
-        if (vsci != _currentVariableSpaceCharacterIncrement) {
+        if (vsci != currentVariableSpaceCharacterIncrement) {
             setVariableSpaceCharacterIncrement(vsci, afpdata);
-            _currentVariableSpaceCharacterIncrement = vsci;
+            currentVariableSpaceCharacterIncrement = vsci;
         }
 
         // Avoid unnecessary specification of the inter character adjustment
-        if (ica != _currentInterCharacterAdjustment) {
+        if (ica != currentInterCharacterAdjustment) {
             setInterCharacterAdjustment(ica, afpdata);
-            _currentInterCharacterAdjustment = ica;
+            currentInterCharacterAdjustment = ica;
         }
 
         // Avoid unnecessary specification of the text color
-        if (!col.equals(_currentColor)) {
+        if (!col.equals(currentColor)) {
             setExtendedTextColor(col, afpdata);
-            _currentColor = col;
+            currentColor = col;
         }
 
         setCodedFont(BinaryUtils.convert(fontNumber)[0], afpdata);
         addTransparentData(data, afpdata);
-        _currentXCoordinate = -1;
+        currentXCoordinate = -1;
 
         int s = afpdata.size();
 
-        if (_baos.size() + s > MAX_SIZE) {
-            _currentXCoordinate = -1;
-            _currentYCoordinate = -1;
+        if (baos.size() + s > MAX_SIZE) {
+            currentXCoordinate = -1;
+            currentYCoordinate = -1;
             throw new MaximumSizeExceededException();
         }
 
         byte[] outputdata = afpdata.toByteArray();
-        _baos.write(outputdata, 0, outputdata.length);
-
+        baos.write(outputdata, 0, outputdata.length);
     }
 
     /**
@@ -385,24 +354,24 @@
 
         ByteArrayOutputStream afpdata = new ByteArrayOutputStream();
 
-        if (_currentOrientation != orientation) {
+        if (currentOrientation != orientation) {
             setTextOrientation(orientation, afpdata);
-            _currentOrientation = orientation;
+            currentOrientation = orientation;
         }
 
         // Avoid unnecessary specification of the Y coordinate
-        if (y1 != _currentYCoordinate) {
+        if (y1 != currentYCoordinate) {
             absoluteMoveBaseline(y1, afpdata);
         }
 
         // Avoid unnecessary specification of the X coordinate
-        if (x1 != _currentXCoordinate) {
+        if (x1 != currentXCoordinate) {
             absoluteMoveInline(x1, afpdata);
         }
 
-        if (!col.equals(_currentColor)) {
+        if (!col.equals(currentColor)) {
             setExtendedTextColor(col, afpdata);
-            _currentColor = col;
+            currentColor = col;
         }
 
         if (y1 == y2) {
@@ -415,15 +384,14 @@
 
         int s = afpdata.size();
 
-        if (_baos.size() + s > MAX_SIZE) {
-            _currentXCoordinate = -1;
-            _currentYCoordinate = -1;
+        if (baos.size() + s > MAX_SIZE) {
+            currentXCoordinate = -1;
+            currentYCoordinate = -1;
             throw new MaximumSizeExceededException();
         }
 
         byte[] outputdata = afpdata.toByteArray();
-        _baos.write(outputdata, 0, outputdata.length);
-
+        baos.write(outputdata, 0, outputdata.length);
     }
 
     /**
@@ -440,11 +408,8 @@
      * @param afpdata
      *            The output stream to which data should be written.
      */
-    private void setTextOrientation(int orientation,
-        ByteArrayOutputStream afpdata) {
-
+    private void setTextOrientation(int orientation, ByteArrayOutputStream afpdata) {
         afpdata.write(new byte[] { 0x06, (byte) 0xF7, }, 0, 2);
-
         switch (orientation) {
             case 90:
                 afpdata.write(0x2D);
@@ -471,7 +436,6 @@
                 afpdata.write(0x00);
                 break;
         }
-
     }
 
     /**
@@ -528,7 +492,6 @@
             , b[0]
             , b[1]
         }, 0, 4);
-
     }
 
     /**
@@ -540,11 +503,8 @@
      * @param afpdata
      *            The output stream to which data should be written.
      */
-    private void setInterCharacterAdjustment(int incr,
-        ByteArrayOutputStream afpdata) {
-
+    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
@@ -552,25 +512,17 @@
             , 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
+     * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os)
-        throws IOException {
-
-        byte[] data = _baos.toByteArray();
+    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);
-
     }
 
     /**
@@ -583,17 +535,12 @@
      * @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) {
+        if (data.length + baos.size() > MAX_SIZE) {
             throw new MaximumSizeExceededException();
         }
-
-        _baos.write(data, 0, data.length);
-
+        baos.write(data, 0, data.length);
     }
-
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceEnvironmentGroup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceEnvironmentGroup.java?rev=647228&r1=647227&r2=647228&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceEnvironmentGroup.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceEnvironmentGroup.java Fri Apr 11 10:17:14 2008
@@ -95,7 +95,8 @@
      * @param obj the object to add
      */
     public void addObject(AbstractStructuredAFPObject obj) {
-        getMapDataResources().add(new MapDataResource(obj));
+        // TODO: AC - fix
+//        getMapDataResources().add(new MapDataResource(obj));
         getPreprocessPresentationObjects().add(new PreprocessPresentationObject(obj));
     }
         

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java?rev=647228&r1=647227&r2=647228&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceGroup.java Fri Apr 11 10:17:14 2008
@@ -21,10 +21,13 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Iterator;
 import java.util.Map;
 
-import org.apache.fop.render.afp.DataObjectParameters;
-import org.apache.fop.render.afp.ImageObjectParameters;
+import org.apache.fop.render.afp.DataObjectInfo;
+import org.apache.fop.render.afp.ImageObjectInfo;
+import org.apache.fop.render.afp.ResourceInfo;
 import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet;
 import org.apache.fop.render.afp.tools.StringUtils;
 import org.apache.xmlgraphics.image.codec.tiff.TIFFImage;
@@ -42,13 +45,19 @@
     /**
      * Mapping of resource uri to data resource object (image/graphic) 
      */
-    private Map/*<String,AbstractAFPObject>*/ resourceMap = null;
+    private Map/*<String,IncludeObject>*/ resourceMap = null;
+
+    /**
+     * This resource groups container
+     */
+    private AbstractResourceGroupContainer container = null;
 
     /**
      * Default constructor
+     * @param container the resource group container 
      */
-    public ResourceGroup() {
-        this(DEFAULT_NAME);
+    public ResourceGroup(AbstractResourceGroupContainer container) {
+        this(DEFAULT_NAME, container);
     }
 
     /**
@@ -56,159 +65,86 @@
      * name parameter which must be 8 characters long.
      * @param name the resource group name
      */
-    public ResourceGroup(String name) {
+    public ResourceGroup(String name, AbstractResourceGroupContainer container) {
         super(name);
+        this.container = container;
     }
 
-    private static final String IMAGE_NAME_PREFIX = "IMG";
-    private static final String GRAPHIC_NAME_PREFIX = "GRA";
-    private static final String PAGE_SEGMENT_NAME_PREFIX = "PAG";
-    private static final String BARCODE_NAME_PREFIX = "BAR";
-    private static final String OTHER_NAME_PREFIX = "OTH";
+    private static final String RESOURCE_NAME_PREFIX = "RES";
+    private static final String INCLUDE_NAME_PREFIX = "INC";
     
     /**
-     * Converts a byte array containing 24 bit RGB image data to a grayscale
-     * image.
-     * 
-     * @param io
-     *            the target image object
-     * @param raw
-     *            the buffer containing the RGB image data
-     * @param width
-     *            the width of the image in pixels
-     * @param height
-     *            the height of the image in pixels
-     * @param bitsPerPixel
-     *            the number of bits to use per pixel
-     */
-    private static void convertToGrayScaleImage(ImageObject io, byte[] raw, int width,
-            int height, int bitsPerPixel) {
-        int pixelsPerByte = 8 / bitsPerPixel;
-        int bytewidth = (width / pixelsPerByte);
-        if ((width % pixelsPerByte) != 0) {
-            bytewidth++;
-        }
-        byte[] bw = new byte[height * bytewidth];
-        byte ib;
-        for (int y = 0; y < height; y++) {
-            ib = 0;
-            int i = 3 * y * width;
-            for (int x = 0; x < width; x++, i += 3) {
-
-                // see http://www.jguru.com/faq/view.jsp?EID=221919
-                double greyVal = 0.212671d * ((int) raw[i] & 0xff) + 0.715160d
-                        * ((int) raw[i + 1] & 0xff) + 0.072169d
-                        * ((int) raw[i + 2] & 0xff);
-                switch (bitsPerPixel) {
-                case 1:
-                    if (greyVal < 128) {
-                        ib |= (byte) (1 << (7 - (x % 8)));
-                    }
-                    break;
-                case 4:
-                    greyVal /= 16;
-                    ib |= (byte) ((byte) greyVal << ((1 - (x % 2)) * 4));
-                    break;
-                case 8:
-                    ib = (byte) greyVal;
-                    break;
-                default:
-                    throw new UnsupportedOperationException(
-                            "Unsupported bits per pixel: " + bitsPerPixel);
-                }
-
-                if ((x % pixelsPerByte) == (pixelsPerByte - 1)
-                        || ((x + 1) == width)) {
-                    bw[(y * bytewidth) + (x / pixelsPerByte)] = ib;
-                    ib = 0;
-                }
-            }
-        }
-        io.setImageIDESize((byte) bitsPerPixel);
-        io.setImageData(bw);
-    }
-
-    /**
-     * Helper method to create an image on the current container and to return
+     * Helper method to create a new resource object in the current container and to return
      * the object.
-     * @param params the set of image object parameters
-     * @return a newly created image object
+     * @return a newly created resource object
      */
-    private ImageObject createImage(ImageObjectParameters params) {
-        String name = IMAGE_NAME_PREFIX
-                + StringUtils.lpad(String.valueOf(getResourceCount() + 1), '0', 5);
-        ImageObject imageObj = new ImageObject(name);
-        if (params.hasCompression()) {
-            int compression = params.getCompression();
-            switch (compression) {
-            case TIFFImage.COMP_FAX_G3_1D:
-                imageObj.setImageEncoding(ImageContent.COMPID_G3_MH);
-                    break;
-                case TIFFImage.COMP_FAX_G3_2D:
-                    imageObj.setImageEncoding(ImageContent.COMPID_G3_MR);
-                    break;
-                case TIFFImage.COMP_FAX_G4_2D:
-                    imageObj.setImageEncoding(ImageContent.COMPID_G3_MMR);
-                    break;
-                default:
-                    throw new IllegalStateException(
-                            "Invalid compression scheme: " + compression);
-            }
-        }
-        imageObj.setFullyQualifiedName(
-                FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF,
-                FullyQualifiedNameTriplet.FORMAT_URL, params.getUri());
-        imageObj.setImageParameters(params.getWidthRes(), params.getHeightRes(), 
-                params.getImageDataWidth(), params.getImageDataHeight());
-        if (params.isColor()) {
-            imageObj.setImageIDESize((byte)24);
-            imageObj.setImageData(params.getData());
-        } else {
-            convertToGrayScaleImage(imageObj, params.getData(),
-                    params.getImageDataWidth(), params.getImageDataHeight(),
-                    params.getBitsPerPixel());
-        }
-        return imageObj;
-    }
-    
-    /**
-     * Helper method to create a graphic in the current container and to return
-     * the object.
-     * @param params the data object parameters
-     * @return a newly created graphics object
-     */
-    private GraphicsObject createGraphic(DataObjectParameters params) {
-        String name = GRAPHIC_NAME_PREFIX
-            + StringUtils.lpad(String.valueOf(getResourceCount() + 1), '0', 5);
-        GraphicsObject graphicsObj = new GraphicsObject(name);
-        return graphicsObj;
-    }
+    private ResourceObject createResourceObject() {
+        String name = RESOURCE_NAME_PREFIX
+        + StringUtils.lpad(String.valueOf(getResourceCount() + 1), '0', 5);
+        ResourceObject resource = new ResourceObject(name);
+        return resource;
+    }
+    
+//    /**
+//     * Helper method to create a new resource object in the current container and to return
+//     * the object.
+//     * @return a newly created resource object
+//     */
+//    private IncludeObject createIncludeObject() {
+//        String name = INCLUDE_NAME_PREFIX
+//        + StringUtils.lpad(String.valueOf(getResourceCount() + 1), '0', 5);
+//        IncludeObject includeObj = new IncludeObject(name);
+//        return includeObj;
+//    }
 
     /**
-     * Adds a data object to this resource group
-     * @param params the data object parameters
+     * Creates a data object in this resource group
+     * @param info the data object info
      * @return an include object reference
      */
-    public IncludeObject addObject(DataObjectParameters params) {
-        ResourceObject resourceObj = (ResourceObject)getResourceMap().get(params.getUri());
-        if (resourceObj == null) {
+    public IncludeObject createObject(DataObjectInfo info) {
+        IncludeObject includeObj = (IncludeObject)getResourceMap().get(info.getUri());
+        if (includeObj == null) {
             AbstractDataObject dataObj;
-            if (params instanceof ImageObjectParameters) {
-                dataObj = createImage((ImageObjectParameters)params);
+            if (info instanceof ImageObjectInfo) {
+                dataObj = container.createImage((ImageObjectInfo)info);
+            } else {
+                dataObj = container.createGraphic();
+            }
+
+            ResourceInfo resourceInfo = info.getResourceInfo();
+            String resourceName = resourceInfo.getName();
+            if (resourceInfo.isExternal()) {
+                ObjectContainer objectContainer = new ObjectContainer(resourceName, dataObj, info);
             } else {
-                dataObj = createGraphic(params);
+                
             }
+            
+            // Wrap the data object in a page segment
+            PageSegment pageSegment = container.createPageSegment();
+            pageSegment.addObject(dataObj);
+
+            
             // TODO: AC - rotation?
             int rotation = 0;
-            dataObj.setViewport(params.getX(), params.getY(),
-                    params.getWidth(), params.getHeight(),
-                    params.getWidthRes(), params.getHeightRes(), rotation);
+            dataObj.setViewport(info.getX(), info.getY(),
+                    info.getWidth(), info.getHeight(),
+                    info.getWidthRes(), info.getHeightRes(), rotation);
             
-            // Wrap the data object in a resource object
-            resourceObj = new ResourceObject(dataObj.getName(), dataObj);
-            getResourceMap().put(params.getUri(), resourceObj);
+            includeObj.setResourceInfo(resourceInfo);
+
+            // If resource is to be stored externally,
+            // wrap the page segment in a resource object 
+            if (resourceInfo.isExternal()) {
+                ResourceObject resource = createResourceObject();
+                resource.setReferencedObject(pageSegment);
+                includeObj = new IncludeObject(resource);
+            } else {
+                includeObj = new IncludeObject(pageSegment);
+            }
+            // Add include object to resource map
+            getResourceMap().put(info.getUri(), includeObj);                
         }
-        IncludeObject includeObj = new IncludeObject(resourceObj);
         //includeObj.setObjectAreaSize(params.getX(), params.getY());
         return includeObj;
     }
@@ -218,7 +154,7 @@
      */
     public int getResourceCount() {
         if (resourceMap != null) {
-           return resourceMap.size(); 
+            return resourceMap.size(); 
         }
         return 0;
     }
@@ -250,7 +186,13 @@
      */
     public void writeContent(OutputStream os) throws IOException {
         if (resourceMap != null) {
-            super.writeObjects(resourceMap.values(), os);
+            Collection includes = resourceMap.values();
+            Iterator it = includes.iterator();
+            while (it.hasNext()) {
+                IncludeObject includeObj = (IncludeObject)it.next();
+                AbstractStructuredAFPObject obj = includeObj.getReferencedObject();
+                obj.writeDataStream(os);
+            }
         }
     }
 

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceObject.java?rev=647228&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceObject.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ResourceObject.java Fri Apr 11 10:17:14 2008
@@ -0,0 +1,195 @@
+/*
+ * 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.ResourceInfo;
+import org.apache.fop.render.afp.modca.triplets.Triplet;
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * This resource structured field begins an envelope that is used to carry
+ * resource objects in print-file-level (external) resource groups. 
+ */
+public class ResourceObject extends AbstractPreparedAFPObject {
+    
+    /**
+     * Resource object types
+     */
+    private static final byte GRAPHICS_OBJECT = 0x03;
+    private static final byte BARCODE_OBJECT = 0x05;
+    private static final byte IMAGE_OBJECT = 0x06;
+    private static final byte FONT_CHARACTER_SET_OBJECT = 0x40;
+    private static final byte CODE_PAGE_OBJECT = 0x41;
+    private static final byte CODED_FONT_OBJECT = 0x42;
+    private static final byte OBJECT_CONTAINER = (byte) 0x92;
+    private static final byte DOCUMENT_OBJECT = (byte) 0xA8;
+    private static final byte PAGE_SEGMENT_OBJECT = (byte) 0xFB;
+    private static final byte OVERLAY_OBJECT = (byte) 0xFC;
+    private static final byte PAGEDEF_OBJECT = (byte) 0xFD;
+    private static final byte FORMDEF_OBJECT = (byte) 0xFE;
+        
+    /**
+     * the referenced data object
+     */    
+    private AbstractNamedAFPObject dataObj = null;
+        
+    /**
+     * Default constructor
+     * 
+     * @param name the name of this resource (reference id)
+     * @param dataObj the resource object to be added
+     */
+    public ResourceObject(String name) {
+        super(name);
+    }
+        
+    /**
+     * Sets the data object referenced by this resource object
+     * @param dataObj the data object
+     */
+    public void setReferencedObject(AbstractNamedAFPObject dataObj) {
+        this.dataObj = dataObj;
+        setResourceObjectType(dataObj);
+    }
+
+    /**
+     * @return the resource object contained in this envelope 
+     */
+    public AbstractNamedAFPObject getReferencedObject() {
+        return this.dataObj;
+    }
+    
+    private void setResourceObjectType(AbstractNamedAFPObject resourceObj) {
+        byte type;
+        if (resourceObj instanceof ImageObject) {
+            type = IMAGE_OBJECT;
+        } else if (resourceObj instanceof GraphicsObject) {
+            type = GRAPHICS_OBJECT;
+        } else if (resourceObj instanceof Document) {
+            type = DOCUMENT_OBJECT;
+        } else if (resourceObj instanceof PageSegment) {
+            type = PAGE_SEGMENT_OBJECT;
+        } else if (resourceObj instanceof Overlay) {
+            type = OVERLAY_OBJECT;
+        } else {
+            throw new UnsupportedOperationException(
+                    "Unsupported resource object type " + resourceObj);
+        }
+        getTriplets().add(new ResourceObjectTypeTriplet(type));        
+    }
+        
+    /**
+     * {@inheritDoc}
+     */
+    protected void writeStart(OutputStream os) throws IOException {
+        super.writeStart(os);
+        
+        // Set the total record length
+        byte[] len = BinaryUtils.convert(18 + getTripletDataLength(), 2);
+        byte[] data = new byte[] {
+            0x5A, // Structured field identifier
+            len[0], // Length byte 1
+            len[1], // Length byte 2
+            (byte)0xD3, // Structured field id byte 1
+            (byte)0xA8, // Structured field id byte 2
+            (byte)0xCE, // Structured field id byte 3
+            0x00, // Flags
+            0x00, // Reserved
+            0x00, // Reserved
+            nameBytes[0],            
+            nameBytes[1],
+            nameBytes[2],
+            nameBytes[3],
+            nameBytes[4],
+            nameBytes[5],
+            nameBytes[6],
+            nameBytes[7],
+            0x00, // Reserved
+            0x00, // Reserved
+        };
+        os.write(data);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void writeContent(OutputStream os) throws IOException {
+        super.writeContent(os); // write triplets
+        if (dataObj != null) {
+            dataObj.writeDataStream(os);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void writeEnd(OutputStream os) throws IOException {
+        byte[] data = new byte[] {
+           0x5A, // Structured field identifier
+           0x00, // Length byte 1
+           0x10, // Length byte 2
+           (byte)0xD3, // Structured field id byte 1
+           (byte)0xA9, // Structured field id byte 2
+           (byte)0xCE, // Structured field id byte 3
+           0x00, // Flags
+           0x00, // Reserved
+           0x00, // Reserved
+           nameBytes[0],            
+           nameBytes[1],
+           nameBytes[2],
+           nameBytes[3],
+           nameBytes[4],
+           nameBytes[5],
+           nameBytes[6],
+           nameBytes[7],
+        };
+        os.write(data);
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String toString() {
+        return this.getName();
+    }
+    
+    private class ResourceObjectTypeTriplet extends Triplet {
+
+        private static final byte RESOURCE_OBJECT = 0x21;
+
+        /**
+         * Main constructor
+         * 
+         * @param type
+         *            the resource type
+         */
+        public ResourceObjectTypeTriplet(byte type) {
+            super(RESOURCE_OBJECT,
+                new byte[] {
+                    type,
+                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+                }
+            );
+        }
+    }
+}

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/FullyQualifiedNameTriplet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/FullyQualifiedNameTriplet.java?rev=647228&r1=647227&r2=647228&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/FullyQualifiedNameTriplet.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/FullyQualifiedNameTriplet.java Fri Apr 11 10:17:14 2008
@@ -37,6 +37,10 @@
 /* $Id: $ */
 package org.apache.fop.render.afp.modca.triplets;
 
+import java.io.UnsupportedEncodingException;
+
+import org.apache.fop.render.afp.modca.AFPConstants;
+
 
 /**
  * A Fully Qualified Name triplet enable the identification and referencing of
@@ -75,28 +79,39 @@
     public static final byte FORMAT_OID = (byte)0x10;
     public static final byte FORMAT_URL = (byte)0x20;
     
-    private byte[] fqName;
+    private byte[] nameBytes;
     
     /**
      * @return the actual fully qualified name of this triplet
      */
     public byte[] getFullyQualifiedName() {
-        return fqName;
+        return nameBytes;
     }
 
     /**
      * Main constructor
-     * @param fqnType the fully qualified name type
-     * @param fqnFmt the fully qualified name format
-     * @param fqName the fully qualified name
+     * @param type the fully qualified name type
+     * @param format the fully qualified name format
+     * @param name the fully qualified name
      */
-    public FullyQualifiedNameTriplet(byte fqnType, byte fqnFmt, byte[] fqName) {
+    public FullyQualifiedNameTriplet(byte type, byte format, byte[] name) {
         super(FULLY_QUALIFIED_NAME);
-        this.fqName = fqName;
-        super.data = new byte[2 + fqName.length];
-        data[0] = fqnType;
-        data[1] = fqnFmt;
+        this.nameBytes = name;
+        super.data = new byte[2 + name.length];
+        data[0] = type;
+        data[1] = format;
         // FQName
-        System.arraycopy(fqName, 0, data, 2, fqName.length);
+        System.arraycopy(name, 0, data, 2, name.length);
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String toString() {
+        try {
+            return new String(nameBytes, AFPConstants.EBCIDIC_ENCODING);
+        } catch (UnsupportedEncodingException e) {
+        }
+        return null;
     }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/ObjectClassificationTriplet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/ObjectClassificationTriplet.java?rev=647228&r1=647227&r2=647228&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/ObjectClassificationTriplet.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/ObjectClassificationTriplet.java Fri Apr 11 10:17:14 2008
@@ -19,52 +19,83 @@
 
 package org.apache.fop.render.afp.modca.triplets;
 
-import org.apache.fop.render.afp.modca.Registry;
+import org.apache.fop.render.afp.modca.ObjectTypeRegistry;
 
 /**
  * The Object Classification is used to classify and identify object data.
  * The object data may or may not be defined by an IBM presentation architecture
  */
-public class ObjectClassificationTriplet extends Triplet {    
+public class ObjectClassificationTriplet extends Triplet {
+    
+    /**
+     * The scope of this object is the including page or overlay
+     */
     public static final byte CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT = 0x01;
+    
+    /**
+     * The scope of this object is not defined
+     */
     public static final byte CLASS_TIME_VARIANT_PRESENTATION_OBJECT = 0x10;
+    
+    /**
+     * This is not a presentation object, the scope of this object is not defined
+     */
     public static final byte CLASS_EXECUTABLE_PROGRAM = 0x20;
+    
+    /** 
+     * Setup information file, document level.  This is not a presentation object,
+     */    
     public static final byte CLASS_SETUP_FILE = 0x30;
+    
+    /**
+     * This is a resource used by a presentation object that may itself be a resource.
+     * The scope of the resource is the object that uses the resource.
+     */
     public static final byte CLASS_SECONDARY_RESOURCE = 0x40;
+
+    /** 
+     * Data object font.  This is a non-FOCA font resource used to present
+     * text in a data object.  The scope of the resource is the object that
+     * uses the resource.
+     */
     public static final byte CLASS_DATA_OBJECT_FONT = 0x41;
-    
+        
     /**
      * Main constructor
      * 
      * @param objectClass
      *             the object class type
-     * @param componentId
-     *             the object componentId
+     * @param entry
+     *             the object type registry entry
+     * @param strucFlgs
+     *             the structured flags pertaining to this object classification triplet
      */
-    public ObjectClassificationTriplet(byte objectClass, byte componentId) {
+    public ObjectClassificationTriplet(byte objectClass, ObjectTypeRegistry.ObjectType entry,
+            StrucFlgs strucFlgs) {
         super(OBJECT_CLASSIFICATION);
         byte[] data = new byte[93];
         data[0] = 0x00; // reserved (must be zero)
         data[1] = objectClass; // ObjClass
         data[2] = 0x00; // reserved (must be zero)
         data[3] = 0x00; // reserved (must be zero)
-        data[4] = 0x00; // StrucFlgs - Information on the structure of the object container
+        // StrucFlgs - Information on the structure of the object container        
+        data[4] = strucFlgs.getValue();
         data[5] = 0x00; // StrucFlgs
         
-        Registry.Entry entry = Registry.getInstance().getEntry(componentId);
-        
         if (entry == null) {
-            throw new UnsupportedOperationException("unknown registry entry " + componentId);
+            throw new UnsupportedOperationException("Unknown registry entry");
         }
+        
+        byte[] oid = entry.getOID();
         // RegObjId - MOD:CA-registered ASN.1 OID for object type (8-23)
-        System.arraycopy(entry.getOID(), 0, data, 6, entry.getOID().length);
+        System.arraycopy(oid, 0, data, 6, oid.length);
             
+        byte[] objectTypeName = entry.getName();
         // ObjTpName - name of object type (24-55)
-        System.arraycopy(entry.getObjectTypeName(), 0, data, 22,
-                entry.getObjectTypeName().length);
+        System.arraycopy(objectTypeName, 0, data, 22, objectTypeName.length);
              
         // ObjLev (not specified) - Release level or version number of object type (56-63)
 
         // CompName (not specified) - Name of company or org that owns object definition (64-95)
-    }        
+    }
 }

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/StrucFlgs.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/StrucFlgs.java?rev=647228&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/StrucFlgs.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/triplets/StrucFlgs.java Fri Apr 11 10:17:14 2008
@@ -0,0 +1,80 @@
+/*
+ * 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.triplets;
+
+/**
+ * Used by ObjectClassificationTriplet to provide
+ * information on the structure of the object and its container
+ */
+public class StrucFlgs {
+    private static final int OBJECT_DATA_NOT_CARRIED_IN_OBJECT_CONTAINER = 1;
+    private static final int OBJECT_DATA_OBJECT_CONTAINER_STRUCTURE_UNKNOWN = 2;
+    private static final int OBJECT_DATA_CARRIED_IN_OBJECT_CONTAINER = 3;
+    
+    private static final int OBJECT_CONTAINER_NOT_INCLUDE_OBJECT_ENVIRONMENT_GROUP = 4;
+    private static final int OBJECT_CONTAINER_OBJECT_ENVIRONMENT_GROUP_CONTAINMENT_UNKNOWN = 8;
+    private static final int OBJECT_CONTAINER_INCLUDES_OBJECT_ENVIRONMENT_GROUP = 12;
+    
+    private static final int OBJECT_CONTAINER_DATA_NOT_CARRIED_IN_OBJECT_DATA = 16;
+    private static final int OBJECT_CONTAINER_DATA_OBJECT_DATA_CONTAINMENT_UNKNOWN = 32;
+    private static final int OBJECT_CONTAINER_DATA_CARRIES_OBJECT_DATA = 48;
+
+    private byte value = 0;
+    
+    /**
+     * Main constructor
+     * @param dataInContainer true if the object data in carried in the object container
+     * @param containerHasOEG true if the object container has an object environment group
+     * @param dataInOCD true if the object container data carries the object data 
+     */
+    public StrucFlgs(boolean dataInContainer, boolean containerHasOEG, boolean dataInOCD) {
+        if (dataInContainer) {
+            this.value += OBJECT_DATA_CARRIED_IN_OBJECT_CONTAINER;
+        } else {
+            this.value += OBJECT_DATA_NOT_CARRIED_IN_OBJECT_CONTAINER;                
+        }
+        if (containerHasOEG) {
+            this.value += OBJECT_CONTAINER_INCLUDES_OBJECT_ENVIRONMENT_GROUP;
+        } else {
+            this.value += OBJECT_CONTAINER_NOT_INCLUDE_OBJECT_ENVIRONMENT_GROUP;                
+        }
+        if (dataInOCD) {
+            this.value += OBJECT_CONTAINER_DATA_CARRIES_OBJECT_DATA;
+        } else {
+            this.value += OBJECT_CONTAINER_DATA_NOT_CARRIED_IN_OBJECT_DATA;                
+        }
+    }
+    
+    /**
+     * Default constructor
+     */
+    public StrucFlgs() {
+        this.value = OBJECT_DATA_OBJECT_CONTAINER_STRUCTURE_UNKNOWN
+            + OBJECT_CONTAINER_OBJECT_ENVIRONMENT_GROUP_CONTAINMENT_UNKNOWN
+            + OBJECT_CONTAINER_DATA_OBJECT_DATA_CONTAINMENT_UNKNOWN;
+    }
+
+    /**
+     * @return the value of structure flags value
+     */
+    public byte getValue() {
+        return this.value;
+    }
+}
\ No newline at end of file



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