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/11/17 16:26:08 UTC

svn commit: r718262 [1/2] - in /xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop: afp/ afp/fonts/ afp/goca/ afp/ioca/ afp/modca/ afp/modca/triplets/ afp/svg/ svg/

Author: acumiskey
Date: Mon Nov 17 07:26:06 2008
New Revision: 718262

URL: http://svn.apache.org/viewvc?rev=718262&view=rev
Log:
Memory usage optimizations.

Added:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java
      - copied, changed from r713747, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsObjectContainer.java
      - copied, changed from r713745, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractPreparedObjectContainer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsString.java   (with props)
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsStringRelative.java   (with props)
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractStructuredObject.java
      - copied, changed from r713745, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractStructuredAFPObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java   (with props)
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/StructuredDataObject.java
      - copied, changed from r713745, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PreparedAFPObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/AbstractTriplet.java
      - copied, changed from r713745, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/Triplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/CommentTriplet.java   (with props)
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/DescriptorPositionTriplet.java   (with props)
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/svg/AFPGraphicsConfiguration.java
      - copied, changed from r713745, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPGraphicsConfiguration.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/svg/AFPGraphicsDevice.java
      - copied, changed from r713745, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPGraphicsDevice.java
Removed:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPGraphicsConfiguration.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPGraphicsDevice.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractPreparedAFPObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractPreparedObjectContainer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractStructuredAFPObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PreparedAFPObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/Triplet.java
Modified:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPGraphics2D.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/fonts/RasterFont.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsArea.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsBox.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsData.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFillet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFilletRelative.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFullArc.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsImage.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsLine.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsLineRelative.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetCharacterSet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetLineType.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetLineWidth.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsString.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/ioca/ImageContent.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractDescriptor.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/GraphicsObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/IncludeObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/MapCodedFont.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/MapContainerData.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/MapDataResource.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/ObjectAreaDescriptor.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PreprocessPresentationObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PresentationEnvironmentControl.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/Registry.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/ResourceObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/ExtendedResourceLocalIdentifierTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/FullyQualifiedNameTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/MappingOptionTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/MeasurementUnitsTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/ObjectAreaSizeTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/ObjectByteExtentTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/ObjectClassificationTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/PresentationSpaceMixingRulesTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/PresentationSpaceResetMixingTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/ResourceObjectTypeTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/svg/PDFGraphics2D.java

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPGraphics2D.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPGraphics2D.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPGraphics2D.java Mon Nov 17 07:26:06 2008
@@ -47,6 +47,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.fop.afp.goca.GraphicsSetLineType;
 import org.apache.fop.afp.modca.GraphicsObject;
+import org.apache.fop.afp.svg.AFPGraphicsConfiguration;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.svg.NativeImageHandler;
 import org.apache.xmlgraphics.image.loader.ImageInfo;
@@ -101,6 +102,9 @@
     /** Current AFP state */
     private AFPPaintingState paintingState = null;
 
+    /** AFP graphics configuration */
+    private final AFPGraphicsConfiguration graphicsConfig = new AFPGraphicsConfiguration();
+
     /** The AFP FontInfo */
     private FontInfo fontInfo;
 
@@ -246,8 +250,8 @@
         if (fill) {
             graphicsObj.beginArea();
         }
-        AffineTransform trans = super.getTransform();
 
+        AffineTransform trans = gc.getTransform();
         PathIterator iter = shape.getPathIterator(trans);
         double[] dstPts = new double[6];
         int[] coords = null;
@@ -294,44 +298,39 @@
                     mhr
             );
         } else {
-            for (int[] openingCoords = new int[2], currCoords = new int[2];
-                !iter.isDone(); iter.next()) {
+            for (int[] openingCoords = new int[2]; !iter.isDone(); iter.next()) {
                 int type = iter.currentSegment(dstPts);
-                if (type == PathIterator.SEG_MOVETO) {
-                    openingCoords[X] = currCoords[X] = (int)Math.round(dstPts[X]);
-                    openingCoords[Y] = currCoords[Y] = (int)Math.round(dstPts[Y]);
-                    graphicsObj.setCurrentPosition(openingCoords);
+                int numCoords;
+                if (type == PathIterator.SEG_MOVETO || type == PathIterator.SEG_LINETO) {
+                    numCoords = 2;
+                } else if (type == PathIterator.SEG_QUADTO) {
+                    numCoords = 4;
+                } else if (type == PathIterator.SEG_CUBICTO) {
+                    numCoords = 6;
                 } else {
-                    int numCoords;
-                    if (type == PathIterator.SEG_LINETO) {
-                        numCoords = 2;
-                    } else if (type == PathIterator.SEG_QUADTO) {
-                        numCoords = 4;
-                    } else if (type == PathIterator.SEG_CUBICTO) {
-                        numCoords = 6;
+                    // close of the graphics segment
+                    if (type == PathIterator.SEG_CLOSE) {
+                        // close segment by drawing to opening position
+                        graphicsObj.addLine(openingCoords, true);
                     } else {
-                        // close of the graphics segment
-                        if (type == PathIterator.SEG_CLOSE) {
-                            graphicsObj.addLine(openingCoords, true);
-                        } else {
-                            log.debug("Unrecognised path iterator type: "
-                                    + type);
-                        }
-                        continue;
-                    }
-                    coords = new int[numCoords];
-                    for (int i = 0; i < numCoords; i++) {
-                        coords[i] = (int) Math.round(dstPts[i]);
+                        log.debug("Unrecognised path iterator type: "
+                                + type);
                     }
-                    if (type == PathIterator.SEG_LINETO) {
-                        graphicsObj.addLine(coords, true);
-                    } else if (type == PathIterator.SEG_QUADTO
-                            || type == PathIterator.SEG_CUBICTO) {
-                        graphicsObj.addFillet(coords, true);
-                    }
-                    // update current position coordinates
-                    currCoords[X] = coords[coords.length - 2];
-                    currCoords[Y] = coords[coords.length - 1];
+                    continue;
+                }
+                coords = new int[numCoords];
+                for (int i = 0; i < numCoords; i++) {
+                    coords[i] = (int) Math.round(dstPts[i]);
+                }
+                if (type == PathIterator.SEG_MOVETO) {
+                    graphicsObj.setCurrentPosition(coords);
+                    openingCoords[X] = coords[X];
+                    openingCoords[Y] = coords[Y];
+                } else if (type == PathIterator.SEG_LINETO) {
+                    graphicsObj.addLine(coords, true);
+                } else if (type == PathIterator.SEG_QUADTO
+                        || type == PathIterator.SEG_CUBICTO) {
+                    graphicsObj.addFillet(coords, true);
                 }
             }
         }
@@ -379,7 +378,7 @@
 
     /** {@inheritDoc} */
     public GraphicsConfiguration getDeviceConfiguration() {
-        return new AFPGraphicsConfiguration();
+        return graphicsConfig;
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/fonts/RasterFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/fonts/RasterFont.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/fonts/RasterFont.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/fonts/RasterFont.java Mon Nov 17 07:26:06 2008
@@ -35,7 +35,7 @@
 public class RasterFont extends AFPFont {
 
     /** Static logging instance */
-    protected static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp.fonts");
+    protected static final Log log = LogFactory.getLog("org.apache.fop.afp.fonts");
 
     private final Map/*<String,CharacterSet>*/ charSets
         = new java.util.HashMap/*<String,CharacterSet>*/();

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java (from r713747, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java&r1=713747&r2=718262&rev=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsCoord.java Mon Nov 17 07:26:06 2008
@@ -19,13 +19,18 @@
 
 package org.apache.fop.afp.goca;
 
-import org.apache.fop.afp.modca.AbstractPreparedAFPObject;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.fop.afp.modca.AbstractNamedAFPObject;
+import org.apache.fop.afp.modca.StructuredDataObject;
 import org.apache.fop.afp.util.BinaryUtils;
 
 /**
  * A base class encapsulating the structure of coordinate based GOCA objects
  */
-public abstract class AbstractGraphicsCoord extends AbstractPreparedAFPObject {
+public abstract class AbstractGraphicsCoord extends AbstractNamedAFPObject
+    implements StructuredDataObject {
 
     /** array of x/y coordinates */
     protected int[] coords = null;
@@ -37,7 +42,6 @@
      */
     public AbstractGraphicsCoord(int[] coords) {
         this.coords = coords;
-        prepareData();
     }
 
     /**
@@ -62,40 +66,48 @@
         this(new int[] {x1, y1, x2, y2});
     }
 
+    /** {@inheritDoc} */
+    public int getDataLength() {
+        return 2 + (coords.length * 2);
+    }
+
     /**
-     * Returns the order code to use
+     * Returns the order code of this structured field
      *
-     * @return the order code to use
+     * @return the order code of this structured field
      */
-    protected abstract byte getOrderCode();
+    abstract byte getOrderCode();
 
     /**
-     * Returns the length of this order code (typically this is the same as the coordinate length)
+     * Returns the coordinate data start index
      *
-     * @return the length of this order code
+     * @return the coordinate data start index
      */
-    protected int getLength() {
-        return this.coords.length * 2;
+    int getCoordinateDataStartIndex() {
+        return 2;
     }
 
     /**
-     * Creates a newly created and initialized byte data
+     * Returns the coordinate data
      *
-     * @return a newly created and initialized byte data
+     * @return the coordinate data
      */
-    protected byte[] createData() {
-        int len = getLength();
-        byte[] data = new byte[len + 2];
-        data[0] = getOrderCode(); // ORDER CODE
-        data[1] = (byte)len; // LENGTH
+    byte[] getData() {
+        int len = getDataLength();
+        byte[] data = new byte[len];
+        data[0] = getOrderCode();
+        data[1] = (byte)(len - 2);
+
+        if (coords != null) {
+            addCoords(data, getCoordinateDataStartIndex());
+        }
+
         return data;
     }
 
     /** {@inheritDoc} */
-    protected void prepareData() {
-        super.data = createData();
-        int fromIndex = data.length - getLength();
-        addCoords(data, fromIndex);
+    public void writeToStream(OutputStream os) throws IOException {
+        os.write(getData());
     }
 
     /**

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsObjectContainer.java (from r713745, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractPreparedObjectContainer.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsObjectContainer.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsObjectContainer.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractPreparedObjectContainer.java&r1=713745&r2=718262&rev=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractPreparedObjectContainer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsObjectContainer.java Mon Nov 17 07:26:06 2008
@@ -17,27 +17,30 @@
 
 /* $Id: $ */
 
-package org.apache.fop.afp.modca;
+package org.apache.fop.afp.goca;
 
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.fop.afp.modca.AbstractNamedAFPObject;
+import org.apache.fop.afp.modca.StructuredDataObject;
+
 /**
  * A base container of prepared structured AFP objects
  */
-public abstract class AbstractPreparedObjectContainer extends AbstractNamedAFPObject
-implements PreparedAFPObject {
+public abstract class AbstractGraphicsObjectContainer extends AbstractNamedAFPObject
+implements StructuredDataObject {
 
     /** list of objects contained within this container */
-    protected List/*<PreparedAFPObject>*/ objects
-        = new java.util.ArrayList/*<PreparedAFPObject>*/();
+    protected List/*<StructuredDataObject>*/ objects
+        = new java.util.ArrayList/*<StructuredDataObject>*/();
 
     /**
      * Default constructor
      */
-    protected AbstractPreparedObjectContainer() {
+    protected AbstractGraphicsObjectContainer() {
     }
 
     /**
@@ -45,7 +48,7 @@
      *
      * @param name the name of the container
      */
-    protected AbstractPreparedObjectContainer(String name) {
+    protected AbstractGraphicsObjectContainer(String name) {
         super(name);
     }
 
@@ -55,12 +58,12 @@
     }
 
     /**
-     * Adds a given prepared object to this container
+     * Adds a given graphics object to this container
      *
-     * @param preparedObject the prepared object
+     * @param drawingOrder the graphics object
      */
-    public void addObject(PreparedAFPObject preparedObject) {
-        objects.add(preparedObject);
+    public void addObject(StructuredDataObject drawingOrder) {
+        objects.add(drawingOrder);
     }
 
     /**
@@ -73,11 +76,7 @@
         int dataLen = 0;
         Iterator it = objects.iterator();
         while (it.hasNext()) {
-            Object obj = it.next();
-            if (obj instanceof PreparedAFPObject) {
-                PreparedAFPObject prepObj = (PreparedAFPObject)obj;
-                dataLen += prepObj.getDataLength();
-            }
+            dataLen += ((StructuredDataObject)it.next()).getDataLength();
         }
         return dataLen;
     }

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsString.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsString.java?rev=718262&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsString.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsString.java Mon Nov 17 07:26:06 2008
@@ -0,0 +1,74 @@
+/*
+ * 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.afp.goca;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.fop.afp.AFPConstants;
+
+public abstract class AbstractGraphicsString extends AbstractGraphicsCoord {
+
+    /** Up to 255 bytes of character data */
+    protected static final int MAX_STR_LEN = 255;
+
+    /** the string to draw */
+    protected final String str;
+
+    /**
+     * Constructor (relative)
+     *
+     * @param str the text string
+     */
+    public AbstractGraphicsString(String str) {
+        super(null);
+        if (str.length() > MAX_STR_LEN) {
+            str = str.substring(0, MAX_STR_LEN);
+            log.warn("truncated character string, longer than " + MAX_STR_LEN + " chars");
+        }
+        this.str = str;
+    }
+
+    /**
+     * Constructor (absolute)
+     *
+     * @param str the text string
+     * @param x the x coordinate
+     * @param y the y coordinate
+     */
+    public AbstractGraphicsString(String str, int x, int y) {
+        super(x, y);
+        this.str = str;
+    }
+
+    /** {@inheritDoc} */
+    public int getDataLength() {
+        return 2 + str.length();
+    }
+
+    /**
+     * Returns the text string as an encoded byte array
+     *
+     * @return the text string as an encoded byte array
+     */
+    protected byte[] getStringAsBytes() throws UnsupportedEncodingException {
+        return str.getBytes(AFPConstants.EBCIDIC_ENCODING);
+    }
+
+}

Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsString.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsString.java
------------------------------------------------------------------------------
    svn:keywords = Revision Id

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsArea.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsArea.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsArea.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsArea.java Mon Nov 17 07:26:06 2008
@@ -22,12 +22,11 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.afp.modca.AbstractPreparedObjectContainer;
 
 /**
  * A GOCA graphics area (container for filled shapes/objects)
  */
-public final class GraphicsArea extends AbstractPreparedObjectContainer {
+public final class GraphicsArea extends AbstractGraphicsObjectContainer {
 
     private static final int RES1 = 1;
     private static final int BOUNDARY = 2;
@@ -47,7 +46,6 @@
 
     /** {@inheritDoc} */
     public int getDataLength() {
-        // start len + end len + data len
         return 4 + super.getDataLength();
     }
 
@@ -62,11 +60,11 @@
 
     /** {@inheritDoc} */
     protected void writeEnd(OutputStream os) throws IOException {
-        byte[] endData = new byte[] {
+        byte[] data = new byte[] {
             (byte)0x60, // GEAR order code
             0x00, // LENGTH
         };
-        os.write(endData);
+        os.write(data);
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsBox.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsBox.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsBox.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsBox.java Mon Nov 17 07:26:06 2008
@@ -19,6 +19,9 @@
 
 package org.apache.fop.afp.goca;
 
+import java.io.IOException;
+import java.io.OutputStream;
+
 /**
  * A GOCA graphics rectangular box
  */
@@ -34,28 +37,27 @@
     }
 
     /** {@inheritDoc} */
-    protected byte getOrderCode() {
-        return (byte)0xC0;
+    public int getDataLength() {
+        return 12;
     }
 
     /** {@inheritDoc} */
-    protected int getLength() {
-        return 10;
+    int getCoordinateDataStartIndex() {
+        return 4;
     }
 
     /** {@inheritDoc} */
-    protected void prepareData() {
-        super.data = createData();
-        final int fromIndex = 4;
-        addCoords(data, fromIndex);
+    byte getOrderCode() {
+        return (byte)0xC0;
     }
 
     /** {@inheritDoc} */
-    protected byte[] createData() {
-        byte[] data = super.createData();
+    public void writeToStream(OutputStream os) throws IOException {
+        byte[] data = getData();
         data[2] = (byte)0x20; // CONTROL draw control flags
         data[3] = 0x00; // reserved
-        return data;
+
+        os.write(data);
     }
 
 }
\ No newline at end of file

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsChainedSegment.java Mon Nov 17 07:26:06 2008
@@ -22,14 +22,13 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.afp.modca.AbstractPreparedObjectContainer;
-import org.apache.fop.afp.modca.PreparedAFPObject;
+import org.apache.fop.afp.modca.StructuredDataObject;
 import org.apache.fop.afp.util.BinaryUtils;
 
 /**
  * A GOCA graphics segment
  */
-public final class GraphicsChainedSegment extends AbstractPreparedObjectContainer {
+public final class GraphicsChainedSegment extends AbstractGraphicsObjectContainer {
 
     /** The maximum segment data length */
     protected static final int MAX_DATA_LEN = 8192;
@@ -84,11 +83,16 @@
     }
 
     /** {@inheritDoc} */
+    byte getOrderCode() {
+        return 0x70;
+    }
+
+    /** {@inheritDoc} */
     protected void writeStart(OutputStream os) throws IOException {
         super.writeStart(os);
 
         byte[] data = new byte[14];
-        data[0] = 0x70; // BEGIN_SEGMENT
+        data[0] = getOrderCode(); // BEGIN_SEGMENT
         data[1] = 0x0C; // Length of following parameters
 
         // segment name
@@ -133,7 +137,7 @@
     }
 
     /** {@inheritDoc} */
-    public void addObject(PreparedAFPObject drawingOrder) {
+    public void addObject(StructuredDataObject drawingOrder) {
         if (currentArea != null) {
             currentArea.addObject(drawingOrder);
         } else {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsData.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsData.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsData.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsData.java Mon Nov 17 07:26:06 2008
@@ -22,21 +22,20 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.afp.modca.AbstractPreparedObjectContainer;
-import org.apache.fop.afp.modca.PreparedAFPObject;
+import org.apache.fop.afp.modca.StructuredDataObject;
 import org.apache.fop.afp.util.BinaryUtils;
 import org.apache.fop.afp.util.StringUtils;
 
 /**
  * A GOCA graphics data
  */
-public final class GraphicsData extends AbstractPreparedObjectContainer {
+public final class GraphicsData extends AbstractGraphicsObjectContainer {
 
     /** The maximum graphics data length */
     public static final int MAX_DATA_LEN = 32767;
 
     /** The graphics segment */
-    private GraphicsChainedSegment currentSegment = null;
+    private GraphicsChainedSegment segment = null;
 
     /** {@inheritDoc} */
     public int getDataLength() {
@@ -74,10 +73,10 @@
      * @return the current graphics chained segment
      */
     private GraphicsChainedSegment getSegment() {
-        if (currentSegment == null) {
+        if (segment == null) {
             newSegment();
         }
-        return this.currentSegment;
+        return this.segment;
     }
 
     /**
@@ -87,23 +86,23 @@
      */
     public GraphicsChainedSegment newSegment() {
         String name = createSegmentName();
-        if (currentSegment == null) {
-            this.currentSegment = new GraphicsChainedSegment(name);
+        if (segment == null) {
+            this.segment = new GraphicsChainedSegment(name);
         } else {
-            this.currentSegment = new GraphicsChainedSegment(name, currentSegment);
+            this.segment = new GraphicsChainedSegment(name, segment);
         }
-        super.addObject(currentSegment);
-        return currentSegment;
+        super.addObject(segment);
+        return segment;
     }
 
     /** {@inheritDoc} */
-    public void addObject(PreparedAFPObject drawingOrder) {
-        if (currentSegment == null
-            || (currentSegment.getDataLength() + drawingOrder.getDataLength())
+    public void addObject(StructuredDataObject drawingOrder) {
+        if (segment == null
+            || (segment.getDataLength() + drawingOrder.getDataLength())
             >= GraphicsChainedSegment.MAX_DATA_LEN) {
             newSegment();
         }
-        currentSegment.addObject(drawingOrder);
+        segment.addObject(drawingOrder);
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFillet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFillet.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFillet.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFillet.java Mon Nov 17 07:26:06 2008
@@ -34,8 +34,7 @@
         super(coords);
     }
 
-    /** {@inheritDoc} */
-    protected byte getOrderCode() {
+    byte getOrderCode() {
         return (byte)0xC5;
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFilletRelative.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFilletRelative.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFilletRelative.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFilletRelative.java Mon Nov 17 07:26:06 2008
@@ -19,6 +19,7 @@
 
 package org.apache.fop.afp.goca;
 
+
 /**
  * A GOCA graphics curved tangential line to a specified set of
  * straight lines drawn from the given position or current position
@@ -35,8 +36,7 @@
     }
 
     /** {@inheritDoc} */
-    protected byte getOrderCode() {
+    byte getOrderCode() {
         return (byte)0x85;
     }
-
 }
\ No newline at end of file

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFullArc.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFullArc.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFullArc.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsFullArc.java Mon Nov 17 07:26:06 2008
@@ -19,12 +19,16 @@
 
 package org.apache.fop.afp.goca;
 
+import java.io.IOException;
+import java.io.OutputStream;
+
 import org.apache.fop.afp.util.BinaryUtils;
 
 /**
  * A GOCA graphics arc (circle/ellipse)
  */
 public class GraphicsFullArc extends AbstractGraphicsCoord {
+
     /** the integer portion of the multiplier */
     private final int mh;
 
@@ -43,27 +47,29 @@
         super(x, y);
         this.mh = mh;
         this.mhr = mhr;
-        // integer portion of multiplier
-        data[data.length - 2] = BinaryUtils.convert(mh, 1)[0];
-        // fractional portion of multiplier
-        data[data.length - 1] = BinaryUtils.convert(mhr, 1)[0];
     }
 
     /** {@inheritDoc} */
-    protected byte getOrderCode() {
-        return (byte)0xC7;
+    public int getDataLength() {
+        return 8;
     }
 
     /** {@inheritDoc} */
-    protected int getLength() {
-        return super.getLength() + 2;
+    byte getOrderCode() {
+        return (byte)0xC7;
     }
 
     /** {@inheritDoc} */
-    protected void prepareData() {
-        super.data = super.createData();
-        final int fromIndex = 2;
-        super.addCoords(data, fromIndex);
+    public void writeToStream(OutputStream os) throws IOException {
+        byte[] data = getData();
+
+        // integer portion of multiplier
+        data[6] = BinaryUtils.convert(mh, 1)[0];
+
+        // fractional portion of multiplier
+        data[7] = BinaryUtils.convert(mhr, 1)[0];
+
+        os.write(data);
     }
 
     /** {@inheritDoc} */
@@ -75,4 +81,5 @@
              + ", mhr=" + mhr
          + "}";
     }
+
 }
\ No newline at end of file

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsImage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsImage.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsImage.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsImage.java Mon Nov 17 07:26:06 2008
@@ -22,13 +22,13 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.afp.modca.AbstractStructuredAFPObject;
+import org.apache.fop.afp.modca.AbstractStructuredObject;
 import org.apache.fop.afp.util.BinaryUtils;
 
 /**
  * A GOCA Image
  */
-public class GraphicsImage extends AbstractStructuredAFPObject {
+public class GraphicsImage extends AbstractStructuredObject {
 
     /** x coordinate */
     private final int x;

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsLine.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsLine.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsLine.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsLine.java Mon Nov 17 07:26:06 2008
@@ -21,7 +21,7 @@
 
 /**
  * A GOCA graphics straight line drawn from the
- * given position
+ * given absolute position
  */
 public class GraphicsLine extends AbstractGraphicsCoord {
 
@@ -35,7 +35,7 @@
     }
 
     /** {@inheritDoc} */
-    protected byte getOrderCode() {
+    byte getOrderCode() {
         return (byte)0xC1;
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsLineRelative.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsLineRelative.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsLineRelative.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsLineRelative.java Mon Nov 17 07:26:06 2008
@@ -35,7 +35,7 @@
     }
 
     /** {@inheritDoc} */
-    protected byte getOrderCode() {
+    byte getOrderCode() {
         return (byte)0x81;
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetCharacterSet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetCharacterSet.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetCharacterSet.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetCharacterSet.java Mon Nov 17 07:26:06 2008
@@ -19,13 +19,18 @@
 
 package org.apache.fop.afp.goca;
 
-import org.apache.fop.afp.modca.AbstractPreparedAFPObject;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.fop.afp.modca.AbstractNamedAFPObject;
+import org.apache.fop.afp.modca.StructuredDataObject;
 import org.apache.fop.afp.util.BinaryUtils;
 
 /**
  * Sets the current character set (font) to be used for following graphics strings
  */
-public class GraphicsSetCharacterSet extends AbstractPreparedAFPObject {
+public class GraphicsSetCharacterSet extends AbstractNamedAFPObject
+    implements StructuredDataObject {
 
     /** font character set reference */
     private final int fontReference;
@@ -35,19 +40,25 @@
      */
     public GraphicsSetCharacterSet(int fontReference) {
         this.fontReference = fontReference;
-        prepareData();
     }
 
     /** {@inheritDoc} */
-    protected void prepareData() {
-        super.data = new byte[] {
+    public void writeToStream(OutputStream os) throws IOException {
+        byte[] data = new byte[] {
             0x38, // GSCS order code
             BinaryUtils.convert(fontReference)[0]
         };
+        os.write(data);
+    }
+
+    /** {@inheritDoc} */
+    public int getDataLength() {
+        return 2;
     }
 
     /** {@inheritDoc} */
     public String toString() {
         return "GraphicsSetCharacterSet(" + fontReference + ")";
     }
+
 }
\ No newline at end of file

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetLineType.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetLineType.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetLineType.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetLineType.java Mon Nov 17 07:26:06 2008
@@ -19,12 +19,17 @@
 
 package org.apache.fop.afp.goca;
 
-import org.apache.fop.afp.modca.AbstractPreparedAFPObject;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.fop.afp.modca.AbstractNamedAFPObject;
+import org.apache.fop.afp.modca.StructuredDataObject;
 
 /**
  * Sets the value of the current line type attribute when stroking GOCA shapes (structured fields)
  */
-public class GraphicsSetLineType extends AbstractPreparedAFPObject {
+public class GraphicsSetLineType extends AbstractNamedAFPObject
+implements StructuredDataObject {
 
     /** the default line type */
     public static final byte DEFAULT = 0x00; // normally SOLID
@@ -63,15 +68,20 @@
      */
     public GraphicsSetLineType(byte type) {
        this.type = type;
-       prepareData();
     }
 
     /** {@inheritDoc} */
-    protected void prepareData() {
-        super.data = new byte[] {
-           0x18, // GSLW order code
-           type // line type
+    public int getDataLength() {
+        return 2;
+    }
+
+    /** {@inheritDoc} */
+    public void writeToStream(OutputStream os) throws IOException {
+        byte[] data = new byte[] {
+            0x18, // GSLW order code
+            type // line type
         };
+        os.write(data);
     }
 
     private static final String[] TYPES = {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetLineWidth.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetLineWidth.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetLineWidth.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetLineWidth.java Mon Nov 17 07:26:06 2008
@@ -19,12 +19,17 @@
 
 package org.apache.fop.afp.goca;
 
-import org.apache.fop.afp.modca.AbstractPreparedAFPObject;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.fop.afp.modca.AbstractNamedAFPObject;
+import org.apache.fop.afp.modca.StructuredDataObject;
 
 /**
  * Sets the line width to use when stroking GOCA shapes (structured fields)
  */
-public class GraphicsSetLineWidth extends AbstractPreparedAFPObject {
+public class GraphicsSetLineWidth extends AbstractNamedAFPObject implements StructuredDataObject {
+
     /** line width multiplier */
     private int multiplier = 1;
 
@@ -35,15 +40,20 @@
      */
     public GraphicsSetLineWidth(int multiplier) {
         this.multiplier = multiplier;
-        prepareData();
     }
 
     /** {@inheritDoc} */
-    protected void prepareData() {
-        super.data = new byte[] {
+    public int getDataLength() {
+        return 2;
+    }
+
+    /** {@inheritDoc} */
+    public void writeToStream(OutputStream os) throws IOException {
+        byte[] data = new byte[] {
            0x19, // GSLW order code
            (byte)multiplier // MH (line-width)
         };
+        os.write(data);
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetMix.java Mon Nov 17 07:26:06 2008
@@ -19,9 +19,12 @@
 
 package org.apache.fop.afp.goca;
 
-import org.apache.fop.afp.modca.AbstractPreparedAFPObject;
+import java.io.IOException;
+import java.io.OutputStream;
 
-public class GraphicsSetMix extends AbstractPreparedAFPObject {
+import org.apache.fop.afp.modca.AbstractNamedAFPObject;
+
+public class GraphicsSetMix extends AbstractNamedAFPObject {
 
     public static final byte MODE_DEFAULT = 0x00;
     public static final byte MODE_OVERPAINT = 0x02;
@@ -36,15 +39,15 @@
      */
     public GraphicsSetMix(byte mode) {
         this.mode = mode;
-        prepareData();
     }
 
     /** {@inheritDoc} */
-    protected void prepareData() {
-        super.data = new byte[] {
+    public void writeToStream(OutputStream os) throws IOException {
+        byte[] data = new byte[] {
            0x0C, // GSMX order code
            mode // MODE (mix mode value)
         };
+        os.write(data);
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetPatternSymbol.java Mon Nov 17 07:26:06 2008
@@ -19,12 +19,18 @@
 
 package org.apache.fop.afp.goca;
 
-import org.apache.fop.afp.modca.AbstractPreparedAFPObject;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.fop.afp.modca.AbstractNamedAFPObject;
+import org.apache.fop.afp.modca.StructuredDataObject;
 
 /**
  * Sets the pattern symbol to use when filling following GOCA structured fields
  */
-public class GraphicsSetPatternSymbol extends AbstractPreparedAFPObject {
+public class GraphicsSetPatternSymbol extends AbstractNamedAFPObject
+implements StructuredDataObject {
+
     /** dotted density 1 */
     public static final byte DOTTED_DENSITY_1 = 0x01;
 
@@ -86,15 +92,20 @@
      */
     public GraphicsSetPatternSymbol(byte symb) {
         this.symbol = symb;
-        prepareData();
     }
 
     /** {@inheritDoc} */
-    protected void prepareData() {
-        super.data = new byte[] {
+    public int getDataLength() {
+        return 2;
+    }
+
+    /** {@inheritDoc} */
+    public void writeToStream(OutputStream os) throws IOException {
+        byte[] data = new byte[] {
             0x28, // GSPT order code
             symbol
         };
+        os.write(data);
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsSetProcessColor.java Mon Nov 17 07:26:06 2008
@@ -21,16 +21,22 @@
 
 import java.awt.Color;
 import java.awt.color.ColorSpace;
+import java.io.IOException;
+import java.io.OutputStream;
 
-import org.apache.fop.afp.modca.AbstractPreparedAFPObject;
+import org.apache.fop.afp.modca.AbstractNamedAFPObject;
+import org.apache.fop.afp.modca.StructuredDataObject;
 
 /**
  * Sets the current processing color for the following GOCA structured fields
  */
-public class GraphicsSetProcessColor extends AbstractPreparedAFPObject {
-    /** the color to set */
+public class GraphicsSetProcessColor extends AbstractNamedAFPObject
+implements StructuredDataObject {
+
     private final Color color;
 
+    private final float[] colorComponents;
+
     /**
      * Main constructor
      *
@@ -38,11 +44,22 @@
      */
     public GraphicsSetProcessColor(Color color) {
         this.color = color;
-        prepareData();
+        this.colorComponents = color.getColorComponents(null);
+    }
+
+    /** {@inheritDoc} */
+    public int getDataLength() {
+        return 12 + colorComponents.length;
     }
 
     /** {@inheritDoc} */
-    protected void prepareData() {
+    byte getOrderCode() {
+        return (byte)0xB2;
+    }
+
+    /** {@inheritDoc} */
+    public void writeToStream(OutputStream os) throws IOException {
+
         // COLSPCE
         byte colspace;
         int colSpaceType = color.getColorSpace().getType();
@@ -56,16 +73,15 @@
         }
 
         // COLSIZE(S)
-        float[] colcomp = color.getColorComponents(null);
         byte[] colsizes = new byte[] {0x00, 0x00, 0x00, 0x00};
-        for (int i = 0; i < colcomp.length; i++) {
+        for (int i = 0; i < colorComponents.length; i++) {
             colsizes[i] = (byte)8;
         }
 
-        int len = 10 + colcomp.length;
-        super.data = new byte[len + 2];
-        data[0] = (byte)0xB2; // GSPCOL order code
-        data[1] = (byte)len; // LEN
+        int len = getDataLength();
+        byte[] data = new byte[len];
+        data[0] = getOrderCode(); // GSPCOL order code
+        data[1] = (byte)(len - 2); // LEN
         data[2] = 0x00; // reserved; must be zero
         data[3] = colspace; // COLSPCE
         data[4] = 0x00; // reserved; must be zero
@@ -76,10 +92,13 @@
         data[9] = colsizes[1];
         data[10] = colsizes[2];
         data[11] = colsizes[3];
+
         // COLVALUE(S)
-        for (int i = 0; i < colcomp.length; i++) {
-            data[i + 12] = (byte)(colcomp[i] * 255);
+        for (int i = 0; i < colorComponents.length; i++) {
+            data[i + 12] = (byte)(colorComponents[i] * 255);
         }
+
+        os.write(data);
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsString.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsString.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsString.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsString.java Mon Nov 17 07:26:06 2008
@@ -19,41 +19,13 @@
 
 package org.apache.fop.afp.goca;
 
-import java.io.UnsupportedEncodingException;
-
-import org.apache.fop.afp.AFPConstants;
-import org.apache.fop.afp.modca.AbstractPreparedAFPObject;
-import org.apache.fop.afp.util.BinaryUtils;
+import java.io.IOException;
+import java.io.OutputStream;
 
 /**
  * A GOCA graphics string
  */
-public class GraphicsString extends AbstractPreparedAFPObject {
-    /** Up to 255 bytes of character data */
-    private static final int MAX_STR_LEN = 255;
-
-    /** drawn from the current position */
-    private boolean fromCurrentPosition = false;
-
-    /** the string to draw */
-    private String str = null;
-
-    /** x coordinate */
-    private int x;
-
-    /** y coordinate */
-    private int y;
-
-    /**
-     * Constructor
-     *
-     * @param str the character string
-     */
-    public GraphicsString(String str) {
-        this.str  = str;
-        fromCurrentPosition = true;
-        prepareData();
-    }
+public class GraphicsString extends AbstractGraphicsString {
 
     /**
      * Constructor
@@ -63,53 +35,30 @@
      * @param y the y coordinate
      */
     public GraphicsString(String str, int x, int y) {
-        this.str = str;
-        this.x = x;
-        this.y = y;
-        prepareData();
+        super(str, x, y);
+    }
+
+    /** {@inheritDoc} */
+    byte getOrderCode() {
+        return (byte)0xC3;
     }
 
     /** {@inheritDoc} */
-    protected void prepareData() {
-        int maxStrLen = MAX_STR_LEN - (fromCurrentPosition ? 0 : 4);
-        if (str.length() > maxStrLen) {
-            str = str.substring(0, maxStrLen);
-            log.warn("truncated character string, longer than " + maxStrLen + " chars");
-        }
-        byte[] strData = null;
-        try {
-            strData = str.getBytes(AFPConstants.EBCIDIC_ENCODING);
-        } catch (UnsupportedEncodingException ex) {
-            log.error("unsupported encoding: " + ex.getMessage());
-        }
-        int len = strData.length;
-        if (fromCurrentPosition) {
-            data = new byte[len + 2];
-            data[0] = (byte)0x83;
-            data[1] = (byte)len;
-            System.arraycopy(strData, 0, data, 2, strData.length);
-        } else {
-            len += 4; // x/y coordinates
-            byte[] osx = BinaryUtils.convert(x, 2);
-            byte[] osy = BinaryUtils.convert(y, 2);
-            data = new byte[len + 2];
-            data[0] = (byte)0xC3;
-            data[1] = (byte)len;
-            data[2] = osx[0];
-            data[3] = osx[1];
-            data[4] = osy[0];
-            data[5] = osy[1];
-            System.arraycopy(strData, 0, data, 6, strData.length);
-        }
+    public int getDataLength() {
+        return super.getDataLength() + (coords.length * 2);
+    }
+
+    /** {@inheritDoc} */
+    public void writeToStream(OutputStream os) throws IOException {
+        byte[] data = getData();
+        byte[] strData = getStringAsBytes();
+        System.arraycopy(strData, 0, data, 6, strData.length);
+
+        os.write(data);
     }
 
     /** {@inheritDoc} */
     public String toString() {
-        String string = "GraphicsString{str='" + str + "'";
-        if (!fromCurrentPosition) {
-            string += ",x=" + x + ",y=" + y;
-        }
-        string += "}";
-        return string;
+        return "GraphicsString{x=" + coords[0] + ", y=" + coords[1] + "str='" + str + "'" + "}";
     }
 }
\ No newline at end of file

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsStringRelative.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsStringRelative.java?rev=718262&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsStringRelative.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsStringRelative.java Mon Nov 17 07:26:06 2008
@@ -0,0 +1,57 @@
+/*
+ * 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.afp.goca;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * A GOCA graphics string
+ */
+public class GraphicsStringRelative extends AbstractGraphicsString {
+
+    /**
+     * Constructor
+     *
+     * @param str the character string
+     */
+    public GraphicsStringRelative(String str) {
+        super(str);
+    }
+
+    /** {@inheritDoc} */
+    byte getOrderCode() {
+        return (byte)0x83;
+    }
+
+    /** {@inheritDoc} */
+    public void writeToStream(OutputStream os) throws IOException {
+        byte[] data = getData();
+        byte[] strData = getStringAsBytes();
+        System.arraycopy(strData, 0, data, 2, strData.length);
+        os.write(data);
+    }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return "GraphicsStringRelative{str='" + str + "'" + "}";
+    }
+
+}
\ No newline at end of file

Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsStringRelative.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsStringRelative.java
------------------------------------------------------------------------------
    svn:keywords = Revision Id

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/ioca/ImageContent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/ioca/ImageContent.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/ioca/ImageContent.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/ioca/ImageContent.java Mon Nov 17 07:26:06 2008
@@ -22,12 +22,12 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.afp.modca.AbstractStructuredAFPObject;
+import org.apache.fop.afp.modca.AbstractStructuredObject;
 
 /**
  * An IOCA Image Content
  */
-public class ImageContent extends AbstractStructuredAFPObject {
+public class ImageContent extends AbstractStructuredObject {
 
     /**
      * The CCITT T.4 Group 3 Coding Standard (G3 MH-Modified Huffman) is a

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractAFPObject.java Mon Nov 17 07:26:06 2008
@@ -20,6 +20,7 @@
 package org.apache.fop.afp.modca;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Collection;
 import java.util.Iterator;
@@ -27,6 +28,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.fop.afp.Streamable;
+import org.apache.fop.afp.util.BinaryUtils;
 
 /**
  * This is the base class for all data stream objects. Page objects are
@@ -100,6 +102,81 @@
         }
     }
 
+    /**
+     * Reads data chunks from an inputstream
+     * and then formats them with a structured header to a given outputstream
+     *
+     * @param dataHeader the header data
+     * @param lengthOffset offset of length field in data chunk
+     * @param maxChunkLength the maximum chunk length
+     * @param inputStream the inputstream to read from
+     * @param outputStream the outputstream to write to
+     * @throws IOException thrown if an I/O exception of some sort has occurred.
+     */
+    protected static void copyChunks(byte[] dataHeader, int lengthOffset,
+            int maxChunkLength, InputStream inputStream, OutputStream outputStream)
+    throws IOException {
+        int headerLen = dataHeader.length - lengthOffset;
+        // length field is just before data so do not include in data length
+        if (headerLen == 2) {
+            headerLen = 0;
+        }
+        byte[] data = new byte[maxChunkLength];
+        int numBytesRead = 0;
+        while ((numBytesRead = inputStream.read(data, 0, maxChunkLength)) > 0) {
+            byte[] len = BinaryUtils.convert(headerLen + numBytesRead, 2);
+            dataHeader[lengthOffset] = len[0]; // Length byte 1
+            dataHeader[lengthOffset + 1] = len[1]; // Length byte 2
+            outputStream.write(dataHeader);
+            outputStream.write(data, 0, numBytesRead);
+        }
+    }
+
+    /**
+     * Writes data chunks to a given outputstream
+     *
+     * @param data the data byte array
+     * @param dataHeader the header data
+     * @param lengthOffset offset of length field in data chunk
+     * @param maxChunkLength the maximum chunk length
+     * @param os the outputstream to write to
+     * @throws IOException thrown if an I/O exception of some sort has occurred.
+     */
+    protected static void writeChunksToStream(byte[] data, byte[] dataHeader,
+            int lengthOffset, int maxChunkLength, OutputStream os) throws IOException {
+        int dataLength = data.length;
+        int numFullChunks = dataLength / maxChunkLength;
+        int lastChunkLength = dataLength % maxChunkLength;
+
+        int headerLen = dataHeader.length - lengthOffset;
+        // length field is just before data so do not include in data length
+        if (headerLen == 2) {
+            headerLen = 0;
+        }
+
+        byte[] len;
+        int off = 0;
+        if (numFullChunks > 0) {
+            // write out full data chunks
+            len = BinaryUtils.convert(headerLen + maxChunkLength, 2);
+            dataHeader[lengthOffset] = len[0]; // Length byte 1
+            dataHeader[lengthOffset + 1] = len[1]; // Length byte 2
+            for (int i = 0; i < numFullChunks; i++, off += maxChunkLength) {
+                os.write(dataHeader);
+                os.write(data, off, maxChunkLength);
+            }
+        }
+
+        if (lastChunkLength > 0) {
+            // write last data chunk
+            len = BinaryUtils.convert(headerLen + lastChunkLength, 2);
+            dataHeader[lengthOffset] = len[0]; // Length byte 1
+            dataHeader[lengthOffset + 1] = len[1]; // Length byte 2
+            os.write(dataHeader);
+            os.write(data, off, lastChunkLength);
+        }
+    }
+
     /** structured field type codes */
     public interface Type {
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractDescriptor.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractDescriptor.java Mon Nov 17 07:26:06 2008
@@ -22,7 +22,7 @@
 /**
  * Base class for AFP descriptor objects
  */
-public abstract class AbstractDescriptor extends AbstractStructuredAFPObject {
+public abstract class AbstractDescriptor extends AbstractTripletStructuredObject {
     /** width of this descriptor */
     protected int width = 0;
     /** height of this descriptor */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractNamedAFPObject.java Mon Nov 17 07:26:06 2008
@@ -27,7 +27,7 @@
  * This is the base class for all named data stream objects.
  * A named data stream object has an 8 byte EBCIDIC name.
  */
-public abstract class AbstractNamedAFPObject extends AbstractStructuredAFPObject {
+public abstract class AbstractNamedAFPObject extends AbstractTripletStructuredObject {
 
     private static final int DEFAULT_NAME_LENGTH = 8;
 

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractStructuredObject.java (from r713745, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractStructuredAFPObject.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractStructuredObject.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractStructuredObject.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractStructuredAFPObject.java&r1=713745&r2=718262&rev=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractStructuredAFPObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractStructuredObject.java Mon Nov 17 07:26:06 2008
@@ -20,88 +20,17 @@
 package org.apache.fop.afp.modca;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.fop.afp.modca.Registry.ObjectType;
-import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet;
-import org.apache.fop.afp.modca.triplets.ObjectClassificationTriplet;
-import org.apache.fop.afp.modca.triplets.Triplet;
-import org.apache.fop.afp.util.BinaryUtils;
 
 /**
  * An abstract class encapsulating an MODCA structured object
  */
-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;
+public abstract class AbstractStructuredObject extends AbstractAFPObject {
 
     /**
      * Default constructor
      */
-    protected AbstractStructuredAFPObject() {
-    }
-
-    /**
-     * Returns the triplet data length
-     *
-     * @return the triplet data length
-     */
-    protected int getTripletDataLength() {
-        if (tripletData == null) {
-            try {
-                getTripletData();
-            } catch (IOException e) {
-                log.error("failed to get triplet data");
-            }
-        }
-        if (tripletData != null) {
-            return tripletData.length;
-        }
-        return 0;
-    }
-
-    /**
-     * Returns the triplet data
-     *
-     * @return the triplet data
-     * @throws IOException throws an I/O exception if one occurred
-     */
-    protected byte[] getTripletData() throws IOException {
-        if (tripletData == null && triplets != null) {
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            writeObjects(triplets, baos);
-            this.tripletData = baos.toByteArray();
-            triplets = null; // gc
-        }
-        return this.tripletData;
-    }
-
-    /**
-     * 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);
-            triplets = null; // gc
-        }
+    protected AbstractStructuredObject() {
     }
 
     /**
@@ -111,7 +40,6 @@
      * @throws IOException throws an I/O exception if one occurred
      */
     protected void writeStart(OutputStream os) throws IOException {
-        getTripletData();
     }
 
     /**
@@ -130,7 +58,6 @@
      * @throws IOException throws an I/O exception if one occurred
      */
     protected void writeContent(OutputStream os) throws IOException {
-        writeTriplets(os);
     }
 
     /** {@inheritDoc} */
@@ -139,186 +66,4 @@
         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;
-    }
-
-    /**
-     * Returns true of this structured field has the given triplet
-     *
-     * @param tripletId the triplet identifier
-     * @return true if the structured field has the given triplet
-     */
-    public boolean hasTriplet(byte tripletId) {
-        return getTriplet(tripletId) != null;
-    }
-
-    /**
-     * Adds a triplet to this structured object
-     *
-     * @param triplet the triplet to add
-     */
-    protected 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
-     */
-    public 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) {
-        addTriplet(new FullyQualifiedNameTriplet(fqnType, fqnFormat, fqName));
-    }
-
-    /** @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);
-        if (fqNameTriplet != null) {
-            return fqNameTriplet.getFullyQualifiedName();
-        }
-        log.warn(this + " has no fully qualified name");
-        return null;
-    }
-
-    /**
-     * Sets the objects classification
-     *
-     * @param objectClass the classification of the object
-     * @param objectType the MOD:CA registry object type entry for the given
-     *        object/component type of the object
-     * @param dataInContainer whether the data resides in the container
-     * @param containerHasOEG whether the container has an object environment group
-     * @param dataInOCD whether the data resides in a object container data structured field
-     */
-    public void setObjectClassification(
-            byte objectClass, ObjectType objectType,
-            boolean dataInContainer, boolean containerHasOEG, boolean dataInOCD) {
-        addTriplet(
-                new ObjectClassificationTriplet(
-                        objectClass, objectType, dataInContainer, containerHasOEG, dataInOCD));
-    }
-
-    /**
-     * 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());
-        }
-    }
-
-    /**
-     * Reads data chunks from an inputstream
-     * and then formats them with a structured header to a given outputstream
-     *
-     * @param dataHeader the header data
-     * @param lengthOffset offset of length field in data chunk
-     * @param maxChunkLength the maximum chunk length
-     * @param inputStream the inputstream to read from
-     * @param outputStream the outputstream to write to
-     * @throws IOException thrown if an I/O exception of some sort has occurred.
-     */
-    protected static void copyChunks(byte[] dataHeader, int lengthOffset,
-            int maxChunkLength, InputStream inputStream, OutputStream outputStream)
-    throws IOException {
-        int headerLen = dataHeader.length - lengthOffset;
-        // length field is just before data so do not include in data length
-        if (headerLen == 2) {
-            headerLen = 0;
-        }
-        byte[] data = new byte[maxChunkLength];
-        int numBytesRead = 0;
-        while ((numBytesRead = inputStream.read(data, 0, maxChunkLength)) > 0) {
-            byte[] len = BinaryUtils.convert(headerLen + numBytesRead, 2);
-            dataHeader[lengthOffset] = len[0]; // Length byte 1
-            dataHeader[lengthOffset + 1] = len[1]; // Length byte 2
-            outputStream.write(dataHeader);
-            outputStream.write(data, 0, numBytesRead);
-        }
-    }
-
-    /**
-     * Writes data chunks to a given outputstream
-     *
-     * @param data the data byte array
-     * @param dataHeader the header data
-     * @param lengthOffset offset of length field in data chunk
-     * @param maxChunkLength the maximum chunk length
-     * @param os the outputstream to write to
-     * @throws IOException thrown if an I/O exception of some sort has occurred.
-     */
-    protected static void writeChunksToStream(byte[] data, byte[] dataHeader,
-            int lengthOffset, int maxChunkLength, OutputStream os) throws IOException {
-        int dataLength = data.length;
-        int numFullChunks = dataLength / maxChunkLength;
-        int lastChunkLength = dataLength % maxChunkLength;
-
-        int headerLen = dataHeader.length - lengthOffset;
-        // length field is just before data so do not include in data length
-        if (headerLen == 2) {
-            headerLen = 0;
-        }
-
-        byte[] len;
-        int off = 0;
-        if (numFullChunks > 0) {
-            // write out full data chunks
-            len = BinaryUtils.convert(headerLen + maxChunkLength, 2);
-            dataHeader[lengthOffset] = len[0]; // Length byte 1
-            dataHeader[lengthOffset + 1] = len[1]; // Length byte 2
-            for (int i = 0; i < numFullChunks; i++, off += maxChunkLength) {
-                os.write(dataHeader);
-                os.write(data, off, maxChunkLength);
-            }
-        }
-
-        if (lastChunkLength > 0) {
-            // write last data chunk
-            len = BinaryUtils.convert(headerLen + lastChunkLength, 2);
-            dataHeader[lengthOffset] = len[0]; // Length byte 1
-            dataHeader[lengthOffset + 1] = len[1]; // Length byte 2
-            os.write(dataHeader);
-            os.write(data, off, lastChunkLength);
-        }
-    }
 }

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java?rev=718262&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java Mon Nov 17 07:26:06 2008
@@ -0,0 +1,178 @@
+/*
+ * 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.afp.modca;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.fop.afp.modca.Registry.ObjectType;
+import org.apache.fop.afp.modca.triplets.AbstractTriplet;
+import org.apache.fop.afp.modca.triplets.CommentTriplet;
+import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet;
+import org.apache.fop.afp.modca.triplets.ObjectClassificationTriplet;
+
+public class AbstractTripletStructuredObject extends AbstractStructuredObject {
+
+    /** list of object triplets */
+    protected List/*<AbstractTriplet>*/ triplets = new java.util.ArrayList/*<AbstractTriplet>*/();
+
+    /**
+     * Returns the triplet data length
+     *
+     * @return the triplet data length
+     */
+    protected int getTripletDataLength() {
+        int dataLength = 0;
+        if (hasTriplets()) {
+            Iterator it = triplets.iterator();
+            while (it.hasNext()) {
+                AbstractTriplet triplet = (AbstractTriplet)it.next();
+                dataLength += triplet.getDataLength();
+            }
+        }
+        return dataLength;
+    }
+
+    /**
+     * Returns true when this structured field contains triplets
+     *
+     * @return true when this structured field contains triplets
+     */
+    public boolean hasTriplets() {
+        return triplets.size() > 0;
+    }
+
+    /**
+     * 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 (hasTriplets()) {
+            writeObjects(triplets, os);
+            triplets = null; // gc
+        }
+    }
+
+    /**
+     * Returns the first matching triplet found in the structured field triplet list
+     *
+     * @param tripletId the triplet identifier
+     */
+    private AbstractTriplet getTriplet(byte tripletId) {
+        Iterator it = getTriplets().iterator();
+        while (it.hasNext()) {
+            AbstractTriplet triplet = (AbstractTriplet)it.next();
+            if (triplet.getId() == tripletId) {
+                return triplet;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Returns true of this structured field has the given triplet
+     *
+     * @param tripletId the triplet identifier
+     * @return true if the structured field has the given triplet
+     */
+    public boolean hasTriplet(byte tripletId) {
+        return getTriplet(tripletId) != null;
+    }
+
+    /**
+     * Adds a triplet to this structured object
+     *
+     * @param triplet the triplet to add
+     */
+    protected void addTriplet(AbstractTriplet triplet) {
+        triplets.add(triplet);
+    }
+
+    /**
+     * Adds a list of triplets to the triplets contained within this structured field
+     *
+     * @param tripletCollection a collection of triplets
+     */
+    public void addTriplets(Collection/*<Triplet>*/ tripletCollection) {
+        if (tripletCollection != null) {
+            triplets.addAll(tripletCollection);
+        }
+    }
+
+    /** @return the triplet list pertaining to this resource */
+    protected List/*<Triplet>*/ getTriplets() {
+        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) {
+        addTriplet(new FullyQualifiedNameTriplet(fqnType, fqnFormat, fqName));
+    }
+
+    /** @return the fully qualified name of this triplet or null if it does not exist */
+    public String getFullyQualifiedName() {
+        FullyQualifiedNameTriplet fqNameTriplet
+            = (FullyQualifiedNameTriplet)getTriplet(AbstractTriplet.FULLY_QUALIFIED_NAME);
+        if (fqNameTriplet != null) {
+            return fqNameTriplet.getFullyQualifiedName();
+        }
+        log.warn(this + " has no fully qualified name");
+        return null;
+    }
+
+    /**
+     * Sets the objects classification
+     *
+     * @param objectClass the classification of the object
+     * @param objectType the MOD:CA registry object type entry for the given
+     *        object/component type of the object
+     * @param dataInContainer whether the data resides in the container
+     * @param containerHasOEG whether the container has an object environment group
+     * @param dataInOCD whether the data resides in a object container data structured field
+     */
+    public void setObjectClassification(
+            byte objectClass, ObjectType objectType,
+            boolean dataInContainer, boolean containerHasOEG, boolean dataInOCD) {
+        addTriplet(
+                new ObjectClassificationTriplet(
+                        objectClass, objectType, dataInContainer, containerHasOEG, dataInOCD));
+    }
+
+    /**
+     * Sets a comment on this resource
+     *
+     * @param commentString a comment string
+     */
+    public void setComment(String commentString) {
+        addTriplet(new CommentTriplet(AbstractTriplet.COMMENT, commentString));
+    }
+
+}

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

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

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/GraphicsObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/GraphicsObject.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/GraphicsObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/GraphicsObject.java Mon Nov 17 07:26:06 2008
@@ -51,11 +51,11 @@
 public class GraphicsObject extends AbstractDataObject {
 
     /** The graphics data */
-    private GraphicsData currentGraphicsData = null;
+    private GraphicsData data = null;
 
     /** list of objects contained within this container */
-    protected List/*<PreparedAFPObject>*/ objects
-        = new java.util.ArrayList/*<PreparedAFPObject>*/();
+    protected List/*<GraphicsDrawingOrder>*/ objects
+        = new java.util.ArrayList/*<GraphicsDrawingOrder>*/();
 
     /**
      * Default constructor
@@ -85,13 +85,13 @@
     }
 
     /** {@inheritDoc} */
-    public void addObject(PreparedAFPObject drawingOrder) {
-        if (currentGraphicsData == null
-                || (currentGraphicsData.getDataLength() + drawingOrder.getDataLength())
+    public void addObject(StructuredDataObject drawingOrder) {
+        if (data == null
+                || (data.getDataLength() + drawingOrder.getDataLength())
                 >= GraphicsData.MAX_DATA_LEN) {
             newData();
         }
-        currentGraphicsData.addObject(drawingOrder);
+        data.addObject(drawingOrder);
     }
 
     /**
@@ -100,10 +100,10 @@
      * @return the current graphics data
      */
     private GraphicsData getData() {
-        if (this.currentGraphicsData == null) {
+        if (this.data == null) {
             return newData();
         }
-        return this.currentGraphicsData;
+        return this.data;
     }
 
     /**
@@ -112,9 +112,9 @@
      * @return a newly created graphics data
      */
     private GraphicsData newData() {
-        this.currentGraphicsData = factory.createGraphicsData();
-        objects.add(currentGraphicsData);
-        return currentGraphicsData;
+        this.data = factory.createGraphicsData();
+        objects.add(data);
+        return data;
     }
 
     /**
@@ -284,18 +284,18 @@
      * Begins a graphics area (start of fill)
      */
     public void beginArea() {
-        if (currentGraphicsData == null) {
+        if (data == null) {
             newData();
         }
-        currentGraphicsData.beginArea();
+        data.beginArea();
     }
 
     /**
      * Ends a graphics area (end of fill)
      */
     public void endArea() {
-        if (currentGraphicsData != null) {
-            currentGraphicsData.endArea();
+        if (data != null) {
+            data.endArea();
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/IncludeObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/IncludeObject.java?rev=718262&r1=718261&r2=718262&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/IncludeObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/IncludeObject.java Mon Nov 17 07:26:06 2008
@@ -238,9 +238,7 @@
         os.write(data);
 
         // Write triplet for FQN internal/external object reference
-        if (tripletData != null) {
-            os.write(tripletData);
-        }
+        writeTriplets(os);
     }
 
     private String getObjectTypeName() {



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