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 sp...@apache.org on 2008/02/14 22:57:53 UTC

svn commit: r627882 [12/41] - in /xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking: ./ examples/embedding/ examples/embedding/java/embedding/ examples/embedding/java/embedding/intermediate/ examples/embedding/xml/xml/ examples/fo/ examples/...

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java Thu Feb 14 13:55:44 2008
@@ -21,10 +21,17 @@
 
 import java.awt.Color;
 import java.awt.Rectangle;
+import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
 import java.util.List;
 import java.util.Map;
 
+import org.w3c.dom.Document;
+
+import org.apache.batik.parser.AWTTransformProducer;
+
+import org.apache.xmlgraphics.image.loader.ImageSize;
+
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
 import org.apache.fop.area.BlockViewport;
@@ -35,10 +42,10 @@
 import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.inline.Viewport;
 import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.extensions.ExtensionElementMapping;
 import org.apache.fop.fonts.FontMetrics;
-import org.apache.fop.image.FopImage;
 import org.apache.fop.traits.BorderProps;
-import org.w3c.dom.Document;
+import org.apache.fop.util.QName;
 
 /**
  * Abstract base class for renderers like PDF and PostScript where many painting operations
@@ -151,51 +158,47 @@
                 updateColor(back.getColor(), true);
                 fillRect(sx, sy, paddRectWidth, paddRectHeight);
             }
-            if (back.getFopImage() != null) {
-                FopImage fopimage = back.getFopImage();
-                if (fopimage != null && fopimage.load(FopImage.DIMENSIONS)) {
-                    saveGraphicsState();
-                    clipRect(sx, sy, paddRectWidth, paddRectHeight);
-                    int horzCount = (int)((paddRectWidth 
-                            * 1000 / fopimage.getIntrinsicWidth()) + 1.0f); 
-                    int vertCount = (int)((paddRectHeight 
-                            * 1000 / fopimage.getIntrinsicHeight()) + 1.0f); 
-                    if (back.getRepeat() == EN_NOREPEAT) {
-                        horzCount = 1;
-                        vertCount = 1;
-                    } else if (back.getRepeat() == EN_REPEATX) {
-                        vertCount = 1;
-                    } else if (back.getRepeat() == EN_REPEATY) {
-                        horzCount = 1;
-                    }
-                    //change from points to millipoints
-                    sx *= 1000;
-                    sy *= 1000;
-                    if (horzCount == 1) {
-                        sx += back.getHoriz();
-                    }
-                    if (vertCount == 1) {
-                        sy += back.getVertical();
-                    }
-                    for (int x = 0; x < horzCount; x++) {
-                        for (int y = 0; y < vertCount; y++) {
-                            // place once
-                            Rectangle2D pos;
-                            // Image positions are relative to the currentIP/BP
-                            pos = new Rectangle2D.Float(sx - currentIPPosition 
-                                                            + (x * fopimage.getIntrinsicWidth()),
-                                                        sy - currentBPPosition
-                                                            + (y * fopimage.getIntrinsicHeight()),
-                                                        fopimage.getIntrinsicWidth(),
-                                                        fopimage.getIntrinsicHeight());
-                            drawImage(back.getURL(), pos);
-                        }
+            if (back.getImageInfo() != null) {
+                ImageSize imageSize = back.getImageInfo().getSize(); 
+                saveGraphicsState();
+                clipRect(sx, sy, paddRectWidth, paddRectHeight);
+                int horzCount = (int)((paddRectWidth 
+                        * 1000 / imageSize.getWidthMpt()) + 1.0f); 
+                int vertCount = (int)((paddRectHeight 
+                        * 1000 / imageSize.getHeightMpt()) + 1.0f); 
+                if (back.getRepeat() == EN_NOREPEAT) {
+                    horzCount = 1;
+                    vertCount = 1;
+                } else if (back.getRepeat() == EN_REPEATX) {
+                    vertCount = 1;
+                } else if (back.getRepeat() == EN_REPEATY) {
+                    horzCount = 1;
+                }
+                //change from points to millipoints
+                sx *= 1000;
+                sy *= 1000;
+                if (horzCount == 1) {
+                    sx += back.getHoriz();
+                }
+                if (vertCount == 1) {
+                    sy += back.getVertical();
+                }
+                for (int x = 0; x < horzCount; x++) {
+                    for (int y = 0; y < vertCount; y++) {
+                        // place once
+                        Rectangle2D pos;
+                        // Image positions are relative to the currentIP/BP
+                        pos = new Rectangle2D.Float(sx - currentIPPosition 
+                                                        + (x * imageSize.getWidthMpt()),
+                                                    sy - currentBPPosition
+                                                        + (y * imageSize.getHeightMpt()),
+                                                        imageSize.getWidthMpt(),
+                                                        imageSize.getHeightMpt());
+                        drawImage(back.getURL(), pos);
                     }
-                    
-                    restoreGraphicsState();
-                } else {
-                    log.warn("Can't find background image: " + back.getURL());
                 }
+                
+                restoreGraphicsState();
             }
         }
 
@@ -403,6 +406,9 @@
         
     }
     
+    private static final QName FOX_TRANSFORM
+            = new QName(ExtensionElementMapping.URI, "fox:transform");
+    
     /** {@inheritDoc} */
     protected void renderBlockViewport(BlockViewport bv, List children) {
         // clip and position viewport if necessary
@@ -410,25 +416,17 @@
         // save positions
         int saveIP = currentIPPosition;
         int saveBP = currentBPPosition;
-        //String saveFontName = currentFontName;
 
         CTM ctm = bv.getCTM();
         int borderPaddingStart = bv.getBorderAndPaddingWidthStart();
         int borderPaddingBefore = bv.getBorderAndPaddingWidthBefore();
-        float x, y;
-        x = (float)(bv.getXOffset() + containingIPPosition) / 1000f;
-        y = (float)(bv.getYOffset() + containingBPPosition) / 1000f;
         //This is the content-rect
         float width = (float)bv.getIPD() / 1000f;
         float height = (float)bv.getBPD() / 1000f;
-        
 
         if (bv.getPositioning() == Block.ABSOLUTE
                 || bv.getPositioning() == Block.FIXED) {
 
-            currentIPPosition = bv.getXOffset();
-            currentBPPosition = bv.getYOffset();
-
             //For FIXED, we need to break out of the current viewports to the
             //one established by the page. We save the state stack for restoration
             //after the block-container has been painted. See below.
@@ -437,37 +435,51 @@
                 breakOutList = breakOutOfStateStack();
             }
             
-            CTM tempctm = new CTM(containingIPPosition, containingBPPosition);
-            ctm = tempctm.multiply(ctm);
-
-            //Adjust for spaces (from margin or indirectly by start-indent etc.
-            x += bv.getSpaceStart() / 1000f;
-            currentIPPosition += bv.getSpaceStart();
+            AffineTransform positionTransform = new AffineTransform();
+            positionTransform.translate(bv.getXOffset(), bv.getYOffset());
             
-            y += bv.getSpaceBefore() / 1000f;
-            currentBPPosition += bv.getSpaceBefore(); 
+            //"left/"top" (bv.getX/YOffset()) specify the position of the content rectangle
+            positionTransform.translate(-borderPaddingStart, -borderPaddingBefore);
+
+            //Free transformation for the block-container viewport
+            String transf;
+            transf = bv.getForeignAttributeValue(FOX_TRANSFORM);
+            if (transf != null) {
+                AffineTransform freeTransform = AWTTransformProducer.createAffineTransform(transf);
+                positionTransform.concatenate(freeTransform);
+            }
 
+            saveGraphicsState();
+            //Viewport position
+            concatenateTransformationMatrix(mptToPt(positionTransform));
+            
+            //Background and borders
             float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f;
             float bpheight = (borderPaddingBefore + bv.getBorderAndPaddingWidthAfter()) / 1000f;
+            drawBackAndBorders(bv, 0, 0, width + bpwidth, height + bpheight);
 
-            drawBackAndBorders(bv, x, y, width + bpwidth, height + bpheight);
-
-            //Now adjust for border/padding
-            currentIPPosition += borderPaddingStart;
-            currentBPPosition += borderPaddingBefore;
+            //Shift to content rectangle after border painting
+            AffineTransform contentRectTransform = new AffineTransform();
+            contentRectTransform.translate(borderPaddingStart, borderPaddingBefore);
+            concatenateTransformationMatrix(mptToPt(contentRectTransform));
             
-            Rectangle2D clippingRect = null;
+            //Clipping
             if (bv.getClip()) {
-                clippingRect = new Rectangle(currentIPPosition, currentBPPosition, 
-                        bv.getIPD(), bv.getBPD());
+                clipRect(0f, 0f, width, height);
             }
 
-            startVParea(ctm, clippingRect);
+            saveGraphicsState();
+            //Set up coordinate system for content rectangle
+            AffineTransform contentTransform = ctm.toAffineTransform();
+            concatenateTransformationMatrix(mptToPt(contentTransform));
+            
             currentIPPosition = 0;
             currentBPPosition = 0;
             renderBlocks(bv, children);
-            endVParea();
 
+            restoreGraphicsState();
+            restoreGraphicsState();
+            
             if (breakOutList != null) {
                 restoreStateStackAfterBreakOut(breakOutList);
             }
@@ -507,10 +519,16 @@
             
             currentBPPosition += (int)(bv.getAllocBPD());
         }
-        //currentFontName = saveFontName;
     }
 
     /**
+     * Concatenates the current transformation matrix with the given one, therefore establishing
+     * a new coordinate system.
+     * @param at the transformation matrix to process (coordinates in points)
+     */
+    protected abstract void concatenateTransformationMatrix(AffineTransform at);
+    
+    /**
      * Render an inline viewport.
      * This renders an inline viewport by clipping if necessary.
      * @param viewport the viewport to handle
@@ -615,10 +633,10 @@
         
     /**
      * Clip using a rectangular area.
-     * @param x the x coordinate
-     * @param y the y coordinate
-     * @param width the width of the rectangle
-     * @param height the height of the rectangle
+     * @param x the x coordinate (in points)
+     * @param y the y coordinate (in points)
+     * @param width the width of the rectangle (in points)
+     * @param height the height of the rectangle (in points)
      */
     protected abstract void clipRect(float x, float y, float width, float height);
     

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRenderer.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRenderer.java Thu Feb 14 13:55:44 2008
@@ -21,35 +21,39 @@
 
 // Java
 import java.awt.Rectangle;
+import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.List;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 
-// XML
 import org.w3c.dom.Document;
 
-// FOP
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.BeforeFloat;
 import org.apache.fop.area.Block;
 import org.apache.fop.area.BlockViewport;
 import org.apache.fop.area.BodyRegion;
 import org.apache.fop.area.CTM;
-import org.apache.fop.area.NormalFlow;
 import org.apache.fop.area.Footnote;
 import org.apache.fop.area.LineArea;
 import org.apache.fop.area.MainReference;
-import org.apache.fop.area.Span;
+import org.apache.fop.area.NormalFlow;
+import org.apache.fop.area.OffDocumentItem;
 import org.apache.fop.area.Page;
+import org.apache.fop.area.PageSequence;
 import org.apache.fop.area.PageViewport;
-import org.apache.fop.area.RegionViewport;
 import org.apache.fop.area.RegionReference;
+import org.apache.fop.area.RegionViewport;
+import org.apache.fop.area.Span;
 import org.apache.fop.area.Trait;
-import org.apache.fop.area.OffDocumentItem;
 import org.apache.fop.area.inline.Character;
 import org.apache.fop.area.inline.Container;
 import org.apache.fop.area.inline.ForeignObject;
@@ -59,15 +63,12 @@
 import org.apache.fop.area.inline.InlineParent;
 import org.apache.fop.area.inline.Leader;
 import org.apache.fop.area.inline.Space;
-import org.apache.fop.area.inline.Viewport;
+import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.area.inline.TextArea;
+import org.apache.fop.area.inline.Viewport;
 import org.apache.fop.area.inline.WordArea;
-import org.apache.fop.area.inline.SpaceArea;
-import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fonts.FontInfo;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  * Abstract base class for all renderers. The Abstract renderer does all the
@@ -170,15 +171,7 @@
         return this.currentPageViewport;
     }
     
-    /**
-     * Prepare a page for rendering. This is called if the renderer supports
-     * out of order rendering. The renderer should prepare the page so that a
-     * page further on in the set of pages can be rendered. The body of the
-     * page should not be rendered. The page will be rendered at a later time
-     * by the call to render page.
-     *
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public void preparePage(PageViewport page) { }
 
     /**
@@ -218,6 +211,11 @@
     public void startPageSequence(LineArea seqTitle) {
         //do nothing
     }
+    
+    /** {@inheritDoc} */
+    public void startPageSequence(PageSequence pageSequence) {
+        startPageSequence(pageSequence.getTitle());
+    }
 
     // normally this would be overriden to create a page in the
     // output
@@ -556,31 +554,20 @@
             int saveIP = currentIPPosition;
             int saveBP = currentBPPosition;
 
-            if (block.getPositioning() == Block.ABSOLUTE) {
-                currentIPPosition += block.getXOffset();
-                currentBPPosition += block.getYOffset();
-                currentBPPosition += block.getSpaceBefore();
+            currentIPPosition += block.getXOffset();
+            currentBPPosition += block.getYOffset();
+            currentBPPosition += block.getSpaceBefore();
 
-                handleBlockTraits(block);
+            handleBlockTraits(block);
 
-                if (children != null) {
-                    renderBlocks(block, children);
-                }
+            if (children != null) {
+                renderBlocks(block, children);
+            }
 
+            if (block.getPositioning() == Block.ABSOLUTE) {
                 // absolute blocks do not effect the layout
                 currentBPPosition = saveBP;
             } else {
-                // relative blocks are offset
-                currentIPPosition += block.getXOffset();
-                currentBPPosition += block.getYOffset();
-                currentBPPosition += block.getSpaceBefore();
-
-                handleBlockTraits(block);
-
-                if (children != null) {
-                    renderBlocks(block, children);
-                }
-
                 // stacked and relative blocks effect stacking
                 currentIPPosition = saveIP;
                 currentBPPosition = saveBP + block.getAllocBPD();
@@ -835,5 +822,33 @@
      */
     public String getMimeType() {
         return null;
+    }
+
+    /**
+     * Converts a millipoint-based transformation matrix to points.
+     * @param at a millipoint-based transformation matrix
+     * @return a point-based transformation matrix
+     */
+    protected AffineTransform mptToPt(AffineTransform at) {
+        double[] matrix = new double[6];
+        at.getMatrix(matrix);
+        //Convert to points
+        matrix[4] = matrix[4] / 1000;
+        matrix[5] = matrix[5] / 1000;
+        return new AffineTransform(matrix);
+    }
+
+    /**
+     * Converts a point-based transformation matrix to millipoints.
+     * @param at a point-based transformation matrix
+     * @return a millipoint-based transformation matrix
+     */
+    protected AffineTransform ptToMpt(AffineTransform at) {
+        double[] matrix = new double[6];
+        at.getMatrix(matrix);
+        //Convert to millipoints
+        matrix[4] = matrix[4] * 1000;
+        matrix[5] = matrix[5] * 1000;
+        return new AffineTransform(matrix);
     }
 }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRendererConfigurator.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRendererConfigurator.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render;
 

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRendererConfigurator.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRendererMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRendererMaker.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRendererMaker.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRendererMaker.java Thu Feb 14 13:55:44 2008
@@ -1,71 +1,71 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render;
-
-import org.apache.fop.apps.FOUserAgent;
-
-/**
- * Base class for factory classes which instantiate Renderers and provide information
- * about them.
- */
-public abstract class AbstractRendererMaker {
-    
-    /**
-     * Instantiates a new renderer.
-     * @param userAgent the user agent
-     * @return the newly instantiated renderer
-     */
-    public abstract Renderer makeRenderer(FOUserAgent userAgent);
-
-    /**
-     * @return Indicates whether this renderer requires an OutputStream to work with.
-     */
-    public abstract boolean needsOutputStream();
-    
-    /**
-     * @return an array of MIME types the renderer supports.
-     */
-    public abstract String[] getSupportedMimeTypes();
-
-    /**
-     * Returns a renderer config object that can be used to
-     * configure the renderer.
-     * @param userAgent user agent
-     * @return a config object that can be used to configure the renderer
-     */
-    public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
-        return null;
-    }
-
-    /**
-     * Indicates whether a specific MIME type is supported by this renderer.
-     * @param mimeType the MIME type (ex. "application/pdf")
-     * @return true if the MIME type is supported
-     */
-    public boolean isMimeTypeSupported(String mimeType) {
-        String[] mimes = getSupportedMimeTypes();
-        for (int i = 0; i < mimes.length; i++) {
-            if (mimes[i].equals(mimeType)) {
-                return true;
-            }
-        }
-        return false;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render;
+
+import org.apache.fop.apps.FOUserAgent;
+
+/**
+ * Base class for factory classes which instantiate Renderers and provide information
+ * about them.
+ */
+public abstract class AbstractRendererMaker {
+    
+    /**
+     * Instantiates a new renderer.
+     * @param userAgent the user agent
+     * @return the newly instantiated renderer
+     */
+    public abstract Renderer makeRenderer(FOUserAgent userAgent);
+
+    /**
+     * @return Indicates whether this renderer requires an OutputStream to work with.
+     */
+    public abstract boolean needsOutputStream();
+    
+    /**
+     * @return an array of MIME types the renderer supports.
+     */
+    public abstract String[] getSupportedMimeTypes();
+
+    /**
+     * Returns a renderer config object that can be used to
+     * configure the renderer.
+     * @param userAgent user agent
+     * @return a config object that can be used to configure the renderer
+     */
+    public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
+        return null;
+    }
+
+    /**
+     * Indicates whether a specific MIME type is supported by this renderer.
+     * @param mimeType the MIME type (ex. "application/pdf")
+     * @return true if the MIME type is supported
+     */
+    public boolean isMimeTypeSupported(String mimeType) {
+        String[] mimes = getSupportedMimeTypes();
+        for (int i = 0; i < mimes.length; i++) {
+            if (mimes[i].equals(mimeType)) {
+                return true;
+            }
+        }
+        return false;
+    }
+}

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/AbstractRendererMaker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/DefaultFontResolver.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/Graphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/Graphics2DAdapter.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/Graphics2DAdapter.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/Graphics2DAdapter.java Thu Feb 14 13:55:44 2008
@@ -1,50 +1,50 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
- 
-package org.apache.fop.render;
-
-import java.io.IOException;
-
-/**
- * This interface represents an optional feature that can be provided by
- * a renderer. It is exposed by calling the getGraphics2DAdapter() method
- * on the renderer. Renderers that support this feature allow painting
- * of arbitrary images through a Graphics2D instance.
- */
-public interface Graphics2DAdapter {
-
-    /**
-     * Paints an arbitrary images on a given Graphics2D instance. The renderer
-     * providing this functionality must set up a Graphics2D instance so that
-     * the image with the given extents (in mpt) can be painted by the painter
-     * passed to this method. The Graphics2DImagePainter is then passed this
-     * Graphics2D instance so the image can be painted.
-     * @param painter the painter which will paint the actual image
-     * @param context the renderer context for the current renderer
-     * @param x X position of the image
-     * @param y Y position of the image
-     * @param width width of the image
-     * @param height height of the image
-     * @throws IOException In case of an I/O error while writing the output format
-     */
-    void paintImage(Graphics2DImagePainter painter, 
-            RendererContext context,
-            int x, int y, int width, int height) throws IOException;
-    
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+ 
+package org.apache.fop.render;
+
+import java.io.IOException;
+
+/**
+ * This interface represents an optional feature that can be provided by
+ * a renderer. It is exposed by calling the getGraphics2DAdapter() method
+ * on the renderer. Renderers that support this feature allow painting
+ * of arbitrary images through a Graphics2D instance.
+ */
+public interface Graphics2DAdapter {
+
+    /**
+     * Paints an arbitrary images on a given Graphics2D instance. The renderer
+     * providing this functionality must set up a Graphics2D instance so that
+     * the image with the given extents (in mpt) can be painted by the painter
+     * passed to this method. The Graphics2DImagePainter is then passed this
+     * Graphics2D instance so the image can be painted.
+     * @param painter the painter which will paint the actual image
+     * @param context the renderer context for the current renderer
+     * @param x X position of the image
+     * @param y Y position of the image
+     * @param width width of the image
+     * @param height height of the image
+     * @throws IOException In case of an I/O error while writing the output format
+     */
+    void paintImage(org.apache.xmlgraphics.java2d.Graphics2DImagePainter painter, 
+            RendererContext context,
+            int x, int y, int width, int height) throws IOException;
+    
+}

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/Graphics2DAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/Graphics2DImagePainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/Graphics2DImagePainter.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/Graphics2DImagePainter.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/Graphics2DImagePainter.java Thu Feb 14 13:55:44 2008
@@ -1,45 +1,30 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
- 
-package org.apache.fop.render;
-
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.geom.Rectangle2D;
-
-/**
- * This interface is used by the Graphics2DAdapter. Components that can paint using
- * a Graphics2D instance can implement this interface to paint themselves.
- */
-public interface Graphics2DImagePainter {
-
-    /**
-     * Called to paint the image. Implementations should scale so the image is
-     * painted fully inside the given area indicated by then Rectangle2D object.
-     * @param g2d the Graphics2D instance to paint on
-     * @param area the target area for the image
-     */
-    void paint(Graphics2D g2d, Rectangle2D area);
-
-    /**
-     * @return the dimensions of the image to be painted in millipoints
-     */
-    Dimension getImageSize();
-    
-}
\ No newline at end of file
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+ 
+package org.apache.fop.render;
+
+/**
+ * This interface is used by the Graphics2DAdapter. Components that can paint using
+ * a Graphics2D instance can implement this interface to paint themselves.
+ * @deprecated use {@link org.apache.xmlgraphics.java2d.Graphics2DImagePainter} directly!
+ */
+public interface Graphics2DImagePainter
+        extends org.apache.xmlgraphics.java2d.Graphics2DImagePainter {
+
+}

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/Graphics2DImagePainter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ImageAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ImageAdapter.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ImageAdapter.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ImageAdapter.java Thu Feb 14 13:55:44 2008
@@ -1,47 +1,47 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
- 
-package org.apache.fop.render;
-
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-
-/**
- * This interface represents an optional feature that can be provided by
- * a renderer. It is exposed by calling the getImageAdapter() method
- * on the renderer. Renderers that support this feature allow painting
- * of images (RendererImage instances).
- */
-public interface ImageAdapter {
-
-    /**
-     * Paints an image at the given position.
-     * @param image the image which will be painted
-     * @param context the renderer context for the current renderer
-     * @param x X position of the image
-     * @param y Y position of the image
-     * @param width width of the image
-     * @param height height of the image
-     * @throws IOException In case of an I/O error while writing the output format
-     */
-    void paintImage(RenderedImage image, 
-            RendererContext context,
-            int x, int y, int width, int height) throws IOException;
-    
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+ 
+package org.apache.fop.render;
+
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+
+/**
+ * This interface represents an optional feature that can be provided by
+ * a renderer. It is exposed by calling the getImageAdapter() method
+ * on the renderer. Renderers that support this feature allow painting
+ * of images (RendererImage instances).
+ */
+public interface ImageAdapter {
+
+    /**
+     * Paints an image at the given position.
+     * @param image the image which will be painted
+     * @param context the renderer context for the current renderer
+     * @param x X position of the image
+     * @param y Y position of the image
+     * @param width width of the image
+     * @param height height of the image
+     * @throws IOException In case of an I/O error while writing the output format
+     */
+    void paintImage(RenderedImage image, 
+            RendererContext context,
+            int x, int y, int width, int height) throws IOException;
+    
+}

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ImageAdapter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/ImageAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/PrintRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/PrintRendererConfigurator.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/PrintRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/PrintRendererConfigurator.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render;
 

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/PrintRendererConfigurator.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/Renderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/Renderer.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/Renderer.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/Renderer.java Thu Feb 14 13:55:44 2008
@@ -20,16 +20,16 @@
 package org.apache.fop.render;
 
 // Java
-import java.io.OutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 
-// FOP
 import org.apache.fop.apps.FOPException;
-import org.apache.fop.area.PageViewport;
+import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.area.LineArea;
 import org.apache.fop.area.OffDocumentItem;
+import org.apache.fop.area.PageSequence;
+import org.apache.fop.area.PageViewport;
 import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.apps.FOUserAgent;
 
 
 /**
@@ -142,8 +142,16 @@
      * Tells the renderer that a new page sequence starts.
      *
      * @param seqTitle  The title of the page sequence
+     * @deprecated Use startPageSequence(PageSequence) instead
      */
     void startPageSequence(LineArea seqTitle);
+
+    /**
+     * Tells the renderer that a new page sequence starts.
+     *
+     * @param pageSequence the page sequence
+     */
+    void startPageSequence(PageSequence pageSequence);
 
     /**
      * Tells the renderer to render a particular page. A renderer typically

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/RendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/RendererConfigurator.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/RendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/RendererConfigurator.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render;
 

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/RendererConfigurator.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/RendererFactory.java
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords Thu Feb 14 13:55:44 2008
@@ -1 +1 @@
-Author Date Id Revision
+Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/XMLHandlerConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/XMLHandlerConfigurator.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/XMLHandlerConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/XMLHandlerConfigurator.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render;
 

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/XMLHandlerConfigurator.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/XMLHandlerRegistry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/XMLHandlerRegistry.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/XMLHandlerRegistry.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/XMLHandlerRegistry.java Thu Feb 14 13:55:44 2008
@@ -1,166 +1,166 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.render;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.xmlgraphics.util.Service;
-
-/**
- * This class holds references to various XML handlers used by FOP. It also
- * supports automatic discovery of additional XML handlers available through
- * the class path.
- */
-public class XMLHandlerRegistry {
-
-    /** the logger */
-    private static Log log = LogFactory.getLog(XMLHandlerRegistry.class);
-    
-    /** Map containing XML handlers for various document types */
-    private Map handlers = new java.util.HashMap();
-    
-    /**
-     * Default constructor.
-     */
-    public XMLHandlerRegistry() {
-        discoverXMLHandlers();
-    }
-    
-    /**
-     * Add a default XML handler which is able to handle any namespace.
-     * @param handler XMLHandler to use
-     */
-    private void setDefaultXMLHandler(XMLHandler handler) {
-        addXMLHandler(XMLHandler.HANDLE_ALL, handler);
-    }
-    
-    /**
-     * Add an XML handler. The handler itself is inspected to find out what it supports.
-     * @param classname the fully qualified class name
-     */
-    public void addXMLHandler(String classname) {
-        try {
-            XMLHandler handlerInstance = (XMLHandler)Class.forName(classname).newInstance();
-            addXMLHandler(handlerInstance);
-        } catch (ClassNotFoundException e) {
-            throw new IllegalArgumentException("Could not find "
-                                               + classname);
-        } catch (InstantiationException e) {
-            throw new IllegalArgumentException("Could not instantiate "
-                                               + classname);
-        } catch (IllegalAccessException e) {
-            throw new IllegalArgumentException("Could not access "
-                                               + classname);
-        } catch (ClassCastException e) {
-            throw new IllegalArgumentException(classname
-                                               + " is not an " 
-                                               + XMLHandler.class.getName());
-        }
-    }
-    
-    /**
-     * Add an XML handler. The handler itself is inspected to find out what it supports.
-     * @param handler the XMLHandler instance
-     */
-    public void addXMLHandler(XMLHandler handler) {
-        String ns = handler.getNamespace();
-        if (ns == null) {
-            setDefaultXMLHandler(handler);
-        } else {
-            addXMLHandler(ns, handler);
-        }
-    }
-    
-    /**
-     * Add an XML handler for the given MIME type and XML namespace.
-     * @param ns Namespace URI
-     * @param handler XMLHandler to use
-     */
-    private void addXMLHandler(String ns,
-                              XMLHandler handler) {
-        List lst = (List)handlers.get(ns);
-        if (lst == null) {
-            lst = new java.util.ArrayList();
-            handlers.put(ns, lst);
-        }
-        lst.add(handler);
-    }
-    
-    /**
-     * Returns an XMLHandler which handles an XML dialect of the given namespace and for
-     * a specified output format defined by its MIME type.
-     * @param renderer the Renderer for which to retrieve a Renderer
-     * @param ns the XML namespace associated with the XML to be rendered
-     * @return the XMLHandler responsible for handling the XML or null if none is available
-     */
-    public XMLHandler getXMLHandler(Renderer renderer, String ns) {
-        XMLHandler handler;
-
-        List lst = (List)handlers.get(ns);
-        handler = getXMLHandler(renderer, lst);
-        if (handler == null) {
-            lst = (List)handlers.get(XMLHandler.HANDLE_ALL);
-            handler = getXMLHandler(renderer, lst);
-        }
-        return handler;
-    }
-
-    private XMLHandler getXMLHandler(Renderer renderer, List lst) {
-        XMLHandler handler;
-        if (lst != null) {
-            for (int i = 0, c = lst.size(); i < c; i++) {
-                //TODO Maybe add priorities later
-                handler = (XMLHandler)lst.get(i);
-                if (handler.supportsRenderer(renderer)) {
-                    return handler;
-                }
-            }
-        }
-        return null; //No handler found
-    }
-    
-    /**
-     * Discovers XMLHandler implementations through the classpath and dynamically
-     * registers them.
-     */
-    private void discoverXMLHandlers() {
-        // add mappings from available services
-        Iterator providers = Service.providers(XMLHandler.class);
-        if (providers != null) {
-            while (providers.hasNext()) {
-                XMLHandler handler = (XMLHandler)providers.next();
-                try {
-                    if (log.isDebugEnabled()) {
-                        log.debug("Dynamically adding XMLHandler: " + handler.getClass().getName());
-                    }
-                    addXMLHandler(handler);
-                } catch (IllegalArgumentException e) {
-                    log.error("Error while adding XMLHandler", e);
-                }
-
-            }
-        }
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.xmlgraphics.util.Service;
+
+/**
+ * This class holds references to various XML handlers used by FOP. It also
+ * supports automatic discovery of additional XML handlers available through
+ * the class path.
+ */
+public class XMLHandlerRegistry {
+
+    /** the logger */
+    private static Log log = LogFactory.getLog(XMLHandlerRegistry.class);
+    
+    /** Map containing XML handlers for various document types */
+    private Map handlers = new java.util.HashMap();
+    
+    /**
+     * Default constructor.
+     */
+    public XMLHandlerRegistry() {
+        discoverXMLHandlers();
+    }
+    
+    /**
+     * Add a default XML handler which is able to handle any namespace.
+     * @param handler XMLHandler to use
+     */
+    private void setDefaultXMLHandler(XMLHandler handler) {
+        addXMLHandler(XMLHandler.HANDLE_ALL, handler);
+    }
+    
+    /**
+     * Add an XML handler. The handler itself is inspected to find out what it supports.
+     * @param classname the fully qualified class name
+     */
+    public void addXMLHandler(String classname) {
+        try {
+            XMLHandler handlerInstance = (XMLHandler)Class.forName(classname).newInstance();
+            addXMLHandler(handlerInstance);
+        } catch (ClassNotFoundException e) {
+            throw new IllegalArgumentException("Could not find "
+                                               + classname);
+        } catch (InstantiationException e) {
+            throw new IllegalArgumentException("Could not instantiate "
+                                               + classname);
+        } catch (IllegalAccessException e) {
+            throw new IllegalArgumentException("Could not access "
+                                               + classname);
+        } catch (ClassCastException e) {
+            throw new IllegalArgumentException(classname
+                                               + " is not an " 
+                                               + XMLHandler.class.getName());
+        }
+    }
+    
+    /**
+     * Add an XML handler. The handler itself is inspected to find out what it supports.
+     * @param handler the XMLHandler instance
+     */
+    public void addXMLHandler(XMLHandler handler) {
+        String ns = handler.getNamespace();
+        if (ns == null) {
+            setDefaultXMLHandler(handler);
+        } else {
+            addXMLHandler(ns, handler);
+        }
+    }
+    
+    /**
+     * Add an XML handler for the given MIME type and XML namespace.
+     * @param ns Namespace URI
+     * @param handler XMLHandler to use
+     */
+    private void addXMLHandler(String ns,
+                              XMLHandler handler) {
+        List lst = (List)handlers.get(ns);
+        if (lst == null) {
+            lst = new java.util.ArrayList();
+            handlers.put(ns, lst);
+        }
+        lst.add(handler);
+    }
+    
+    /**
+     * Returns an XMLHandler which handles an XML dialect of the given namespace and for
+     * a specified output format defined by its MIME type.
+     * @param renderer the Renderer for which to retrieve a Renderer
+     * @param ns the XML namespace associated with the XML to be rendered
+     * @return the XMLHandler responsible for handling the XML or null if none is available
+     */
+    public XMLHandler getXMLHandler(Renderer renderer, String ns) {
+        XMLHandler handler;
+
+        List lst = (List)handlers.get(ns);
+        handler = getXMLHandler(renderer, lst);
+        if (handler == null) {
+            lst = (List)handlers.get(XMLHandler.HANDLE_ALL);
+            handler = getXMLHandler(renderer, lst);
+        }
+        return handler;
+    }
+
+    private XMLHandler getXMLHandler(Renderer renderer, List lst) {
+        XMLHandler handler;
+        if (lst != null) {
+            for (int i = 0, c = lst.size(); i < c; i++) {
+                //TODO Maybe add priorities later
+                handler = (XMLHandler)lst.get(i);
+                if (handler.supportsRenderer(renderer)) {
+                    return handler;
+                }
+            }
+        }
+        return null; //No handler found
+    }
+    
+    /**
+     * Discovers XMLHandler implementations through the classpath and dynamically
+     * registers them.
+     */
+    private void discoverXMLHandlers() {
+        // add mappings from available services
+        Iterator providers = Service.providers(XMLHandler.class);
+        if (providers != null) {
+            while (providers.hasNext()) {
+                XMLHandler handler = (XMLHandler)providers.next();
+                try {
+                    if (log.isDebugEnabled()) {
+                        log.debug("Dynamically adding XMLHandler: " + handler.getClass().getName());
+                    }
+                    addXMLHandler(handler);
+                } catch (IllegalArgumentException e) {
+                    log.error("Error while adding XMLHandler", e);
+                }
+
+            }
+        }
+    }
+}

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/XMLHandlerRegistry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphics2D.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphics2D.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphics2D.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render.afp;
 

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphics2D.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphics2D.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java Thu Feb 14 13:55:44 2008
@@ -22,8 +22,9 @@
 import java.awt.image.BufferedImage;
 import java.io.IOException;
 
+import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
+
 import org.apache.fop.render.AbstractGraphics2DAdapter;
-import org.apache.fop.render.Graphics2DImagePainter;
 import org.apache.fop.render.RendererContext;
 
 /**

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphicsConfiguration.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphicsConfiguration.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphicsConfiguration.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphicsConfiguration.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render.afp;
 

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphicsConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphicsConfiguration.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphicsDevice.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphicsDevice.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphicsDevice.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphicsDevice.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render.afp;
 

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphicsDevice.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPGraphicsDevice.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPInfo.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPInfo.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render.afp;
 

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPInfo.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPPageFonts.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPPageFonts.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPPageFonts.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPPageFonts.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render.afp;
 

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPPageFonts.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPPageFonts.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPRenderer.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPRenderer.java Thu Feb 14 13:55:44 2008
@@ -20,10 +20,14 @@
 package org.apache.fop.render.afp;
 
 import java.awt.Color;
+import java.awt.Point;
 import java.awt.Rectangle;
+import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
@@ -32,7 +36,22 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.output.ByteArrayOutputStream;
+
+import org.apache.xmlgraphics.image.codec.tiff.TIFFImage;
+import org.apache.xmlgraphics.image.loader.ImageException;
+import org.apache.xmlgraphics.image.loader.ImageFlavor;
+import org.apache.xmlgraphics.image.loader.ImageInfo;
+import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
+import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
+import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
+import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
+import org.apache.xmlgraphics.image.loader.util.ImageUtil;
+import org.apache.xmlgraphics.ps.ImageEncodingHelper;
+
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.area.Block;
@@ -49,6 +68,7 @@
 import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.area.inline.TextArea;
 import org.apache.fop.area.inline.WordArea;
+import org.apache.fop.datatypes.URISpecification;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
 import org.apache.fop.fonts.FontInfo;
@@ -56,10 +76,6 @@
 import org.apache.fop.fonts.base14.Courier;
 import org.apache.fop.fonts.base14.Helvetica;
 import org.apache.fop.fonts.base14.TimesRoman;
-import org.apache.fop.image.FopImage;
-import org.apache.fop.image.ImageFactory;
-import org.apache.fop.image.TIFFImage;
-import org.apache.fop.image.XMLImage;
 import org.apache.fop.render.AbstractPathOrientedRenderer;
 import org.apache.fop.render.Graphics2DAdapter;
 import org.apache.fop.render.RendererContext;
@@ -74,7 +90,6 @@
 import org.apache.fop.render.afp.modca.AFPDataStream;
 import org.apache.fop.render.afp.modca.ImageObject;
 import org.apache.fop.render.afp.modca.PageObject;
-import org.w3c.dom.Document;
 
 /**
  * This is an implementation of a FOP Renderer that renders areas to AFP.
@@ -511,6 +526,12 @@
         // currentFontName = saveFontName;
     }
 
+    /** {@inheritDoc} */
+    protected void concatenateTransformationMatrix(AffineTransform at) {
+        //Not used here since AFPRenderer defines its own renderBlockViewport() method.
+        throw new UnsupportedOperationException("NYI");
+    }
+    
     /**
      * {@inheritDoc}
      */
@@ -735,20 +756,117 @@
         return context;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public void drawImage(String url, Rectangle2D pos, Map foreignAttributes) {
+    private static final ImageFlavor[] FLAVORS = new ImageFlavor[]
+                                                     {ImageFlavor.RAW_CCITTFAX,
+                                                      ImageFlavor.GRAPHICS2D,
+                                                      ImageFlavor.BUFFERED_IMAGE, 
+                                                      ImageFlavor.RENDERED_IMAGE,
+                                                      ImageFlavor.XML_DOM};
+
+    /** {@inheritDoc} */
+    public void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) {
+        uri = URISpecification.getURL(uri);
+        Rectangle posInt = new Rectangle(
+                (int)pos.getX(),
+                (int)pos.getY(),
+                (int)pos.getWidth(),
+                (int)pos.getHeight());
+        Point origin = new Point(currentIPPosition, currentBPPosition);
+        int x = origin.x + posInt.x;
+        int y = origin.y + posInt.y;
+
         String name = null;
         if (pageSegmentsMap != null) {
-            name = (String) pageSegmentsMap.get(url);
+            name = (String) pageSegmentsMap.get(uri);
         }
         if (name != null) {
-            int x = mpts2units(pos.getX() + currentIPPosition);
-            int y = mpts2units(pos.getY() + currentBPPosition);
-            afpDataStream.createIncludePageSegment(name, x, y);
+            afpDataStream.createIncludePageSegment(name, mpts2units(x), mpts2units(y));
         } else {
-            url = ImageFactory.getURL(url);
+            ImageManager manager = getUserAgent().getFactory().getImageManager();
+            ImageInfo info = null;
+            try {
+                ImageSessionContext sessionContext = getUserAgent().getImageSessionContext();
+                info = manager.getImageInfo(uri, sessionContext);
+                
+                //Only now fully load/prepare the image
+                Map hints = ImageUtil.getDefaultHints(sessionContext);
+                org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
+                        info, FLAVORS, hints, sessionContext);
+                
+                //...and process the image
+                if (img instanceof ImageGraphics2D) {
+                    ImageGraphics2D imageG2D = (ImageGraphics2D)img;
+                    RendererContext context = createRendererContext(
+                            posInt.x, posInt.y,
+                            posInt.width, posInt.height, foreignAttributes);
+                    getGraphics2DAdapter().paintImage(imageG2D.getGraphics2DImagePainter(),
+                            context,
+                            origin.x + posInt.x, origin.y + posInt.y,
+                            posInt.width, posInt.height);
+                } else if (img instanceof ImageRendered) {
+                    ImageRendered imgRend = (ImageRendered)img;
+                    RenderedImage ri = imgRend.getRenderedImage();
+                    
+                    drawBufferedImage(ri, getResolution(),
+                            posInt.x + currentIPPosition,
+                            posInt.y + currentBPPosition,
+                            posInt.width,
+                            posInt.height);
+                } else if (img instanceof ImageRawCCITTFax) {
+                    ImageRawCCITTFax ccitt = (ImageRawCCITTFax)img;
+                    int afpx = mpts2units(posInt.x + currentIPPosition);
+                    int afpy = mpts2units(posInt.y + currentBPPosition);
+                    int afpw = mpts2units(posInt.getWidth());
+                    int afph = mpts2units(posInt.getHeight());
+                    int afpres = getResolution();
+                    ImageObject io = afpDataStream.getImageObject(afpx, afpy, afpw, afph,
+                            afpres, afpres);
+                    io.setImageParameters(
+                            (int) (ccitt.getSize().getDpiHorizontal() * 10),
+                            (int) (ccitt.getSize().getDpiVertical() * 10),
+                            ccitt.getSize().getWidthPx(),
+                            ccitt.getSize().getHeightPx());
+                    int compression = ccitt.getCompression();
+                    switch (compression) {
+                    case TIFFImage.COMP_FAX_G3_1D :
+                        io.setImageEncoding((byte) 0x80);
+                        break;
+                    case TIFFImage.COMP_FAX_G3_2D :
+                        io.setImageEncoding((byte) 0x81);
+                        break;
+                    case TIFFImage.COMP_FAX_G4_2D :
+                        io.setImageEncoding((byte) 0x82);
+                        break;
+                    default:
+                        throw new IllegalStateException(
+                                "Invalid compression scheme: " + compression);
+                    }
+                    InputStream in = ccitt.createInputStream();
+                    try {
+                        byte[] buf = IOUtils.toByteArray(in);
+                        io.setImageData(buf);
+                    } finally {
+                        IOUtils.closeQuietly(in);
+                    }
+                } else if (img instanceof ImageXMLDOM) {
+                    ImageXMLDOM imgXML = (ImageXMLDOM)img;
+                    renderDocument(imgXML.getDocument(), imgXML.getRootNamespace(),
+                            pos, foreignAttributes);
+                } else {
+                    throw new UnsupportedOperationException("Unsupported image type: " + img);
+                }
+
+            } catch (ImageException ie) {
+                log.error("Error while processing image: "
+                        + (info != null ? info.toString() : uri), ie);
+            } catch (FileNotFoundException fe) {
+                log.error(fe.getMessage());
+            } catch (IOException ioe) {
+                log.error("I/O error while processing image: "
+                        + (info != null ? info.toString() : uri), ioe);
+            }
+            
+            /*
             ImageFactory fact = userAgent.getFactory().getImageFactory();
             FopImage fopimage = fact.getImage(url, userAgent);
             if (fopimage == null) {
@@ -768,6 +886,7 @@
                 renderDocument(doc, ns, pos, foreignAttributes);
             } else if (MimeConstants.MIME_EPS.equals(mime)) {
                 log.warn("EPS images are not supported by this renderer");
+                */
                 /*
                  * } else if (MimeConstants.MIME_JPEG.equals(mime)) { if
                  * (!fopimage.load(FopImage.ORIGINAL_DATA)) { return; }
@@ -785,7 +904,7 @@
                  * io.setImageIDESize((byte)fopimage.getBitsPerPixel());
                  * io.setImageEncoding((byte)0x83);
                  * io.setImageData(fopimage.getRessourceBytes());
-                 */
+                 *//*
             } else if (MimeConstants.MIME_TIFF.equals(mime)
                     && fopimage instanceof TIFFImage) {
                 TIFFImage tiffImage = (TIFFImage) fopimage;
@@ -852,43 +971,30 @@
                     convertToGrayScaleImage(io, fopimage.getBitmaps(), fopimage
                             .getWidth(), fopimage.getHeight(), this.bitsPerPixel);
                 }
-            }
+            }*/
         }
     }
 
     /**
-     * Writes a BufferedImage to an OutputStream as raw sRGB bitmaps.
+     * Writes a RenderedImage to an OutputStream as raw sRGB bitmaps.
      * 
-     * @param img
-     *            the BufferedImage
+     * @param image
+     *            the RenderedImage
      * @param out
      *            the OutputStream
      * @throws IOException
      *             In case of an I/O error.
      */
-    public static void writeImage(BufferedImage img, OutputStream out)
+    public static void writeImage(RenderedImage image, OutputStream out)
             throws IOException {
-        int w = img.getWidth();
-        int h = img.getHeight();
-        int[] tmpMap = img.getRGB(0, 0, w, h, null, 0, w);
-        for (int i = 0; i < h; i++) {
-            for (int j = 0; j < w; j++) {
-                int p = tmpMap[i * w + j];
-                int r = (p >> 16) & 0xFF;
-                int g = (p >> 8) & 0xFF;
-                int b = (p) & 0xFF;
-                out.write((byte) (r & 0xFF));
-                out.write((byte) (g & 0xFF));
-                out.write((byte) (b & 0xFF));
-            }
-        }
+        ImageEncodingHelper.encodeRenderedImageAsRGB(image, out);
     }
 
     /**
      * Draws a BufferedImage to AFP.
      * 
-     * @param bi
-     *            the BufferedImage
+     * @param image
+     *            the RenderedImage
      * @param imageResolution
      *            the resolution of the BufferedImage
      * @param x
@@ -900,7 +1006,7 @@
      * @param h
      *            the height of the viewport (in mpt)
      */
-    public void drawBufferedImage(BufferedImage bi, int imageResolution, int x,
+    public void drawBufferedImage(RenderedImage image, int imageResolution, int x,
             int y, int w, int h) {
         int afpx = mpts2units(x);
         int afpy = mpts2units(y);
@@ -910,21 +1016,24 @@
         ByteArrayOutputStream baout = new ByteArrayOutputStream();
         try {
             // Serialize image
-            writeImage(bi, baout);
+            //TODO Eventually, this should be changed not to buffer as this increases the
+            //memory consumption (see PostScript output)
+            writeImage(image, baout);
             byte[] buf = baout.toByteArray();
 
             // Generate image
             ImageObject io = afpDataStream.getImageObject(afpx, afpy, afpw,
                     afph, afpres, afpres);
             io.setImageParameters(imageResolution, imageResolution,
-                    bi.getWidth(), bi.getHeight());
+                    image.getWidth(), image.getHeight());
             if (colorImages) {
                 io.setImageIDESize((byte)24);
                 io.setImageData(buf);
             } else {
                 // TODO Teach it how to handle grayscale BufferedImages directly
                 // because this is pretty inefficient
-                convertToGrayScaleImage(io, buf, bi.getWidth(), bi.getHeight(), this.bitsPerPixel);
+                convertToGrayScaleImage(io, buf,
+                        image.getWidth(), image.getHeight(), this.bitsPerPixel);
             }
         } catch (IOException ioe) {
             log.error("Error while serializing bitmap: " + ioe.getMessage(),

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render.afp;
 

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPSVGHandler.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPSVGHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPSVGHandler.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render.afp;
 

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPState.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPState.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPState.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPState.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: $ */
+/* $Id$ */
 
 package org.apache.fop.render.afp;
 

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPState.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPTextElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPTextElementBridge.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPTextElementBridge.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPTextElementBridge.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: PSTextElementBridge.java 426576 2006-07-28 15:44:37Z jeremias $ */
+/* $Id$ */
 
 package org.apache.fop.render.afp;
 

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPTextElementBridge.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPTextElementBridge.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPTextHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPTextHandler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPTextPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPTextPainter.java?rev=627882&r1=627881&r2=627882&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPTextPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPTextPainter.java Thu Feb 14 13:55:44 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id: PSTextPainter.java 542237 2007-05-28 14:31:24Z jeremias $ */
+/* $Id$ */
 
 package org.apache.fop.render.afp;
 

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPTextPainter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/render/afp/AFPTextPainter.java
------------------------------------------------------------------------------
    svn:keywords = Id



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