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/28 12:13:33 UTC

svn commit: r721430 [5/6] - in /xmlgraphics/fop/trunk: ./ conf/ lib/ src/documentation/content/xdocs/ src/documentation/content/xdocs/trunk/ src/java/META-INF/services/ src/java/org/apache/fop/afp/ src/java/org/apache/fop/afp/fonts/ src/java/org/apache...

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererConfigurator.java Fri Nov 28 03:13:12 2008
@@ -19,10 +19,16 @@
 
 package org.apache.fop.render.afp;
 
+import java.io.File;
 import java.util.List;
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.fop.afp.fonts.AFPFontInfo;
+import org.apache.fop.afp.fonts.CharacterSet;
+import org.apache.fop.afp.fonts.FopCharacterSet;
+import org.apache.fop.afp.fonts.OutlineFont;
+import org.apache.fop.afp.fonts.RasterFont;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.fonts.FontTriplet;
@@ -30,11 +36,6 @@
 import org.apache.fop.fonts.Typeface;
 import org.apache.fop.render.PrintRendererConfigurator;
 import org.apache.fop.render.Renderer;
-import org.apache.fop.render.afp.fonts.AFPFontInfo;
-import org.apache.fop.render.afp.fonts.CharacterSet;
-import org.apache.fop.render.afp.fonts.FopCharacterSet;
-import org.apache.fop.render.afp.fonts.OutlineFont;
-import org.apache.fop.render.afp.fonts.RasterFont;
 import org.apache.fop.util.LogUtil;
 
 /**
@@ -44,6 +45,7 @@
 
     /**
      * Default constructor
+     *
      * @param userAgent user agent
      */
     public AFPRendererConfigurator(FOUserAgent userAgent) {
@@ -54,16 +56,17 @@
         throws ConfigurationException {
 
         Configuration[] triple = fontCfg.getChildren("font-triplet");
-        List tripleList = new java.util.ArrayList();
+        List/*<FontTriplet>*/ tripletList = new java.util.ArrayList/*<FontTriplet>*/();
         if (triple.length == 0) {
             log.error("Mandatory font configuration element '<font-triplet...' is missing");
             return null;
         }
         for (int j = 0; j < triple.length; j++) {
             int weight = FontUtil.parseCSS2FontWeight(triple[j].getAttribute("weight"));
-            tripleList.add(new FontTriplet(triple[j].getAttribute("name"),
-                                           triple[j].getAttribute("style"),
-                                           weight));
+            FontTriplet triplet = new FontTriplet(triple[j].getAttribute("name"),
+                    triple[j].getAttribute("style"),
+                    weight);
+            tripletList.add(triplet);
         }
 
         //build the fonts
@@ -137,21 +140,17 @@
                         codepage, encoding, characterset, path));
                 }
             }
-            return new AFPFontInfo(font, tripleList);
+            return new AFPFontInfo(font, tripletList);
 
         } else if ("outline".equalsIgnoreCase(type)) {
-
             String characterset = afpFontCfg.getAttribute("characterset");
             if (characterset == null) {
                 log.error("Mandatory afp-font configuration attribute 'characterset=' is missing");
                 return null;
             }
             String name = afpFontCfg.getAttribute("name", characterset);
-
             CharacterSet characterSet = null;
-
             String base14 = afpFontCfg.getAttribute("base14-font", null);
-
             if (base14 != null) {
                 try {
                     Class clazz = Class.forName("org.apache.fop.fonts.base14."
@@ -175,7 +174,7 @@
             }
             // Create a new font object
             OutlineFont font = new OutlineFont(name, characterSet);
-            return new AFPFontInfo(font, tripleList);
+            return new AFPFontInfo(font, tripletList);
         } else {
             log.error("No or incorrect type attribute");
         }
@@ -184,36 +183,45 @@
 
     /**
      * Builds a list of AFPFontInfo objects for use with the setup() method.
+     *
      * @param cfg Configuration object
      * @return List the newly created list of fonts
      * @throws ConfigurationException if something's wrong with the config data
      */
-    private List buildFontListFromConfiguration(Configuration cfg)
+    private List/*<AFPFontInfo>*/ buildFontListFromConfiguration(Configuration cfg)
             throws ConfigurationException {
-        List fontList = new java.util.ArrayList();
+        List/*<AFPFontInfo>*/ fontList = new java.util.ArrayList();
         Configuration[] font = cfg.getChild("fonts").getChildren("font");
+        final String fontPath = null;
         for (int i = 0; i < font.length; i++) {
-            AFPFontInfo afi = buildFont(font[i], null);
+            AFPFontInfo afi = buildFont(font[i], fontPath);
             if (afi != null) {
                 if (log.isDebugEnabled()) {
                     log.debug("Adding font " + afi.getAFPFont().getFontName());
-                    for (int j = 0; j < afi.getFontTriplets().size(); ++j) {
-                        FontTriplet triplet = (FontTriplet) afi.getFontTriplets().get(j);
+                    List/*<FontTriplet>*/ fontTriplets = afi.getFontTriplets();
+                    for (int j = 0; j < fontTriplets.size(); ++j) {
+                        FontTriplet triplet = (FontTriplet) fontTriplets.get(j);
                         log.debug("  Font triplet "
                                   + triplet.getName() + ", "
                                   + triplet.getStyle() + ", "
                                   + triplet.getWeight());
                     }
                 }
-
                 fontList.add(afi);
             }
         }
         return fontList;
     }
 
+    /** images are converted to grayscale bitmapped IOCA */
+    private static final String IMAGES_MODE_GRAYSCALE = "b+w";
+
+    /** images are converted to color bitmapped IOCA */
+    private static final String IMAGES_MODE_COLOR = "color";
+
     /**
      * Configure the AFP renderer.
+     *
      * @param renderer AFP renderer
      * @throws FOPException fop exception
      * @see org.apache.fop.render.PrintRendererConfigurator#configure(Renderer)
@@ -223,24 +231,56 @@
         if (cfg != null) {
             AFPRenderer afpRenderer = (AFPRenderer)renderer;
             try {
-                List fontList = buildFontListFromConfiguration(cfg);
+                List/*<AFPFontInfo>*/ fontList = buildFontListFromConfiguration(cfg);
                 afpRenderer.setFontList(fontList);
             } catch (ConfigurationException e) {
                 LogUtil.handleException(log, e,
                         userAgent.getFactory().validateUserConfigStrictly());
             }
 
+            // image information
             Configuration imagesCfg = cfg.getChild("images");
-            if (!"color".equalsIgnoreCase(imagesCfg.getAttribute("mode", "b+w"))) {
-                afpRenderer.setBitsPerPixel(imagesCfg.getAttributeAsInteger("bits-per-pixel", 8));
-            } else {
+
+            // default to grayscale images
+            String imagesMode = imagesCfg.getAttribute("mode", IMAGES_MODE_GRAYSCALE);
+            if (IMAGES_MODE_COLOR.equals(imagesMode)) {
                 afpRenderer.setColorImages(true);
+            } else {
+                afpRenderer.setColorImages(false);
+                // default to 8 bits per pixel
+                int bitsPerPixel = imagesCfg.getAttributeAsInteger("bits-per-pixel", 8);
+                afpRenderer.setBitsPerPixel(bitsPerPixel);
             }
 
+            // native image support
+            boolean nativeImageSupport = imagesCfg.getAttributeAsBoolean("native", false);
+            afpRenderer.setNativeImagesSupported(nativeImageSupport);
+
+            // renderer resolution
             Configuration rendererResolutionCfg = cfg.getChild("renderer-resolution", false);
             if (rendererResolutionCfg != null) {
                 afpRenderer.setResolution(rendererResolutionCfg.getValueAsInteger(240));
             }
+
+            // a default external resource group file setting
+            Configuration resourceGroupFileCfg
+                = cfg.getChild("resource-group-file", false);
+            if (resourceGroupFileCfg != null) {
+                String resourceGroupDest = null;
+                try {
+                    resourceGroupDest = resourceGroupFileCfg.getValue();
+                } catch (ConfigurationException e) {
+                    LogUtil.handleException(log, e,
+                            userAgent.getFactory().validateUserConfigStrictly());
+                }
+                File resourceGroupFile = new File(resourceGroupDest);
+                if (resourceGroupFile.canWrite()) {
+                    afpRenderer.setDefaultResourceGroupFilePath(resourceGroupDest);
+                } else {
+                    log.warn("Unable to write to default external resource group file '"
+                                + resourceGroupDest + "'");
+                }
+            }
         }
     }
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRendererContextConstants.java Fri Nov 28 03:13:12 2008
@@ -32,4 +32,12 @@
      */
     String AFP_GRAYSCALE = "afpGrayscale";
 
+    /** The font information for the AFP renderer. */
+    String AFP_FONT_INFO = "afpFontInfo";
+
+    /** The afp resource manager */
+    String AFP_RESOURCE_MANAGER = "afpResourceManager";
+
+    /** The afp painting state */
+    String AFP_PAINTING_STATE = "afpPaintingState";
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPSVGHandler.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPSVGHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPSVGHandler.java Fri Nov 28 03:13:12 2008
@@ -20,9 +20,35 @@
 package org.apache.fop.render.afp;
 
 // FOP
+import java.awt.Dimension;
+import java.awt.geom.AffineTransform;
+import java.io.IOException;
+
+import org.apache.batik.bridge.BridgeContext;
+import org.apache.batik.dom.svg.SVGDOMImplementation;
+import org.apache.batik.gvt.GraphicsNode;
+import org.apache.fop.afp.AFPGraphics2D;
+import org.apache.fop.afp.AFPGraphicsObjectInfo;
+import org.apache.fop.afp.AFPObjectAreaInfo;
+import org.apache.fop.afp.AFPPaintingState;
+import org.apache.fop.afp.AFPResourceInfo;
+import org.apache.fop.afp.AFPResourceManager;
+import org.apache.fop.afp.AFPUnitConverter;
+import org.apache.fop.afp.svg.AFPBridgeContext;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.image.loader.batik.Graphics2DImagePainterImpl;
 import org.apache.fop.render.AbstractGenericSVGHandler;
 import org.apache.fop.render.Renderer;
 import org.apache.fop.render.RendererContext;
+import org.apache.fop.render.RendererContext.RendererContextWrapper;
+import org.apache.fop.svg.SVGEventProducer;
+import org.apache.fop.svg.SVGUserAgent;
+import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
+import org.apache.xmlgraphics.util.MimeConstants;
+import org.w3c.dom.Document;
 
 /**
  * AFP XML handler for SVG. Uses Apache Batik for SVG processing.
@@ -31,6 +57,147 @@
  */
 public class AFPSVGHandler extends AbstractGenericSVGHandler {
 
+    private boolean paintAsBitmap = false;
+
+    /** {@inheritDoc} */
+    public void handleXML(RendererContext context,
+                Document doc, String ns) throws Exception {
+        if (SVGDOMImplementation.SVG_NAMESPACE_URI.equals(ns)) {
+            renderSVGDocument(context, doc);
+        }
+    }
+
+    /**
+     * Render the SVG document.
+     *
+     * @param rendererContext the renderer context
+     * @param doc the SVG document
+     * @throws IOException In case of an I/O error while painting the image
+     */
+    protected void renderSVGDocument(final RendererContext rendererContext,
+            final Document doc) throws IOException {
+
+        AFPRendererContext afpRendererContext = (AFPRendererContext)rendererContext;
+        AFPInfo afpInfo = afpRendererContext.getInfo();
+
+        this.paintAsBitmap = afpInfo.paintAsBitmap();
+
+        FOUserAgent userAgent = rendererContext.getUserAgent();
+
+        // fallback paint as bitmap
+        String uri = getDocumentURI(doc);
+        if (paintAsBitmap) {
+            try {
+                super.renderSVGDocument(rendererContext, doc);
+            } catch (IOException ioe) {
+                SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+                        userAgent.getEventBroadcaster());
+                eventProducer.svgRenderingError(this, ioe, uri);
+            }
+            return;
+        }
+
+        // Create a new AFPGraphics2D
+        final boolean textAsShapes = afpInfo.strokeText();
+        AFPGraphics2D g2d = afpInfo.createGraphics2D(textAsShapes);
+
+        AFPPaintingState paintingState = g2d.getPaintingState();
+        paintingState.setImageUri(uri);
+
+        // Create an AFPBridgeContext
+        BridgeContext bridgeContext = createBridgeContext(userAgent, g2d);
+
+        // Build the SVG DOM and provide the painter with it
+        GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, doc);
+
+        // Create Graphics2DImagePainter
+        final RendererContextWrapper wrappedContext
+            = RendererContext.wrapRendererContext(rendererContext);
+        Dimension imageSize = getImageSize(wrappedContext);
+        Graphics2DImagePainter painter
+            = createGrapics2DImagePainter(bridgeContext, root, imageSize);
+
+        // Create AFPObjectAreaInfo
+        RendererContextWrapper rctx = RendererContext.wrapRendererContext(rendererContext);
+        int x = rctx.getCurrentXPosition();
+        int y = rctx.getCurrentYPosition();
+        int width = afpInfo.getWidth();
+        int height = afpInfo.getHeight();
+        int resolution = afpInfo.getResolution();
+
+        paintingState.save(); // save
+
+        AFPObjectAreaInfo objectAreaInfo
+            = createObjectAreaInfo(paintingState, x, y, width, height, resolution);
+
+        // Create AFPGraphicsObjectInfo
+        AFPResourceInfo resourceInfo = afpInfo.getResourceInfo();
+        AFPGraphicsObjectInfo graphicsObjectInfo = createGraphicsObjectInfo(
+                paintingState, painter, userAgent, resourceInfo, g2d);
+        graphicsObjectInfo.setObjectAreaInfo(objectAreaInfo);
+
+        // Create the GOCA GraphicsObject in the DataStream
+        AFPResourceManager resourceManager = afpInfo.getResourceManager();
+        resourceManager.createObject(graphicsObjectInfo);
+
+        paintingState.restore(); // resume
+    }
+
+    private AFPObjectAreaInfo createObjectAreaInfo(AFPPaintingState paintingState,
+            int x, int y, int width, int height, int resolution) {
+        // set the data object parameters
+        AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo();
+
+        AffineTransform at = paintingState.getData().getTransform();
+        at.translate(x, y);
+        objectAreaInfo.setX((int)Math.round(at.getTranslateX()));
+        objectAreaInfo.setY((int)Math.round(at.getTranslateY()));
+
+        objectAreaInfo.setWidthRes(resolution);
+        objectAreaInfo.setHeightRes(resolution);
+
+        AFPUnitConverter unitConv = paintingState.getUnitConverter();
+        objectAreaInfo.setWidth(Math.round(unitConv.mpt2units(width)));
+        objectAreaInfo.setHeight(Math.round(unitConv.mpt2units(height)));
+
+        int rotation = paintingState.getRotation();
+        objectAreaInfo.setRotation(rotation);
+
+        return objectAreaInfo;
+    }
+
+    private AFPGraphicsObjectInfo createGraphicsObjectInfo(AFPPaintingState paintingState, Graphics2DImagePainter painter,
+            FOUserAgent userAgent, AFPResourceInfo resourceInfo, AFPGraphics2D g2d) {
+        AFPGraphicsObjectInfo graphicsObjectInfo = new AFPGraphicsObjectInfo();
+
+        String uri = paintingState.getImageUri();
+        graphicsObjectInfo.setUri(uri);
+
+        graphicsObjectInfo.setMimeType(MimeConstants.MIME_AFP_GOCA);
+
+        graphicsObjectInfo.setResourceInfo(resourceInfo);
+
+        graphicsObjectInfo.setPainter(painter);
+
+        // Set the afp graphics 2d implementation
+        graphicsObjectInfo.setGraphics2D(g2d);
+
+        return graphicsObjectInfo;
+    }
+
+    public static BridgeContext createBridgeContext(FOUserAgent userAgent, AFPGraphics2D g2d) {
+        ImageManager imageManager = userAgent.getFactory().getImageManager();
+
+        SVGUserAgent svgUserAgent
+            = new SVGUserAgent(userAgent, new AffineTransform());
+
+        ImageSessionContext imageSessionContext = userAgent.getImageSessionContext();
+
+        FontInfo fontInfo = g2d.getFontInfo();
+        return new AFPBridgeContext(svgUserAgent, fontInfo, imageManager, imageSessionContext,
+                new AffineTransform(), g2d);
+    }
+
     /** {@inheritDoc} */
     public boolean supportsRenderer(Renderer renderer) {
         return (renderer instanceof AFPRenderer);
@@ -39,9 +206,29 @@
     /** {@inheritDoc} */
     protected void updateRendererContext(RendererContext context) {
         //Work around a problem in Batik: Gradients cannot be done in ColorSpace.CS_GRAY
-        context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE,
-                Boolean.FALSE);
+        context.setProperty(AFPRendererContextConstants.AFP_GRAYSCALE, Boolean.FALSE);
     }
 
-}
+    /** {@inheritDoc} */
+    protected Graphics2DImagePainter createGrapics2DImagePainter(BridgeContext ctx, GraphicsNode root, Dimension imageSize) {
+        Graphics2DImagePainter painter = null;
+        if (paintAsBitmap()) {
+            // paint as IOCA Image
+            painter = super.createGraphics2DImagePainter(root, ctx, imageSize);
+        } else {
+            // paint as GOCA Graphics
+            painter = new Graphics2DImagePainterImpl(root, ctx, imageSize);
+        }
+        return painter;
+    }
 
+    /**
+     * Returns true if the SVG is to be painted as a bitmap
+     *
+     * @return true if the SVG is to be painted as a bitmap
+     */
+    private boolean paintAsBitmap() {
+        return paintAsBitmap;
+    }
+
+}

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPAttribute.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPAttribute.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPAttribute.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPAttribute.java Fri Nov 28 03:13:12 2008
@@ -19,14 +19,13 @@
 
 package org.apache.fop.render.afp.extensions;
 
-import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.properties.Property;
 import org.apache.fop.fo.properties.StringProperty;
 
 /**
  * This class extends the org.apache.fop.fo.StringProperty.Maker inner class
- * in order to provide a static property maker. The object faciliates
+ * in order to provide a static property maker. The object facilitates
  * extraction of attributes from formatted objects based on the static list
  * as defined in the AFPElementMapping implementation.
  * <p/>
@@ -58,5 +57,4 @@
         }
         return property;
     }
-
 }
\ No newline at end of file

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElement.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElement.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElement.java Fri Nov 28 03:13:12 2008
@@ -23,6 +23,7 @@
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.ValidationException;
+import org.apache.fop.fo.extensions.ExtensionAttachment;
 
 /**
  * This class extends the org.apache.fop.extensions.ExtensionObj class. The
@@ -45,13 +46,13 @@
     /** {@inheritDoc} */
     protected void startOfNode() throws FOPException {
         super.startOfNode();
-        //if (!AFPElementMapping.NAMESPACE.equals(parent.getNamespaceURI())
-        //    || !AFPElementMapping.PAGE.equals(parent.getLocalName())) {
-        //    throw new ValidationException(getName() + " must be a child of afp:page.");
-        //}
         if (parent.getNameId() != Constants.FO_SIMPLE_PAGE_MASTER) {
             throw new ValidationException(getName() + " must be a child of fo:simple-page-master.");
         }
     }
 
+    /** {@inheritDoc} */    
+    protected ExtensionAttachment instantiateExtensionAttachment() {
+        return new AFPPageSetup(getName());
+    }
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java Fri Nov 28 03:13:12 2008
@@ -19,8 +19,6 @@
 
 package org.apache.fop.render.afp.extensions;
 
-import java.util.HashMap;
-
 import org.apache.fop.fo.ElementMapping;
 import org.apache.fop.fo.FONode;
 
@@ -39,7 +37,7 @@
     public static final String PAGE = "page";
 
     /** page group element */
-    public static final String PAGE_GROUP = "page-group";
+//    public static final String PAGE_GROUP = "page-group";
 
     /** tag logical element */
     public static final String TAG_LOGICAL_ELEMENT = "tag-logical-element";
@@ -53,6 +51,9 @@
     /** NOP */
     public static final String NO_OPERATION = "no-operation";
 
+    /** resource information (name, level, dest) */
+//    public static final String RESOURCE_INFO = "resource-info";
+
     /**
      * The namespace used for AFP extensions
      */
@@ -69,15 +70,18 @@
     }
 
     /**
-     * Private static synchronized method to set up the element and atribute
+     * Private static synchronized method to set up the element and attribute
      * HashMaps, this defines what elements and attributes are extracted.
      */
     protected void initialize() {
 
         if (foObjs == null) {
-            foObjs = new HashMap();
+            super.foObjs = new java.util.HashMap();
             foObjs.put(PAGE, new AFPPageSetupMaker());
-            // foObjs.put(PAGE_GROUP, new AFPMaker());
+//            foObjs.put(
+//              PAGE_GROUP,
+//              new AFPPageGroupMaker()
+//            );
             foObjs.put(
                 TAG_LOGICAL_ELEMENT,
                 new AFPTagLogicalElementMaker());
@@ -90,8 +94,10 @@
             foObjs.put(
                 NO_OPERATION,
                 new AFPNoOperationMaker());
+//           foObjs.put(
+//               RESOURCE_INFO,
+//               new AFPResourceInfoMaker());
         }
-
     }
 
     static class AFPPageSetupMaker extends ElementMapping.Maker {
@@ -123,4 +129,16 @@
             return new AFPElement(parent, NO_OPERATION);
         }
     }
+
+//    static class AFPResourceInfoMaker extends ElementMapping.Maker {
+//        public FONode make(FONode parent) {
+//            return new AFPResourceInfoElement(parent);
+//        }
+//    }
+
+//    static class AFPPageGroupMaker extends ElementMapping.Maker {
+//        public FONode make(FONode parent) {
+//            return new AFPElement(parent, PAGE_GROUP);
+//        }
+//    }
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPExtensionHandler.java Fri Nov 28 03:13:12 2008
@@ -54,7 +54,7 @@
                     || localName.equals(AFPElementMapping.INCLUDE_PAGE_OVERLAY)
                     || localName.equals(AFPElementMapping.INCLUDE_PAGE_SEGMENT)
                     || localName.equals(AFPElementMapping.PAGE)
-                    || localName.equals(AFPElementMapping.PAGE_GROUP)) {
+                    /*|| localName.equals(AFPElementMapping.PAGE_GROUP)*/) {
                 //handled in endElement
             } else {
                 handled = false;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetup.java Fri Nov 28 03:13:12 2008
@@ -19,33 +19,10 @@
 
 package org.apache.fop.render.afp.extensions;
 
-import java.io.Serializable;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-import org.apache.xmlgraphics.util.XMLizable;
-
-import org.apache.fop.fo.extensions.ExtensionAttachment;
-
 /**
  * This is the pass-through value object for the PostScript extension.
  */
-public class AFPPageSetup implements ExtensionAttachment, Serializable, XMLizable  {
-
-    private static final long serialVersionUID = 7190606822558332901L;
-
-    /** The category URI for this extension attachment. */
-    public static final String CATEGORY = "apache:fop:extensions:afp";
-
-    private String elementName;
-
-    private String name;
-
-    private String value;
-
-    private String content;
+public class AFPPageSetup extends AFPExtensionAttachment {
 
     /**
      * Default constructor.
@@ -53,85 +30,16 @@
      * @param elementName the name of the setup code object, may be null
      */
     public AFPPageSetup(String elementName) {
-        this.elementName = elementName;
-    }
-
-    /** @return the name */
-    public String getElementName() {
-        return elementName;
-    }
-
-    /** @return the name */
-    public String getName() {
-        return name;
-    }
-
-    /**
-     * Sets the name of the setup code object.
-     * @param name The name to set.
-     */
-    public void setName(String name) {
-        this.name = name;
+        super(elementName);
     }
 
-    /**
-     * @return the value
-     */
-    public String getValue() {
-        return value;
-    }
-
-    /**
-     * Sets the value
-     * @param source The value name to set.
-     */
-    public void setValue(String source) {
-        this.value = source;
-    }
-
-    /** {@inheritDoc} */
-    public String getCategory() {
-        return CATEGORY;
-    }
+    private static final long serialVersionUID = -549941295384013190L;
 
     /**
-     * @return the data
+     * {@inheritDoc}
      */
-    public String getContent() {
-        return content;
-    }
-
-    /**
-     * Sets the data
-     * @param content The byte data to set.
-     */
-    public void setContent(String content) {
-        this.content = content;
-    }
-
-    /** {@inheritDoc} */
     public String toString() {
         return "AFPPageSetup(element-name=" + getElementName()
             + " name=" + getName() + " value=" + getValue() + ")";
     }
-
-    private static final String ATT_NAME = "name";
-    private static final String ATT_VALUE = "value";
-
-    /** {@inheritDoc} */
-    public void toSAX(ContentHandler handler) throws SAXException {
-        AttributesImpl atts = new AttributesImpl();
-        if (name != null && name.length() > 0) {
-            atts.addAttribute(null, ATT_NAME, ATT_NAME, "CDATA", name);
-        }
-        if (value != null && value.length() > 0) {
-            atts.addAttribute(null, ATT_VALUE, ATT_VALUE, "CDATA", value);
-        }
-        handler.startElement(CATEGORY, elementName, elementName, atts);
-        if (content != null && content.length() > 0) {
-            char[] chars = content.toCharArray();
-            handler.characters(chars, 0, chars.length);
-        }
-        handler.endElement(CATEGORY, elementName, elementName);
-    }
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AFPPageSetupElement.java Fri Nov 28 03:13:12 2008
@@ -23,9 +23,10 @@
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.ValidationException;
+import org.apache.fop.fo.extensions.ExtensionAttachment;
 
 /**
- * Extension element for fox:ps-page-setup-code.
+ * Extension element for afp:ps-page-setup-code.
  */
 public class AFPPageSetupElement extends AbstractAFPExtensionObject {
 
@@ -45,4 +46,10 @@
         }
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    protected ExtensionAttachment instantiateExtensionAttachment() {
+        return new AFPPageSetup(this.name);
+    }
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/extensions/AbstractAFPExtensionObject.java Fri Nov 28 03:13:12 2008
@@ -35,11 +35,14 @@
 public abstract class AbstractAFPExtensionObject extends FONode {
 
     /**
-     * AFP setup code
+     * the AFP extension attachment
      */
-    private AFPPageSetup setupCode;
+    protected AFPExtensionAttachment extensionAttachment;
 
-    private String name;
+    /**
+     * the element name of this extension
+     */
+    protected String name;
 
     /**
      * @see org.apache.fop.fo.FONode#FONode(FONode)
@@ -49,10 +52,11 @@
     public AbstractAFPExtensionObject(FONode parent, String name) {
         super(parent);
         this.name = name;
-        this.setupCode = new AFPPageSetup(name);
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     protected void validateChildNode(Locator loc, String nsURI, String localName)
                 throws ValidationException {
         if (FO_URI.equals(nsURI)) {
@@ -60,60 +64,85 @@
         }
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     protected void characters(char[] data, int start, int length,
-                                 PropertyList pList, Locator locator) {
-        setupCode.setContent(new String(data, start, length));
+                                 PropertyList pList, Locator locator) throws FOPException {
+        ((AFPExtensionAttachment)getExtensionAttachment()).setContent(
+                new String(data, start, length));       
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public String getNamespaceURI() {
         return AFPElementMapping.NAMESPACE;
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public String getNormalNamespacePrefix() {
         return AFPElementMapping.NAMESPACE_PREFIX;
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public void processNode(String elementName, Locator locator,
                             Attributes attlist, PropertyList propertyList)
                                 throws FOPException {
-        String name = attlist.getValue("name");
-        if (name != null && name.length() > 0) {
-            setupCode.setName(name);
+        getExtensionAttachment();
+        String attr = attlist.getValue("name");
+        if (attr != null && attr.length() > 0) {
+            extensionAttachment.setName(attr);
         } else {
             throw new FOPException(elementName + " must have a name attribute.");
         }
         if (AFPElementMapping.INCLUDE_PAGE_SEGMENT.equals(elementName)) {
-            name = attlist.getValue("src");
-            if (name != null && name.length() > 0) {
-                setupCode.setValue(name);
+            attr = attlist.getValue("src");
+            if (attr != null && attr.length() > 0) {
+                extensionAttachment.setValue(attr);
             } else {
                 throw new FOPException(elementName + " must have a src attribute.");
             }
         } else if (AFPElementMapping.TAG_LOGICAL_ELEMENT.equals(elementName)) {
-            name = attlist.getValue("value");
-            if (name != null && name.length() > 0) {
-                setupCode.setValue(name);
+            attr = attlist.getValue("value");
+            if (attr != null && attr.length() > 0) {
+                extensionAttachment.setValue(attr);
             } else {
                 throw new FOPException(elementName + " must have a value attribute.");
             }
         }
     }
-
-    /** {@inheritDoc} */
+    
+    /**
+     * {@inheritDoc}
+     */
     protected void endOfNode() throws FOPException {
         super.endOfNode();
     }
 
-    /** {@inheritDoc} */
+    /**
+     * Instantiates extension attachment object
+     * @return extension attachment
+     */
+    protected abstract ExtensionAttachment instantiateExtensionAttachment();
+
+    /**
+     * {@inheritDoc}
+     */
     public ExtensionAttachment getExtensionAttachment() {
-        return this.setupCode;
+        if (extensionAttachment == null) {
+            this.extensionAttachment = (AFPExtensionAttachment)instantiateExtensionAttachment();
+        }
+        return this.extensionAttachment;
     }
 
-    /** {@inheritDoc} */
+    /**
+     * {@inheritDoc}
+     */
     public String getLocalName() {
         return name;
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/AWTRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/AWTRenderer.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/AWTRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/awt/AWTRenderer.java Fri Nov 28 03:13:12 2008
@@ -149,14 +149,11 @@
         Rectangle2D bounds = getPageViewport(pageNum).getViewArea();
         pageWidth = (int) Math.round(bounds.getWidth() / 1000f);
         pageHeight = (int) Math.round(bounds.getHeight() / 1000f);
-        double scaleX = scaleFactor
+        double scale = scaleFactor
                 * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
                 / userAgent.getTargetPixelUnitToMillimeter();
-        double scaleY = scaleFactor
-                * (25.4 / FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION)
-                / userAgent.getTargetPixelUnitToMillimeter();
-        int bitmapWidth = (int) ((pageWidth * scaleX) + 0.5);
-        int bitmapHeight = (int) ((pageHeight * scaleY) + 0.5);
+        int bitmapWidth = (int) ((pageWidth * scale) + 0.5);
+        int bitmapHeight = (int) ((pageHeight * scale) + 0.5);
         return new Dimension(bitmapWidth, bitmapHeight);
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java Fri Nov 28 03:13:12 2008
@@ -135,7 +135,7 @@
     /** The current state, holds a Graphics2D and its context */
     protected Java2DGraphicsState state;
 
-    private Stack stateStack = new Stack();
+    private final Stack stateStack = new Stack();
 
     /** true if the renderer has finished rendering all the pages */
     private boolean renderingDone;
@@ -146,9 +146,7 @@
     public Java2DRenderer() {
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public void setUserAgent(FOUserAgent foUserAgent) {
         super.setUserAgent(foUserAgent);
         userAgent.setRendererOverride(this); // for document regeneration
@@ -164,9 +162,7 @@
         return userAgent;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public void setupFontInfo(FontInfo inFontInfo) {
         //Don't call super.setupFontInfo() here! Java2D needs a special font setup
         // create a temp Image to test font metrics on
@@ -442,16 +438,12 @@
         state.transform(new AffineTransform(CTMHelper.toPDFArray(ctm)));
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected void endVParea() {
         restoreGraphicsState();
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected List breakOutOfStateStack() {
         log.debug("Block.FIXED --> break out");
         List breakOutList;
@@ -464,10 +456,7 @@
         return breakOutList;
     }
 
-    /**
-     * {@inheritDoc}
-     *          java.util.List)
-     */
+    /** {@inheritDoc} */
     protected void restoreStateStackAfterBreakOut(List breakOutList) {
         log.debug("Block.FIXED --> restoring context after break-out");
 
@@ -479,16 +468,12 @@
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected void updateColor(Color col, boolean fill) {
         state.updateColor(col);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected void clip() {
         if (currentPath == null) {
             throw new IllegalStateException("No current path available!");
@@ -497,16 +482,12 @@
         currentPath = null;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected void closePath() {
         currentPath.closePath();
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected void lineTo(float x, float y) {
         if (currentPath == null) {
             currentPath = new GeneralPath();
@@ -514,9 +495,7 @@
         currentPath.lineTo(x, y);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected void moveTo(float x, float y) {
         if (currentPath == null) {
             currentPath = new GeneralPath();
@@ -524,23 +503,17 @@
         currentPath.moveTo(x, y);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected void clipRect(float x, float y, float width, float height) {
         state.updateClip(new Rectangle2D.Float(x, y, width, height));
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected void fillRect(float x, float y, float width, float height) {
         state.getGraph().fill(new Rectangle2D.Float(x, y, width, height));
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     protected void drawBorderLine(float x1, float y1, float x2, float y2,
             boolean horz, boolean startOrBefore, int style, Color col) {
         Graphics2D g2d = state.getGraph();
@@ -711,9 +684,7 @@
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public void renderText(TextArea text) {
         renderInlineAreaBackAndBorders(text);
 
@@ -895,18 +866,20 @@
         super.renderLeader(area);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public void renderImage(Image image, Rectangle2D pos) {
         // endTextObject();
         String url = image.getURL();
         drawImage(url, pos);
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    private static final ImageFlavor[] FLAVOURS = new ImageFlavor[]
+                                                  {ImageFlavor.GRAPHICS2D,
+                                                      ImageFlavor.BUFFERED_IMAGE,
+                                                      ImageFlavor.RENDERED_IMAGE,
+                                                      ImageFlavor.XML_DOM};
+
+    /** {@inheritDoc} */
     protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) {
 
         int x = currentIPPosition + (int)Math.round(pos.getX());
@@ -918,14 +891,9 @@
         try {
             ImageSessionContext sessionContext = getUserAgent().getImageSessionContext();
             info = manager.getImageInfo(uri, sessionContext);
-            final ImageFlavor[] flavors = new ImageFlavor[]
-                {ImageFlavor.GRAPHICS2D,
-                    ImageFlavor.BUFFERED_IMAGE,
-                    ImageFlavor.RENDERED_IMAGE,
-                    ImageFlavor.XML_DOM};
             Map hints = ImageUtil.getDefaultHints(sessionContext);
             org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
-                    info, flavors, hints, sessionContext);
+                    info, FLAVOURS, hints, sessionContext);
             if (img instanceof ImageGraphics2D) {
                 ImageGraphics2D imageG2D = (ImageGraphics2D)img;
                 int width = (int)pos.getWidth();

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java Fri Nov 28 03:13:12 2008
@@ -20,20 +20,21 @@
 package org.apache.fop.render.java2d;
 
 import java.awt.geom.AffineTransform;
-
-import org.w3c.dom.Document;
+import java.io.IOException;
+import java.util.Map;
 
 import org.apache.batik.bridge.BridgeContext;
 import org.apache.batik.bridge.GVTBuilder;
 import org.apache.batik.gvt.GraphicsNode;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.fop.render.AbstractGenericSVGHandler;
 import org.apache.fop.render.Renderer;
 import org.apache.fop.render.RendererContext;
+import org.apache.fop.render.RendererContextConstants;
 import org.apache.fop.svg.SVGEventProducer;
 import org.apache.fop.svg.SVGUserAgent;
+import org.w3c.dom.Document;
 
 /**
  * Java2D XML handler for SVG (uses Apache Batik).
@@ -66,6 +67,11 @@
         pdfi.height = ((Integer)context.getProperty(HEIGHT)).intValue();
         pdfi.currentXPosition = ((Integer)context.getProperty(XPOS)).intValue();
         pdfi.currentYPosition = ((Integer)context.getProperty(YPOS)).intValue();
+        Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES);
+        if (foreign != null
+                && BITMAP.equalsIgnoreCase((String)foreign.get(CONVERSION_MODE))) {
+            pdfi.paintAsBitmap = true;
+        }
         return pdfi;
     }
 
@@ -83,6 +89,7 @@
         public int currentXPosition;
         /** see Java2D_YPOS */
         public int currentYPosition;
+        public boolean paintAsBitmap;
 
         /** {@inheritDoc} */
         public String toString() {
@@ -91,7 +98,8 @@
                 + "width = " + width + ", "
                 + "height = " + height + ", "
                 + "currentXPosition = " + currentXPosition + ", "
-                + "currentYPosition = " + currentYPosition + "}";
+                + "currentYPosition = " + currentYPosition  + ", "
+                + "paintAsBitmap = " + paintAsBitmap + "}";
         }
     }
 
@@ -103,6 +111,18 @@
             log.debug("renderSVGDocument(" + context + ", " + doc + ", " + info + ")");
         }
 
+        // fallback paint as bitmap
+        if (info.paintAsBitmap) {
+            try {
+                super.renderSVGDocument(context, doc);
+            } catch (IOException ioe) {
+                SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
+                        context.getUserAgent().getEventBroadcaster());
+                eventProducer.svgRenderingError(this, ioe, getDocumentURI(doc));
+            }
+            return;
+        }
+
         int x = info.currentXPosition;
         int y = info.currentYPosition;
 
@@ -126,8 +146,8 @@
         float iw = (float) ctx.getDocumentSize().getWidth() * 1000f;
         float ih = (float) ctx.getDocumentSize().getHeight() * 1000f;
 
-        float w = (float) info.width;
-        float h = (float) info.height;
+        float w = info.width;
+        float h = info.height;
 
         AffineTransform origTransform = info.state.getGraph().getTransform();
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java Fri Nov 28 03:13:12 2008
@@ -717,7 +717,7 @@
                     public Dimension getImageSize() {
                         return paintRect.getSize();
                     }
-
+                    
                 };
                 g2a.paintImage(painter, rc,
                         paintRect.x, paintRect.y, paintRect.width, paintRect.height);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFGraphics2DAdapter.java Fri Nov 28 03:13:12 2008
@@ -95,8 +95,8 @@
 
         AffineTransform transform = new AffineTransform();
         transform.translate(fx, fy);
-        pdfInfo.pdfState.concatenate(transform);
-        graphics.setPDFState(pdfInfo.pdfState);
+        pdfInfo.pdfPaintingState.concatenate(transform);
+        graphics.setPaintingState(pdfInfo.pdfPaintingState);
         graphics.setOutputStream(pdfInfo.outputStream);
 
         if (pdfInfo.paintAsBitmap) {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandler.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandler.java Fri Nov 28 03:13:12 2008
@@ -23,36 +23,15 @@
 import java.awt.Rectangle;
 import java.io.IOException;
 
-import org.apache.xmlgraphics.image.loader.Image;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-
 import org.apache.fop.pdf.PDFXObject;
+import org.apache.fop.render.ImageHandler;
 import org.apache.fop.render.RendererContext;
+import org.apache.xmlgraphics.image.loader.Image;
 
 /**
  * This interface is used for handling all sorts of image type for PDF output.
  */
-public interface PDFImageHandler {
-
-    /**
-     * Returns the priority for this image handler. A lower value means higher priority. This
-     * information is used to build the ordered/prioritized list of supported ImageFlavors for
-     * the PDF renderer. The built-in handlers use priorities between 100 and 999.
-     * @return a positive integer (>0) indicating the priority
-     */
-    int getPriority();
-
-    /**
-     * Returns the {@link ImageFlavor}s supported by this instance
-     * @return the supported image flavors
-     */
-    ImageFlavor[] getSupportedImageFlavors();
-
-    /**
-     * Returns the {@link Image} subclass supported by this instance.
-     * @return the Image type
-     */
-    Class getSupportedImageClass();
+public interface PDFImageHandler extends ImageHandler {
 
     /**
      * Generates the PDF objects for the given {@link Image} instance. If the handler generates

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerGraphics2D.java Fri Nov 28 03:13:12 2008
@@ -23,13 +23,12 @@
 import java.awt.Rectangle;
 import java.io.IOException;
 
+import org.apache.fop.pdf.PDFXObject;
+import org.apache.fop.render.RendererContext;
 import org.apache.xmlgraphics.image.loader.Image;
 import org.apache.xmlgraphics.image.loader.ImageFlavor;
 import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
 
-import org.apache.fop.pdf.PDFXObject;
-import org.apache.fop.render.RendererContext;
-
 /**
  * PDFImageHandler implementation which handles Graphics2D images.
  */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawCCITTFax.java Fri Nov 28 03:13:12 2008
@@ -23,15 +23,14 @@
 import java.awt.Rectangle;
 import java.io.IOException;
 
-import org.apache.xmlgraphics.image.loader.Image;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
-
 import org.apache.fop.pdf.PDFDocument;
 import org.apache.fop.pdf.PDFImage;
 import org.apache.fop.pdf.PDFResourceContext;
 import org.apache.fop.pdf.PDFXObject;
 import org.apache.fop.render.RendererContext;
+import org.apache.xmlgraphics.image.loader.Image;
+import org.apache.xmlgraphics.image.loader.ImageFlavor;
+import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
 
 /**
  * PDFImageHandler implementation which handles CCITT encoded images (CCITT fax group 3/4).

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawJPEG.java Fri Nov 28 03:13:12 2008
@@ -23,15 +23,14 @@
 import java.awt.Rectangle;
 import java.io.IOException;
 
-import org.apache.xmlgraphics.image.loader.Image;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG;
-
 import org.apache.fop.pdf.PDFDocument;
 import org.apache.fop.pdf.PDFImage;
 import org.apache.fop.pdf.PDFResourceContext;
 import org.apache.fop.pdf.PDFXObject;
 import org.apache.fop.render.RendererContext;
+import org.apache.xmlgraphics.image.loader.Image;
+import org.apache.xmlgraphics.image.loader.ImageFlavor;
+import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG;
 
 /**
  * PDFImageHandler implementation which handles raw JPEG images.

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRegistry.java Fri Nov 28 03:13:12 2008
@@ -19,171 +19,18 @@
 
 package org.apache.fop.render.pdf;
 
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.xmlgraphics.image.loader.Image;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-import org.apache.xmlgraphics.util.Service;
+import org.apache.fop.render.AbstractImageHandlerRegistry;
 
 /**
  * This class holds references to various image handlers used by the PDF renderer. It also
  * supports automatic discovery of additional handlers available through
  * the class path.
  */
-public class PDFImageHandlerRegistry {
-
-    /** the logger */
-    private static Log log = LogFactory.getLog(PDFImageHandlerRegistry.class);
-
-    private static final Comparator HANDLER_COMPARATOR = new Comparator() {
-        public int compare(Object o1, Object o2) {
-            PDFImageHandler h1 = (PDFImageHandler)o1;
-            PDFImageHandler h2 = (PDFImageHandler)o2;
-            return h1.getPriority() - h2.getPriority();
-        }
-    };
-
-    /** Map containing PDF image handlers for various MIME types */
-    private Map handlers = new java.util.HashMap();
-    /** List containing the same handlers as above but ordered by priority */
-    private List handlerList = new java.util.LinkedList();
+public class PDFImageHandlerRegistry extends AbstractImageHandlerRegistry {
 
-    /** Sorted Set of registered handlers */
-    private ImageFlavor[] supportedFlavors = new ImageFlavor[0];
-    private int handlerRegistrations;
-    private int lastSync;
-
-    /**
-     * Default constructor.
-     */
-    public PDFImageHandlerRegistry() {
-        discoverHandlers();
-    }
-
-    /**
-     * Add an PDFImageHandler. The handler itself is inspected to find out what it supports.
-     * @param classname the fully qualified class name
-     */
-    public void addHandler(String classname) {
-        try {
-            PDFImageHandler handlerInstance
-                = (PDFImageHandler)Class.forName(classname).newInstance();
-            addHandler(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 "
-                                               + PDFImageHandler.class.getName());
-        }
+    /** {@inheritDoc} */
+    public Class getHandlerClass() {
+        return PDFImageHandler.class;
     }
 
-    /**
-     * Add an image handler. The handler itself is inspected to find out what it supports.
-     * @param handler the PDFImageHandler instance
-     */
-    public synchronized void addHandler(PDFImageHandler handler) {
-        Class imageClass = handler.getSupportedImageClass();
-        this.handlers.put(imageClass, handler);
-
-        //Sorted insert
-        ListIterator iter = this.handlerList.listIterator();
-        while (iter.hasNext()) {
-            PDFImageHandler h = (PDFImageHandler)iter.next();
-            if (HANDLER_COMPARATOR.compare(handler, h) < 0) {
-                iter.previous();
-                break;
-            }
-        }
-        iter.add(handler);
-        this.handlerRegistrations++;
-    }
-
-    /**
-     * Returns an PDFImageHandler which handles an specific image type given the MIME type
-     * of the image.
-     * @param img the Image to be handled
-     * @return the PDFImageHandler responsible for handling the image or null if none is available
-     */
-    public PDFImageHandler getHandler(Image img) {
-        return getHandler(img.getClass());
-    }
-
-    /**
-     * Returns an PDFImageHandler which handles an specific image type given the MIME type
-     * of the image.
-     * @param imageClass the Image subclass for which to get a handler
-     * @return the PDFImageHandler responsible for handling the image or null if none is available
-     */
-    protected synchronized PDFImageHandler getHandler(Class imageClass) {
-        PDFImageHandler handler = null;
-        Class cl = imageClass;
-        while (cl != null) {
-            handler = (PDFImageHandler)handlers.get(cl);
-            if (handler != null) {
-                break;
-            }
-            cl = cl.getSuperclass();
-        }
-        return handler;
-    }
-
-    /**
-     * Returns the ordered array of supported image flavors.
-     * @return the array of image flavors
-     */
-    public synchronized ImageFlavor[] getSupportedFlavors() {
-        if (this.lastSync != this.handlerRegistrations) {
-            //Extract all ImageFlavors into a single array
-            List flavors = new java.util.ArrayList();
-            Iterator iter = this.handlerList.iterator();
-            while (iter.hasNext()) {
-                ImageFlavor[] f = ((PDFImageHandler)iter.next()).getSupportedImageFlavors();
-                for (int i = 0; i < f.length; i++) {
-                    flavors.add(f[i]);
-                }
-            }
-            this.supportedFlavors = (ImageFlavor[])flavors.toArray(new ImageFlavor[flavors.size()]);
-            this.lastSync = this.handlerRegistrations;
-        }
-        return this.supportedFlavors;
-    }
-
-    /**
-     * Discovers PDFImageHandler implementations through the classpath and dynamically
-     * registers them.
-     */
-    private void discoverHandlers() {
-        // add mappings from available services
-        Iterator providers = Service.providers(PDFImageHandler.class);
-        if (providers != null) {
-            while (providers.hasNext()) {
-                PDFImageHandler handler = (PDFImageHandler)providers.next();
-                try {
-                    if (log.isDebugEnabled()) {
-                        log.debug("Dynamically adding PDFImageHandler: "
-                                + handler.getClass().getName());
-                    }
-                    addHandler(handler);
-                } catch (IllegalArgumentException e) {
-                    log.error("Error while adding PDFImageHandler", e);
-                }
-
-            }
-        }
-    }
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRenderedImage.java Fri Nov 28 03:13:12 2008
@@ -23,15 +23,14 @@
 import java.awt.Rectangle;
 import java.io.IOException;
 
-import org.apache.xmlgraphics.image.loader.Image;
-import org.apache.xmlgraphics.image.loader.ImageFlavor;
-import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
-
 import org.apache.fop.pdf.PDFDocument;
 import org.apache.fop.pdf.PDFImage;
 import org.apache.fop.pdf.PDFResourceContext;
 import org.apache.fop.pdf.PDFXObject;
 import org.apache.fop.render.RendererContext;
+import org.apache.xmlgraphics.image.loader.Image;
+import org.apache.xmlgraphics.image.loader.ImageFlavor;
+import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
 
 /**
  * PDFImageHandler implementation which handles RenderedImage instances.

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerXML.java Fri Nov 28 03:13:12 2008
@@ -24,14 +24,12 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.w3c.dom.Document;
-
+import org.apache.fop.pdf.PDFXObject;
+import org.apache.fop.render.RendererContext;
 import org.apache.xmlgraphics.image.loader.Image;
 import org.apache.xmlgraphics.image.loader.ImageFlavor;
 import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
-
-import org.apache.fop.pdf.PDFXObject;
-import org.apache.fop.render.RendererContext;
+import org.w3c.dom.Document;
 
 /**
  * PDFImageHandler implementation which handles XML-based images.

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java Fri Nov 28 03:13:12 2008
@@ -40,16 +40,6 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.commons.io.IOUtils;
-
-import org.apache.xmlgraphics.image.loader.ImageException;
-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.util.ImageUtil;
-import org.apache.xmlgraphics.xmp.Metadata;
-import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter;
-import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
-
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
@@ -104,9 +94,9 @@
 import org.apache.fop.pdf.PDFOutputIntent;
 import org.apache.fop.pdf.PDFPage;
 import org.apache.fop.pdf.PDFPageLabels;
+import org.apache.fop.pdf.PDFPaintingState;
 import org.apache.fop.pdf.PDFResourceContext;
 import org.apache.fop.pdf.PDFResources;
-import org.apache.fop.pdf.PDFState;
 import org.apache.fop.pdf.PDFStream;
 import org.apache.fop.pdf.PDFTextUtil;
 import org.apache.fop.pdf.PDFXMode;
@@ -114,9 +104,19 @@
 import org.apache.fop.render.AbstractPathOrientedRenderer;
 import org.apache.fop.render.Graphics2DAdapter;
 import org.apache.fop.render.RendererContext;
+import org.apache.fop.util.AbstractPaintingState;
 import org.apache.fop.util.CharUtilities;
 import org.apache.fop.util.ColorProfileUtil;
 import org.apache.fop.util.ColorUtil;
+import org.apache.fop.util.AbstractPaintingState.AbstractData;
+import org.apache.xmlgraphics.image.loader.ImageException;
+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.util.ImageUtil;
+import org.apache.xmlgraphics.xmp.Metadata;
+import org.apache.xmlgraphics.xmp.schemas.XMPBasicAdapter;
+import org.apache.xmlgraphics.xmp.schemas.XMPBasicSchema;
 
 /**
  * Renderer that renders areas to PDF.
@@ -250,8 +250,8 @@
     /** Optional URI to an output profile to be used. */
     protected String outputProfileURI;
 
-    /** drawing state */
-    protected PDFState currentState = null;
+    /** Painting state */
+    protected PDFPaintingState paintingState = null;
 
     /** Text generation utility holding the current font status */
     protected PDFTextUtil textutil;
@@ -262,7 +262,7 @@
     protected Map filterMap;
 
     /** Image handler registry */
-    private PDFImageHandlerRegistry imageHandlerRegistry = new PDFImageHandlerRegistry();
+    private final PDFImageHandlerRegistry imageHandlerRegistry = new PDFImageHandlerRegistry();
 
     /**
      * create the PDF renderer
@@ -519,7 +519,7 @@
         currentStream = null;
         currentContext = null;
         currentPage = null;
-        currentState = null;
+        paintingState = null;
         this.textutil = null;
 
         idPositions.clear();
@@ -640,7 +640,7 @@
     /** {@inheritDoc} */
     protected void saveGraphicsState() {
         endTextObject();
-        currentState.push();
+        paintingState.save();
         currentStream.add("q\n");
     }
 
@@ -648,7 +648,7 @@
         endTextObject();
         currentStream.add("Q\n");
         if (popState) {
-            currentState.pop();
+            paintingState.restore();
         }
     }
 
@@ -783,11 +783,11 @@
             }
         };
 
-        currentState = new PDFState();
+        paintingState = new PDFPaintingState();
         // Transform the PDF's default coordinate system (0,0 at lower left) to the PDFRenderer's
         AffineTransform basicPageTransform = new AffineTransform(1, 0, 0, -1, 0,
                 pageHeight / 1000f);
-        currentState.concatenate(basicPageTransform);
+        paintingState.concatenate(basicPageTransform);
         currentStream.add(CTMHelper.toPDFString(basicPageTransform, false) + " cm\n");
 
         super.renderPage(page);
@@ -807,7 +807,7 @@
     protected void startVParea(CTM ctm, Rectangle2D clippingRect) {
         saveGraphicsState();
         // Set the given CTM in the graphics state
-        currentState.concatenate(
+        paintingState.concatenate(
                 new AffineTransform(CTMHelper.toPDFArray(ctm)));
 
         if (clippingRect != null) {
@@ -828,7 +828,7 @@
     /** {@inheritDoc} */
     protected void concatenateTransformationMatrix(AffineTransform at) {
         if (!at.isIdentity()) {
-            currentState.concatenate(at);
+            paintingState.concatenate(at);
             currentStream.add(CTMHelper.toPDFString(at, false) + " cm\n");
         }
     }
@@ -1018,7 +1018,7 @@
      * @param width line width in points
      */
     private void updateLineWidth(float width) {
-        if (currentState.setLineWidth(width)) {
+        if (paintingState.setLineWidth(width)) {
             //Only write if value has changed WRT the current line width
             currentStream.add(format(width) + " w\n");
         }
@@ -1069,10 +1069,10 @@
     /**
      * {@inheritDoc}
      */
-    protected void fillRect(float x, float y, float w, float h) {
-        if (w != 0 && h != 0) {
+    protected void fillRect(float x, float y, float width, float height) {
+        if (width > 0 && height > 0) {
             currentStream.add(format(x) + " " + format(y) + " "
-                    + format(w) + " " + format(h) + " re f\n");
+                    + format(width) + " " + format(height) + " re f\n");
         }
     }
 
@@ -1094,11 +1094,12 @@
      * @return the saved state stack to recreate later
      */
     protected List breakOutOfStateStack() {
+//        return currentState.popAll();
         List breakOutList = new java.util.ArrayList();
-        PDFState.Data data;
+        AbstractPaintingState.AbstractData data;
         while (true) {
-            data = currentState.getData();
-            if (currentState.pop() == null) {
+            data = paintingState.getData();
+            if (paintingState.restore() == null) {
                 break;
             }
             if (breakOutList.size() == 0) {
@@ -1116,10 +1117,11 @@
      */
     protected void restoreStateStackAfterBreakOut(List breakOutList) {
         comment("------ restoring context after break-out...");
-        PDFState.Data data;
+//        currentState.pushAll(breakOutList);
+        AbstractData data;
         Iterator i = breakOutList.iterator();
         while (i.hasNext()) {
-            data = (PDFState.Data)i.next();
+            data = (AbstractData)i.next();
             saveGraphicsState();
             AffineTransform at = data.getTransform();
             concatenateTransformationMatrix(at);
@@ -1259,7 +1261,7 @@
      */
     protected void saveAbsolutePosition(String id, int relativeIPP, int relativeBPP) {
         saveAbsolutePosition(id, currentPageRef,
-                             relativeIPP, relativeBPP, currentState.getTransform());
+                             relativeIPP, relativeBPP, paintingState.getTransform());
     }
 
     /**
@@ -1283,8 +1285,8 @@
                 bpp += currentBPPosition;
             }
             AffineTransform tf = positioning == Block.FIXED
-                ? currentState.getBaseTransform()
-                : currentState.getTransform();
+                ? paintingState.getBaseTransform()
+                : paintingState.getTransform();
             saveAbsolutePosition(id, currentPageRef, ipp, bpp, tf);
         }
     }
@@ -1347,7 +1349,7 @@
             int bpp = currentBPPosition + ip.getOffset();
             ipRect = new Rectangle2D.Float(ipp / 1000f, bpp / 1000f,
                                            ip.getIPD() / 1000f, ip.getBPD() / 1000f);
-            AffineTransform transform = currentState.getTransform();
+            AffineTransform transform = paintingState.getTransform();
             ipRect = transform.createTransformedShape(ipRect).getBounds2D();
 
             factory = pdfDoc.getFactory();
@@ -1581,9 +1583,9 @@
         }
         boolean update = false;
         if (fill) {
-            update = currentState.setBackColor(col);
+            update = paintingState.setBackColor(col);
         } else {
-            update = currentState.setColor(col);
+            update = paintingState.setColor(col);
         }
 
         if (update) {
@@ -1656,7 +1658,8 @@
                         info, imageHandlerRegistry.getSupportedFlavors(), hints, sessionContext);
 
             //First check for a dynamically registered handler
-            PDFImageHandler handler = imageHandlerRegistry.getHandler(img.getClass());
+            PDFImageHandler handler
+                = (PDFImageHandler)imageHandlerRegistry.getHandler(img.getClass());
             if (handler != null) {
                 if (log.isDebugEnabled()) {
                     log.debug("Using PDFImageHandler: " + handler.getClass().getName());
@@ -1695,6 +1698,7 @@
             this.pdfDoc.output(ostream);
         } catch (IOException ioe) {
             // ioexception will be caught later
+            log.error(ioe.getMessage());
         }
     }
 
@@ -1723,7 +1727,7 @@
                 x, y, width, height, foreignAttributes);
         context.setProperty(PDFRendererContextConstants.PDF_DOCUMENT, pdfDoc);
         context.setProperty(PDFRendererContextConstants.OUTPUT_STREAM, ostream);
-        context.setProperty(PDFRendererContextConstants.PDF_STATE, currentState);
+        context.setProperty(PDFRendererContextConstants.PDF_PAINTING_STATE, paintingState);
         context.setProperty(PDFRendererContextConstants.PDF_PAGE, currentPage);
         context.setProperty(PDFRendererContextConstants.PDF_CONTEXT,
                     currentContext == null ? currentPage : currentContext);
@@ -1743,7 +1747,7 @@
     public void renderLeader(Leader area) {
         renderInlineAreaBackAndBorders(area);
 
-        currentState.push();
+        paintingState.save();
         saveGraphicsState();
         int style = area.getRuleStyle();
         float startx = (currentIPPosition + area.getBorderAndPaddingWidthStart()) / 1000f;
@@ -1801,7 +1805,7 @@
         }
 
         restoreGraphicsState();
-        currentState.pop();
+        paintingState.restore();
         beginTextObject();
         super.renderLeader(area);
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java Fri Nov 28 03:13:12 2008
@@ -42,6 +42,7 @@
 
     /**
      * Default constructor
+     * 
      * @param userAgent user agent
      */
     public PDFRendererConfigurator(FOUserAgent userAgent) {
@@ -52,6 +53,7 @@
      * Configure the PDF renderer.
      * Get the configuration to be used for pdf stream filters,
      * fonts etc.
+     * 
      * @param renderer pdf renderer
      * @throws FOPException fop exception
      */
@@ -79,7 +81,8 @@
             if (s != null) {
                 pdfRenderer.setXMode(PDFXMode.valueOf(s));
             }
-            Configuration encryptionParamsConfig = cfg.getChild(PDFRenderer.ENCRYPTION_PARAMS, false);
+            Configuration encryptionParamsConfig
+                = cfg.getChild(PDFRenderer.ENCRYPTION_PARAMS, false);
             if (encryptionParamsConfig != null) {
                 PDFEncryptionParams encryptionParams = new PDFEncryptionParams();
                 Configuration ownerPasswordConfig = encryptionParamsConfig.getChild(
@@ -124,15 +127,18 @@
             if (s != null) {
                 pdfRenderer.setOutputProfileURI(s);
             }
-            Configuration disableColorSpaceConfig = cfg.getChild(PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false);
+            Configuration disableColorSpaceConfig = cfg.getChild(
+                    PDFRenderer.KEY_DISABLE_SRGB_COLORSPACE, false);
             if (disableColorSpaceConfig != null) {
-                pdfRenderer.disableSRGBColorSpace = disableColorSpaceConfig.getValueAsBoolean(false);
+                pdfRenderer.disableSRGBColorSpace
+                    = disableColorSpaceConfig.getValueAsBoolean(false);
             }
         }
     }
 
     /**
      * Builds a filter map from an Avalon Configuration object.
+     * 
      * @param cfg the Configuration object
      * @return Map the newly built filter map
      * @throws ConfigurationException if a filter list is defined twice

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererContextConstants.java Fri Nov 28 03:13:12 2008
@@ -29,8 +29,8 @@
     /** The PDF document that this image is being drawn into. */
     String PDF_DOCUMENT = "pdfDoc";
 
-    /** The current pdf state. */
-    String PDF_STATE = "pdfState";
+    /** The current PDF painting state. */
+    String PDF_PAINTING_STATE = "pdfPaintingState";
 
     /** The current PDF page for page renference and as a resource context. */
     String PDF_PAGE = "pdfPage";

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFSVGHandler.java Fri Nov 28 03:13:12 2008
@@ -25,8 +25,6 @@
 import java.io.OutputStream;
 import java.util.Map;
 
-import org.w3c.dom.Document;
-
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.batik.bridge.BridgeContext;
 import org.apache.batik.bridge.GVTBuilder;
@@ -35,16 +33,12 @@
 import org.apache.batik.util.SVGConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
-import org.apache.xmlgraphics.util.QName;
-
 import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.fo.extensions.ExtensionElementMapping;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.pdf.PDFDocument;
 import org.apache.fop.pdf.PDFPage;
+import org.apache.fop.pdf.PDFPaintingState;
 import org.apache.fop.pdf.PDFResourceContext;
-import org.apache.fop.pdf.PDFState;
 import org.apache.fop.pdf.PDFStream;
 import org.apache.fop.render.AbstractGenericSVGHandler;
 import org.apache.fop.render.Renderer;
@@ -55,6 +49,7 @@
 import org.apache.fop.svg.PDFGraphics2D;
 import org.apache.fop.svg.SVGEventProducer;
 import org.apache.fop.svg.SVGUserAgent;
+import org.w3c.dom.Document;
 
 /**
  * PDF XML handler for SVG (uses Apache Batik).
@@ -78,7 +73,7 @@
         PDFInfo pdfi = new PDFInfo();
         pdfi.pdfDoc = (PDFDocument)context.getProperty(PDF_DOCUMENT);
         pdfi.outputStream = (OutputStream)context.getProperty(OUTPUT_STREAM);
-        pdfi.pdfState = (PDFState)context.getProperty(PDF_STATE);
+        pdfi.pdfPaintingState = (PDFPaintingState)context.getProperty(PDF_PAINTING_STATE);
         pdfi.pdfPage = (PDFPage)context.getProperty(PDF_PAGE);
         pdfi.pdfContext = (PDFResourceContext)context.getProperty(PDF_CONTEXT);
         pdfi.currentStream = (PDFStream)context.getProperty(PDF_STREAM);
@@ -91,9 +86,9 @@
         pdfi.currentYPosition = ((Integer)context.getProperty(YPOS)).intValue();
         pdfi.cfg = (Configuration)context.getProperty(HANDLER_CONFIGURATION);
         Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES);
-        QName qName = new QName(ExtensionElementMapping.URI, null, "conversion-mode");
+
         if (foreign != null
-                && "bitmap".equalsIgnoreCase((String)foreign.get(qName))) {
+                && BITMAP.equalsIgnoreCase((String)foreign.get(CONVERSION_MODE))) {
             pdfi.paintAsBitmap = true;
         }
         return pdfi;
@@ -108,7 +103,7 @@
         /** see OUTPUT_STREAM */
         public OutputStream outputStream;
         /** see PDF_STATE */
-        public PDFState pdfState;
+        public PDFPaintingState pdfPaintingState;
         /** see PDF_PAGE */
         public PDFPage pdfPage;
         /** see PDF_CONTEXT */
@@ -198,8 +193,8 @@
         float w = (float)ctx.getDocumentSize().getWidth() * 1000f;
         float h = (float)ctx.getDocumentSize().getHeight() * 1000f;
 
-        float sx = pdfInfo.width / (float)w;
-        float sy = pdfInfo.height / (float)h;
+        float sx = pdfInfo.width / w;
+        float sy = pdfInfo.height / h;
 
         //Scaling and translation for the bounding box of the image
         AffineTransform scaling = new AffineTransform(
@@ -248,16 +243,16 @@
         pdfInfo.currentStream.add("%SVG start\n");
 
         //Save state and update coordinate system for the SVG image
-        pdfInfo.pdfState.push();
-        pdfInfo.pdfState.concatenate(imageTransform);
+        pdfInfo.pdfPaintingState.save();
+        pdfInfo.pdfPaintingState.concatenate(imageTransform);
 
         //Now that we have the complete transformation matrix for the image, we can update the
         //transformation matrix for the AElementBridge.
         PDFAElementBridge aBridge = (PDFAElementBridge)ctx.getBridge(
                 SVGDOMImplementation.SVG_NAMESPACE_URI, SVGConstants.SVG_A_TAG);
-        aBridge.getCurrentTransform().setTransform(pdfInfo.pdfState.getTransform());
+        aBridge.getCurrentTransform().setTransform(pdfInfo.pdfPaintingState.getTransform());
 
-        graphics.setPDFState(pdfInfo.pdfState);
+        graphics.setPaintingState(pdfInfo.pdfPaintingState);
         graphics.setOutputStream(pdfInfo.outputStream);
         try {
             root.paint(graphics);
@@ -267,7 +262,7 @@
                     context.getUserAgent().getEventBroadcaster());
             eventProducer.svgRenderingError(this, e, getDocumentURI(doc));
         }
-        pdfInfo.pdfState.pop();
+        pdfInfo.pdfPaintingState.restore();
         renderer.restoreGraphicsState();
         pdfInfo.currentStream.add("%SVG end\n");
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSGraphics2DAdapter.java Fri Nov 28 03:13:12 2008
@@ -33,6 +33,7 @@
 
 import org.apache.fop.fo.extensions.ExtensionElementMapping;
 import org.apache.fop.render.AbstractGraphics2DAdapter;
+import org.apache.fop.render.Graphics2DAdapter;
 import org.apache.fop.render.RendererContext;
 import org.apache.fop.render.RendererContextConstants;
 import org.apache.fop.render.RendererContext.RendererContextWrapper;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java Fri Nov 28 03:13:12 2008
@@ -19,41 +19,35 @@
 
 package org.apache.fop.render.ps;
 
+import java.awt.Color;
 import java.awt.Graphics2D;
+import java.awt.Paint;
+import java.awt.Shape;
+import java.awt.Stroke;
+import java.awt.font.TextAttribute;
 import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
-/* java.awt.Font is not imported to avoid confusion with
-   org.apache.fop.fonts.Font */
-
+import java.io.IOException;
 import java.text.AttributedCharacterIterator;
 import java.text.CharacterIterator;
-import java.awt.font.TextAttribute;
-import java.awt.Shape;
-import java.awt.Paint;
-import java.awt.Stroke;
-import java.awt.Color;
-import java.io.IOException;
-import java.util.List;
 import java.util.Iterator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
-import org.apache.xmlgraphics.java2d.TextHandler;
+import java.util.List;
 
 import org.apache.batik.dom.svg.SVGOMTextElement;
-import org.apache.batik.gvt.text.Mark;
-import org.apache.batik.gvt.TextPainter;
 import org.apache.batik.gvt.TextNode;
-import org.apache.batik.gvt.text.GVTAttributedCharacterIterator;
-import org.apache.batik.gvt.text.TextPaintInfo;
+import org.apache.batik.gvt.TextPainter;
 import org.apache.batik.gvt.font.GVTFontFamily;
 import org.apache.batik.gvt.renderer.StrokingTextPainter;
-
+import org.apache.batik.gvt.text.GVTAttributedCharacterIterator;
+import org.apache.batik.gvt.text.Mark;
+import org.apache.batik.gvt.text.TextPaintInfo;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontTriplet;
+import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
+
 
 /**
  * Renders the attributed character iterator of a <tt>TextNode</tt>.
@@ -74,8 +68,8 @@
     /** the logger for this class */
     protected Log log = LogFactory.getLog(PSTextPainter.class);
 
-    private NativeTextHandler nativeTextHandler;
-    private FontInfo fontInfo;
+    private final NativeTextHandler nativeTextHandler;
+    private final FontInfo fontInfo;
 
     /**
      * Use the stroking text painter to get the bounds and shape.
@@ -317,7 +311,7 @@
         }
 
         drawPrimitiveString(g2d, loc, font, txt, tx);
-        loc.setLocation(loc.getX() + (double)advance, loc.getY());
+        loc.setLocation(loc.getX() + advance, loc.getY());
         return loc;
     }
 
@@ -422,7 +416,7 @@
             fStyle |= java.awt.Font.ITALIC;
         }
         return new java.awt.Font(font.getFontName(), fStyle,
-                             (int)(font.getFontSize() / 1000));
+                             (font.getFontSize() / 1000));
     }
 
     private float getStringWidth(String str, Font font) {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/extensions/PSCommentAfterElement.java Fri Nov 28 03:13:12 2008
@@ -43,7 +43,7 @@
      * @see org.apache.fop.fo.FONode#getLocalName()
      */
     public String getLocalName() {
-        return ELEMENT;
+        return PSCommentAfter.ELEMENT;
     }
 
     /**

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/extensions/PSCommentBeforeElement.java Fri Nov 28 03:13:12 2008
@@ -43,7 +43,7 @@
      * @see org.apache.fop.fo.FONode#getLocalName()
      */
     public String getLocalName() {
-        return ELEMENT;
+        return PSCommentBefore.ELEMENT;
     }
 
     /**



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