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/05/14 14:26:20 UTC

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

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectInfo.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/DataObjectInfo.java Wed May 14 05:26:18 2008
@@ -191,14 +191,14 @@
     }
 
     /**
-     * @return the object type entry
+     * @return the object type MOD:CA Registry entry
      */
-    protected ObjectType getObjectType() {
+    public ObjectType getObjectType() {
         return objectType;
     }
 
     /**
-     * @return returns the resource level at which this data object should reside
+     * @return the resource level at which this data object should reside
      */
     public ResourceInfo getResourceInfo() {
         return resourceInfo;
@@ -239,8 +239,26 @@
                             throw new UnsupportedOperationException(msg);
                         }
                         File resourceExternalGroupFile = new File(resourceExternalDest);
-                        if (resourceExternalGroupFile.canWrite()) {
+                        SecurityManager security = System.getSecurityManager();
+                        try {
+                            if (security != null) {
+                                security.checkWrite(resourceExternalGroupFile.getPath());
+                            }
+                        } catch (SecurityException ex) {
+                            log.warn("unable to gain write access to external resource file: "
+                                    + resourceExternalDest);                            
+                        }
+                        
+                        try {
+                            boolean exists = resourceExternalGroupFile.exists();
+                            if (exists) {
+                                log.warn("overwritting external resource file: "
+                                        + resourceExternalDest);
+                            }
                             resourceInfo.setExternalResourceGroupFile(resourceExternalGroupFile);
+                        } catch (SecurityException ex) {
+                            log.warn("unable to gain read access to external resource file: "
+                                    + resourceExternalDest);
                         }
                     }
                 } else {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/goca/GraphicsChainedSegment.java Wed May 14 05:26:18 2008
@@ -136,7 +136,7 @@
         if (previous == null) {
             GraphicsChainedSegment current = this.next;
             while (current != null) {
-                current.writeDataStream(os);
+                current.write(os);
                 current = current.next;
             }
         }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/AFPDataStream.java Wed May 14 05:26:18 2008
@@ -21,7 +21,6 @@
 
 import java.awt.Color;
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Iterator;
@@ -57,7 +56,8 @@
     /**
      * Static logging instance
      */
-    protected static Log log = LogFactory.getLog("org.apache.fop.render.afp.modca");
+    protected static Log log = LogFactory
+            .getLog("org.apache.fop.render.afp.modca");
 
     /**
      * Boolean completion indicator
@@ -67,9 +67,8 @@
     /**
      * The application producing the AFP document
      */
-// not used
-//    private String producer = null;
-
+    // not used
+    // private String producer = null;
     /**
      * The AFP document object
      */
@@ -86,11 +85,6 @@
     private PageObject currentPageObject = null;
 
     /**
-     * The current resource group
-     */
-//    private ResourceGroup currentResourceGroup = null;
-    
-    /**
      * The current overlay object
      */
     private Overlay currentOverlay = null;
@@ -113,7 +107,7 @@
     /**
      * The overlay count
      */
-    private int ovlCount = 0;
+    private int overlayCount = 0;
 
     /**
      * The portrait rotation
@@ -145,11 +139,20 @@
      */
     private OutputStream outputStream = null;
 
+    /** Maintain a reference count of instream objects for referencing purposes */
+    private int instreamObjectCount = 0;
+
+    /**
+     * The MO:DCA interchange set in use (default to MO:DCA-L resource set)
+     */
+    private InterchangeSet interchangeSet
+        = InterchangeSet.valueOf(InterchangeSet.MODCA_RESOURCE_INTERCHANGE_SET);
+
     /**
      * The external resource group manager
      */
     private ExternalResourceGroupManager externalResourceGroupManager = null;
-    
+
     /**
      * Default constructor for the AFPDataStream.
      */
@@ -157,10 +160,16 @@
         this.document = new Document();
     }
 
+    /**
+     * @return the document object
+     */
     private Document getDocument() {
         return this.document;
     }
-    
+
+    /**
+     * @return the current page
+     */
     private AbstractPageObject getCurrentPage() {
         return this.currentPage;
     }
@@ -173,37 +182,28 @@
      *            the name of this document.
      */
     public void setDocumentName(String name) {
-//        if (document != null) {
-//            String msg = "Invalid state - document already started.";
-//            log.warn("startDocument():: " + msg);
-//            throw new IllegalStateException(msg);
-//        }
-//        if (document != null) {
-//            String msg = "Invalid state - print file level document already started"; 
-//            log.warn(msg);
-//            throw new IllegalStateException(msg);
-//        }
-
         if (name != null) {
-            document.setFullyQualifiedName(
+            getDocument().setFullyQualifiedName(
                     FullyQualifiedNameTriplet.TYPE_BEGIN_DOCUMENT_REF,
-                    FullyQualifiedNameTriplet.FORMAT_CHARSTR,
-                    name);
+                    FullyQualifiedNameTriplet.FORMAT_CHARSTR, name);
         }
     }
 
     /**
      * Sets the OutputStream
-     * @param outputStream the AFP OutputStream
+     * 
+     * @param outputStream
+     *            the AFP OutputStream
      */
     public void setOutputStream(OutputStream outputStream) {
         this.outputStream = outputStream;
     }
-    
+
     /**
-     * The document is written/ended by invoking this method which creates an instance
-     * of the AFP Document object and registers the start with a validation map
-     * which ensures that methods are not invoked out of the correct sequence.
+     * The document is written/ended by invoking this method which creates an
+     * instance of the AFP Document object and registers the start with a
+     * validation map which ensures that methods are not invoked out of the
+     * correct sequence.
      * 
      * @throws java.io.IOException
      *             throws an I/O exception of some sort has occurred
@@ -230,24 +230,24 @@
 
         // Write out any print-file level resources
         if (hasResources()) {
-            getResourceGroup().writeDataStream(this.outputStream);
+            getResourceGroup().write(this.outputStream);
         }
 
         // Write out document
         if (document != null) {
             document.endDocument();
-            document.writeDataStream(this.outputStream);
+            document.write(this.outputStream);
         }
 
         this.outputStream.flush();
 
-        complete = true;
+        this.complete = true;
 
-        document = null;
+        this.document = null;
 
         this.outputStream = null;
     }
-    
+
     /**
      * Start a new page. When processing has finished on the current page, the
      * {@link #endPage()}method must be invoked to mark the page ending.
@@ -266,7 +266,7 @@
     public void startPage(int pageWidth, int pageHeight, int pageRotation,
             int pageWidthRes, int pageHeightRes) {
         String pageName = "PGN"
-                + StringUtils.lpad(String.valueOf(pageCount++), '0', 5);
+                + StringUtils.lpad(String.valueOf(++pageCount), '0', 5);
 
         currentPageObject = new PageObject(pageName, pageWidth, pageHeight,
                 pageRotation, pageWidthRes, pageHeightRes);
@@ -292,17 +292,18 @@
      *            the width resolution of the overlay
      * @param heightRes
      *            the height resolution of the overlay
-     * @param rotation
+     * @param overlayRotation
      *            the rotation of the overlay
      */
     public void startOverlay(int x, int y, int width, int height, int widthRes,
-            int heightRes, int rotation) {
+            int heightRes, int overlayRotation) {
         String overlayName = "OVL"
-                + StringUtils.lpad(String.valueOf(ovlCount++), '0', 5);
+                + StringUtils.lpad(String.valueOf(++overlayCount), '0', 5);
 
-        currentOverlay = new Overlay(overlayName, width, height,
-                widthRes, heightRes, rotation);
-        
+        this.currentOverlay = new Overlay(overlayName, width, height, widthRes,
+                heightRes, overlayRotation);
+
+        getResourceGroup().addObject(currentOverlay);
         currentPageObject.createIncludePageOverlay(overlayName, x, y, 0);
         currentPage = currentOverlay;
         setOffsets(0, 0, 0);
@@ -312,9 +313,11 @@
      * Helper method to mark the end of the current overlay.
      */
     public void endOverlay() {
-        currentOverlay.endPage();
-        currentOverlay = null;
-        currentPage = currentPageObject;
+        if (currentOverlay != null) {
+            currentOverlay.endPage();
+            currentOverlay = null;
+            currentPage = currentPageObject;
+        }
     }
 
     /**
@@ -349,11 +352,13 @@
      * Helper method to mark the end of the current page.
      */
     public void endPage() {
-        currentPageObject.endPage();
-        if (currentPageGroup != null) {
-            currentPageGroup.addPage(currentPageObject);
-        } else {
-            document.addPage(currentPageObject);
+        if (currentPageObject != null) {
+            currentPageObject.endPage();
+            if (currentPageGroup != null) {
+                currentPageGroup.addPage(currentPageObject);
+            } else {
+                document.addPage(currentPageObject);
+            }
         }
         currentPageObject = null;
         currentPage = null;
@@ -377,16 +382,17 @@
 
     /**
      * Creates the given page fonts in the current page
-     * @param pageFonts a collection of AFP font attributes
+     * 
+     * @param pageFonts
+     *            a collection of AFP font attributes
      */
     public void addFontsToCurrentPage(Map pageFonts) {
         Iterator iter = pageFonts.values().iterator();
         while (iter.hasNext()) {
-            AFPFontAttributes afpFontAttributes = (AFPFontAttributes)iter.next();
-            createFont(
-                afpFontAttributes.getFontReference(),
-                afpFontAttributes.getFont(),
-                afpFontAttributes.getPointSize());
+            AFPFontAttributes afpFontAttributes = (AFPFontAttributes) iter
+                    .next();
+            createFont(afpFontAttributes.getFontReference(), afpFontAttributes
+                    .getFont(), afpFontAttributes.getPointSize());
         }
     }
 
@@ -425,60 +431,71 @@
      * @param data
      *            the text data to create
      */
-    public void createText(int fontReference, int x, int y, Color col, int vsci,
-            int ica, byte[] data) {
-        getCurrentPage().createText(fontReference, x + xOffset, y + yOffset, rotation,
-                col, vsci, ica, data);
+    public void createText(int fontReference, int x, int y, Color col,
+            int vsci, int ica, byte[] data) {
+        getCurrentPage().createText(fontReference, x + xOffset, y + yOffset,
+                rotation, col, vsci, ica, data);
     }
 
-    /** Maintain a reference count of instream objects */
-    private int instreamObjectCount = 0;
-
     /**
-     * Creates a data object in the datastream.  The data object resides according
-     * to its type, info and MO:DCA-L (resource) support.
+     * Creates a data object in the datastream. The data object resides
+     * according to its type, info and MO:DCA-L (resource) support.
      * 
      * @param dataObjectInfo
      *            the data object info
-     * @return
-     *            a data object
+     * @return a data object
      */
     public AbstractNamedAFPObject createObject(DataObjectInfo dataObjectInfo) {
         String uri = dataObjectInfo.getUri();
-        
-        // if this is an instream data object adjust uri to ensure that it is unique
+
+        // if this is an instream data object adjust uri to ensure that it is
+        // unique
         if (uri.endsWith("/")) {
             uri += "#" + (++instreamObjectCount);
             dataObjectInfo.setUri(uri);
         }
-        
-        Registry.ObjectType objectType = Registry.getInstance().getObjectType(dataObjectInfo);
+
+        Registry registry = Registry.getInstance();
+        Registry.ObjectType objectType = registry.getObjectType(dataObjectInfo);
         // recognised object type
         if (objectType != null) {
             dataObjectInfo.setObjectType(objectType);
 
-            // can this data object use the include object (IOB) referencing mechanism?
-            if (objectType.canBeIncluded()) {
-                ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
-                ResourceGroup resourceGroup = getResourceGroup(resourceInfo);
-                IncludeObject includeObject = resourceGroup.createObject(dataObjectInfo);
-                
-                // add include to current page
-                getCurrentPage().addObject(includeObject);
-                return includeObject.getDataObject();
+            ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
+
+            // is MO:DCA-L available?
+            if (interchangeSet.supportsLevel2()) {
+                // can this data object use the include object (IOB) referencing
+                // mechanism?
+                if (objectType.canBeIncluded()) {
+                    ResourceGroup resourceGroup = getResourceGroup(resourceInfo);
+                    IncludeObject includeObject = resourceGroup.createObject(dataObjectInfo);
+
+                    // add include to current page
+                    getCurrentPage().addObject(includeObject);
+                    return includeObject.getDataObject();
+                } else {
+                    log.warn("data object located at '" + uri
+                        + "' cannot be referenced with an include so it will be embedded directly");
+                }
             } else {
-                log.warn(uri + "cannot be included so will embed directly");
+                if (resourceInfo.isExternal()) {
+                    log.warn( interchangeSet
+                            + ": not available, object " + getName() + " will reside inline");
+                }                
             }
+
         }
-        // unrecognised/unsupported object type so create/embed data object directly in current page
-        AbstractNamedAFPObject dataObj = getCurrentPage().createObject(dataObjectInfo);
+        // unrecognised/unsupported object type so create/embed data object
+        // directly in current page
+        AbstractNamedAFPObject dataObj = currentPageObject.createObject(dataObjectInfo);
         getCurrentPage().addObject(dataObj);
         return dataObj;
     }
-    
+
     /**
      * Sets the object view port taking into account rotation.
-     *
+     * 
      * @param x
      *            the x position of the object
      * @param y
@@ -491,11 +508,10 @@
      *            the resolution width of the object
      * @param hr
      *            the resolution height of the object
-     * @return
-     *            a new graphics object
+     * @return a new graphics object
      */
-    private void setObjectViewPort(AbstractDataObject dataObj,
-            int x, int y, int w, int h, int wr, int hr) {
+    private void setObjectViewPort(AbstractDataObject dataObj, int x, int y,
+            int w, int h, int wr, int hr) {
         int xOrigin;
         int yOrigin;
         int width;
@@ -536,9 +552,10 @@
             heightRes = hr;
             break;
         }
-        dataObj.setViewport(xOrigin, yOrigin, width, height, widthRes, heightRes, rotation);
+        dataObj.setViewport(xOrigin, yOrigin, width, height, widthRes,
+                heightRes, rotation);
     }
-        
+
     /**
      * Method to create a line on the current page.
      * 
@@ -557,8 +574,8 @@
      */
     public void createLine(int x1, int y1, int x2, int y2, int thickness,
             Color col) {
-        getCurrentPage().createLine(x1 + xOffset, y1 + yOffset, x2 + xOffset, y2
-                + yOffset, thickness, rotation, col);
+        getCurrentPage().createLine(x1 + xOffset, y1 + yOffset, x2 + xOffset,
+                y2 + yOffset, thickness, rotation, col);
     }
 
     /**
@@ -574,17 +591,12 @@
      *            the width of the shaded area
      * @param h
      *            the height of the shaded area
-     * @param red
-     *            the red value
-     * @param green
-     *            the green value
-     * @param blue
-     *            the blue value
-     */
-    public void createShading(int x, int y, int w, int h, int red, int green,
-            int blue) {
-        getCurrentPage().createShading(x + xOffset, y + xOffset, w, h, red, green,
-                blue);
+     * @param col
+     *            the shading color
+     */
+    public void createShading(int x, int y, int w, int h, Color col) {
+        currentPageObject.createShading(x + xOffset, y + xOffset, w, h,
+                col.getRed(), col.getGreen(), col.getBlue());
     }
 
     /**
@@ -700,12 +712,13 @@
     private PageGroup getCurrentPageGroup() {
         if (currentPageGroup == null) {
             String pageGroupName = "PGP"
-                + StringUtils.lpad(String.valueOf(pageGroupCount++), '0', 5);
+                    + StringUtils
+                            .lpad(String.valueOf(++pageGroupCount), '0', 5);
             this.currentPageGroup = new PageGroup(pageGroupName);
         }
         return currentPageGroup;
     }
- 
+
     /**
      * Start a new page group. When processing has finished on the current page
      * group the {@link #endPageGroup()}method must be invoked to mark the page
@@ -760,10 +773,11 @@
         }
     }
 
-    
     /**
      * Returns the resource group for a given resource into
-     * @param resourceInfo resource info
+     * 
+     * @param resourceInfo
+     *            resource info
      * @return a resource group container for the given resource info
      */
     private ResourceGroup getResourceGroup(ResourceInfo resourceInfo) {
@@ -775,20 +789,23 @@
         } else if (resourceInfo.isPageGroup()) {
             resourceGroup = getCurrentPageGroup().getResourceGroup();
         } else if (resourceInfo.isPage()) {
-            resourceGroup = getCurrentPage().getResourceGroup(); 
+            resourceGroup = currentPageObject.getResourceGroup();
         } else if (resourceInfo.isExternal()) {
-            resourceGroup = getExternalResourceGroupManager().getExternalResourceGroup(
-                    resourceInfo);
+            resourceGroup = getExternalResourceGroupManager()
+                    .getExternalResourceGroup(resourceInfo);
         }
         return resourceGroup;
     }
 
     /**
      * Sets the default resource group file
-     * @param resourceGroupFile the default resource group file
+     * 
+     * @param resourceGroupFile
+     *            the default resource group file
      */
     public void setDefaultResourceGroupFile(File resourceGroupFile) {
-        getExternalResourceGroupManager().setDefaultResourceGroupFile(resourceGroupFile);
+        getExternalResourceGroupManager().setDefaultResourceGroupFile(
+                resourceGroupFile);
     }
 
     /**
@@ -801,7 +818,6 @@
         return this.externalResourceGroupManager;
     }
 
-    
     /**
      * Manages the use of resource groups (external and internal)
      */
@@ -809,7 +825,7 @@
         /**
          * A mapping of external resource destinations to resource groups
          */
-        private Map/*<File, ResourceGroup>*/ externalResourceGroups = null;
+        private Map/*<File,ResourceGroup>*/externalResourceGroups = null;
 
         /** sets the default resource group file */
         private File defaultResourceGroupFile;
@@ -819,15 +835,20 @@
 
         /**
          * Main constructor
-         * @param container the container of this manager
+         * 
+         * @param container
+         *            the container of this manager
          */
-        private ExternalResourceGroupManager(AbstractResourceGroupContainer container) {
+        private ExternalResourceGroupManager(
+                AbstractResourceGroupContainer container) {
             this.container = container;
         }
-        
+
         /**
          * Sets the default resource group file
-         * @param resourceGroupFile the default resource group file
+         * 
+         * @param resourceGroupFile
+         *            the default resource group file
          */
         private void setDefaultResourceGroupFile(File resourceGroupFile) {
             this.defaultResourceGroupFile = resourceGroupFile;
@@ -840,36 +861,44 @@
             // write any external resources
             Iterator it = getExternalResourceGroups().keySet().iterator();
             while (it.hasNext()) {
-                File resourceGroupFile = (File)it.next();
-                ResourceGroup resourceGroup
-                    = (ResourceGroup)getExternalResourceGroups().get(resourceGroupFile);
+                File resourceGroupFile = (File) it.next();
+                ResourceGroup resourceGroup = (ResourceGroup) getExternalResourceGroups()
+                        .get(resourceGroupFile);
                 OutputStream os = null;
                 try {
                     log.debug("Writing external AFP resource file "
                             + resourceGroupFile.getAbsolutePath());
-                            
+
                     os = new java.io.FileOutputStream(resourceGroupFile);
-                    resourceGroup.writeDataStream(os);
+                    resourceGroup.write(os);
                 } catch (IOException e) {
                     log.error(
                             "An error occurred when attempting to write external AFP resource file "
-                            + resourceGroupFile.getAbsolutePath());
+                                    + resourceGroupFile.getAbsolutePath());
                 } finally {
                     if (os != null) {
                         try {
                             os.close();
                         } catch (IOException e) {
                             log.error("Failed to close outputstream for external AFP resource file "
-                                    + resourceGroupFile.getAbsolutePath());
+                                            + resourceGroupFile.getAbsolutePath());
                         }
                     }
                 }
             }
         }
-        
+
+        /**
+         * Returns the corresponding resource group for the given resource info
+         * 
+         * @param resourceInfo
+         *            resource info
+         * @return the corresponding resource group for the given resource info
+         */
         private ResourceGroup getExternalResourceGroup(ResourceInfo resourceInfo) {
             ResourceGroup resourceGroup;
-            // this resource info does not have a an external resource group file definition
+            // this resource info does not have a an external resource group
+            // file definition
             if (!resourceInfo.hasExternalResourceGroupFile()) {
                 if (defaultResourceGroupFile != null) {
                     // fallback to default resource group file
@@ -881,21 +910,52 @@
                     resourceGroup = container.getResourceGroup();
                 }
             } else {
-                File resourceGroupFile = resourceInfo.getExternalResourceGroupFile();
+                File resourceGroupFile = resourceInfo
+                        .getExternalResourceGroupFile();
                 resourceGroup = (ResourceGroup)getExternalResourceGroups().get(resourceGroupFile);
-                if (resourceGroup == null) {        
+                if (resourceGroup == null) {
                     resourceGroup = new ResourceGroup(container);
-                    externalResourceGroups.put(resourceGroupFile, resourceGroup);
+                    externalResourceGroups
+                            .put(resourceGroupFile, resourceGroup);
                 }
             }
             return resourceGroup;
         }
-        
-        private Map/*<File, ResourceGroup>*/ getExternalResourceGroups() {
+
+        private Map/*<File,ResourceGroup>*/getExternalResourceGroups() {
             if (externalResourceGroups == null) {
-                externalResourceGroups = new java.util.HashMap/*<File, ResourceGroup>*/();
+                externalResourceGroups = new java.util.HashMap/*<File,ResourceGroup>*/();
             }
             return externalResourceGroups;
-        }      
+        }
+    }
+
+    /**
+     * Starts a new page segment.
+     */
+    public void startPageSegment() {
+        currentPageObject.startPageSegment();
+    }
+
+    /**
+     * Ends the current page segment.
+     */
+    public void endPageSegment() {
+        currentPageObject.endPageSegment();
+    }
+
+    /**
+     * Sets the MO:DCA interchange set to use
+     * @param interchangeSet the MO:DCA interchange set
+     */
+    public void setInterchangeSet(InterchangeSet interchangeSet) {
+        this.interchangeSet = interchangeSet;
+    }
+
+    /**
+     * @return the MO:DCA interchange set in use 
+     */
+    public InterchangeSet getInterchangeSet() {
+        return this.interchangeSet;
     }
 }

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=656249&r1=656248&r2=656249&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 May 14 05:26:18 2008
@@ -33,7 +33,7 @@
  * AFP format.
  *
  */
-public abstract class AbstractAFPObject implements AFPDataStreamWriter {
+public abstract class AbstractAFPObject implements Writable {
 
     /**
      * Static logging instance
@@ -51,7 +51,7 @@
         if (objects != null) {
             for (Iterator it = objects.iterator(); it.hasNext();) {
                 AbstractAFPObject obj = (AbstractAFPObject)it.next(); 
-                obj.writeDataStream(os);
+                obj.write(os);
             }
         }
     }

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=656249&r1=656248&r2=656249&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 May 14 05:26:18 2008
@@ -82,7 +82,7 @@
      */
     protected void writeContent(OutputStream os) throws IOException {
         if (objectEnvironmentGroup != null) {
-            objectEnvironmentGroup.writeDataStream(os);
+            objectEnvironmentGroup.write(os);
         }
         super.writeContent(os);
     }

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=656249&r1=656248&r2=656249&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 May 14 05:26:18 2008
@@ -25,7 +25,6 @@
 import java.util.List;
 
 import org.apache.fop.render.afp.fonts.AFPFont;
-import org.apache.fop.render.afp.tools.StringUtils;
 
 /**
  * Pages contain the data objects that comprise a presentation document. Each
@@ -47,27 +46,32 @@
  * in page state.
  *
  */
-public abstract class AbstractPageObject extends AbstractResourceGroupContainer {
+public abstract class AbstractPageObject extends AbstractNamedAFPObject {
 
     /**
      * The active environment group for the page
      */
-    protected ActiveEnvironmentGroup activeEnvironmentGroup;
+    protected ActiveEnvironmentGroup activeEnvironmentGroup = null;
 
     /**
-     * The presentation text object, we only have one per page
+     * The current presentation text object
      */
-    private PresentationTextObject presentationTextObject;
+    private PresentationTextObject currentPresentationTextObject = null;
 
     /**
      * The list of tag logical elements
      */
-    protected List tagLogicalElements;
+    protected List/*<TagLogicalElement>*/ tagLogicalElements = null;
 
     /**
      * The list of the include page segments
      */
-    protected List segments;
+    protected List/*<IncludePageSegment>*/ includePageSegments = null;
+
+    /**
+     * The list of objects within this resource container
+     */
+    protected List/*<AbstractStructuredAFPObject>*/ objects = null;
 
     /**
      * The page width
@@ -82,7 +86,7 @@
     /**
      * The page rotation
      */
-    private int rotation = 0;
+    protected int rotation = 0;
 
     /**
      * The page state
@@ -90,6 +94,30 @@
     private boolean complete = false;
 
     /**
+     * The width resolution
+     */
+    private int widthRes;
+
+    /**
+     * The height resolution
+     */
+    private int heightRes;
+
+    /**
+     * Default constructor
+     */
+    public AbstractPageObject() {
+    }
+
+    /**
+     * Named constructor
+     * @param name the name of this page object
+     */
+    public AbstractPageObject(String name) {
+        super(name);
+    }
+
+    /**
      * Construct a new page object for the specified name argument, the page
      * name should be an 8 character identifier.
      *
@@ -113,27 +141,8 @@
         this.width = width;
         this.height = height;
         this.rotation = rotation;
-
-        /**
-         * Every page object must have an ActiveEnvironmentGroup
-         */
-        this.activeEnvironmentGroup = new ActiveEnvironmentGroup(
-                width, height, widthRes, heightRes);
-
-        if (rotation != 0) {
-            switch (rotation) {
-                case 90:
-                    activeEnvironmentGroup.setPosition(width, 0, rotation);
-                    break;
-                case 180:
-                    activeEnvironmentGroup.setPosition(width, height, rotation);
-                    break;
-                case 270:
-                    activeEnvironmentGroup.setPosition(0, height, rotation);
-                    break;
-                default:
-            }
-        }
+        this.widthRes = widthRes;
+        this.heightRes = heightRes;
     }
 
     /**
@@ -208,111 +217,31 @@
      * sequence on the current presentation text object.
      */
     public void endPage() {
-        if (presentationTextObject != null) {
-            presentationTextObject.endControlSequence();
+        if (currentPresentationTextObject != null) {
+            currentPresentationTextObject.endControlSequence();
         }
         complete = true;
     }
 
-    /**
-     * This method will create shading on the page using the specified
-     * coordinates (the shading contrast is controlled via the red, green blue
-     * parameters, by converting this to grey scale).
-     *
-     * @param x
-     *            the x coordinate of the shading
-     * @param y
-     *            the y coordinate of the shading
-     * @param w
-     *            the width of the shaded area
-     * @param h
-     *            the height of the shaded area
-     * @param red
-     *            the red value
-     * @param green
-     *            the green value
-     * @param blue
-     *            the blue value
-     */
-    public void createShading(int x, int y, int w, int h, int red, int green, int blue) {
-        int xCoord = 0;
-        int yCoord = 0;
-        int areaWidth = 0;
-        int areaHeight = 0;
-        switch (rotation) {
-            case 90:
-                xCoord = areaWidth - y - h;
-                yCoord = x;
-                areaWidth = h;
-                areaHeight = w;
-                break;
-            case 180:
-                xCoord = areaWidth - x - w;
-                yCoord = areaHeight - y - h;
-                areaWidth = w;
-                areaHeight = h;
-                break;
-            case 270:
-                xCoord = y;
-                yCoord = areaHeight - x - w;
-                areaWidth = h;
-                areaHeight = w;
-                break;
-            default:
-                xCoord = x;
-                yCoord = y;
-                areaWidth = w;
-                areaHeight = h;
-                break;
-        }
-
-        // Convert the color to grey scale
-        float shade = (float) ((red * 0.3) + (green * 0.59) + (blue * 0.11));
-
-        int greyscale = Math.round((shade / 255) * 16);
-
-        String imageName = "IMG"
-            + StringUtils.lpad(String.valueOf(getResourceCount() + 1),
-            '0', 5);
-
-        IMImageObject io = new IMImageObject(imageName);
-        ImageOutputControl ioc = new ImageOutputControl(0, 0);
-        ImageInputDescriptor iid = new ImageInputDescriptor();
-        ImageCellPosition icp = new ImageCellPosition(xCoord, yCoord);
-        icp.setXFillSize(areaWidth);
-        icp.setYFillSize(areaHeight);
-        icp.setXSize(64);
-        icp.setYSize(8);
-
-        //defining this as a resource
-        ImageRasterData ird = new ImageRasterData(
-                ImageRasterPattern.getRasterData(greyscale));
-
-        io.setImageOutputControl(ioc);
-        io.setImageInputDescriptor(iid);
-        io.setImageCellPosition(icp);
-        io.setImageRasterData(ird);
-        addObject(io);
-    }
-
     private void endPresentationObject() {
-        if (presentationTextObject != null) {
-            presentationTextObject.endControlSequence();
-            presentationTextObject = null;
+        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 (presentationTextObject == null) {
-            this.presentationTextObject = new PresentationTextObject();
-            super.addObject(this.presentationTextObject);
+        if (currentPresentationTextObject == null) {
+            PresentationTextObject presentationTextObject = new PresentationTextObject();
+            addObject(presentationTextObject);
+            this.currentPresentationTextObject = presentationTextObject;
         }
-        return presentationTextObject;
+        return currentPresentationTextObject;
     }
     
     /**
@@ -326,7 +255,7 @@
     public void createTagLogicalElement(String name, String value) {
         TagLogicalElement tle = new TagLogicalElement(name, value);
         if (tagLogicalElements == null) {
-            tagLogicalElements = new java.util.ArrayList();
+            tagLogicalElements = new java.util.ArrayList/*<TagLogicalElement>*/();
         }
         tagLogicalElements.add(tle);
     }
@@ -352,10 +281,10 @@
      */
     public void createIncludePageSegment(String name, int xCoor, int yCoor) {
         IncludePageSegment ips = new IncludePageSegment(name, xCoor, yCoor);
-        if (segments == null) {
-            segments = new java.util.ArrayList();
+        if (includePageSegments == null) {
+            includePageSegments = new java.util.ArrayList/*<IncludePageSegment>*/();
         }
-        segments.add(ips);
+        includePageSegments.add(ips);
     }
 
     /**
@@ -364,6 +293,28 @@
      * @return the ActiveEnvironmentGroup object
      */
     public ActiveEnvironmentGroup getActiveEnvironmentGroup() {
+        if (activeEnvironmentGroup == null) {
+            /**
+             * Every page object must have an ActiveEnvironmentGroup
+             */
+            this.activeEnvironmentGroup = new ActiveEnvironmentGroup(
+                    width, height, widthRes, heightRes);
+
+            if (rotation != 0) {
+                switch (rotation) {
+                    case 90:
+                        activeEnvironmentGroup.setPosition(width, 0, rotation);
+                        break;
+                    case 180:
+                        activeEnvironmentGroup.setPosition(width, height, rotation);
+                        break;
+                    case 270:
+                        activeEnvironmentGroup.setPosition(0, height, rotation);
+                        break;
+                    default:
+                }
+            }
+        }
         return activeEnvironmentGroup;
     }
 
@@ -404,21 +355,33 @@
      */
     protected void writeContent(OutputStream os) throws IOException {
         super.writeContent(os);
-        getActiveEnvironmentGroup().writeDataStream(os);
-        writeObjects(segments, os);
-        writeObjects(tagLogicalElements, os);
-        writeObjects(objects, os);
+        if (this instanceof PageObject) {
+            getActiveEnvironmentGroup().write(os);
+        }
+        writeObjects(this.includePageSegments, os);
+        writeObjects(this.tagLogicalElements, os);
+        writeObjects(this.objects, os);
     }
     
     /**
-     * {@inheritDoc}
+     * Adds an AFP object to the resource group in this container
+     * @param obj an AFP object
      */
-    protected void addObject(AbstractStructuredAFPObject obj) {
-        if (obj instanceof IncludeObject) {
-            IncludeObject includeObj = (IncludeObject)obj;
-            getActiveEnvironmentGroup().createResource(includeObj);            
+    protected void addObject(AbstractAFPObject obj) {
+        if (objects == null) {
+            this.objects = new java.util.ArrayList/*<AbstractAFPObject>*/();
         }
-        endPresentationObject();
-        super.addObject(obj);
+        objects.add(obj);
     }
+
+//    /**
+//     * {@inheritDoc}
+//     */
+//    protected void addObject(AbstractAFPObject obj) {
+//        if (obj instanceof DataObjectAccessor) {
+//            DataObjectAccessor dataObjectAccessor = (DataObjectAccessor)obj;
+//            getActiveEnvironmentGroup().createMapDataResource(dataObjectAccessor);
+//        }
+//        endPresentationObject();
+//    }    
 }

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=656249&r1=656248&r2=656249&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 May 14 05:26:18 2008
@@ -21,7 +21,6 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Iterator;
 
 /**
  * An abstract class which encapsulates the common features of 
@@ -75,19 +74,7 @@
     protected void writeContent(OutputStream os) throws IOException {
         super.writeContent(os);
         if (resourceEnvironmentGroup != null) {
-            resourceEnvironmentGroup.writeDataStream(os);
-        }
-        if (objects != null) {
-            for (Iterator it = objects.iterator(); it.hasNext();) {
-                AbstractAFPObject ao = (AbstractAFPObject)it.next();
-                if (ao instanceof PageObject && ((PageObject)ao).isComplete()
-                    || ao instanceof PageGroup && ((PageGroup)ao).isComplete()) {
-                    ao.writeDataStream(os);
-                    it.remove();
-                } else {
-                    break;
-                }
-            }
+            resourceEnvironmentGroup.write(os);
         }
     }
     

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=656249&r1=656248&r2=656249&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 May 14 05:26:18 2008
@@ -21,7 +21,6 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Set;
 
 import org.apache.fop.render.afp.DataObjectInfo;
 import org.apache.fop.render.afp.ImageObjectInfo;
@@ -32,21 +31,17 @@
 /**
  * An abstract container of resource objects
  */
-public abstract class AbstractResourceGroupContainer extends AbstractNamedAFPObject {
+public abstract class AbstractResourceGroupContainer extends AbstractPageObject {
     /**
      * The resource group object
      */
     private ResourceGroup resourceGroup = null;
-    
-    /**
-     * The list of objects within this resource container
-     */
-    protected Set/*<AbstractStructuredAFPObject>*/ objects = null;
 
     /**
-     * Unnamed constructor
+     * Default constructor
      */
     public AbstractResourceGroupContainer() {
+        super();
     }
 
     /**
@@ -58,6 +53,28 @@
     }
 
     /**
+     * Construct a new page object for the specified name argument, the page
+     * name should be an 8 character identifier.
+     *
+     * @param name
+     *            the name of the page.
+     * @param width
+     *            the width of the page.
+     * @param height
+     *            the height of the page.
+     * @param rotation
+     *            the rotation of the page.
+     * @param widthRes
+     *            the width resolution of the page.
+     * @param heightRes
+     *            the height resolution of the page.
+     */
+    public AbstractResourceGroupContainer(String name, int width, int height,
+            int rotation, int widthRes, int heightRes) {
+        super(name, width, height, rotation, widthRes, heightRes);
+    }
+
+    /**
      * @return the number of resources in this container
      */
     protected int getResourceCount() {
@@ -68,17 +85,6 @@
     }
     
     /**
-     * Adds an AFP object to the resource group in this container
-     * @param obj an AFP object
-     */
-    protected void addObject(AbstractAFPObject obj) {
-        if (objects == null) {
-            this.objects = new java.util.LinkedHashSet/*<AbstractAFPObject>*/();
-        }
-        objects.add(obj);
-    }
-
-    /**
      * @return true if this resource group container contains resources
      */
     protected boolean hasResources() {
@@ -161,7 +167,6 @@
 
     private static final String IMAGE_NAME_PREFIX = "IMG";
     private static final String GRAPHIC_NAME_PREFIX = "GRA";
-    private static final String PAGE_SEGMENT_NAME_PREFIX = "PSG";
     
     // not currently used/implemented
     private static final String BARCODE_NAME_PREFIX = "BAR";
@@ -221,18 +226,6 @@
     }
 
     /**
-     * Helper method to create a page segment in the current container and to return
-     * the object.
-     * @return a newly created page segment
-     */
-    protected PageSegment createPageSegment() {
-        String name = PAGE_SEGMENT_NAME_PREFIX
-        + StringUtils.lpad(String.valueOf(getResourceCount() + 1), '0', 5);
-        PageSegment pageSegment = new PageSegment(name);
-        return pageSegment;
-    }
-
-    /**
      * Creates and returns a new data object
      * @param info the data object parameters
      * @return a newly created data object
@@ -244,10 +237,9 @@
         } else {
             dataObject = createGraphic(info);
         }
-
-         dataObject.setFullyQualifiedName(
-                FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF,
-                FullyQualifiedNameTriplet.FORMAT_URL, info.getUri());
+        dataObject.setFullyQualifiedName(
+            FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_INTERNAL_RESOURCE_REF,
+            FullyQualifiedNameTriplet.FORMAT_CHARSTR, dataObject.getName());
 
         return dataObject;
     }
@@ -258,7 +250,7 @@
     protected void writeContent(OutputStream os) throws IOException {
         super.writeContent(os);
         if (resourceGroup != null) {
-            resourceGroup.writeDataStream(os);
+            resourceGroup.write(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=656249&r1=656248&r2=656249&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 May 14 05:26:18 2008
@@ -129,7 +129,7 @@
      * @param os The stream to write to
      * @throws IOException in the event that an I/O exception occurred
      */
-    public void writeDataStream(OutputStream os) throws IOException {
+    public void write(OutputStream os) throws IOException {
         writeStart(os);
         writeContent(os);
         writeEnd(os);
@@ -193,12 +193,7 @@
      * @param fqName the fully qualified name of this resource
      */
     public void setFullyQualifiedName(byte fqnType, byte fqnFormat, String fqName) {
-        try {
-            byte[] fqNameBytes = fqName.getBytes(AFPConstants.EBCIDIC_ENCODING);
-            addTriplet(new FullyQualifiedNameTriplet(fqnType, fqnFormat, fqNameBytes));
-        } catch (UnsupportedEncodingException e) {
-            log.error(e.getMessage());
-        }
+        addTriplet(new FullyQualifiedNameTriplet(fqnType, fqnFormat, fqName));
     }
 
     /**
@@ -208,17 +203,9 @@
         FullyQualifiedNameTriplet fqNameTriplet
             = (FullyQualifiedNameTriplet)getTriplet(Triplet.FULLY_QUALIFIED_NAME);
         if (fqNameTriplet != null) {
-            byte[] nameBytes = fqNameTriplet.getFullyQualifiedName();
-            if (nameBytes != null) {
-                try {
-                    return new String(nameBytes, AFPConstants.EBCIDIC_ENCODING);
-                } catch (UnsupportedEncodingException e) {
-                    log.error(e.getMessage());
-                }
-            } else {
-                log.warn(this + " has no fully qualified name");
-            }
+            return fqNameTriplet.getFullyQualifiedName();
         }
+        log.warn(this + " has no fully qualified name");
         return null;
     }
     
@@ -233,6 +220,16 @@
             StrucFlgs strucFlgs) {
         addTriplet(new ObjectClassificationTriplet(objectClass, objectType, strucFlgs));
     }
+
+    /**
+     * 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());
+    }
         
     /**
      * Specifies the extent of an object area in the X and Y directions

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=656249&r1=656248&r2=656249&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 May 14 05:26:18 2008
@@ -150,14 +150,14 @@
         writeObjects(mapPageOverlays, os);
         
         if (pageDescriptor != null) {
-            pageDescriptor.writeDataStream(os);            
+            pageDescriptor.write(os);            
         }
         if (objectAreaDescriptor != null && objectAreaPosition != null) {
-            objectAreaDescriptor.writeDataStream(os);
-            objectAreaPosition.writeDataStream(os);
+            objectAreaDescriptor.write(os);
+            objectAreaPosition.write(os);
         }
         if (presentationTextDataDescriptor != null) {
-            presentationTextDataDescriptor.writeDataStream(os);
+            presentationTextDataDescriptor.write(os);
         }
     }
 
@@ -243,7 +243,7 @@
             }
         }
     }
-    
+
     /**
      * Getter method for the most recent MapCodedFont added to the
      * Active Environment Group (returns null if no MapCodedFonts exist)
@@ -260,9 +260,9 @@
     
     /**
      * Method to create a map data resource object
-     * @param obj creates a map data resource entry for a given AFP data resource object
+     * @param dataObjectAccessor a data object accessor
      */
-    public void createResource(IncludeObject obj) {
-        getMapDataResources().add(new MapDataResource(obj));
+    protected void createMapDataResource(DataObjectAccessor dataObjectAccessor) {
+        getMapDataResources().add(new MapDataResource(dataObjectAccessor));
     }
 }
\ No newline at end of file

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataObjectAccessor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataObjectAccessor.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataObjectAccessor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/DataObjectAccessor.java Wed May 14 05:26:18 2008
@@ -19,13 +19,26 @@
 
 package org.apache.fop.render.afp.modca;
 
+import org.apache.fop.render.afp.DataObjectInfo;
+
 /**
  * A common interface of ResourceObject and ContainerObject
  */
-public interface DataObjectAccessor extends AFPDataStreamWriter {
+public interface DataObjectAccessor extends Writable {
 
     /**
      * @return the actual data object referenced in this envelope 
      */
     AbstractNamedAFPObject getDataObject();
+    
+    /**
+     * @return the data object info relating to the data object
+     */
+    DataObjectInfo getDataObjectInfo();
+
+    /**
+     * Sets the data object info
+     * @param dataObjectInfo the data object info
+     */
+    void setDataObjectInfo(DataObjectInfo dataObjectInfo);
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Document.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Document.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Document.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Document.java Wed May 14 05:26:18 2008
@@ -94,9 +94,9 @@
      * @param os The stream to write to
      * @throws java.io.IOException thrown if an I/O exception of some sort has occurred
      */
-    public void writeDataStream(OutputStream os) throws IOException {
+    public void write(OutputStream os) throws IOException {
         if (isComplete()) {
-            super.writeDataStream(os);
+            super.write(os);
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsDataDescriptor.java Wed May 14 05:26:18 2008
@@ -61,7 +61,7 @@
     /**
      * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os) throws IOException {
+    public void write(OutputStream os) throws IOException {
         byte[] xreswind = BinaryUtils.convert(xresol * 10, 2);
         byte[] yreswind = BinaryUtils.convert(yresol * 10, 2);
         byte[] xlcoord = BinaryUtils.convert(xlwind, 2);

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IMImageObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IMImageObject.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IMImageObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IMImageObject.java Wed May 14 05:26:18 2008
@@ -104,16 +104,16 @@
     protected void writeContent(OutputStream os) throws IOException {
         super.writeContent(os);
         if (imageOutputControl != null) {
-            imageOutputControl.writeDataStream(os);
+            imageOutputControl.write(os);
         }
         if (imageInputDescriptor != null) {
-            imageInputDescriptor.writeDataStream(os);
+            imageInputDescriptor.write(os);
         }
         if (imageCellPosition != null) {
-            imageCellPosition.writeDataStream(os);
+            imageCellPosition.write(os);
         }
         if (imageRasterData != null) {
-            imageRasterData.writeDataStream(os);
+            imageRasterData.write(os);
         }
     }
 

Modified: 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/modca/ImageCellPosition.java?rev=656249&r1=656248&r2=656249&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/modca/ImageCellPosition.java Wed May 14 05:26:18 2008
@@ -74,7 +74,7 @@
      * @param os The stream to write to
      * @throws java.io.IOException if an I/O exception occurred
      */
-    public void writeDataStream(OutputStream os) throws IOException {
+    public void write(OutputStream os) throws IOException {
         byte[] data = new byte[21];
 
         data[0] = 0x5A;

Modified: 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/modca/ImageContent.java?rev=656249&r1=656248&r2=656249&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/modca/ImageContent.java Wed May 14 05:26:18 2008
@@ -143,7 +143,7 @@
      */
     protected void writeContent(OutputStream os) throws IOException {
         if (_imageSizeParameter != null) {
-            _imageSizeParameter.writeDataStream(os);
+            _imageSizeParameter.write(os);
         }
         os.write(getImageEncodingParameter());
         os.write(getImageIDESizeParameter());

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageDataDescriptor.java Wed May 14 05:26:18 2008
@@ -54,7 +54,7 @@
      * @param os The stream to write to
      * @throws java.io.IOException
      */
-    public void writeDataStream(OutputStream os)
+    public void write(OutputStream os)
         throws IOException {
 
         byte[] data = new byte[] {

Modified: 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/modca/ImageInputDescriptor.java?rev=656249&r1=656248&r2=656249&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/modca/ImageInputDescriptor.java Wed May 14 05:26:18 2008
@@ -41,7 +41,7 @@
      * @param os The stream to write to
      * @throws java.io.IOException if an I/O exception occurred
      */
-    public void writeDataStream(OutputStream os) throws IOException {
+    public void write(OutputStream os) throws IOException {
 
         byte[] data = new byte[45];
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageObject.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ImageObject.java Wed May 14 05:26:18 2008
@@ -144,7 +144,7 @@
         super.writeContent(os);
         if (imageSegment != null) {
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            imageSegment.writeDataStream(baos);
+            imageSegment.write(baos);
             byte[] b = baos.toByteArray();
             int off = 0;
             while (off < b.length) {

Modified: 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/modca/ImageOutputControl.java?rev=656249&r1=656248&r2=656249&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/modca/ImageOutputControl.java Wed May 14 05:26:18 2008
@@ -78,7 +78,7 @@
      * @param os The stream to write to
      * @throws java.io.IOException if an I/O exception occured
      */
-    public void writeDataStream(OutputStream os) throws IOException {
+    public void write(OutputStream os) throws IOException {
 
         byte[] data = new byte[33];
 

Modified: 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/modca/ImageRasterData.java?rev=656249&r1=656248&r2=656249&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/modca/ImageRasterData.java Wed May 14 05:26:18 2008
@@ -63,7 +63,7 @@
      * @param os The stream to write to
      * @throws java.io.IOException if an I/O exception occurred
      */
-    public void writeDataStream(OutputStream os) throws IOException {
+    public void write(OutputStream os) throws IOException {
 
         byte[] data = new byte[9];
 

Modified: 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/modca/ImageSegment.java?rev=656249&r1=656248&r2=656249&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/modca/ImageSegment.java Wed May 14 05:26:18 2008
@@ -141,7 +141,7 @@
      */
     public void writeContent(OutputStream os) throws IOException {
         if (imageContent != null) {
-            imageContent.writeDataStream(os);
+            imageContent.write(os);
         }
     }
 

Modified: 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/modca/ImageSizeParameter.java?rev=656249&r1=656248&r2=656249&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/modca/ImageSizeParameter.java Wed May 14 05:26:18 2008
@@ -53,7 +53,7 @@
      * @param os The stream to write to
      * @throws java.io.IOException if an I/O exception occured
      */
-    public void writeDataStream(OutputStream os) throws IOException {
+    public void write(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/IncludeObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludeObject.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludeObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludeObject.java Wed May 14 05:26:18 2008
@@ -22,8 +22,8 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.render.afp.ResourceInfo;
-import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet;
+import org.apache.fop.render.afp.DataObjectInfo;
+import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet;
 import org.apache.fop.render.afp.tools.BinaryUtils;
 
 /**
@@ -69,7 +69,7 @@
     /**
      * The object type (default is other)
      */
-    private byte objectType = TYPE_OTHER;
+    private byte dataObjectType = TYPE_OTHER;
 
     /**
      * The orientation on the include object
@@ -95,11 +95,6 @@
      * The Y-axis origin defined in the object
      */
     private int yContentOffset = -1;
-        
-    /**
-     * the resource info
-     */
-    private ResourceInfo resourceInfo = null;
 
     /**
      * the referenced data object
@@ -113,75 +108,72 @@
      *
      * @param name the name of this include object
      * @param dataObjectAccessor the data object accessor
-     * @param resourceInfo the resource information
      */
-    public IncludeObject(String name, DataObjectAccessor dataObjectAccessor,
-            ResourceInfo resourceInfo) {
+    public IncludeObject(String name, DataObjectAccessor dataObjectAccessor) {
         super(name);
-        
-        setDataObjectAccessor(dataObjectAccessor);
-        setResourceInfo(resourceInfo);
-    }
 
-    /**
-     * Sets the data object accessor and the object type
-     * @param dataObjectAccessor the data object accessor
-     */
-    private void setDataObjectAccessor(DataObjectAccessor dataObjectAccessor) {
         this.dataObjectAccessor = dataObjectAccessor;
         
         AbstractNamedAFPObject dataObject = dataObjectAccessor.getDataObject();
-        
+
+        // Strip any object container
+        if (dataObject instanceof ObjectContainer) {
+            ObjectContainer objectContainer = (ObjectContainer)dataObject;
+            dataObject = objectContainer.getDataObject();
+        }
         if (dataObject instanceof ImageObject) {
-            this.objectType = TYPE_IMAGE;
+            this.dataObjectType = TYPE_IMAGE;
         } else if (dataObject instanceof GraphicsObject) {
-            this.objectType = TYPE_GRAPHIC;
+            this.dataObjectType = TYPE_GRAPHIC;
         } else if (dataObject instanceof PageSegment) {
-            this.objectType = TYPE_PAGE_SEGMENT;
+            this.dataObjectType = TYPE_PAGE_SEGMENT;
         } else {
-            this.objectType = TYPE_OTHER;
+            this.dataObjectType = TYPE_OTHER;
+            DataObjectInfo dataObjectInfo = dataObjectAccessor.getDataObjectInfo();
+            Registry registry = Registry.getInstance();
+            Registry.ObjectType objectType = registry.getObjectType(dataObjectInfo);
+            // When other type must set object classification
+            super.setObjectClassification(
+                    ObjectClassificationTriplet.CLASS_TIME_INVARIANT_PAGINATED_PRESENTATION_OBJECT,
+                    objectType);
         }
+        
+//        ResourceInfo resourceInfo = dataObjectAccessor.getDataObjectInfo().getResourceInfo();
+//        // Set data object reference triplet
+//        if (resourceInfo != null && resourceInfo.isExternal()) {
+//            String dest = resourceInfo.getExternalResourceGroupDest();
+//            super.setFullyQualifiedName(
+//                    FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_EXTERNAL_RESOURCE_REF,
+//                    FullyQualifiedNameTriplet.FORMAT_URL, dest);
+//        } else {
+//            super.setFullyQualifiedName(
+//                    FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_INTERNAL_RESOURCE_REF,
+//                    FullyQualifiedNameTriplet.FORMAT_CHARSTR, dataObject.getName());
+//        }
+        
+        // Set measurement units triplet
+        setMeasurementUnits();
     }
 
     /**
-     * @return the data object accessor
-     */
-    private DataObjectAccessor getDataObjectAccessor() {
-        return this.dataObjectAccessor;
-    }
-    
-    /**
-     * Sets the resource level for this resource object
-     * @param resourceInfo the resource information
+     * {@inheritDoc}
      */
-    private void setResourceInfo(ResourceInfo resourceInfo) {
-        this.resourceInfo = resourceInfo;
-        
-        // set data object reference triplet
-        if (resourceInfo != null && resourceInfo.isExternal()) {
-            String dest = resourceInfo.getExternalResourceGroupDest();
-            super.setFullyQualifiedName(
-                    FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_EXTERNAL_RESOURCE_REF,
-                    FullyQualifiedNameTriplet.FORMAT_URL, dest);
-        } else {
-            super.setFullyQualifiedName(
-                    FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_INTERNAL_RESOURCE_REF,
-                    FullyQualifiedNameTriplet.FORMAT_CHARSTR, getDataObject().getName());
-        }        
+    public AbstractNamedAFPObject getDataObject() {
+        return dataObjectAccessor.getDataObject();
     }
     
     /**
-     * @return the resource info of this resource object
+     * {@inheritDoc}
      */
-    public ResourceInfo getResourceInfo() {
-        return this.resourceInfo;
+    public DataObjectInfo getDataObjectInfo() {
+        return dataObjectAccessor.getDataObjectInfo();
     }
 
     /**
-     * @return the actual resource data object referenced by this include object
+     * {@inheritDoc}
      */
-    public AbstractNamedAFPObject getDataObject() {
-        return getDataObjectAccessor().getDataObject();
+    public void setDataObjectInfo(DataObjectInfo dataObjectInfo) {
+        dataObjectAccessor.setDataObjectInfo(dataObjectInfo);
     }
 
     /**
@@ -223,7 +215,7 @@
     /**
      * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os) throws IOException {       
+    public void write(OutputStream os) throws IOException {       
         byte[] data = new byte[36];
         data[0] = 0x5A;
 
@@ -246,7 +238,7 @@
         }
 
         data[17] = 0x00; // reserved
-        data[18] = objectType;
+        data[18] = dataObjectType;
 
         //XoaOset (object area)
         if (xOffset > 0) {
@@ -337,4 +329,11 @@
         byte[] tripletData = super.getTripletData();
         os.write(tripletData);
     }
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String toString() {
+        return "IOB: " + this.getName();
+    }
 }
\ No newline at end of file

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageOverlay.java Wed May 14 05:26:18 2008
@@ -87,7 +87,7 @@
     /**
      * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os) throws IOException {
+    public void write(OutputStream os) throws IOException {
         byte[] data = new byte[25]; //(9 +16)
         data[0] = 0x5A;
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/IncludePageSegment.java Wed May 14 05:26:18 2008
@@ -67,7 +67,7 @@
     /**
      * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os) throws IOException {
+    public void write(OutputStream os) throws IOException {
 
         byte[] data = new byte[23]; //(9 +14)
 

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/InterchangeSet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/InterchangeSet.java?rev=656249&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/InterchangeSet.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/InterchangeSet.java Wed May 14 05:26:18 2008
@@ -0,0 +1,106 @@
+/*
+ * 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;
+
+/**
+ * MO:DCA Interchange Set
+ */
+public class InterchangeSet {
+    /** interchange set 1 string value */
+    public static final String MODCA_PRESENTATION_INTERCHANGE_SET_1 = "MO:DCA-P IS/1";
+    
+    /** interchange set 2 string value */
+    public static final String MODCA_PRESENTATION_INTERCHANGE_SET_2 = "MO:DCA-P IS/2";
+    
+    /** resource interchange set string value */
+    public static final String MODCA_RESOURCE_INTERCHANGE_SET = "MO:DCA-L";
+
+    private static final String[] NAMES = {
+        MODCA_PRESENTATION_INTERCHANGE_SET_1,
+        MODCA_PRESENTATION_INTERCHANGE_SET_2,
+        MODCA_RESOURCE_INTERCHANGE_SET
+    };
+
+    private static final int SET_1 = 0;
+    private static final int SET_2 = 1;
+    private static final int RESOURCE_SET = 2;
+
+    /** the actual interchange set in use */
+    private int value;
+
+    /**
+     * @param str an interchange set value
+     * @return an interchange set
+     */
+    public static InterchangeSet valueOf(String str) {
+        if (MODCA_PRESENTATION_INTERCHANGE_SET_1.equals(str)) {
+            return new InterchangeSet(SET_1);
+        } else if (MODCA_PRESENTATION_INTERCHANGE_SET_2.equals(str)) {
+            return new InterchangeSet(SET_2);
+        } else if (MODCA_RESOURCE_INTERCHANGE_SET.equals(str)) {
+            return new InterchangeSet(RESOURCE_SET);
+        } else {
+            throw new IllegalArgumentException("Invalid MO:DCA interchange set :" + str);
+        }
+    }
+    /**
+     * Main constructor
+     * 
+     * @param value the interchange set value
+     */
+    public InterchangeSet(int value) {
+        this.value = value;
+    }
+
+    /**
+     * @return true if complies with MOD:CA interchange set 1
+     */
+    protected boolean is1() {
+        return value == SET_1;
+    }
+    
+    /**
+     * @return true if complies with MOD:CA interchange set 2
+     */
+    public boolean is2() {
+        return value == SET_2;
+    }
+    
+    /**
+     * @return true if complies with MOD:CA resource set
+     */
+    public boolean isResource() {
+        return value == RESOURCE_SET;
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String toString() {
+        return NAMES[value];
+    }
+    
+    /**
+     * @return true if MOD:CA interchange set 2 (resource groups) is supported
+     */
+    public boolean supportsLevel2() {
+        return is2() || isResource();
+    }
+}

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/InvokeMediumMap.java Wed May 14 05:26:18 2008
@@ -43,7 +43,7 @@
     /**
      * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os) throws IOException {
+    public void write(OutputStream os) throws IOException {
 
         byte[] data = new byte[17];
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapCodedFont.java Wed May 14 05:26:18 2008
@@ -63,7 +63,7 @@
      * @param os The stream to write to
      * @throws java.io.IOException an I/O exception of some sort has occurred
      */
-    public void writeDataStream(OutputStream os) throws IOException {
+    public void write(OutputStream os) throws IOException {
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         baos.write(0x5A);

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java Wed May 14 05:26:18 2008
@@ -23,6 +23,7 @@
 import java.io.OutputStream;
 
 //import org.apache.fop.render.afp.ResourceLevel;
+import org.apache.fop.render.afp.DataObjectInfo;
 import org.apache.fop.render.afp.ResourceInfo;
 import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet;
 import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet;
@@ -41,44 +42,31 @@
 
     /**
      * Main constructor
-     * @param includeObj a map data resource for a given structured AFP object
+     * @param dataObjectAccessor a data object accessor
      */
-    public MapDataResource(IncludeObject includeObj) {
-        AbstractStructuredAFPObject dataObject = includeObj.getDataObject();
-//        ResourceObject resObj = includeObj.getResource();
-        String fqName = dataObject.getFullyQualifiedName();
-        ResourceInfo resourceInfo = includeObj.getResourceInfo();
-        if (fqName != null) {
-            if (resourceInfo.isExternal()) {
-                String dest = resourceInfo.getExternalResourceGroupDest();
+    public MapDataResource(DataObjectAccessor dataObjectAccessor) {
+        AbstractNamedAFPObject namedDataObject = dataObjectAccessor.getDataObject();
+        DataObjectInfo dataObjectInfo = dataObjectAccessor.getDataObjectInfo();
+        ResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
+        if (resourceInfo.isExternal()) {
+            String dest = resourceInfo.getExternalResourceGroupDest();
+            if (dest != null) {
                 super.setFullyQualifiedName(
-                    FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_EXTERNAL_RESOURCE_REF,
-                    FullyQualifiedNameTriplet.FORMAT_CHARSTR, dest);
-            } else {
-//            super.setFullyQualifiedName(
-//                    FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_INTERNAL_RESOURCE_REF,
-//                    FullyQualifiedNameTriplet.FORMAT_CHARSTR, fqName);            
-                super.setFullyQualifiedName(
-                    FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF,
-                    FullyQualifiedNameTriplet.FORMAT_CHARSTR, fqName);
+                        FullyQualifiedNameTriplet.TYPE_DATA_OBJECT_EXTERNAL_RESOURCE_REF,
+                        FullyQualifiedNameTriplet.FORMAT_URL, dest);
             }
+        } else {
+            String fqName = namedDataObject.getFullyQualifiedName();
+            super.setFullyQualifiedName(
+                    FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF,
+                    FullyQualifiedNameTriplet.FORMAT_CHARSTR, fqName);            
         }
-//        if (fqName != null) {
-//            super.setFullyQualifiedName(
-//                FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF,
-//                FullyQualifiedNameTriplet.FORMAT_CHARSTR, fqName);
-//        }
-        final boolean dataInContainer = true;
-        final boolean containerHasOEG = false;
-        final boolean dataInOCD = true;
-        StrucFlgs strucFlgs = new StrucFlgs(
-            dataInContainer, containerHasOEG, dataInOCD
-        );
-
-        //  
-//        super.setObjectClassification(
-//                ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT,
-//                objectType, strucFlgs);
+
+        // Set object classification
+        Registry.ObjectType objectType = dataObjectInfo.getObjectType();
+        super.setObjectClassification(
+                ObjectClassificationTriplet.CLASS_TIME_VARIANT_PRESENTATION_OBJECT,
+                objectType);
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapPageOverlay.java Wed May 14 05:26:18 2008
@@ -83,7 +83,7 @@
      * @param os The stream to write to
      * @throws java.io.IOException if an I/O exception occurred
      */
-    public void writeDataStream(OutputStream os) throws IOException {
+    public void write(OutputStream os) throws IOException {
         int oLayCount = getOverlays().size();
         int recordlength = oLayCount * 18;
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/NoOperation.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/NoOperation.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/NoOperation.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/NoOperation.java Wed May 14 05:26:18 2008
@@ -60,7 +60,7 @@
      * @param os The outputsteam stream
      * @throws java.io.IOException if an I/O exception occurs during processing
      */
-    public void writeDataStream(OutputStream os) throws IOException {
+    public void write(OutputStream os) throws IOException {
         byte[] contentData = content.getBytes(AFPConstants.EBCIDIC_ENCODING);
         int contentLen = contentData.length;
         

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java?rev=656249&r1=656248&r2=656249&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaDescriptor.java Wed May 14 05:26:18 2008
@@ -47,7 +47,7 @@
      * @param os The stream to write to
      * @throws java.io.IOException thrown if an I/O exception of some sort has occurred
      */
-    public void writeDataStream(OutputStream os)
+    public void write(OutputStream os)
         throws IOException {
 
         byte[] data = new byte[29];



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