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/20 17:38:47 UTC

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

Author: acumiskey
Date: Thu Nov 20 08:38:44 2008
New Revision: 719274

URL: http://svn.apache.org/viewvc?rev=719274&view=rev
Log:
SetCurrentPosition fix for line drawing.
AbstractPaintingState push(), pushAll(), pop(), popAll() renamed to save(), saveAll() and restore(), restoreAll().
Some Javadoc improvements/updates.
Added Completable, Startable object writing interfaces.
StructuredDataObject interface renamed to StructuredData.
High level DataStream class moved from afp.modca to afp package.
Graphics*Relative objects removed and feature provided by absolute implementation.
GraphicsArea broken into GraphicsAreaBegin and GraphicsAreaEnd since areas are able to span more than one segment.
Improvement in SetLineWidth thickness precision.

Added:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/BorderPaintingInfo.java
      - copied, changed from r718594, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/BorderPaintInfo.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Completable.java   (with props)
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/DataStream.java
      - copied, changed from r718594, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/DataStream.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/PaintingInfo.java
      - copied, changed from r718594, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/PaintInfo.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/RectanglePaintingInfo.java
      - copied, changed from r718594, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/RectanglePaintInfo.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Startable.java   (with props)
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/StructuredData.java
      - copied, changed from r718594, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/StructuredDataObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrder.java   (with props)
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java
      - copied, changed from r718594, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsObjectContainer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsAreaBegin.java   (with props)
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsAreaEnd.java   (with props)
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java
      - copied, changed from r718594, 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/svg/package.html
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/util/package.html
Removed:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/BorderPaintInfo.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/PaintInfo.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/RectanglePaintInfo.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsObjectContainer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsString.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/GraphicsFilletRelative.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/GraphicsString.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsStringRelative.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/DataStream.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/StructuredDataObject.java
Modified:
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPBorderPainter.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPDataObjectFactory.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPGraphics2D.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPPaintingState.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPRectanglePainter.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPResourceManager.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPStreamer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPUnitConverter.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AbstractAFPPainter.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Factory.java
    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/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/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/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/ioca/ImageCellPosition.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/ioca/ImageInputDescriptor.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/ioca/ImageOutputControl.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/ioca/ImageRasterData.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/AbstractDataObject.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/AbstractPageObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractResourceGroupContainer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/AbstractTripletStructuredObject.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/Document.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/MapCodedFont.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/ObjectEnvironmentGroup.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/PageGroup.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/ResourceEnvironmentGroup.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/StreamedResourceGroup.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/AbstractTriplet.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/triplets/DescriptorPositionTriplet.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/afp/svg/AFPBridgeContext.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/svg/AFPImageElementBridge.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/pdf/PDFPaintingState.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPInfo.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFRenderer.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/svg/AbstractFOPBridgeContext.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/svg/PDFGraphics2D.java
    xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/util/AbstractPaintingState.java

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPBorderPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPBorderPainter.java?rev=719274&r1=719273&r2=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPBorderPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPBorderPainter.java Thu Nov 20 08:38:44 2008
@@ -21,7 +21,6 @@
 
 import java.awt.geom.AffineTransform;
 
-import org.apache.fop.afp.modca.DataStream;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.util.ColorUtil;
 
@@ -33,16 +32,16 @@
     /**
      * Main constructor
      *
-     * @param state the AFP painting state converter
+     * @param paintingState the AFP painting state converter
      * @param dataStream the AFP datastream
      */
-    public AFPBorderPainter(AFPPaintingState state, DataStream dataStream) {
-        super(state, dataStream);
+    public AFPBorderPainter(AFPPaintingState paintingState, DataStream dataStream) {
+        super(paintingState, dataStream);
     }
 
     /** {@inheritDoc} */
-    public void paint(PaintInfo paintInfo) {
-        BorderPaintInfo borderPaintInfo = (BorderPaintInfo)paintInfo;
+    public void paint(PaintingInfo paintInfo) {
+        BorderPaintingInfo borderPaintInfo = (BorderPaintingInfo)paintInfo;
         float w = borderPaintInfo.getX2() - borderPaintInfo.getX1();
         float h = borderPaintInfo.getY2() - borderPaintInfo.getY1();
         if ((w < 0) || (h < 0)) {
@@ -52,15 +51,15 @@
 
         int pageWidth = dataStream.getCurrentPage().getWidth();
         int pageHeight = dataStream.getCurrentPage().getHeight();
-        AFPUnitConverter unitConv = state.getUnitConverter();
-        AffineTransform at = state.getData().getTransform();
+        AFPUnitConverter unitConv = paintingState.getUnitConverter();
+        AffineTransform at = paintingState.getData().getTransform();
 
         float x1 = unitConv.pt2units(borderPaintInfo.getX1());
         float y1 = unitConv.pt2units(borderPaintInfo.getY1());
         float x2 = unitConv.pt2units(borderPaintInfo.getX2());
         float y2 = unitConv.pt2units(borderPaintInfo.getY2());
 
-        switch (state.getRotation()) {
+        switch (paintingState.getRotation()) {
         case 0:
             x1 += at.getTranslateX();
             y1 += at.getTranslateY();
@@ -89,7 +88,7 @@
 
         AFPLineDataInfo lineDataInfo = new AFPLineDataInfo();
         lineDataInfo.setColor(borderPaintInfo.getColor());
-        lineDataInfo.setRotation(state.getRotation());
+        lineDataInfo.setRotation(paintingState.getRotation());
         lineDataInfo.x1 = Math.round(x1);
         lineDataInfo.y1 = Math.round(y1);
         if (borderPaintInfo.isHorizontal()) {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPDataObjectFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPDataObjectFactory.java?rev=719274&r1=719273&r2=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPDataObjectFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPDataObjectFactory.java Thu Nov 20 08:38:44 2008
@@ -132,8 +132,11 @@
         Rectangle2D area = graphicsObjectInfo.getArea();
         g2d.scale(1, -1);
         g2d.translate(0, -area.getHeight());
+
         painter.paint(g2d, area);
 
+        graphicsObj.setComplete(true);
+
         // return painted graphics object
         return graphicsObj;
     }

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=719274&r1=719273&r2=719274&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 Thu Nov 20 08:38:44 2008
@@ -28,9 +28,11 @@
 import java.awt.Graphics;
 import java.awt.GraphicsConfiguration;
 import java.awt.Image;
+import java.awt.Paint;
 import java.awt.Rectangle;
 import java.awt.Shape;
 import java.awt.Stroke;
+import java.awt.TexturePaint;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Ellipse2D;
 import java.awt.geom.Line2D;
@@ -83,6 +85,9 @@
 
     private static final int Y2 = 3;
 
+    private static final int X3 = 4;
+
+    private static final int Y3 = 5;
 
     /** graphics object */
     private GraphicsObject graphicsObj = null;
@@ -188,7 +193,7 @@
 
             // set line width
             float lineWidth = basicStroke.getLineWidth();
-            getGraphicsObject().setLineWidth(Math.round(lineWidth * 2));
+            graphicsObj.setLineWidth(Math.round(lineWidth / 2));
 
             // set line type/style (note: this is an approximation at best!)
             float[] dashArray = basicStroke.getDashArray();
@@ -219,7 +224,7 @@
                         }
                     }
                 }
-                getGraphicsObject().setLineType(type);
+                graphicsObj.setLineType(type);
             }
         } else {
             log.warn("Unsupported Stroke: " + stroke.getClass().getName());
@@ -227,6 +232,33 @@
     }
 
     /**
+     * Apply the java paint to the AFP.
+     * This takes the java paint sets up the appropriate AFP commands
+     * for the drawing with that paint.
+     * Currently this supports the gradients and patterns from batik.
+     *
+     * @param paint the paint to convert to AFP
+     * @param fill true if the paint should be set for filling
+     * @return true if the paint is handled natively, false if the paint should be rasterized
+     */
+    private boolean applyPaint(Paint paint, boolean fill) {
+        if (paint instanceof Color) {
+            return true;
+        }
+        log.debug("NYI: applyPaint() " + paint + " fill=" + fill);
+        if (paint instanceof TexturePaint) {
+//            TexturePaint texturePaint = (TexturePaint)paint;
+//            BufferedImage bufferedImage = texturePaint.getImage();
+//            AffineTransform at = paintingState.getTransform();
+//            int x = (int)Math.round(at.getTranslateX());
+//            int y = (int)Math.round(at.getTranslateY());
+//            drawImage(bufferedImage, x, y, null);
+        }
+        return false;
+    }
+
+
+    /**
      * Handle the Batik drawing event
      *
      * @param shape
@@ -239,25 +271,22 @@
             graphicsObj.newSegment();
         }
 
-        Color color = getColor();
-        if (paintingState.setColor(color)) {
-            graphicsObj.setColor(color);
-        }
+        graphicsObj.setColor(gc.getColor());
 
-        Stroke stroke = getStroke();
-        applyStroke(stroke);
+        applyPaint(gc.getPaint(), fill);
 
         if (fill) {
             graphicsObj.beginArea();
+        } else {
+            applyStroke(gc.getStroke());
         }
 
         AffineTransform trans = gc.getTransform();
         PathIterator iter = shape.getPathIterator(trans);
-        double[] dstPts = new double[6];
-        int[] coords = null;
         if (shape instanceof Line2D) {
+            double[] dstPts = new double[6];
             iter.currentSegment(dstPts);
-            coords = new int[4];
+            int[] coords = new int[4];
             coords[X1] = (int) Math.round(dstPts[X]);
             coords[Y1] = (int) Math.round(dstPts[Y]);
             iter.next();
@@ -266,8 +295,9 @@
             coords[Y2] = (int) Math.round(dstPts[Y]);
             graphicsObj.addLine(coords);
         } else if (shape instanceof Rectangle2D) {
+            double[] dstPts = new double[6];
             iter.currentSegment(dstPts);
-            coords = new int[4];
+            int[] coords = new int[4];
             coords[X2] = (int) Math.round(dstPts[X]);
             coords[Y2] = (int) Math.round(dstPts[Y]);
             iter.next();
@@ -277,6 +307,7 @@
             coords[Y1] = (int) Math.round(dstPts[Y]);
             graphicsObj.addBox(coords);
         } else if (shape instanceof Ellipse2D) {
+            double[] dstPts = new double[6];
             Ellipse2D elip = (Ellipse2D) shape;
             double scale = trans.getScaleX();
             double radiusWidth = elip.getWidth() / 2;
@@ -298,56 +329,73 @@
                     mhr
             );
         } else {
-            for (int[] openingCoords = new int[2]; !iter.isDone(); iter.next()) {
-                int type = iter.currentSegment(dstPts);
-                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 {
-                    // close of the graphics segment
-                    if (type == PathIterator.SEG_CLOSE) {
-                        // close segment by drawing to opening position
-                        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]);
-                }
-                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);
-                }
-            }
+            processPathIterator(iter);
         }
+
         if (fill) {
             graphicsObj.endArea();
         }
     }
 
+    /**
+     * Processes a path iterator generating the necessary painting operations.
+     *
+     * @param iter PathIterator to process
+     */
+    private void processPathIterator(PathIterator iter) {
+        double[] dstPts = new double[6];
+        for (int[] openingCoords = new int[2]; !iter.isDone(); iter.next()) {
+            switch (iter.currentSegment(dstPts)) {
+            case PathIterator.SEG_LINETO:
+                graphicsObj.addLine(new int[] {
+                        (int)Math.round(dstPts[X]),
+                        (int)Math.round(dstPts[Y])
+                     }, true);
+                break;
+            case PathIterator.SEG_QUADTO:
+                graphicsObj.addFillet(new int[] {
+                        (int)Math.round(dstPts[X1]),
+                        (int)Math.round(dstPts[Y1]),
+                        (int)Math.round(dstPts[X2]),
+                        (int)Math.round(dstPts[Y2])
+                     }, true);
+                break;
+            case PathIterator.SEG_CUBICTO:
+                graphicsObj.addFillet(new int[] {
+                        (int)Math.round(dstPts[X1]),
+                        (int)Math.round(dstPts[Y1]),
+                        (int)Math.round(dstPts[X2]),
+                        (int)Math.round(dstPts[Y2]),
+                        (int)Math.round(dstPts[X3]),
+                        (int)Math.round(dstPts[Y3])
+                     }, true);
+                break;
+            case PathIterator.SEG_MOVETO:
+                openingCoords = new int[] {
+                        (int)Math.round(dstPts[X]),
+                        (int)Math.round(dstPts[Y])
+                };
+                graphicsObj.setCurrentPosition(openingCoords);
+                break;
+            case PathIterator.SEG_CLOSE:
+                graphicsObj.addLine(openingCoords, true);
+                break;
+            default:
+                log.debug("Unrecognised path iterator type");
+                break;
+            }
+        }
+    }
+
     /** {@inheritDoc} */
     public void draw(Shape shape) {
-//        log.debug("draw() shape=" + shape);
+        log.debug("draw() shape=" + shape);
         doDrawing(shape, false);
     }
 
     /** {@inheritDoc} */
     public void fill(Shape shape) {
-//        log.debug("fill() shape=" + shape);
+        log.debug("fill() shape=" + shape);
         doDrawing(shape, true);
     }
 
@@ -382,11 +430,6 @@
     }
 
     /** {@inheritDoc} */
-    public void copyArea(int x, int y, int width, int height, int dx, int dy) {
-        log.debug("copyArea() NYI: ");
-    }
-
-    /** {@inheritDoc} */
     public Graphics create() {
         return new AFPGraphics2D(this);
     }
@@ -643,4 +686,9 @@
         log.debug("NYI: addNativeImage() "+ "image=" + image
                 + ",x=" + x + ",y=" + y + ",width=" + width + ",height=" + height);
     }
+
+    /** {@inheritDoc} */
+    public void copyArea(int x, int y, int width, int height, int dx, int dy) {
+        log.debug("copyArea() NYI: ");
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPPaintingState.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPPaintingState.java?rev=719274&r1=719273&r2=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPPaintingState.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPPaintingState.java Thu Nov 20 08:38:44 2008
@@ -27,7 +27,8 @@
 /**
  * This keeps information about the current painting state when writing to an AFP datastream.
  */
-public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState  implements Cloneable {
+public class AFPPaintingState extends org.apache.fop.util.AbstractPaintingState
+implements Cloneable {
 
     private static final long serialVersionUID = 8206711712452344473L;
 
@@ -337,14 +338,14 @@
 
     /** {@inheritDoc} */
     public Object clone() {
-        AFPPaintingState state = (AFPPaintingState)super.clone();
-        state.pagePaintingState = (AFPPagePaintingState)this.pagePaintingState.clone();
-        state.portraitRotation = this.portraitRotation;
-        state.landscapeRotation = this.landscapeRotation;
-        state.bitsPerPixel = this.bitsPerPixel;
-        state.colorImages = this.colorImages;
-        state.resolution = this.resolution;
-        return state;
+        AFPPaintingState paintingState = (AFPPaintingState)super.clone();
+        paintingState.pagePaintingState = (AFPPagePaintingState)this.pagePaintingState.clone();
+        paintingState.portraitRotation = this.portraitRotation;
+        paintingState.landscapeRotation = this.landscapeRotation;
+        paintingState.bitsPerPixel = this.bitsPerPixel;
+        paintingState.colorImages = this.colorImages;
+        paintingState.resolution = this.resolution;
+        return paintingState;
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPRectanglePainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPRectanglePainter.java?rev=719274&r1=719273&r2=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPRectanglePainter.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPRectanglePainter.java Thu Nov 20 08:38:44 2008
@@ -21,37 +21,39 @@
 
 import java.awt.geom.AffineTransform;
 
-import org.apache.fop.afp.modca.DataStream;
 
+/**
+ * A painter of rectangles in AFP
+ */
 public class AFPRectanglePainter extends AbstractAFPPainter {
 
     /**
      * Main constructor
      *
-     * @param state the AFP painting state
-     * @param dataStream the afp datastream
+     * @param paintingState the AFP painting state
+     * @param dataStream the AFP datastream
      */
-    public AFPRectanglePainter(AFPPaintingState state, DataStream dataStream) {
-        super(state, dataStream);
+    public AFPRectanglePainter(AFPPaintingState paintingState, DataStream dataStream) {
+        super(paintingState, dataStream);
     }
 
     /** {@inheritDoc} */
-    public void paint(PaintInfo paintInfo) {
-        RectanglePaintInfo rectanglePaintInfo = (RectanglePaintInfo)paintInfo;
+    public void paint(PaintingInfo paintInfo) {
+        RectanglePaintingInfo rectanglePaintInfo = (RectanglePaintingInfo)paintInfo;
         int pageWidth = dataStream.getCurrentPage().getWidth();
         int pageHeight = dataStream.getCurrentPage().getHeight();
 
-        AFPUnitConverter unitConv = state.getUnitConverter();
+        AFPUnitConverter unitConv = paintingState.getUnitConverter();
         float width = unitConv.pt2units(rectanglePaintInfo.getWidth());
         float height = unitConv.pt2units(rectanglePaintInfo.getHeight());
         float x = unitConv.pt2units(rectanglePaintInfo.getX());
         float y = unitConv.pt2units(rectanglePaintInfo.getY());
 
-        AffineTransform at = state.getData().getTransform();
+        AffineTransform at = paintingState.getData().getTransform();
 
         AFPLineDataInfo lineDataInfo = new AFPLineDataInfo();
-        lineDataInfo.color = state.getColor();
-        lineDataInfo.rotation = state.getRotation();
+        lineDataInfo.color = paintingState.getColor();
+        lineDataInfo.rotation = paintingState.getRotation();
         lineDataInfo.thickness = Math.round(height);
 
         switch (lineDataInfo.rotation) {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPResourceManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPResourceManager.java?rev=719274&r1=719273&r2=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPResourceManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPResourceManager.java Thu Nov 20 08:38:44 2008
@@ -25,7 +25,6 @@
 
 import org.apache.fop.afp.modca.AbstractDataObject;
 import org.apache.fop.afp.modca.AbstractNamedAFPObject;
-import org.apache.fop.afp.modca.DataStream;
 import org.apache.fop.afp.modca.IncludeObject;
 import org.apache.fop.afp.modca.Registry;
 import org.apache.fop.afp.modca.ResourceGroup;

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPStreamer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPStreamer.java?rev=719274&r1=719273&r2=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPStreamer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPStreamer.java Thu Nov 20 08:38:44 2008
@@ -31,7 +31,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.fop.afp.modca.DataStream;
 import org.apache.fop.afp.modca.ResourceGroup;
 import org.apache.fop.afp.modca.StreamedResourceGroup;
 

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPUnitConverter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPUnitConverter.java?rev=719274&r1=719273&r2=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPUnitConverter.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AFPUnitConverter.java Thu Nov 20 08:38:44 2008
@@ -29,15 +29,15 @@
 public class AFPUnitConverter {
 
     /** the AFP state */
-    private final AFPPaintingState state;
+    private final AFPPaintingState paintingState;
 
     /**
      * Unit converter
      *
-     * @param state the AFP painting state
+     * @param paintingState the AFP painting state
      */
-    public AFPUnitConverter(AFPPaintingState state) {
-        this.state = state;
+    public AFPUnitConverter(AFPPaintingState paintingState) {
+        this.paintingState = paintingState;
     }
 
     /**
@@ -89,7 +89,7 @@
      * @return transformed point
      */
     public float pt2units(float pt) {
-        return pt / ((float)AFPConstants.DPI_72 / state.getResolution());
+        return pt / ((float)AFPConstants.DPI_72 / paintingState.getResolution());
     }
 
     /**
@@ -99,14 +99,14 @@
      * @return transformed point
      */
     public float mpt2units(float mpt) {
-        return mpt / ((float)AFPConstants.DPI_72_MPTS / state.getResolution());
+        return mpt / ((float)AFPConstants.DPI_72_MPTS / paintingState.getResolution());
     }
 
     private int[] transformPoints(float[] srcPts, float[] dstPts, boolean milli) {
         if (dstPts == null) {
             dstPts = new float[srcPts.length];
         }
-        AffineTransform at = state.getData().getTransform();
+        AffineTransform at = paintingState.getData().getTransform();
         at.transform(srcPts, 0, dstPts, 0, srcPts.length / 2);
         int[] coords = new int[srcPts.length];
         for (int i = 0; i < srcPts.length; i++) {

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AbstractAFPPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AbstractAFPPainter.java?rev=719274&r1=719273&r2=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AbstractAFPPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/AbstractAFPPainter.java Thu Nov 20 08:38:44 2008
@@ -21,24 +21,26 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.fop.afp.modca.DataStream;
 
+/**
+ * A base AFP painter
+ */
 public abstract class AbstractAFPPainter {
 
     /** Static logging instance */
     protected static Log log = LogFactory.getLog("org.apache.xmlgraphics.afp");
 
     protected final DataStream dataStream;
-    protected final AFPPaintingState state;
+    protected final AFPPaintingState paintingState;
 
     /**
      * Main constructor
      *
-     * @param state the afp state
-     * @param dataStream the afp datastream
+     * @param paintingState the AFP painting state
+     * @param dataStream the AFP Datastream
      */
-    public AbstractAFPPainter(AFPPaintingState state, DataStream dataStream) {
-        this.state = state;
+    public AbstractAFPPainter(AFPPaintingState paintingState, DataStream dataStream) {
+        this.paintingState = paintingState;
         this.dataStream = dataStream;
     }
 
@@ -47,5 +49,5 @@
      *
      * @param paintInfo the painting information
      */
-    public abstract void paint(PaintInfo paintInfo);
+    public abstract void paint(PaintingInfo paintInfo);
 }

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/BorderPaintingInfo.java (from r718594, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/BorderPaintInfo.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/BorderPaintingInfo.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/BorderPaintingInfo.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/BorderPaintInfo.java&r1=718594&r2=719274&rev=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/BorderPaintInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/BorderPaintingInfo.java Thu Nov 20 08:38:44 2008
@@ -21,11 +21,11 @@
 
 import java.awt.Color;
 
-
 /**
  * Border painting information
  */
-public class BorderPaintInfo implements PaintInfo {
+public class BorderPaintingInfo implements PaintingInfo {
+
     private final float x1;
     private final float y1;
     private final float x2;
@@ -45,7 +45,7 @@
      * @param style the border style
      * @param color the border color
      */
-    public BorderPaintInfo(float x1, float y1, float x2, float y2,
+    public BorderPaintingInfo(float x1, float y1, float x2, float y2,
             boolean isHorizontal, int style, Color color) {
         this.x1 = x1;
         this.y1 = y1;

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Completable.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Completable.java?rev=719274&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Completable.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Completable.java Thu Nov 20 08:38:44 2008
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+/**
+ * Set and expose the internal completeness of an object.
+ */
+public interface Completable {
+
+    /**
+     * Sets whether or not this object is complete or not
+     *
+     * @param complete true if this object is complete
+     */
+    void setComplete(boolean complete);
+
+    /**
+     * Returns true if this object is complete
+     *
+     * @return true if this object is complete
+     */
+    boolean isComplete();
+}

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

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

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/DataStream.java (from r718594, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/DataStream.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/DataStream.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/DataStream.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/DataStream.java&r1=718594&r2=719274&rev=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/DataStream.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/DataStream.java Thu Nov 20 08:38:44 2008
@@ -17,7 +17,7 @@
 
 /* $Id$ */
 
-package org.apache.fop.afp.modca;
+package org.apache.fop.afp;
 
 import java.awt.Color;
 import java.awt.Point;
@@ -28,13 +28,16 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.fop.afp.AFPLineDataInfo;
-import org.apache.fop.afp.AFPPaintingState;
-import org.apache.fop.afp.AFPResourceLevel;
-import org.apache.fop.afp.AFPTextDataInfo;
-import org.apache.fop.afp.Factory;
 import org.apache.fop.afp.fonts.AFPFont;
 import org.apache.fop.afp.fonts.AFPFontAttributes;
+import org.apache.fop.afp.modca.AbstractPageObject;
+import org.apache.fop.afp.modca.Document;
+import org.apache.fop.afp.modca.InterchangeSet;
+import org.apache.fop.afp.modca.Overlay;
+import org.apache.fop.afp.modca.PageGroup;
+import org.apache.fop.afp.modca.PageObject;
+import org.apache.fop.afp.modca.ResourceGroup;
+import org.apache.fop.afp.modca.TagLogicalElementBean;
 import org.apache.fop.afp.modca.triplets.FullyQualifiedNameTriplet;
 
 /**
@@ -55,7 +58,7 @@
 public class DataStream {
 
     /** Static logging instance */
-    protected static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp.modca");
+    protected static final Log log = LogFactory.getLog("org.apache.xmlgraphics.afp");
 
     /** Boolean completion indicator */
     private boolean complete = false;
@@ -84,17 +87,17 @@
     private OutputStream outputStream;
 
     /** the afp painting state */
-    private final AFPPaintingState state;
+    private final AFPPaintingState paintingState;
 
     /**
      * Default constructor for the AFPDocumentStream.
      *
      * @param factory the resource factory
-     * @param state the AFP painting state
+     * @param paintingState the AFP painting state
      * @param outputStream the outputstream to write to
      */
-    public DataStream(Factory factory, AFPPaintingState state, OutputStream outputStream) {
-        this.state = state;
+    public DataStream(Factory factory, AFPPaintingState paintingState, OutputStream outputStream) {
+        this.paintingState = paintingState;
         this.factory = factory;
         this.outputStream = outputStream;
     }
@@ -141,7 +144,11 @@
         }
     }
 
-    /** {@inheritDoc} */
+    /**
+     * Helper method to mark the end of the current document.
+     *
+     * @throws IOException thrown if an I/O exception of some sort has occurred
+     */
     public void endDocument() throws IOException {
         if (complete) {
             String msg = "Invalid state - document already ended.";
@@ -329,7 +336,7 @@
      */
     private Point getPoint(int x, int y) {
         Point p = new Point();
-        int rotation = state.getRotation();
+        int rotation = paintingState.getRotation();
         switch (rotation) {
         case 90:
             p.x = y;
@@ -359,7 +366,7 @@
      *            the afp text data
      */
     public void createText(AFPTextDataInfo textDataInfo) {
-        int rotation = state.getRotation();
+        int rotation = paintingState.getRotation();
         if (rotation != 0) {
             textDataInfo.setRotation(rotation);
             Point p = getPoint(textDataInfo.getX(), textDataInfo.getY());
@@ -406,7 +413,7 @@
      *            the name of the static overlay
      */
     public void createIncludePageOverlay(String name) {
-        currentPageObject.createIncludePageOverlay(name, 0, 0, state.getRotation());
+        currentPageObject.createIncludePageOverlay(name, 0, 0, paintingState.getRotation());
         currentPageObject.getActiveEnvironmentGroup().createOverlay(name);
     }
 
@@ -433,7 +440,7 @@
     public void createIncludePageSegment(String name, int x, int y) {
         int xOrigin;
         int yOrigin;
-        int orientation = state.getRotation();
+        int orientation = paintingState.getRotation();
         switch (orientation) {
         case 90:
             xOrigin = currentPage.getWidth() - y;

Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Factory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Factory.java?rev=719274&r1=719273&r2=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Factory.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Factory.java Thu Nov 20 08:38:44 2008
@@ -30,7 +30,6 @@
 import org.apache.fop.afp.ioca.ImageSizeParameter;
 import org.apache.fop.afp.modca.ActiveEnvironmentGroup;
 import org.apache.fop.afp.modca.ContainerDataDescriptor;
-import org.apache.fop.afp.modca.DataStream;
 import org.apache.fop.afp.modca.Document;
 import org.apache.fop.afp.modca.GraphicsDataDescriptor;
 import org.apache.fop.afp.modca.GraphicsObject;
@@ -62,7 +61,7 @@
 import org.apache.fop.afp.util.StringUtils;
 
 /**
- * Creator of MO:DCA data objects (mostly)
+ * Creator of MO:DCA structured field objects
  */
 public class Factory {
 
@@ -392,12 +391,12 @@
     /**
      * Creates a new {@link DataStream}
      *
-     * @param state the AFP painting state
+     * @param paintingState the AFP painting state
      * @param outputStream an outputstream to write to
      * @return a new {@link DataStream}
      */
-    public DataStream createDataStream(AFPPaintingState state, OutputStream outputStream) {
-        DataStream dataStream = new DataStream(this, state, outputStream);
+    public DataStream createDataStream(AFPPaintingState paintingState, OutputStream outputStream) {
+        DataStream dataStream = new DataStream(this, paintingState, outputStream);
         return dataStream;
     }
 

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/PaintingInfo.java (from r718594, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/PaintInfo.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/PaintingInfo.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/PaintingInfo.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/PaintInfo.java&r1=718594&r2=719274&rev=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/PaintInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/PaintingInfo.java Thu Nov 20 08:38:44 2008
@@ -22,6 +22,6 @@
 /**
  * Generic painting information interface
  */
-public interface PaintInfo {
+public interface PaintingInfo {
 
 }

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/RectanglePaintingInfo.java (from r718594, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/RectanglePaintInfo.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/RectanglePaintingInfo.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/RectanglePaintingInfo.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/RectanglePaintInfo.java&r1=718594&r2=719274&rev=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/RectanglePaintInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/RectanglePaintingInfo.java Thu Nov 20 08:38:44 2008
@@ -23,7 +23,7 @@
 /**
  * Filled rectangle painting information
  */
-public class RectanglePaintInfo implements PaintInfo {
+public class RectanglePaintingInfo implements PaintingInfo {
 
     private final float x;
     private final float y;
@@ -38,7 +38,7 @@
      * @param width the width
      * @param height the height
      */
-    public RectanglePaintInfo(float x, float y, float width, float height) {
+    public RectanglePaintingInfo(float x, float y, float width, float height) {
         this.x = x;
         this.y = y;
         this.width = width;

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Startable.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Startable.java?rev=719274&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Startable.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/Startable.java Thu Nov 20 08:38:44 2008
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+/**
+ * Set and expose whether an object has started or not.
+ */
+public interface Startable {
+
+    /**
+     * Sets whether or not this object has started or not
+     *
+     * @param complete true if this object has started
+     */
+    void setStarted(boolean started);
+
+    /**
+     * Returns true if this object has started
+     *
+     * @return true if this object has started
+     */
+    boolean isStarted();
+}

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

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

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/StructuredData.java (from r718594, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/StructuredDataObject.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/StructuredData.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/StructuredData.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/StructuredDataObject.java&r1=718594&r2=719274&rev=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/modca/StructuredDataObject.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/StructuredData.java Thu Nov 20 08:38:44 2008
@@ -17,12 +17,12 @@
 
 /* $Id$ */
 
-package org.apache.fop.afp.modca;
+package org.apache.fop.afp;
 
 /**
- * An AFP object which is able to know its own data length before writeToStream()
+ * An AFP object which is able to know its own data length prior to writeToStream()
  */
-public interface StructuredDataObject {
+public interface StructuredData {
 
     /**
      * Returns the data length of this structured field

Modified: 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?rev=719274&r1=719273&r2=719274&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 Thu Nov 20 08:38:44 2008
@@ -22,26 +22,40 @@
 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 AbstractNamedAFPObject
-    implements StructuredDataObject {
+public abstract class AbstractGraphicsCoord extends AbstractGraphicsDrawingOrder {
 
     /** array of x/y coordinates */
     protected int[] coords = null;
 
+    protected boolean relative = false;
+
     /**
      * Constructor
      *
      * @param coords the x/y coordinates for this object
      */
     public AbstractGraphicsCoord(int[] coords) {
-        this.coords = coords;
+        if (coords == null) {
+            relative = true;
+        } else {
+            this.coords = coords;
+        }
+    }
+
+    /**
+     * Constructor
+     *
+     * @param coords the x/y coordinates for this object
+     * @param relative
+     */
+    public AbstractGraphicsCoord(int[] coords, boolean relative) {
+        this(coords);
+        this.relative = relative;
     }
 
     /**
@@ -68,17 +82,10 @@
 
     /** {@inheritDoc} */
     public int getDataLength() {
-        return 2 + (coords.length * 2);
+        return 2 + (coords != null ? coords.length * 2 : 0);
     }
 
     /**
-     * Returns the order code of this structured field
-     *
-     * @return the order code of this structured field
-     */
-    abstract byte getOrderCode();
-
-    /**
      * Returns the coordinate data start index
      *
      * @return the coordinate data start index
@@ -93,15 +100,10 @@
      * @return the coordinate data
      */
     byte[] getData() {
-        int len = getDataLength();
-        byte[] data = new byte[len];
-        data[0] = getOrderCode();
-        data[1] = (byte)(len - 2);
-
+        byte[] data = super.getData();
         if (coords != null) {
             addCoords(data, getCoordinateDataStartIndex());
         }
-
         return data;
     }
 
@@ -125,16 +127,6 @@
         }
     }
 
-    /**
-     * Returns the short name of this GOCA object
-     *
-     * @return the short name of this GOCA object
-     */
-    public String getName() {
-        String className = getClass().getName();
-        return className.substring(className.lastIndexOf(".") + 1);
-    }
-
     /** {@inheritDoc} */
     public String toString() {
         String coordsStr = "";
@@ -145,4 +137,13 @@
         coordsStr = coordsStr.substring(0, coordsStr.length() - 1);
         return getName() + "{" + coordsStr + "}";
     }
+
+    /**
+     * Returns true if this is a relative drawing order
+     *
+     * @return true if this is a relative drawing order
+     */
+    protected boolean isRelative() {
+        return this.relative;
+    }
 }
\ No newline at end of file

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrder.java?rev=719274&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrder.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrder.java Thu Nov 20 08:38:44 2008
@@ -0,0 +1,60 @@
+/*
+ * 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 org.apache.fop.afp.StructuredData;
+import org.apache.fop.afp.modca.AbstractAFPObject;
+
+/**
+ * A base GOCA drawing order
+ */
+public abstract class AbstractGraphicsDrawingOrder extends AbstractAFPObject
+    implements StructuredData {
+
+    /**
+     * Returns the order code of this structured field
+     *
+     * @return the order code of this structured field
+     */
+    abstract byte getOrderCode();
+
+    /**
+     * Returns the coordinate data
+     *
+     * @return the coordinate data
+     */
+    byte[] getData() {
+        int len = getDataLength();
+        byte[] data = new byte[len];
+        data[0] = getOrderCode();
+        data[1] = (byte)(len - 2);
+        return data;
+    }
+
+    /**
+     * Returns the short name of this GOCA object
+     *
+     * @return the short name of this GOCA object
+     */
+    public String getName() {
+        String className = getClass().getName();
+        return className.substring(className.lastIndexOf(".") + 1);
+    }
+}

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

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

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java (from r718594, xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsObjectContainer.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsObjectContainer.java&r1=718594&r2=719274&rev=719274&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsObjectContainer.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java Thu Nov 20 08:38:44 2008
@@ -21,26 +21,35 @@
 
 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.Completable;
+import org.apache.fop.afp.Startable;
+import org.apache.fop.afp.StructuredData;
 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 AbstractGraphicsObjectContainer extends AbstractNamedAFPObject
-implements StructuredDataObject {
+public abstract class AbstractGraphicsDrawingOrderContainer extends AbstractNamedAFPObject
+implements StructuredData, Completable, Startable {
 
     /** list of objects contained within this container */
     protected List/*<StructuredDataObject>*/ objects
         = new java.util.ArrayList/*<StructuredDataObject>*/();
 
+    /** object is complete */
+    private boolean complete = false;
+
+    /** object has started */
+    private boolean started = false;
+
     /**
      * Default constructor
      */
-    protected AbstractGraphicsObjectContainer() {
+    protected AbstractGraphicsDrawingOrderContainer() {
     }
 
     /**
@@ -48,11 +57,16 @@
      *
      * @param name the name of the container
      */
-    protected AbstractGraphicsObjectContainer(String name) {
+    protected AbstractGraphicsDrawingOrderContainer(String name) {
         super(name);
     }
 
     /** {@inheritDoc} */
+    protected void writeStart(OutputStream os) throws IOException {
+        setStarted(true);
+    }
+
+    /** {@inheritDoc} */
     protected void writeContent(OutputStream os) throws IOException {
         writeObjects(objects, os);
     }
@@ -60,10 +74,44 @@
     /**
      * Adds a given graphics object to this container
      *
-     * @param drawingOrder the graphics object
+     * @param object the structured data object
+     */
+    public void addObject(StructuredData object) {
+        objects.add(object);
+    }
+
+    /**
+     * Adds all the contents of a given graphics container to this container
+     *
+     * @param graphicsContainer a graphics container
+     */
+    public void addAll(AbstractGraphicsDrawingOrderContainer graphicsContainer) {
+        Collection/*<StructuredDataObject>*/ objects = graphicsContainer.getObjects();
+        objects.addAll(objects);
+    }
+
+    /**
+     * Returns all the objects in this container
+     *
+     * @return all the objects in this container
+     */
+    private Collection getObjects() {
+        return this.objects;
+    }
+
+    /**
+     * Removes the last drawing order from this container and returns it
+     *
+     * @return the last drawing order from this container or null if empty
      */
-    public void addObject(StructuredDataObject drawingOrder) {
-        objects.add(drawingOrder);
+    public StructuredData removeLast() {
+        int lastIndex = objects.size() - 1;
+        StructuredData object = null;
+        if (lastIndex > -1) {
+            object = (StructuredData)objects.get(lastIndex);
+            objects.remove(lastIndex);
+        }
+        return object;
     }
 
     /**
@@ -76,8 +124,35 @@
         int dataLen = 0;
         Iterator it = objects.iterator();
         while (it.hasNext()) {
-            dataLen += ((StructuredDataObject)it.next()).getDataLength();
+            dataLen += ((StructuredData)it.next()).getDataLength();
         }
         return dataLen;
     }
+
+    /** {@inheritDoc} */
+    public void setComplete(boolean complete) {
+        Iterator it = objects.iterator();
+        while (it.hasNext()) {
+            Object object = it.next();
+            if (object instanceof Completable) {
+                ((Completable)object).setComplete(true);
+            }
+        }
+        this.complete = true;
+    }
+
+    /** {@inheritDoc} */
+    public boolean isComplete() {
+        return this.complete;
+    }
+
+    /** {@inheritDoc} */
+    public boolean isStarted() {
+        return this.started;
+    }
+
+    /** {@inheritDoc} */
+    public void setStarted(boolean started) {
+        this.started = started;
+    }
 }

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsAreaBegin.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsAreaBegin.java?rev=719274&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsAreaBegin.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsAreaBegin.java Thu Nov 20 08:38:44 2008
@@ -0,0 +1,69 @@
+/*
+ * 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;
+
+/**
+ * The beginning of a filled region (graphics area).
+ */
+public class GraphicsAreaBegin extends AbstractGraphicsDrawingOrder {
+
+    private static final int RES1 = 1;
+    private static final int BOUNDARY = 2;
+    private static final int NO_BOUNDARY = 0;
+
+    /** draw boundary lines around this area */
+    private boolean drawBoundary = false;
+
+    /**
+     * Sets whether boundary lines are drawn
+     *
+     * @param drawBoundaryLines whether boundary lines are drawn
+     */
+    public void setDrawBoundaryLines(boolean drawBoundaryLines) {
+        this.drawBoundary = drawBoundaryLines;
+    }
+
+    /** {@inheritDoc} */
+    public void writeToStream(OutputStream os) throws IOException {
+        byte[] data = new byte[] {
+            getOrderCode(), // GBAR order code
+            (byte)(RES1 + (drawBoundary ? BOUNDARY : NO_BOUNDARY))
+        };
+        os.write(data);
+    }
+
+    /** {@inheritDoc} */
+    public int getDataLength() {
+        return 2;
+    }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return "GraphicsAreaBegin{drawBoundary=" + drawBoundary + "}";
+    }
+
+    /** {@inheritDoc} */
+    byte getOrderCode() {
+        return 0x68;
+    }
+}

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

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

Added: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsAreaEnd.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsAreaEnd.java?rev=719274&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsAreaEnd.java (added)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsAreaEnd.java Thu Nov 20 08:38:44 2008
@@ -0,0 +1,53 @@
+/*
+ * 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;
+
+/**
+ * The end of a filled region (graphics area).
+ */
+public class GraphicsAreaEnd extends AbstractGraphicsDrawingOrder {
+
+    /** {@inheritDoc} */
+    public void writeToStream(OutputStream os) throws IOException {
+        byte[] data = new byte[] {
+            getOrderCode(), // GEAR order code
+            0x00, // LENGTH
+        };
+        os.write(data);
+    }
+
+    /** {@inheritDoc} */
+    public int getDataLength() {
+        return 2;
+    }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return "GraphicsAreaEnd";
+    }
+
+    /** {@inheritDoc} */
+    byte getOrderCode() {
+        return 0x60;
+    }
+}

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

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

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=719274&r1=719273&r2=719274&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 Thu Nov 20 08:38:44 2008
@@ -22,25 +22,17 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.afp.modca.StructuredDataObject;
 import org.apache.fop.afp.util.BinaryUtils;
 
 /**
  * A GOCA graphics segment
  */
-public final class GraphicsChainedSegment extends AbstractGraphicsObjectContainer {
+public final class GraphicsChainedSegment extends AbstractGraphicsDrawingOrderContainer {
 
     /** The maximum segment data length */
     protected static final int MAX_DATA_LEN = 8192;
 
-    /** the current area */
-    private GraphicsArea currentArea = null;
-
-    /** the previous segment in the chain */
-    private GraphicsChainedSegment previous = null;
-
-    /** the next segment in the chain */
-    private GraphicsChainedSegment next = null;
+    private byte[] predecessorNameBytes;
 
     /**
      * Main constructor
@@ -57,13 +49,12 @@
      *
      * @param name
      *            the name of this graphics segment
-     * @param previous
-     *            the previous graphics segment in this chain
+     * @param predecessorNameBytes
+     *            the name of the predecessor in this chain
      */
-    public GraphicsChainedSegment(String name, GraphicsChainedSegment previous) {
+    public GraphicsChainedSegment(String name, byte[] predecessorNameBytes) {
         super(name);
-        previous.next = this;
-        this.previous = previous;
+        this.predecessorNameBytes = predecessorNameBytes;
     }
 
     /** {@inheritDoc} */
@@ -88,9 +79,7 @@
     }
 
     /** {@inheritDoc} */
-    protected void writeStart(OutputStream os) throws IOException {
-        super.writeStart(os);
-
+    public void writeToStream(OutputStream os) throws IOException {
         byte[] data = new byte[14];
         data[0] = getOrderCode(); // BEGIN_SEGMENT
         data[1] = 0x0C; // Length of following parameters
@@ -108,41 +97,12 @@
         data[9] = len[1];
 
         // P/S NAME (predecessor name)
-        if (previous != null) {
-            nameBytes = previous.getNameBytes();
-            System.arraycopy(nameBytes, 0, data, 10, NAME_LENGTH);
+        if (predecessorNameBytes != null) {
+            System.arraycopy(predecessorNameBytes, 0, data, 10, NAME_LENGTH);
         }
         os.write(data);
-    }
 
-    /** {@inheritDoc} */
-    protected void writeEnd(OutputStream os) throws IOException {
-        // I am the first segment in the chain so write out the rest
-        if (previous == null) {
-            for (GraphicsChainedSegment segment = next; segment != null; segment = segment.next) {
-                segment.writeToStream(os);
-            }
-        } // else nothing todo
-    }
-
-    /** Begins a graphics area (start of fill) */
-    protected void beginArea() {
-        this.currentArea = new GraphicsArea();
-        super.addObject(currentArea);
-    }
-
-    /** Ends a graphics area (end of fill) */
-    protected void endArea() {
-        this.currentArea = null;
-    }
-
-    /** {@inheritDoc} */
-    public void addObject(StructuredDataObject drawingOrder) {
-        if (currentArea != null) {
-            currentArea.addObject(drawingOrder);
-        } else {
-            super.addObject(drawingOrder);
-        }
+        writeObjects(objects, os);
     }
 
     /** {@inheritDoc} */

Copied: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java (from r718594, 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/GraphicsCharacterString.java?p2=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsCharacterString.java&p1=xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/afp/goca/GraphicsString.java&r1=718594&r2=719274&rev=719274&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/GraphicsCharacterString.java Thu Nov 20 08:38:44 2008
@@ -21,31 +21,57 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.fop.afp.AFPConstants;
 
 /**
  * A GOCA graphics string
  */
-public class GraphicsString extends AbstractGraphicsString {
+public class GraphicsCharacterString 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 (absolute positioning)
+     *
+     * @param str the character string
+     * @param x the x coordinate
+     * @param y the y coordinate
+     */
+    public GraphicsCharacterString(String str, int x, int y) {
+        super(x, y);
+        this.str = truncate(str);
+    }
 
     /**
-     * Constructor
+     * Constructor (relative positioning)
      *
      * @param str the character string
      * @param x the x coordinate
      * @param y the y coordinate
      */
-    public GraphicsString(String str, int x, int y) {
-        super(str, x, y);
+    public GraphicsCharacterString(String str) {
+        super(null);
+        this.str = truncate(str);
     }
 
     /** {@inheritDoc} */
     byte getOrderCode() {
-        return (byte)0xC3;
+        if (isRelative()) {
+            return (byte)0x83;
+        } else {
+            return (byte)0xC3;
+        }
     }
 
     /** {@inheritDoc} */
     public int getDataLength() {
-        return super.getDataLength() + (coords.length * 2);
+        return super.getDataLength() + str.length();
     }
 
     /** {@inheritDoc} */
@@ -53,12 +79,36 @@
         byte[] data = getData();
         byte[] strData = getStringAsBytes();
         System.arraycopy(strData, 0, data, 6, strData.length);
-
         os.write(data);
     }
 
+    /**
+     * Truncates the string as necessary
+     *
+     * @param str a character string
+     * @return a possibly truncated string
+     */
+    private String truncate(String str) {
+        if (str.length() > MAX_STR_LEN) {
+            str = str.substring(0, MAX_STR_LEN);
+            log.warn("truncated character string, longer than " + MAX_STR_LEN + " chars");
+        }
+        return str;
+    }
+
+    /**
+     * Returns the text string as an encoded byte array
+     *
+     * @return the text string as an encoded byte array
+     */
+    private byte[] getStringAsBytes() throws UnsupportedEncodingException {
+        return str.getBytes(AFPConstants.EBCIDIC_ENCODING);
+    }
+
     /** {@inheritDoc} */
     public String toString() {
-        return "GraphicsString{x=" + coords[0] + ", y=" + coords[1] + "str='" + str + "'" + "}";
+        return "GraphicsCharacterString{"
+            + (coords != null ? "x=" + coords[0] + ", y=" + coords[1] : "")
+            + "str='" + str + "'" + "}";
     }
 }
\ No newline at end of file

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=719274&r1=719273&r2=719274&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 Thu Nov 20 08:38:44 2008
@@ -22,38 +22,30 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.afp.modca.StructuredDataObject;
+import org.apache.fop.afp.StructuredData;
 import org.apache.fop.afp.util.BinaryUtils;
 import org.apache.fop.afp.util.StringUtils;
 
 /**
  * A GOCA graphics data
  */
-public final class GraphicsData extends AbstractGraphicsObjectContainer {
+public final class GraphicsData extends AbstractGraphicsDrawingOrderContainer {
 
-    /** The maximum graphics data length */
+    /** the maximum graphics data length */
     public static final int MAX_DATA_LEN = 32767;
 
-    /** The graphics segment */
-    private GraphicsChainedSegment segment = null;
-
-    /** {@inheritDoc} */
-    public int getDataLength() {
-        return 8 + super.getDataLength();
-    }
+    /** the graphics segment */
+    private GraphicsChainedSegment currentSegment = null;
 
     /**
-     * Begins a graphics area (start of fill)
+     * Main constructor
      */
-    public void beginArea() {
-        getSegment().beginArea();
+    public GraphicsData() {
     }
 
-    /**
-     * Ends a graphics area (end of fill)
-     */
-    public void endArea() {
-        getSegment().endArea();
+    /** {@inheritDoc} */
+    public int getDataLength() {
+        return 8 + super.getDataLength();
     }
 
     /**
@@ -61,48 +53,47 @@
      *
      * @return a new segment name
      */
-    private String createSegmentName() {
+    public String createSegmentName() {
         return StringUtils.lpad(String.valueOf(
                 (super.objects != null ? super.objects.size() : 0) + 1),
             '0', 4);
     }
 
     /**
-     * Returns the current graphics segment, creating one if one does not exist
-     *
-     * @return the current graphics chained segment
-     */
-    private GraphicsChainedSegment getSegment() {
-        if (segment == null) {
-            newSegment();
-        }
-        return this.segment;
-    }
-
-    /**
      * Creates a new graphics segment
      *
      * @return a newly created graphics segment
      */
     public GraphicsChainedSegment newSegment() {
-        String name = createSegmentName();
-        if (segment == null) {
-            this.segment = new GraphicsChainedSegment(name);
+        String segmentName = createSegmentName();
+        if (currentSegment == null) {
+            currentSegment = new GraphicsChainedSegment(segmentName);
         } else {
-            this.segment = new GraphicsChainedSegment(name, segment);
+            currentSegment.setComplete(true);
+            currentSegment = new GraphicsChainedSegment(segmentName, currentSegment.getNameBytes());
         }
-        super.addObject(segment);
-        return segment;
+        super.addObject(currentSegment);
+        return currentSegment;
     }
 
     /** {@inheritDoc} */
-    public void addObject(StructuredDataObject drawingOrder) {
-        if (segment == null
-            || (segment.getDataLength() + drawingOrder.getDataLength())
-            >= GraphicsChainedSegment.MAX_DATA_LEN) {
+    public void addObject(StructuredData object) {
+        if (currentSegment == null
+                || (currentSegment.getDataLength() + object.getDataLength())
+                >= GraphicsChainedSegment.MAX_DATA_LEN) {
             newSegment();
         }
-        segment.addObject(drawingOrder);
+        currentSegment.addObject(object);
+    }
+
+    /**
+     * Removes the current segment from this graphics data
+     *
+     * @return the current segment from this graphics data
+     */
+    public StructuredData removeCurrentSegment() {
+        this.currentSegment = null;
+        return super.removeLast();
     }
 
     /** {@inheritDoc} */
@@ -115,13 +106,21 @@
         data[2] = len[1]; // Length byte 2
         os.write(data);
 
-        // get first segment in chain and write (including all its connected segments)
-        GraphicsChainedSegment firstSegment = (GraphicsChainedSegment)objects.get(0);
-        firstSegment.writeToStream(os);
+        writeObjects(objects, os);
     }
 
     /** {@inheritDoc} */
     public String toString() {
         return "GraphicsData";
     }
+
+    /**
+     * Adds the given segment to this graphics data
+     *
+     * @param segment a graphics chained segment
+     */
+    public void addSegment(GraphicsChainedSegment segment) {
+        currentSegment = segment;
+        super.addObject(currentSegment);
+    }
 }
\ No newline at end of file

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=719274&r1=719273&r2=719274&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 Thu Nov 20 08:38:44 2008
@@ -30,12 +30,17 @@
      *
      * @param coords the x/y coordinates for this object
      */
-    public GraphicsFillet(int[] coords) {
-        super(coords);
+    public GraphicsFillet(int[] coords, boolean relative) {
+        super(coords, relative);
     }
 
+    /** {@inheritDoc} */
     byte getOrderCode() {
-        return (byte)0xC5;
+        if (isRelative()) {
+            return (byte)0x85;
+        } else {
+            return (byte)0xC5;
+        }
     }
 
 }
\ 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=719274&r1=719273&r2=719274&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 Thu Nov 20 08:38:44 2008
@@ -22,13 +22,15 @@
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.fop.afp.modca.AbstractStructuredObject;
 import org.apache.fop.afp.util.BinaryUtils;
 
 /**
  * A GOCA Image
  */
-public class GraphicsImage extends AbstractStructuredObject {
+public class GraphicsImage extends AbstractGraphicsDrawingOrder {
+
+    /** the maximum image data length */
+    public static final short MAX_DATA_LEN = 255;
 
     /** x coordinate */
     private final int x;
@@ -63,13 +65,23 @@
     }
 
     /** {@inheritDoc} */
-    protected void writeStart(OutputStream os) throws IOException {
+    public int getDataLength() {
+        //TODO:
+        return 0;
+    }
+
+    byte getOrderCode() {
+        return (byte)0xD1;
+    }
+
+    /** {@inheritDoc} */
+    public void writeToStream(OutputStream os) throws IOException {
         byte[] xcoord = BinaryUtils.convert(x, 2);
         byte[] ycoord = BinaryUtils.convert(y, 2);
         byte[] w = BinaryUtils.convert(width, 2);
         byte[] h = BinaryUtils.convert(height, 2);
-        byte[] data = new byte[] {
-            (byte) 0xD1, // GBIMG order code
+        byte[] startData = new byte[] {
+            getOrderCode(), // GBIMG order code
             (byte) 0x0A, // LENGTH
             xcoord[0],
             xcoord[1],
@@ -82,28 +94,19 @@
             h[0], // HEIGHT
             h[1] //
         };
-        os.write(data);
-    }
-
-    /** the maximum image data length */
-    public static final short MAX_DATA_LEN = 255;
+        os.write(startData);
 
-    /** {@inheritDoc} */
-    protected void writeContent(OutputStream os) throws IOException {
         byte[] dataHeader = new byte[] {
             (byte) 0x92 // GIMD
         };
         final int lengthOffset = 1;
         writeChunksToStream(imageData, dataHeader, lengthOffset, MAX_DATA_LEN, os);
-    }
 
-    /** {@inheritDoc} */
-    protected void writeEnd(OutputStream os) throws IOException {
-        byte[] data = new byte[] {
+        byte[] endData = new byte[] {
             (byte) 0x93, // GEIMG order code
             0x00 // LENGTH
         };
-        os.write(data);
+        os.write(endData);
     }
 
     /** {@inheritDoc} */

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=719274&r1=719273&r2=719274&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 Thu Nov 20 08:38:44 2008
@@ -19,6 +19,9 @@
 
 package org.apache.fop.afp.goca;
 
+import java.io.IOException;
+import java.io.OutputStream;
+
 /**
  * A GOCA graphics straight line drawn from the
  * given absolute position
@@ -29,14 +32,25 @@
      * Constructor
      *
      * @param coords the x/y coordinates for this object
+     *
+     * @param relative is this a relative drawing order
      */
-    public GraphicsLine(int[] coords) {
-        super(coords);
+    public GraphicsLine(int[] coords, boolean relative) {
+        super(coords, relative);
     }
 
     /** {@inheritDoc} */
     byte getOrderCode() {
-        return (byte)0xC1;
+        if (isRelative()) {
+            return (byte)0x81;
+        } else {
+            return (byte)0xC1;
+        }
     }
 
+    /** {@inheritDoc} */
+    public void writeToStream(OutputStream os) throws IOException {
+        byte[] data = getData();
+        os.write(data);
+    }
 }
\ No newline at end of file

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=719274&r1=719273&r2=719274&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 Thu Nov 20 08:38:44 2008
@@ -22,15 +22,12 @@
 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 AbstractNamedAFPObject
-    implements StructuredDataObject {
+public class GraphicsSetCharacterSet extends AbstractGraphicsDrawingOrder {
 
     /** font character set reference */
     private final int fontReference;
@@ -45,7 +42,7 @@
     /** {@inheritDoc} */
     public void writeToStream(OutputStream os) throws IOException {
         byte[] data = new byte[] {
-            0x38, // GSCS order code
+            getOrderCode(), // GSCS order code
             BinaryUtils.convert(fontReference)[0]
         };
         os.write(data);
@@ -61,4 +58,9 @@
         return "GraphicsSetCharacterSet(" + fontReference + ")";
     }
 
+    /** {@inheritDoc} */
+    byte getOrderCode() {
+        return 0x38;
+    }
+
 }
\ No newline at end of file



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