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/03/27 17:16:38 UTC

svn commit: r641873 [4/5] - in /xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop: image/ render/afp/ render/afp/extensions/ render/afp/modca/ render/afp/modca/triplets/ render/pdf/ render/ps/extensions/

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=641873&r1=641872&r2=641873&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 Thu Mar 27 09:16:30 2008
@@ -19,65 +19,225 @@
 
 package org.apache.fop.render.afp.modca;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.fop.render.afp.modca.triplets.FullyQualifiedNameTriplet;
+import org.apache.fop.render.afp.modca.triplets.MeasurementUnitsTriplet;
+import org.apache.fop.render.afp.modca.triplets.ObjectAreaSizeTriplet;
+import org.apache.fop.render.afp.modca.triplets.ObjectClassificationTriplet;
+import org.apache.fop.render.afp.modca.triplets.Triplet;
 
 /**
  * An abstract class encapsulating an MODCA structured object
  */
-public abstract class AbstractStructuredAFPObject extends AbstractNamedAFPObject {
+public abstract class AbstractStructuredAFPObject extends AbstractAFPObject {
    
     /**
+     * list of object triplets
+     */
+    protected List/*<Triplet>*/ triplets = null;
+    
+    /**
+     * triplet data created from triplet list
+     */
+    protected byte[] tripletData = null;
+
+    /**
      * Default constructor
      */
-    public AbstractStructuredAFPObject() {
-        super();
+    protected AbstractStructuredAFPObject() {
     }
     
     /**
-     * Named constructor
-     * @param name name of structured object
+     * @return the triplet data length
      */
-    public AbstractStructuredAFPObject(String name) {
-        super(name);
+    protected int getTripletDataLength() {
+        if (tripletData != null) {
+            return tripletData.length;
+        }
+        return 0;
     }
-
+    
     /**
      * Helper method to write the start of the Object.
      * @param os The stream to write to
      * @throws IOException an I/O exception if one occurred
      */
     protected void writeStart(OutputStream os) throws IOException {
+        if (triplets != null) {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            writeObjects(triplets, baos);
+            this.tripletData = baos.toByteArray();
+        }
     }
 
     /**
      * Helper method to write the contents of the Object.
      * @param os The stream to write to
-     * @throws IOException an I/O exception if one occurred
+     * @throws IOException The stream to write to
      */
     protected void writeContent(OutputStream os) throws IOException {
+        writeTriplets(os);
     }
 
     /**
+     * Writes any triplet data
+     * @param os The stream to write to
+     * @throws IOException The stream to write to
+     */
+    protected void writeTriplets(OutputStream os) throws IOException {
+        if (tripletData != null) {
+            os.write(tripletData);
+        } else if (triplets != null) {
+            writeObjects(triplets, os);
+        }        
+    }
+    
+    /**
      * Helper method to write the end of the Object.
      * @param os The stream to write to
      * @throws IOException an I/O exception if one occurred
      */
     protected void writeEnd(OutputStream os) throws IOException {
     }    
-
+    
     /**
      * Accessor method to write the AFP datastream for the Image Object
      * @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 writeDataStream(OutputStream os) throws IOException {
         writeStart(os);
-
         writeContent(os);
-
         writeEnd(os);
-    }    
+    }
+
+    /**
+     * Returns the first matching triplet found in the structured field triplet list 
+     * @param tripletId the triplet identifier
+     */
+    private Triplet getTriplet(byte tripletId) {
+        Iterator it = getTriplets().iterator();
+        while (it.hasNext()) {
+            Triplet triplet = (Triplet)it.next();
+            if (triplet.getId() == tripletId) {
+                return triplet;
+            }
+        }
+        return null;
+    }
+    
+    /**
+     * @param tripletId the triplet identifier
+     * @return true if the structured field has the given triplet
+     */
+    private boolean hasTriplet(byte tripletId) {
+        return getTriplet(tripletId) != null;
+    }
+
+    /**
+     * Adds a triplet to this structured object
+     * @param triplet the triplet to add
+     */
+    private void addTriplet(Triplet triplet) {
+        getTriplets().add(triplet);
+    }
+
+    /**
+     * Adds a list of triplets to the triplets contained within this structured field
+     * @param tripletCollection a collection of triplets
+     */
+    private void addTriplets(Collection/*<Triplet>*/ tripletCollection) {
+        if (tripletCollection != null) {
+            getTriplets().addAll(tripletCollection);
+        }
+    }
+
+    /**
+     * @return the triplet list pertaining to this resource
+     */
+    protected List/*<Triplet>*/ getTriplets() {
+        if (triplets == null) {
+            triplets = new java.util.ArrayList();
+        }
+        return triplets;
+    }
+        
+    /**
+     * Sets the fully qualified name of this resource
+     * @param fqnType the fully qualified name type of this resource
+     * @param fqnFormat the fully qualified name format of this resource
+     * @param fqName the fully qualified name of this resource
+     */
+    public void setFullyQualifiedName(byte fqnType, byte fqnFormat, String fqName) {
+        byte[] fqNameBytes;
+        try {
+            fqNameBytes = fqName.getBytes(AFPConstants.EBCIDIC_ENCODING);
+            addTriplet(new FullyQualifiedNameTriplet(fqnType, fqnFormat, fqNameBytes));
+        } catch (UnsupportedEncodingException e) {
+            log.error(e.getMessage());
+        }
+    }
+
+    /**
+     * @return the fully qualified name of this triplet or null if it does not exist
+     */
+    public String getFullyQualifiedName() {
+        FullyQualifiedNameTriplet fqNameTriplet
+            = (FullyQualifiedNameTriplet)getTriplet(Triplet.FULLY_QUALIFIED_NAME);
+        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 null;
+    }
+    
+    /**
+     * Sets the objects classification
+     * @param objectClass the classification of the object
+     * @param componentId the component Id of the object 
+     */
+    public void setObjectClassification(byte objectClass, byte componentId) {
+        addTriplet(new ObjectClassificationTriplet(objectClass, componentId));
+    }
+
+    /**
+     * Specifies the extent of an object area in the X and Y directions
+     * @param x the x direction extent
+     * @param y the y direction extent
+     */
+    public void setObjectAreaSize(int x, int y) {
+        addTriplet(new ObjectAreaSizeTriplet(x, y));
+    }
+
+    /**
+     * Sets the measurement units used to specify the units of measure
+     */
+    public void setMeasurementUnits() {
+        addTriplet(new MeasurementUnitsTriplet());
+    }
+
+    /**
+     * Sets a comment on this resource
+     * @param comment a comment string
+     */
+    public void setComment(String comment) {
+        try {
+            addTriplet(new Triplet(Triplet.COMMENT, comment));
+        } catch (UnsupportedEncodingException e) {
+            log.error(e.getMessage());
+        }
+    }
 }

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=641873&r1=641872&r2=641873&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 Thu Mar 27 09:16:30 2008
@@ -18,6 +18,7 @@
 /* $Id$ */
 
 package org.apache.fop.render.afp.modca;
+
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.List;
@@ -37,7 +38,7 @@
  * containing page or overlay.
  *
  */
-public final class ActiveEnvironmentGroup extends AbstractNamedAFPObject {
+public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup {
 
     /**
      * Default name for the active environment group
@@ -47,7 +48,12 @@
     /**
      * The collection of MapCodedFont objects
      */
-    private List mapCodedFonts = new java.util.ArrayList();
+    private List mapCodedFonts = null;
+
+    /**
+     * The collection of MapDataResource objects
+     */
+    private List mapDataResources = null;
 
     /**
      * The Object Area Descriptor for the active environment group
@@ -70,22 +76,14 @@
     private PageDescriptor pageDescriptor = null;
 
     /**
-     * The collection of MapPageOverlay objects
-     */
-    private List mapPageOverlays = new java.util.ArrayList();
-
-    /**
      * Default constructor for the ActiveEnvironmentGroup.
      * @param width the page width
      * @param height the page height
      * @param widthRes the page width resolution
      * @param heightRes the page height resolution
      */
-    public ActiveEnvironmentGroup(int width, int height,
-            int widthRes, int heightRes) {
-
+    public ActiveEnvironmentGroup(int width, int height, int widthRes, int heightRes) {
         this(DEFAULT_NAME, width, height, widthRes, heightRes);
-
     }
 
     /**
@@ -97,9 +95,7 @@
      * @param widthRes the page width resolution
      * @param heightRes the page height resolution
      */
-    public ActiveEnvironmentGroup(String name, int width, int height,
-            int widthRes, int heightRes) {
-
+    public ActiveEnvironmentGroup(String name, int width, int height, int widthRes, int heightRes) {
         super(name);
 
         // Create PageDescriptor
@@ -112,7 +108,6 @@
         // Create PresentationTextDataDescriptor
         presentationTextDataDescriptor = new PresentationTextDescriptor(width, height,
                     widthRes, heightRes);
-
     }
 
     /**
@@ -122,10 +117,8 @@
      * @param rotation the rotation
      */
     public void setPosition(int x, int y, int rotation) {
-
         // Create ObjectAreaPosition
         objectAreaPosition = new ObjectAreaPosition(x, y, rotation);
-
     }
 
     /**
@@ -134,9 +127,7 @@
      * @return the page descriptor object
      */
     public PageDescriptor getPageDescriptor() {
-
         return pageDescriptor;
-
     }
 
     /**
@@ -145,47 +136,36 @@
      * @return the presentation text descriptor
      */
     public PresentationTextDescriptor getPresentationTextDataDescriptor() {
-
         return presentationTextDataDescriptor;
-
     }
 
     /**
-     * Accessor method to write the AFP datastream for the active environment group.
-     * @param os The stream to write to
-     * @throws java.io.IOException throws if an I/O exception of some sort has occurred
+     * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os)
-        throws IOException {
-
-        writeStart(os);
-
-        writeObjectList(mapCodedFonts, os);
-
-        writeObjectList(mapPageOverlays, os);
-
-        pageDescriptor.writeDataStream(os);
-
+    public void writeContent(OutputStream os) throws IOException {
+        super.writeTriplets(os);
+        
+        writeObjects(mapCodedFonts, os);
+        writeObjects(mapPageOverlays, os);
+        writeObjects(mapDataResources, os);
+        
+        if (pageDescriptor != null) {
+            pageDescriptor.writeDataStream(os);            
+        }
         if (objectAreaDescriptor != null && objectAreaPosition != null) {
             objectAreaDescriptor.writeDataStream(os);
             objectAreaPosition.writeDataStream(os);
         }
-
-        presentationTextDataDescriptor.writeDataStream(os);
-
-        writeEnd(os);
-
+        if (presentationTextDataDescriptor != null) {
+            presentationTextDataDescriptor.writeDataStream(os);
+        }
     }
 
     /**
-     * Helper method to write the start of the active environment group.
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeStart(OutputStream os)
-        throws IOException {
-
+    protected void writeStart(OutputStream os) throws IOException {
         byte[] data = new byte[17];
-
         data[0] = 0x5A; // Structured field identifier
         data[1] = 0x00; // Length byte 1
         data[2] = 0x10; // Length byte 2
@@ -195,26 +175,17 @@
         data[6] = 0x00; // Flags
         data[7] = 0x00; // Reserved
         data[8] = 0x00; // Reserved
-
         for (int i = 0; i < nameBytes.length; i++) {
-
             data[9 + i] = nameBytes[i];
-
         }
-
-       os.write(data);
-
+        os.write(data);
     }
 
     /**
-     * Helper method to write the end of the active environment group.
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeEnd(OutputStream os)
-        throws IOException {
-
+    protected void writeEnd(OutputStream os) throws IOException {
         byte[] data = new byte[17];
-
         data[0] = 0x5A; // Structured field identifier
         data[1] = 0x00; // Length byte 1
         data[2] = 0x10; // Length byte 2
@@ -224,130 +195,75 @@
         data[6] = 0x00; // Flags
         data[7] = 0x00; // Reserved
         data[8] = 0x00; // Reserved
-
         for (int i = 0; i < nameBytes.length; i++) {
-
             data[9 + i] = nameBytes[i];
-
         }
-
         os.write(data);
+    }
 
+    private List getMapCodedFonts() {
+        if (mapCodedFonts == null) {
+            mapCodedFonts = new java.util.ArrayList();
+        }
+        return mapCodedFonts;
+    }
+
+    private List getMapDataResources() {
+        if (mapDataResources == null) {
+            mapDataResources = new java.util.ArrayList();
+        }
+        return mapDataResources;
     }
 
     /**
      * Method to create a map coded font object
-     * @param fontReference the font number used as the resource identifier
+     * @param fontRef the font number used as the resource identifier
      * @param font the font
      * @param size the point size of the font
      * @param orientation the orientation of the font (e.g. 0, 90, 180, 270)
      */
-    public void createFont(
-        int fontReference,
-        AFPFont font,
-        int size,
-        int orientation) {
-
+    public void createFont(int fontRef, AFPFont font, int size, int orientation) {
         MapCodedFont mcf = getCurrentMapCodedFont();
-
         if (mcf == null) {
             mcf = new MapCodedFont();
-            mapCodedFonts.add(mcf);
+            getMapCodedFonts().add(mcf);
         }
 
         try {
-            
-            mcf.addFont(
-                fontReference,
-                font,
-                size,
-                orientation);
-
+            mcf.addFont(fontRef, font, size, orientation);
         } catch (MaximumSizeExceededException msee) {
-
             mcf = new MapCodedFont();
-            mapCodedFonts.add(mcf);
+            getMapCodedFonts().add(mcf);
 
             try {
-
-                mcf.addFont(
-                    fontReference,
-                    font,
-                    size,
-                    orientation);
-
+                mcf.addFont(fontRef, font, size, orientation);
             } catch (MaximumSizeExceededException ex) {
-
                 // Should never happen (but log just in case)
                 log.error("createFont():: resulted in a MaximumSizeExceededException");
-
-            }
-
-        }
-
-    }
-
-    /**
-     * Actually creates the MPO object.
-     * Also creates the supporting object (an IPO)
-     * @param name the name of the overlay to be used
-     */
-    public void createOverlay(String name) {
-
-        MapPageOverlay mpo = getCurrentMapPageOverlay();
-
-        if (mpo == null) {
-            mpo = new MapPageOverlay();
-            mapPageOverlays.add(mpo);
-        }
-
-        try {
-
-            mpo.addOverlay(name);
-
-        } catch (MaximumSizeExceededException msee) {
-            mpo = new MapPageOverlay();
-            mapPageOverlays.add(mpo);
-            try {
-                mpo.addOverlay(name);
-            } catch (MaximumSizeExceededException ex) {
-                // Should never happen (but log just in case)
-                log.error("createOverlay():: resulted in a MaximumSizeExceededException");
             }
         }
     }
-
+    
     /**
      * Getter method for the most recent MapCodedFont added to the
      * Active Environment Group (returns null if no MapCodedFonts exist)
      * @return the most recent Map Coded Font.
      */
     private MapCodedFont getCurrentMapCodedFont() {
-
-        int size = mapCodedFonts.size();
+        int size = getMapCodedFonts().size();
         if (size > 0) {
-            return (MapCodedFont) mapCodedFonts.get(mapCodedFonts.size() - 1);
+            return (MapCodedFont)mapCodedFonts.get(size - 1);
         } else {
             return null;
         }
-
     }
-
+    
+    
     /**
-     * Getter method for the most recent MapPageOverlay added to the
-     * Active Environment Group (returns null if no MapPageOverlay exist)
-     * @return the most recent Map Coded Font
+     * Method to create a map data resource object
+     * @param obj creates a map data resource entry for a given AFP data resource object
      */
-    private MapPageOverlay getCurrentMapPageOverlay() {
-
-        int size = mapPageOverlays.size();
-        if (size > 0) {
-            return (MapPageOverlay) mapPageOverlays.get(
-                mapPageOverlays.size() - 1);
-        } else {
-            return null;
-        }
-
+    public void createResource(AbstractStructuredAFPObject obj) {
+        getMapDataResources().add(new MapDataResource(obj));
     }
-
 }

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=641873&r1=641872&r2=641873&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 Thu Mar 27 09:16:30 2008
@@ -18,10 +18,9 @@
 /* $Id$ */
 
 package org.apache.fop.render.afp.modca;
+
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.List;
 
 /**
  * The document is the highest level of the MO:DCA data-stream document
@@ -48,23 +47,13 @@
  * document to be presented.
  *
  */
-public final class Document extends AbstractNamedAFPObject {
+public final class Document extends AbstractResourceEnvironmentGroupContainer {
 
     /**
-     * Ststic default name reference
+     * Static default generated name reference
      */
     private static final String DEFAULT_NAME = "DOC00001";
-
-    /**
-     * A list of the objects in the document
-     */
-    private List objects = new java.util.ArrayList();
-
-    /**
-     * The document started state
-     */
-    private boolean started = false;
-
+    
     /**
      * The document completion state
      */
@@ -82,36 +71,14 @@
      * @param name The name of the document
      */
     public Document(String name) {
-
         super(name);
-
-    }
-
-    /**
-     * Adds a page to the document.
-     * @param page - the Page object
-     */
-    public void addPage(PageObject page) {
-        if (!objects.contains(page)) {
-            objects.add(page);
-        }
-    }
-
-    /**
-     * Adds a PageGroup to the document.
-     * @param pageGroup the PageGroup object
-     */
-    public void addPageGroup(PageGroup pageGroup) {
-        objects.add(pageGroup);
     }
 
     /**
      * Method to mark the end of the page group.
      */
     public void endDocument() {
-
         complete = true;
-
     }
 
     /**
@@ -127,40 +94,17 @@
      * @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 {
-
-        if (!started) {
-            writeStart(os);
-            started = true;
-        }
-
-        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;
-            }
+    public void writeDataStream(OutputStream os) throws IOException {
+        if (isComplete()) {
+            super.writeDataStream(os);
         }
-
-        if (complete) {
-            writeEnd(os);
-        }
-
     }
 
     /**
-     * Helper method to write the start of the Document
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeStart(OutputStream os)
-        throws IOException {
-
+    protected void writeStart(OutputStream os) throws IOException {
         byte[] data = new byte[17];
-
         data[0] = 0x5A; // Structured field identifier
         data[1] = 0x00; // Length byte 1
         data[2] = 0x10; // Length byte 2
@@ -170,26 +114,17 @@
         data[6] = 0x00; // Flags
         data[7] = 0x00; // Reserved
         data[8] = 0x00; // Reserved
-
         for (int i = 0; i < nameBytes.length; i++) {
-
             data[9 + i] = nameBytes[i];
-
         }
-
         os.write(data);
-
     }
 
     /**
-     * Helper method to write the end of the Document.
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeEnd(OutputStream os)
-        throws IOException {
-
+    protected void writeEnd(OutputStream os) throws IOException {
         byte[] data = new byte[17];
-
         data[0] = 0x5A; // Structured field identifier
         data[1] = 0x00; // Length byte 1
         data[2] = 0x10; // Length byte 2
@@ -199,15 +134,16 @@
         data[6] = 0x00; // Flags
         data[7] = 0x00; // Reserved
         data[8] = 0x00; // Reserved
-
         for (int i = 0; i < nameBytes.length; i++) {
-
             data[9 + i] = nameBytes[i];
-
         }
-
         os.write(data);
-
     }
-
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String toString() {
+        return this.name;
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java?rev=641873&r1=641872&r2=641873&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/GraphicsObject.java Thu Mar 27 09:16:30 2008
@@ -23,22 +23,22 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.render.afp.modca.goca.GraphicsBox;
-import org.apache.fop.render.afp.modca.goca.GraphicsData;
-import org.apache.fop.render.afp.modca.goca.GraphicsFillet;
-import org.apache.fop.render.afp.modca.goca.GraphicsFullArc;
-import org.apache.fop.render.afp.modca.goca.GraphicsImageBegin;
-import org.apache.fop.render.afp.modca.goca.GraphicsImageData;
-import org.apache.fop.render.afp.modca.goca.GraphicsImageEnd;
-import org.apache.fop.render.afp.modca.goca.GraphicsLine;
-import org.apache.fop.render.afp.modca.goca.GraphicsSetArcParameters;
-import org.apache.fop.render.afp.modca.goca.GraphicsSetCharacterSet;
-import org.apache.fop.render.afp.modca.goca.GraphicsSetCurrentPosition;
-import org.apache.fop.render.afp.modca.goca.GraphicsSetLineType;
-import org.apache.fop.render.afp.modca.goca.GraphicsSetLineWidth;
-import org.apache.fop.render.afp.modca.goca.GraphicsSetPatternSymbol;
-import org.apache.fop.render.afp.modca.goca.GraphicsSetProcessColor;
-import org.apache.fop.render.afp.modca.goca.GraphicsString;
+import org.apache.fop.render.afp.goca.GraphicsBox;
+import org.apache.fop.render.afp.goca.GraphicsData;
+import org.apache.fop.render.afp.goca.GraphicsFillet;
+import org.apache.fop.render.afp.goca.GraphicsFullArc;
+import org.apache.fop.render.afp.goca.GraphicsImageBegin;
+import org.apache.fop.render.afp.goca.GraphicsImageData;
+import org.apache.fop.render.afp.goca.GraphicsImageEnd;
+import org.apache.fop.render.afp.goca.GraphicsLine;
+import org.apache.fop.render.afp.goca.GraphicsSetArcParameters;
+import org.apache.fop.render.afp.goca.GraphicsSetCharacterSet;
+import org.apache.fop.render.afp.goca.GraphicsSetCurrentPosition;
+import org.apache.fop.render.afp.goca.GraphicsSetLineType;
+import org.apache.fop.render.afp.goca.GraphicsSetLineWidth;
+import org.apache.fop.render.afp.goca.GraphicsSetPatternSymbol;
+import org.apache.fop.render.afp.goca.GraphicsSetProcessColor;
+import org.apache.fop.render.afp.goca.GraphicsString;
 
 /**
  * Top-level GOCA graphics object.
@@ -309,7 +309,7 @@
      * {@inheritDoc}
      */
     public String toString() {
-        return "GraphicsObject";
+        return "GraphicsObject: " + getName();
     }
 
     /**

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=641873&r1=641872&r2=641873&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 Thu Mar 27 09:16:30 2008
@@ -63,9 +63,7 @@
      * @param name The name of the image.
      */
     public IMImageObject(String name) {
-
         super(name);
-
     }
 
     /**
@@ -101,44 +99,29 @@
     }
 
     /**
-     * Accessor method to write the AFP datastream for the IM Image Objetc
-     * @param os The stream to write to
-     * @throws java.io.IOException thrown if an I/O exception of some sort has occurred
+     * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os)
-        throws IOException {
-
-        writeStart(os);
-
+    protected void writeContent(OutputStream os) throws IOException {
+        super.writeContent(os);
         if (imageOutputControl != null) {
             imageOutputControl.writeDataStream(os);
         }
-
         if (imageInputDescriptor != null) {
             imageInputDescriptor.writeDataStream(os);
         }
-
         if (imageCellPosition != null) {
             imageCellPosition.writeDataStream(os);
         }
-
         if (imageRasterData != null) {
             imageRasterData.writeDataStream(os);
         }
-
-        writeEnd(os);
-
     }
 
     /**
-     * Helper method to write the start of the IM Image Object.
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeStart(OutputStream os)
-        throws IOException {
-
+    protected void writeStart(OutputStream os) throws IOException {
         byte[] data = new byte[17];
-
         data[0] = 0x5A; // Structured field identifier
         data[1] = 0x00; // Length byte 1
         data[2] = 0x10; // Length byte 2
@@ -148,26 +131,17 @@
         data[6] = 0x00; // Flags
         data[7] = 0x00; // Reserved
         data[8] = 0x00; // Reserved
-
         for (int i = 0; i < nameBytes.length; i++) {
-
             data[9 + i] = nameBytes[i];
-
         }
-
         os.write(data);
-
     }
 
     /**
-     * Helper method to write the end of the IM Image Object.
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeEnd(OutputStream os)
-        throws IOException {
-
+    protected void writeEnd(OutputStream os) throws IOException {
         byte[] data = new byte[17];
-
         data[0] = 0x5A; // Structured field identifier
         data[1] = 0x00; // Length byte 1
         data[2] = 0x10; // Length byte 2
@@ -177,15 +151,9 @@
         data[6] = 0x00; // Flags
         data[7] = 0x00; // Reserved
         data[8] = 0x00; // Reserved
-
         for (int i = 0; i < nameBytes.length; i++) {
-
             data[9 + i] = nameBytes[i];
-
         }
-
         os.write(data);
-
     }
-
 }

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=641873&r1=641872&r2=641873&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 Thu Mar 27 09:16:30 2008
@@ -26,7 +26,31 @@
 /**
  * Image content IOCA object
  */
-public class ImageContent extends AbstractAFPObject {
+public class ImageContent extends AbstractStructuredAFPObject {
+
+    /**
+     * The CCITT T.4 Group 3 Coding Standard (G3 MH-Modified Huffman) is a
+     * compression method standardized by the International Telegraph and
+     * Telephone Consultative Committee (CCITT) for facsimile.  It enables
+     * one-dimensional compression.
+     */
+    public static final byte COMPID_G3_MH = (byte)0x80;
+    
+    /**
+     * The CCITT T.4 Group 3 Coding Option (G3 MR-Modified READ) is a
+     * compression method standardized by the International Telegraph and
+     * Telephone Consultative Committee (CCITT) for facsimile. It enables
+     * two-dimensional compression.
+     */
+    public static final byte COMPID_G3_MR = (byte)0x81;
+
+    /**
+     * The CCITT T.6 Group 4 Coding Standard (G4 MMR-Modified Modified READ) is a
+     * compression method standardized by the International Telegraph and
+     * Telephone Consultative Committee (CCITT) for facsimile.  It enables
+     * two-dimensional compression. 
+     */
+    public static final byte COMPID_G3_MMR = (byte)0x82;
 
     /**
      * The image size parameter
@@ -56,13 +80,12 @@
     /**
      * The image data
      */
-    private byte[] data = null;
+    private byte[] imageData = null;
 
     /**
      * Constructor for the image content
      */
     public ImageContent() {
-
     }
 
     /**
@@ -111,70 +134,55 @@
 
     /**
      * Set the data of the image.
-     * @param dat the image data
+     * @param data the image data
      */
-    public void setImageData(byte[] dat) {
-        this.data = dat;
+    public void setImageData(byte[] data) {
+        this.imageData = data;
     }
 
     /**
-     * Accessor method to write the AFP datastream for the Image Content
-     * @param os The stream to write to
-     * @throws java.io.IOException if an I/O exception occurs
+     * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os) throws IOException {
-
-        writeStart(os);
-
+    protected void writeContent(OutputStream os) throws IOException {
         if (imageSizeParam != null) {
             imageSizeParam.writeDataStream(os);
         }
-
         os.write(getImageEncodingParameter());
-
         os.write(getImageIDESizeParameter());
-
         os.write(getIDEStructureParameter());
-
         os.write(getExternalAlgorithmParameter());
-
-        if (data != null) {
+        if (imageData != null) {
             int off = 0;
-            while (off < data.length) {
-                int len = Math.min(30000, data.length - off);
+            while (off < imageData.length) {
+                int len = Math.min(30000, imageData.length - off);
                 os.write(getImageDataStart(len));
-                os.write(data, off, len);
+                os.write(imageData, off, len);
                 off += len;
             }
         }
-
-        writeEnd(os);
-
     }
 
     /**
-     * Helper method to write the start of the Image Content.
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeStart(OutputStream os) throws IOException {
-        byte[] startData = new byte[] {
+    protected void writeStart(OutputStream os) throws IOException {
+        byte[] data = new byte[] {
             (byte)0x91, // ID
                   0x01, // Length
             (byte)0xff, // Object Type = IOCA Image Object
         };
-        os.write(startData);
+        os.write(data);
     }
 
     /**
-     * Helper method to write the end of the Image Content.
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeEnd(OutputStream os) throws IOException {
-        byte[] endData = new byte[] {
+    protected void writeEnd(OutputStream os) throws IOException {
+        byte[] data = new byte[] {
             (byte)0x93, // ID
                   0x00, // Length
         };
-        os.write(endData);
+        os.write(data);
     }
 
     /**

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=641873&r1=641872&r2=641873&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 Thu Mar 27 09:16:30 2008
@@ -21,7 +21,6 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
 
 /**
  * An Image Segment is represented by a set of self-defining fields, fields
@@ -33,7 +32,7 @@
  *
  * Only one Image Content can exist within a single IOCA Image Segment.
  */
-public class ImageSegment extends AbstractAFPObject {
+public class ImageSegment extends AbstractNamedAFPObject {
 
     /**
      * Default name for the object environment group
@@ -41,16 +40,6 @@
     private static final String DEFAULT_NAME = "IS01";
 
     /**
-     * The name of the image segment
-     */
-    private String name;
-
-    /**
-     * The name of the image segment as EBCIDIC bytes
-     */
-    private byte[] nameBytes;
-
-    /**
      * The ImageContent for the image segment
      */
     private ImageContent imageContent = null;
@@ -68,20 +57,14 @@
      * @param name The name of the image.
      */
     public ImageSegment(String name) {
-        if (name.length() != 4) {
-            String msg = "Image segment name must be 4 characters long " + name;
-            log.error("Constructor:: " + msg);
-            throw new IllegalArgumentException(msg);
-        }
-        this.name = name;
-        try {
-            this.nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
-        } catch (UnsupportedEncodingException usee) {
-            this.nameBytes = name.getBytes();
-            log.warn(
-                "Constructor:: UnsupportedEncodingException translating the name "
-                + name);
-        }
+        super(name);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected int getNameLength() {
+        return 4;
     }
 
     /**
@@ -155,43 +138,33 @@
     }
 
     /**
-     * Accessor method to write the AFP datastream for the Image Segment
-     * @param os The stream to write to
-     * @throws java.io.IOException if an I/O exception occurred
+     * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os) throws IOException {
-        writeStart(os);
+    public void writeContent(OutputStream os) throws IOException {
         if (imageContent != null) {
             imageContent.writeDataStream(os);
         }
-        writeEnd(os);
     }
 
     /**
-     * Helper method to write the start of the Image Segment.
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeStart(OutputStream os) throws IOException {
+    protected void writeStart(OutputStream os) throws IOException {
         byte[] data = new byte[] {
             0x70, // ID
             0x04, // Length
-            0x00, // Name byte 1
-            0x00, // Name byte 2
-            0x00, // Name byte 3
-            0x00, // Name byte 4
+            nameBytes[0], // Name byte 1
+            nameBytes[1], // Name byte 2
+            nameBytes[2], // Name byte 3
+            nameBytes[3], // Name byte 4
         };
-        for (int i = 0; i < nameBytes.length; i++) {
-            data[2 + i] = nameBytes[i];
-        }
         os.write(data);
-
     }
 
     /**
-     * Helper method to write the end of the Image Segment.
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeEnd(OutputStream os) throws IOException {
+    protected void writeEnd(OutputStream os) throws IOException {
         byte[] data = new byte[] {
             0x71, // ID
             0x00, // 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=641873&r1=641872&r2=641873&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 Thu Mar 27 09:16:30 2008
@@ -40,28 +40,92 @@
 public class IncludeObject extends AbstractNamedAFPObject {
 
     /**
-     * The object type
+     * the include object is of type page segment
      */
-    private byte objectType = (byte) 0x92;
+    protected static final byte TYPE_PAGE_SEGMENT = (byte)0x5F;
+
+    /**
+     * the include object is of type other
+     */
+    protected static final byte TYPE_OTHER = (byte)0x92;
+
+    /**
+     * the include object is of type graphic
+     */
+    protected static final byte TYPE_GRAPHIC = (byte)0xBB;
+
+    /**
+     * the included object is of type barcode
+     */
+    protected static final byte TYPE_BARCODE = (byte)0xEB;
+    
+    /**
+     * the included object is of type image
+     */
+    protected static final byte TYPE_IMAGE = (byte)0xFB;
+        
+    /**
+     * The object type (default is other)
+     */
+    private byte objectType = TYPE_OTHER;
 
     /**
      * The orientation on the include object
      */
-    private int orientation = 0;
+    private int orientation = -1;
+
+    /**
+     * The X-axis origin of the object area 
+     */
+    private int xOffset = -1; 
+    
+    /**
+     * The Y-axis origin of the object area 
+     */    
+    private int yOffset = -1;
+
+    /**
+     * The X-axis origin defined in the object
+     */
+    private int xContentOffset = -1;
 
     /**
+     * The Y-axis origin defined in the object
+     */
+    private int yContentOffset = -1;
+    
+    /**
+     * The object referenced by this include object
+     */
+    private AbstractStructuredAFPObject referencedObject = null;
+    
+    /**
      * Constructor for the include object with the specified name, the name must
      * be a fixed length of eight characters and is the name of the referenced
      * object.
      *
-     * @param name
-     *            the name of the image
+     * @param resourceObj
+     *            the resource object wrapper
      */
-    public IncludeObject(String name) {
-
-        super(name);
-        objectType = (byte) 0xFB;
+    public IncludeObject(ResourceObject resourceObj) {
+        super(resourceObj.getResource().getName());
+        this.referencedObject = resourceObj.getResource();
+        if (referencedObject instanceof ImageObject) {
+            this.objectType = TYPE_IMAGE;
+        } else if (referencedObject instanceof GraphicsObject) {
+            this.objectType = TYPE_GRAPHIC;
+        } else if (referencedObject instanceof PageSegment) {
+            this.objectType = TYPE_PAGE_SEGMENT;
+        } else {
+            this.objectType = TYPE_OTHER;
+        }
+    }
 
+    /**
+     * @return the object referenced by this include object
+     */
+    public AbstractStructuredAFPObject getReferencedObject() {
+        return referencedObject;
     }
 
     /**
@@ -71,7 +135,6 @@
      *            The orientation (0,90, 180, 270)
      */
     public void setOrientation(int orientation) {
-
         if (orientation == 0 || orientation == 90 || orientation == 180
             || orientation == 270) {
             this.orientation = orientation;
@@ -79,25 +142,39 @@
             throw new IllegalArgumentException(
                 "The orientation must be one of the values 0, 90, 180, 270");
         }
-
     }
 
     /**
-     * Accessor method to write the AFP datastream for the Include Object
-     * @param os The stream to write to
-     * @throws java.io.IOException thrown if an I/O exception of some sort has occurred
+     * Sets the x and y offset to the origin in the object area 
+     * @param x the X-axis origin of the object area
+     * @param y the Y-axis origin of the object area
      */
-    public void writeDataStream(OutputStream os)
-        throws IOException {
-
-        byte[] data = new byte[37];
-
+    public void setObjectArea(int x, int y) {
+        this.xOffset = x;
+        this.yOffset = y;
+    }
+    
+    /**
+     * Sets the x and y offset of the content area to the object area 
+     * @param x the X-axis origin defined in the object
+     * @param y the Y-axis origin defined in the object
+     */
+    public void setContentArea(int x, int y) {
+        this.xContentOffset = x;
+        this.yContentOffset = y;
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void writeDataStream(OutputStream os) throws IOException {
+        byte[] data = new byte[36];
         data[0] = 0x5A;
 
         // Set the total record length
-        byte[] rl1 = BinaryUtils.convert(36, 2); //Ignore first byte
-        data[1] = rl1[0];
-        data[2] = rl1[1];
+        byte[] len = BinaryUtils.convert(35, 2); //Ignore first byte
+        data[1] = len[0];
+        data[2] = len[1];
 
         // Structured field ID for a IOB
         data[3] = (byte) 0xD3;
@@ -112,60 +189,91 @@
             data[9 + i] = nameBytes[i];
         }
 
-        data[17] = 0x00;
+        data[17] = 0x00; // reserved
         data[18] = objectType;
 
-        // XoaOset
-        data[20] = (byte) 0xFF;
-        data[21] = (byte) 0xFF;
-        data[22] = (byte) 0xFF;
-
-        // YoaOset
-        data[23] = (byte) 0xFF;
-        data[24] = (byte) 0xFF;
-        data[25] = (byte) 0xFF;
+        //XoaOset (object area)
+        if (xOffset > 0) {
+            byte[] x = BinaryUtils.convert(xOffset, 3);
+            data[19] = x[0];
+            data[20] = x[1];
+            data[21] = x[2];            
+        } else {
+            data[19] = (byte)0xFF;
+            data[20] = (byte)0xFF;
+            data[21] = (byte)0xFF;            
+        }
+
+        // YoaOset (object area)
+        if (yOffset > 0) {
+            byte[] y = BinaryUtils.convert(yOffset, 3);
+            data[22] = y[0];
+            data[23] = y[1];
+            data[24] = y[2];                        
+        } else {
+            data[22] = (byte)0xFF;
+            data[23] = (byte)0xFF;
+            data[24] = (byte)0xFF;            
+        }
 
         switch (orientation) {
+            case -1: // use x/y axis orientation defined in object
+                data[25] = (byte)0xFF; // x axis rotation
+                data[26] = (byte)0xFF; //
+                data[27] = (byte)0xFF; // y axis rotation
+                data[28] = (byte)0xFF;
+                break;                
             case 90:
-                data[26] = 0x2D;
-                data[27] = 0x00;
-                data[28] = 0x5A;
-                data[29] = 0x00;
+                data[25] = 0x2D;
+                data[26] = 0x00;
+                data[27] = 0x5A;
+                data[28] = 0x00;
                 break;
             case 180:
-                data[26] = 0x5A;
-                data[27] = 0x00;
-                data[28] = (byte) 0x87;
-                data[29] = 0x00;
+                data[25] = 0x5A;
+                data[25] = 0x00;
+                data[27] = (byte)0x87;
+                data[28] = 0x00;
                 break;
             case 270:
-                data[26] = (byte) 0x87;
+                data[25] = (byte)0x87;
+                data[26] = 0x00;
                 data[27] = 0x00;
                 data[28] = 0x00;
-                data[29] = 0x00;
                 break;
             default:
+                data[25] = 0x00;
                 data[26] = 0x00;
-                data[27] = 0x00;
-                data[28] = 0x2D;
-                data[29] = 0x00;
+                data[27] = 0x2D;
+                data[28] = 0x00;
                 break;
         }
 
-        // XocaOset
-        data[30] = (byte) 0xFF;
-        data[31] = (byte) 0xFF;
-        data[32] = (byte) 0xFF;
-
-        // YocaOset
-        data[33] = (byte) 0xFF;
-        data[34] = (byte) 0xFF;
-        data[35] = (byte) 0xFF;
+        // XocaOset (object content)
+        if (xContentOffset > 0) {
+            byte[] y = BinaryUtils.convert(xContentOffset, 3);
+            data[29] = y[0];
+            data[30] = y[1];
+            data[31] = y[2];            
+        } else {
+            data[29] = (byte)0xFF;
+            data[30] = (byte)0xFF;
+            data[31] = (byte)0xFF;
+        }
 
-        data[36] = 0x01;
+        // YocaOset (object content)
+        if (yContentOffset > 0) {
+            byte[] y = BinaryUtils.convert(yContentOffset, 3);
+            data[32] = y[0];
+            data[33] = y[1];
+            data[34] = y[2];                        
+        } else {
+            data[32] = (byte)0xFF;
+            data[33] = (byte)0xFF;
+            data[34] = (byte)0xFF;
+        }
 
+        data[35] = 0x01;
         os.write(data);
-
     }
-
 }

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=641873&r1=641872&r2=641873&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 Thu Mar 27 09:16:30 2008
@@ -69,7 +69,7 @@
     }
 
     /**
-     * Sets the orienation to use for the overlay.
+     * Sets the orientation to use for the overlay.
      *
      * @param orientation
      *            The orientation (0,90, 180, 270)
@@ -85,15 +85,10 @@
     }
 
     /**
-     * Accessor method to write the AFP datastream for the Include Page Overlay
-     * @param os The stream to write to
-     * @throws java.io.IOException thrown if an I/O exception of some sort has occurred
+     * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os)
-        throws IOException {
-
+    public void writeDataStream(OutputStream os) throws IOException {
         byte[] data = new byte[25]; //(9 +16)
-
         data[0] = 0x5A;
 
         // Set the total record length

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=641873&r1=641872&r2=641873&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 Thu Mar 27 09:16:30 2008
@@ -59,35 +59,29 @@
      * @param y The y position
      */
     public IncludePageSegment(String name, int x, int y) {
-
         super(name);
         this.x = BinaryUtils.convert(x, 3);
         this.y = BinaryUtils.convert(y, 3);
-
     }
 
     /**
-     * Accessor method to write the AFP datastream for the Include Page Segment
-     * @param os The stream to write to
-     * @throws java.io.IOException thrown if an I/O exception of some sort has occurred
+     * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os)
-        throws IOException {
+    public void writeDataStream(OutputStream os) throws IOException {
 
         byte[] data = new byte[23]; //(9 +14)
 
         data[0] = 0x5A;
 
         // Set the total record length
-        byte[] rl1 = BinaryUtils.convert(22, 2); //Ignore first byte
-        data[1] = rl1[0];
-        data[2] = rl1[1];
+        byte[] len = BinaryUtils.convert(22, 2); //Ignore first byte
+        data[1] = len[0];
+        data[2] = len[1];
 
         // Structured field ID for a IPS
         data[3] = (byte) 0xD3;
         data[4] = (byte) 0xAF;
         data[5] = (byte) 0x5F;
-
         data[6] = 0x00; // Reserved
         data[7] = 0x00; // Reserved
         data[8] = 0x00; // Reserved
@@ -95,11 +89,9 @@
         for (int i = 0; i < nameBytes.length; i++) {
             data[9 + i] = nameBytes[i];
         }
-
         data[17] = x[0]; // x coordinate
         data[18] = x[1];
         data[19] = x[2];
-
         data[20] = y[0]; // y coordinate
         data[21] = y[1];
         data[22] = y[2];

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=641873&r1=641872&r2=641873&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 Thu Mar 27 09:16:30 2008
@@ -34,30 +34,25 @@
 
     /**
      * Constructor for the Invoke Medium Map
-     * @param mediumMapName Name of the medium map
+     * @param name the name of the medium map
      */
-    public InvokeMediumMap(String mediumMapName) {
-
-        super(mediumMapName);
-
+    public InvokeMediumMap(String name) {
+        super(name);
     }
 
     /**
-     * Accessor method to write the AFP datastream for the Invoke Medium Map
-     * @param os The stream to write to
-     * @throws java.io.IOException if an I/O exception of some sort has occurred
+     * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os)
-        throws IOException {
+    public void writeDataStream(OutputStream os) throws IOException {
 
         byte[] data = new byte[17];
 
         data[0] = 0x5A;
 
         // Set the total record length
-        byte[] rl1 = BinaryUtils.convert(16, 2); //Ignore first byte
-        data[1] = rl1[0];
-        data[2] = rl1[1];
+        byte[] len = BinaryUtils.convert(16, 2); //Ignore first byte
+        data[1] = len[0];
+        data[2] = len[1];
 
         // Structured field ID for a IPO
         data[3] = (byte) 0xD3;
@@ -69,13 +64,8 @@
         data[8] = 0x00; // Reserved
 
         for (int i = 0; i < nameBytes.length; i++) {
-
             data[9 + i] = nameBytes[i];
-
         }
-
         os.write(data);
-
     }
-
 }

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=641873&r1=641872&r2=641873&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 Thu Mar 27 09:16:30 2008
@@ -138,7 +138,6 @@
                 baos.write(0x5D);
                 baos.write(BinaryUtils.convert(fd.scale, 2));
             }
-
         }
 
         byte[] data = baos.toByteArray();
@@ -149,7 +148,6 @@
         data[2] = rl1[1];
 
         os.write(data);
-
     }
 
     /**

Added: 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=641873&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/MapDataResource.java Thu Mar 27 09:16:30 2008
@@ -0,0 +1,72 @@
+/*
+ * 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.modca.triplets.FullyQualifiedNameTriplet;
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * The Map Data Resource structured field specifies resources that are
+ * required for presentation.
+ */
+public class MapDataResource extends AbstractStructuredAFPObject {
+    /**
+     * Static default generated name reference
+     */
+    private static final String DEFAULT_NAME = "MDR00001";
+
+    /**
+     * Main constructor
+     * @param obj a map data resource for a given structured AFP object
+     */
+    public MapDataResource(AbstractStructuredAFPObject obj) {
+        String fqName = obj.getFullyQualifiedName();
+        if (fqName != null) {
+            super.setFullyQualifiedName(
+                FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF,
+                FullyQualifiedNameTriplet.FORMAT_CHARSTR, fqName);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void writeStart(OutputStream os) throws IOException {
+        super.writeStart(os);
+        
+        // RGLength
+        byte[] len = BinaryUtils.convert(8 + 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) 0xAB, // Structured field id byte 2
+            (byte) 0xC3, // Structured field id byte 3
+            0x00, // Flags
+            0x00, // Reserved
+            0x00  // Reserved
+        };
+        os.write(data);
+    }
+}

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=641873&r1=641872&r2=641873&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 Thu Mar 27 09:16:30 2008
@@ -36,15 +36,21 @@
     /**
      * The collection of overlays (maximum of 254 stored as byte[])
      */
-    private List overLays = new java.util.ArrayList();
+    private List overLays = null;
 
     /**
      * Constructor for the Map Page Overlay
      */
     public MapPageOverlay() {
-
     }
 
+    private List getOverlays() {
+        if (overLays == null) {
+            this.overLays = new java.util.ArrayList();
+        }
+        return this.overLays;
+    }
+    
     /**
      * Add an overlay to to the map page overlay object.
      *
@@ -53,23 +59,19 @@
      * @throws MaximumSizeExceededException if the maximum size is reached
      */
     public void addOverlay(String name) throws MaximumSizeExceededException {
-
-        if (overLays.size() > 253) {
+        if (getOverlays().size() > 253) {
             throw new MaximumSizeExceededException();
         }
-
         if (name.length() != 8) {
             throw new IllegalArgumentException("The name of overlay " + name
                 + " must be 8 characters");
         }
-
         if (log.isDebugEnabled()) {
             log.debug("addOverlay():: adding overlay " + name);
         }
-
         try {
             byte[] data = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
-            overLays.add(data);
+            getOverlays().add(data);
         } catch (UnsupportedEncodingException usee) {
             log.error("addOverlay():: UnsupportedEncodingException translating the name "
                 + name);
@@ -82,7 +84,7 @@
      * @throws java.io.IOException if an I/O exception occurred
      */
     public void writeDataStream(OutputStream os) throws IOException {
-        int oLayCount = overLays.size();
+        int oLayCount = getOverlays().size();
         int recordlength = oLayCount * 18;
 
         byte[] data = new byte[recordlength + 9];

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java?rev=641873&r1=641872&r2=641873&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectAreaPosition.java Thu Mar 27 09:16:30 2008
@@ -55,7 +55,6 @@
         byte[] len = BinaryUtils.convert(32, 2);
         byte[] xcoord = BinaryUtils.convert(x, 3);
         byte[] ycoord = BinaryUtils.convert(y, 3);
-
         byte[] data = new byte[] {
             0x5A,
             len[0], // Length
@@ -91,9 +90,6 @@
             0x00,
             0x00, // RefCSys
         };
-        
         os.write(data);
-
     }
-
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java?rev=641873&r1=641872&r2=641873&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/ObjectEnvironmentGroup.java Thu Mar 27 09:16:30 2008
@@ -34,7 +34,7 @@
  * normally contained in the object environment group, or it may specify that one or
  * more default values are to be used.
  */
-public final class ObjectEnvironmentGroup extends AbstractStructuredAFPObject {
+public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject {
 
     /**
      * Default name for the object environment group
@@ -150,7 +150,9 @@
     /**
      * {@inheritDoc}
      */
-    public void writeContent(OutputStream os) throws IOException {
+    protected void writeContent(OutputStream os) throws IOException {
+        super.writeContent(os);
+        
         objectAreaDescriptor.writeDataStream(os);
         objectAreaPosition.writeDataStream(os);
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Overlay.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Overlay.java?rev=641873&r1=641872&r2=641873&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Overlay.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/Overlay.java Thu Mar 27 09:16:30 2008
@@ -50,43 +50,14 @@
      */
     public Overlay(String name, int width, int height, int rotation,
             int widthResolution, int heightResolution) {
-
         super(name, width, height, rotation, widthResolution, heightResolution);
-
-    }
-
-    /**
-     * Accessor method to write the AFP datastream for the overlay.
-     *
-     * @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 {
-
-        writeStart(os);
-
-        activeEnvironmentGroup.writeDataStream(os);
-
-        writeObjectList(segments, os);
-
-        writeObjectList(tagLogicalElements, os);
-
-        writeObjectList(objects, os);
-
-        writeEnd(os);
-
     }
 
     /**
-     * Helper method to write the start of the overlay.
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeStart(OutputStream os)
-        throws IOException {
-
+    protected void writeStart(OutputStream os) throws IOException {
         byte[] data = new byte[17];
-
         data[0] = 0x5A; // Structured field identifier
         data[1] = 0x00; // Length byte 1
         data[2] = 0x10; // Length byte 2
@@ -96,26 +67,17 @@
         data[6] = 0x00; // Flags
         data[7] = 0x00; // Reserved
         data[8] = 0x00; // Reserved
-
         for (int i = 0; i < nameBytes.length; i++) {
-
             data[9 + i] = nameBytes[i];
-
         }
-
         os.write(data);
-
     }
 
     /**
-     * Helper method to write the end of the overlay.
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeEnd(OutputStream os)
-        throws IOException {
-
+    protected void writeEnd(OutputStream os) throws IOException {
         byte[] data = new byte[17];
-
         data[0] = 0x5A; // Structured field identifier
         data[1] = 0x00; // Length byte 1
         data[2] = 0x10; // Length byte 2
@@ -125,15 +87,9 @@
         data[6] = 0x00; // Flags
         data[7] = 0x00; // Reserved
         data[8] = 0x00; // Reserved
-
         for (int i = 0; i < nameBytes.length; i++) {
-
             data[9 + i] = nameBytes[i];
-
         }
-
         os.write(data);
-
     }
-
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageGroup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageGroup.java?rev=641873&r1=641872&r2=641873&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageGroup.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageGroup.java Thu Mar 27 09:16:30 2008
@@ -18,9 +18,9 @@
 /* $Id$ */
 
 package org.apache.fop.render.afp.modca;
+
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -34,17 +34,12 @@
  *
  * @author <a href="mailto:pete@townsend.uk.com">Pete Townsend </a>
  */
-public class PageGroup extends AbstractNamedAFPObject {
-
-    /**
-     * The pages contained within this group
-     */
-    private List objects = new ArrayList();
+public class PageGroup extends AbstractResourceEnvironmentGroupContainer {
 
     /**
      * The tag logical elements contained within this group
      */
-    private List tagLogicalElements = new ArrayList();
+    private List tagLogicalElements = null;
 
     /**
      * The page state
@@ -58,32 +53,16 @@
      *            the name of the page group
      */
     public PageGroup(String name) {
-
         super(name);
-
     }
 
-    /**
-     * Adds a page object to the group.
-     *
-     * @param page
-     *            the page object to add
-     */
-    public void addPage(PageObject page) {
-
-        if (!objects.contains(page)) {
-            objects.add(page);
+    private List getTagLogicalElements() {
+        if (tagLogicalElements == null) {
+            this.tagLogicalElements = new java.util.ArrayList();
         }
-
+        return this.tagLogicalElements;
     }
-
-    /**
-     * @return the name of the page group
-     */
-    public String getName() {
-        return name;
-    }
-
+    
     /**
      * Creates a TagLogicalElement on the page.
      *
@@ -93,32 +72,17 @@
      *            the value of the tag
      */
     public void createTagLogicalElement(String name, String value) {
-
         TagLogicalElement tle = new TagLogicalElement(name, value);
-        tagLogicalElements.add(tle);
-
-    }
-
-    /**
-     * Creates an InvokeMediaMap on the page.
-     *
-     * @param name
-     *            the name of the media map
-     */
-    public void createInvokeMediumMap(String name) {
-
-        InvokeMediumMap imm = new InvokeMediumMap(name);
-        objects.add(imm);
-
+        if (!getTagLogicalElements().contains(tle)) {
+            getTagLogicalElements().add(tle);
+        }
     }
 
     /**
      * Method to mark the end of the page group.
      */
-    public void endPageGroup() {
-
+    protected void endPageGroup() {
         complete = true;
-
     }
 
     /**
@@ -129,33 +93,19 @@
         return complete;
     }
 
-   /**
-     * Accessor method to write the AFP datastream for the page group.
-     * @param os The stream to write to
-     * @throws java.io.IOException thrown if an I/O exception of some sort has occurred
+    /**
+     * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os)
-        throws IOException {
-
-        writeStart(os);
-
-        writeObjectList(tagLogicalElements, os);
-
-        writeObjectList(objects, os);
-
-        writeEnd(os);
-
+    protected void writeContent(OutputStream os) throws IOException {
+        writeObjects(tagLogicalElements, os);
+        super.writeContent(os);
     }
 
     /**
-     * Helper method to write the start of the page group.
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeStart(OutputStream os)
-        throws IOException {
-
+    protected void writeStart(OutputStream os) throws IOException {
         byte[] data = new byte[17];
-
         data[0] = 0x5A; // Structured field identifier
         data[1] = 0x00; // Length byte 1
         data[2] = 0x10; // Length byte 2
@@ -165,26 +115,17 @@
         data[6] = 0x00; // Flags
         data[7] = 0x00; // Reserved
         data[8] = 0x00; // Reserved
-
         for (int i = 0; i < nameBytes.length; i++) {
-
             data[9 + i] = nameBytes[i];
-
         }
-
         os.write(data);
-
     }
 
     /**
-     * Helper method to write the end of the page group.
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeEnd(OutputStream os)
-        throws IOException {
-
+    protected void writeEnd(OutputStream os) throws IOException {
         byte[] data = new byte[17];
-
         data[0] = 0x5A; // Structured field identifier
         data[1] = 0x00; // Length byte 1
         data[2] = 0x10; // Length byte 2
@@ -194,15 +135,9 @@
         data[6] = 0x00; // Flags
         data[7] = 0x00; // Reserved
         data[8] = 0x00; // Reserved
-
         for (int i = 0; i < nameBytes.length; i++) {
-
             data[9 + i] = nameBytes[i];
-
         }
-
         os.write(data);
-
     }
-
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageObject.java?rev=641873&r1=641872&r2=641873&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageObject.java Thu Mar 27 09:16:30 2008
@@ -18,11 +18,10 @@
 /* $Id$ */
 
 package org.apache.fop.render.afp.modca;
+
 import java.io.IOException;
 import java.io.OutputStream;
 
-
-
 /**
  * Pages contain the data objects that comprise a presentation document. Each
  * page has a set of data objects associated with it. Each page within a
@@ -46,11 +45,6 @@
 public class PageObject extends AbstractPageObject {
 
     /**
-     * The resource group object
-     */
-    private ResourceGroup resourceGroup = null;
-
-    /**
      * Construct a new page object for the specified name argument, the page
      * name should be an 8 character identifier.
      *
@@ -69,20 +63,7 @@
      */
     public PageObject(String name, int width, int height, int rotation,
             int widthRes, int heightRes) {
-
         super(name, width, height, rotation, widthRes, heightRes);
-
-    }
-
-    /**
-     * Adds an overlay to the page resources
-     * @param overlay the overlay to add
-     */
-    public void addOverlay(Overlay overlay) {
-        if (resourceGroup == null) {
-            resourceGroup = new ResourceGroup();
-        }
-        resourceGroup.addOverlay(overlay);
     }
 
     /**
@@ -98,47 +79,14 @@
      *            the orientation required for the overlay
      */
     public void createIncludePageOverlay(String name, int x, int y, int orientation) {
-
-        IncludePageOverlay ipo = new IncludePageOverlay(name, x, y, orientation);
-        objects.add(ipo);
-
+        addObject(new IncludePageOverlay(name, x, y, orientation));
     }
 
     /**
-     * Accessor method to write the AFP datastream for the page.
-     * @param os The stream to write to
-     * @throws java.io.IOException thrown if an I/O exception of some sort has occurred
+     * {@inheritDoc}
      */
-    public void writeDataStream(OutputStream os)
-        throws IOException {
-
-        writeStart(os);
-
-        if (resourceGroup != null) {
-            resourceGroup.writeDataStream(os);
-        }
-
-        activeEnvironmentGroup.writeDataStream(os);
-
-        writeObjectList(segments, os);
-
-        writeObjectList(tagLogicalElements, os);
-
-        writeObjectList(objects, os);
-
-        writeEnd(os);
-
-    }
-
-    /**
-     * Helper method to write the start of the page.
-     * @param os The stream to write to
-     */
-    private void writeStart(OutputStream os)
-        throws IOException {
-
+    protected void writeStart(OutputStream os) throws IOException {
         byte[] data = new byte[17];
-
         data[0] = 0x5A; // Structured field identifier
         data[1] = 0x00; // Length byte 1
         data[2] = 0x10; // Length byte 2
@@ -148,26 +96,17 @@
         data[6] = 0x00; // Flags
         data[7] = 0x00; // Reserved
         data[8] = 0x00; // Reserved
-
         for (int i = 0; i < nameBytes.length; i++) {
-
             data[9 + i] = nameBytes[i];
-
         }
-
         os.write(data);
-
     }
 
     /**
-     * Helper method to write the end of the page.
-     * @param os The stream to write to
+     * {@inheritDoc}
      */
-    private void writeEnd(OutputStream os)
-        throws IOException {
-
+    protected void writeEnd(OutputStream os) throws IOException {
         byte[] data = new byte[17];
-
         data[0] = 0x5A; // Structured field identifier
         data[1] = 0x00; // Length byte 1
         data[2] = 0x10; // Length byte 2
@@ -177,15 +116,9 @@
         data[6] = 0x00; // Flags
         data[7] = 0x00; // Reserved
         data[8] = 0x00; // Reserved
-
         for (int i = 0; i < nameBytes.length; i++) {
-
             data[9 + i] = nameBytes[i];
-
         }
-
         os.write(data);
-
     }
-
 }

Added: 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=641873&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageSegment.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PageSegment.java Thu Mar 27 09:16:30 2008
@@ -0,0 +1,102 @@
+/*
+ * 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 java.util.List;
+
+/**
+ * A page segment is a MO:DCA-P resource object.  It may be stored in an
+ * external resource library or it may be carried in a resource group.
+ * Page segments contain any combination of IOCA image objects and
+ * GOCA graphics objects.
+ */
+public class PageSegment extends AbstractNamedAFPObject {
+
+    private List objects = null;
+    
+    /**
+     * Main constructor
+     * @param name the name of this object
+     */
+    public PageSegment(String name) {
+        super(name);
+    }
+
+    /**
+     * 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) {
+        if (objects == null) {
+            objects = new java.util.ArrayList();
+        }
+        objects.add(object);
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    protected void writeStart(OutputStream os) throws IOException {
+        byte[] data = new byte[17];
+        data[0] = 0x5A; // Structured field identifier
+        data[1] = 0x00; // Length byte 1
+        data[2] = 0x10; // Length byte 2
+        data[3] = (byte) 0xD3; // Structured field id byte 1
+        data[4] = (byte) 0xA8; // Structured field id byte 2
+        data[5] = (byte) 0x5F; // Structured field id byte 3
+        data[6] = 0x00; // Flags
+        data[7] = 0x00; // Reserved
+        data[8] = 0x00; // Reserved
+        for (int i = 0; i < nameBytes.length; i++) {
+            data[9 + i] = nameBytes[i];
+        }
+        os.write(data);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    protected void writeEnd(OutputStream os) throws IOException {
+        byte[] data = new byte[17];
+        data[0] = 0x5A; // Structured field identifier
+        data[1] = 0x00; // Length byte 1
+        data[2] = 0x10; // Length byte 2
+        data[3] = (byte) 0xD3; // Structured field id byte 1
+        data[4] = (byte) 0xA9; // Structured field id byte 2
+        data[5] = (byte) 0x5F; // Structured field id byte 3
+        data[6] = 0x00; // Flags
+        data[7] = 0x00; // Reserved
+        data[8] = 0x00; // Reserved
+        for (int i = 0; i < nameBytes.length; i++) {
+            data[9 + i] = nameBytes[i];
+        }
+        os.write(data);
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    protected void writeContent(OutputStream os) throws IOException {
+        super.writeContent(os);
+        writeObjects(objects, os);
+    }
+}

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java?rev=641873&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/modca/PreprocessPresentationObject.java Thu Mar 27 09:16:30 2008
@@ -0,0 +1,153 @@
+/*
+ * 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.modca.triplets.FullyQualifiedNameTriplet;
+import org.apache.fop.render.afp.tools.BinaryUtils;
+
+/**
+ * The Preprocess Presentation Object structured field specifies presentation
+ * parameters for a data object that has been mapped as a resource. 
+ */
+public class PreprocessPresentationObject extends AbstractStructuredAFPObject {
+    private static final byte TYPE_OTHER = (byte)0x92;
+    private static final byte TYPE_OVERLAY = (byte)0xDF;
+    private static final byte TYPE_IMAGE = (byte)0xFB;
+    
+    private byte objType = TYPE_OTHER;
+    private byte objOrent = 0; // object always processed at 0 degree orientation
+    private int objXOffset = -1;
+    private int objYOffset = -1;
+    
+    /**
+     * Main constructor
+     * @param prePresObj the presentation object to be preprocessed 
+     */
+    public PreprocessPresentationObject(AbstractStructuredAFPObject prePresObj) {
+        if (prePresObj instanceof ImageObject || prePresObj instanceof Overlay) {
+            if (prePresObj instanceof ImageObject) {
+                this.objType = TYPE_IMAGE;
+            } else {
+                this.objType = TYPE_OVERLAY;
+            }
+            setFullyQualifiedName(
+                    FullyQualifiedNameTriplet.TYPE_BEGIN_RESOURCE_OBJECT_REF, 
+                    FullyQualifiedNameTriplet.FORMAT_CHARSTR,
+                    prePresObj.getFullyQualifiedName());
+        } else {
+            this.objType = TYPE_OTHER;
+//            Registry registry = Registry.getInstance();
+//            Registry.Entry entry = registry.getEntry(compontentId);
+//            entry.
+//            setObjectClassification(objectClass, componentId)
+        }
+    }
+    
+    public static final byte ORIENTATION_ZERO_DEGREES = 1;
+    public static final byte ORIENTATION_90_DEGREES = 2;
+    public static final byte ORIENTATION_180_DEGREES = 4;
+    public static final byte ORIENTATION_270_DEGREES = 8;
+    
+    /**
+     * Sets the object orientations relative to media leading edge
+     * @param orientation the object orientations relative to media leading edge
+     */
+    public void setOrientation(byte orientation) {
+        objOrent = (byte)orientation;
+    }
+    
+    /**
+     * Sets the X axis origin for object content
+     * @param xOffset the X axis origin for object content
+     */
+    public void setXOffset(int xOffset) {
+        this.objXOffset = xOffset;        
+    }
+    
+    /**
+     * Sets the Y axis origin for object content
+     * @param yOffset the Y axis origin for object content
+     */
+    public void setYOffset(int yOffset) {
+        this.objYOffset = yOffset;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void writeStart(OutputStream os) throws IOException {
+        super.writeStart(os);
+
+        byte[] l = BinaryUtils.convert(19 + getTripletDataLength(), 2);
+        byte[] data = new byte[9];
+        data[0] = 0x5A; // Structured field identifier
+        data[1] = l[0]; // Length byte 1
+        data[2] = l[1]; // Length byte 1
+        data[3] = (byte)0xD3; // Structured field id byte 1
+        data[4] = (byte)0xAD; // Structured field id byte 2
+        data[5] = (byte)0xC3; // Structured field id byte 3
+        data[6] = 0x00; // Flags
+        data[7] = 0x00; // Reserved
+        data[8] = 0x00; // Reserved
+        
+        os.write(data);
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void writeContent(OutputStream os) throws IOException {
+        byte[] data = new byte[12];
+        byte[] l = BinaryUtils.convert(12 + getTripletDataLength(), 2);
+        data[0] = l[0]; // RGLength
+        data[1] = l[1]; // RGLength
+        data[2] = objType; // ObjType
+        data[3] = 0x00; // Reserved
+        data[4] = 0x00; // Reserved
+        data[5] = objOrent; // ObjOrent
+        if (objXOffset > 0) {
+            byte[] xOff = BinaryUtils.convert(objYOffset, 3);
+            data[6] = xOff[0]; // XocaOset (not specified)
+            data[7] = xOff[1]; // XocaOset
+            data[8] = xOff[2]; // XocaOset
+        } else {
+            data[6] = (byte)0xFF; // XocaOset (not specified)
+            data[7] = (byte)0xFF; // XocaOset
+            data[8] = (byte)0xFF; // XocaOset
+        }
+        if (objYOffset > 0) {
+            byte[] yOff = BinaryUtils.convert(objYOffset, 3);
+            data[9] = yOff[0]; // YocaOset (not specified)
+            data[10] = yOff[1]; // YocaOset
+            data[11] = yOff[2]; // YocaOset
+        } else {
+            data[9] = (byte)0xFF; // YocaOset (not specified)
+            data[10] = (byte)0xFF; // YocaOset
+            data[11] = (byte)0xFF; // YocaOset
+        }
+        os.write(data);
+        
+        // Triplets
+        super.writeContent(os);
+    }
+}



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