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 [3/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/area/inline/Viewport.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/Viewport.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/Viewport.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/Viewport.java Fri Nov 28 03:13:12 2008
@@ -45,7 +45,7 @@
      * @param child the child content area of this viewport
      */
     public Viewport(Area child) {
-        content = child;
+        this.content = child;
     }
 
     /**
@@ -54,7 +54,7 @@
      * @param c true if this viewport should clip
      */
     public void setClip(boolean c) {
-        clip = c;
+        this.clip = c;
     }
 
     /**
@@ -63,7 +63,7 @@
      * @return true if this viewport should clip
      */
     public boolean getClip() {
-        return clip;
+        return this.clip;
     }
 
     /**
@@ -72,7 +72,7 @@
      * @param cp the position and size to place the content
      */
     public void setContentPosition(Rectangle2D cp) {
-        contentPosition = cp;
+        this.contentPosition = cp;
     }
 
     /**
@@ -81,7 +81,7 @@
      * @return the position and size to place the content
      */
     public Rectangle2D getContentPosition() {
-        return contentPosition;
+        return this.contentPosition;
     }
 
     /**
@@ -98,7 +98,7 @@
      * @return the content area
      */
     public Area getContent() {
-        return content;
+        return this.content;
     }
 
     private void writeObject(java.io.ObjectOutputStream out)
@@ -123,9 +123,9 @@
                                                     in.readFloat(),
                                                     in.readFloat());
         }
-        clip = in.readBoolean();
-        props = (HashMap) in.readObject();
-        content = (Area) in.readObject();
+        this.clip = in.readBoolean();
+        this.props = (HashMap) in.readObject();
+        this.content = (Area) in.readObject();
     }
 
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/cli/InputHandler.java Fri Nov 28 03:13:12 2008
@@ -51,6 +51,9 @@
 import org.apache.fop.apps.Fop;
 import org.apache.fop.apps.FopFactory;
 import org.apache.fop.render.awt.viewer.Renderable;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
 
 /**
  * Class for handling files input from command line

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/events/EventFormatter.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/events/EventFormatter.xml?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/events/EventFormatter.xml (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/events/EventFormatter.xml Fri Nov 28 03:13:12 2008
@@ -26,6 +26,7 @@
   <message key="rule.childOfSPM">The element must be a child of fo:simple-page-master.</message>
   <message key="rule.childOfDeclarations">The element must be a child of fo:declarations.</message>
   <message key="rule.childOfSPMorDeclarations">The element must be a child of fo:declarations or fo:simple-page-master.</message>
+  <message key="rule.childOfInstreamForeignObjectorExternalGraphic">The element must be a child of fo:instream-foreign-object or fo:external-graphic.</message>
   <message key="rule.wrapperInvalidChildForParent">An fo:wrapper is only permitted to have children that would be permitted for its parent.</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.tooManyNodes">For "{elementName}", only one "{offendingNode}" may be declared.{{locator}}</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.nodeOutOfOrder">For "{elementName}", "{tooLateNode}" must be declared before "{tooEarlyNode}"!{{locator}}</message>
@@ -102,4 +103,7 @@
   <message key="org.apache.fop.fonts.FontEventAdapter.fontSubstituted">Font "{requested}" not found. Substituting with "{effective}".</message>
   <message key="org.apache.fop.fonts.FontEventAdapter.fontLoadingErrorAtAutoDetection">Unable to load font file: {fontURL}.[ Reason: {e}]</message>
   <message key="org.apache.fop.fonts.FontEventAdapter.glyphNotAvailable">Glyph "{ch}" (0x{ch,hex}[, {ch,glyph-name}]) not available in font "{fontName}".</message>
+<message key="org.apache.fop.afp.AFPEventProducer.warnDefaultFontSetup"/>
+<message key="org.apache.fop.afp.AFPEventProducer.warnMissingDefaultFont"/>
+<message key="org.apache.fop.afp.AFPEventProducer.characterSetEncodingError"/>
 </catalogue>

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMapping.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMapping.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/ElementMapping.java Fri Nov 28 03:13:12 2008
@@ -19,7 +19,7 @@
 
 package org.apache.fop.fo;
 
-import java.util.HashMap;
+import java.util.Map;
 
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
@@ -38,7 +38,7 @@
     public static final String DEFAULT = "<default>";
 
     /** The HashMap table of formatting objects defined by the ElementMapping */
-    protected HashMap foObjs = null;
+    protected Map foObjs = null;
 
     /** The namespace for the ElementMapping */
     protected String namespaceURI = null;
@@ -48,7 +48,7 @@
      *
      * @return Table of Maker objects for this ElementMapping
      */
-    public HashMap getTable() {
+    public Map getTable() {
         if (foObjs == null) {
             initialize();
         }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FObj.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FObj.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FObj.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FObj.java Fri Nov 28 03:13:12 2008
@@ -573,6 +573,11 @@
         }
     }
 
+    /** @return true if this FObj has extension attachments */ 
+    public boolean hasExtensionAttachments() {
+        return extensionAttachments != null;
+    }
+    
     /**
      * Adds a foreign attribute to this FObj.
      * @param attributeName the attribute name as a QName instance

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Base14Font.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Base14Font.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Base14Font.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Base14Font.java Fri Nov 28 03:13:12 2008
@@ -19,6 +19,7 @@
 
 package org.apache.fop.fonts;
 
+
 /**
  * Base class for all Base 14 fonts.
  */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CIDFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CIDFont.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CIDFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CIDFont.java Fri Nov 28 03:13:12 2008
@@ -76,4 +76,4 @@
         return true;
     }
 
-}
\ No newline at end of file
+}

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFont.java Fri Nov 28 03:13:12 2008
@@ -26,6 +26,7 @@
 
 import javax.xml.transform.Source;
 
+
 /**
  * Abstract base class for custom fonts loaded from files, for example.
  */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Font.java Fri Nov 28 03:13:12 2008
@@ -23,6 +23,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fop.fonts.CodePointMapping;
 
 /**
  * This class holds font state information and provides access to the font

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontCollection.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontCollection.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontCollection.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontCollection.java Fri Nov 28 03:13:12 2008
@@ -24,6 +24,7 @@
  * Sets up a set of fonts
  */
 public interface FontCollection {
+
     /**
      * Sets up fonts in a font info object.
      *

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontDescriptor.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontDescriptor.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontDescriptor.java Fri Nov 28 03:13:12 2008
@@ -19,6 +19,7 @@
 
 package org.apache.fop.fonts;
 
+
 /**
  * This interface enhances the font metrics interface with access methods to
  * value needed to register fonts in various target formats like PDF or

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontEventListener.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontEventListener.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontEventListener.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontEventListener.java Fri Nov 28 03:13:12 2008
@@ -19,7 +19,6 @@
 
 package org.apache.fop.fonts;
 
-
 /**
  * Event listener interface for font-related events.
  */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontInfo.java Fri Nov 28 03:13:12 2008
@@ -110,6 +110,19 @@
     }
 
     /**
+     * Adds a series of new font triplets given an array of font family names.
+     * @param name internal key
+     * @param families an array of font family names
+     * @param style font style (normal, italic, oblique...)
+     * @param weight font weight
+     */
+    public void addFontProperties(String name, String[] families, String style, int weight) {
+        for (int i = 0; i < families.length; i++) {
+            addFontProperties(name, families[i], style, weight);
+        }
+    }
+
+    /**
      * Adds a new font triplet.
      * @param internalFontKey internal font key
      * @param triplet the font triplet to associate with the internal key
@@ -193,7 +206,8 @@
     private FontTriplet fontLookup(String family, String style,
                              int weight, boolean substitutable) {
         if (log.isTraceEnabled()) {
-            log.trace("Font lookup: " + family + " " + style + " " + weight);
+            log.trace("Font lookup: " + family + " " + style + " " + weight
+                    + (substitutable ? " substitutable" : ""));
         }
 
         FontTriplet startKey = createFontKey(family, style, weight);
@@ -215,7 +229,7 @@
     }
 
     private FontTriplet fuzzyFontLookup(String family, String style,
-            int weight, FontTriplet startKey, boolean substFont) {
+            int weight, FontTriplet startKey, boolean substitutable) {
         FontTriplet key;
         String internalFontKey = null;
         if (!family.equals(startKey.getName())) {
@@ -232,7 +246,8 @@
             internalFontKey = getInternalFontKey(key);
         }
 
-        if (!substFont && internalFontKey == null) {
+        // return null if not found and not substitutable
+        if (!substitutable && internalFontKey == null) {
             return null;
         }
 
@@ -263,18 +278,18 @@
 
         // fallback 2: try the same font-family with default style and weight
         /* obsolete: replaced by the loop above
-        if (f == null) {
+        if (internalFontKey == null) {
             key = createFontKey(family, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
-            f = getInternalFontKey(key);
+            internalFontKey = getInternalFontKey(key);
         }*/
 
-        // fallback 3: try any family with orig style/weight
+        // fallback 3: try any family with original style/weight
         if (internalFontKey == null) {
             return fuzzyFontLookup("any", style, weight, startKey, false);
         }
 
         // last resort: use default
-        if (internalFontKey == null) {
+        if (key == null && internalFontKey == null) {
             key = Font.DEFAULT_FONT;
             internalFontKey = getInternalFontKey(key);
         }
@@ -303,6 +318,7 @@
 
     /**
      * Retrieves a (possibly cached) Font instance based on a FontTriplet and a font size.
+     *
      * @param triplet the font triplet designating the requested font
      * @param fontSize the font size
      * @return the requested Font instance
@@ -326,6 +342,57 @@
         return font;
     }
 
+    private List/*<FontTriplet>*/ getTripletsForName(String fontName) {
+        List/*<FontTriplet>*/ matchedTriplets = new java.util.ArrayList/*<FontTriplet>*/();
+        Iterator it = triplets.keySet().iterator();
+        while (it.hasNext()) {
+            FontTriplet triplet = (FontTriplet)it.next();
+            String tripletName = triplet.getName();
+            if (tripletName.toLowerCase().equals(fontName.toLowerCase())) {
+                matchedTriplets.add(triplet);
+            }
+        }
+        return matchedTriplets;
+    }
+
+    /**
+     * Returns a suitable internal font given an AWT Font instance.
+     *
+     * @param awtFont the AWT font
+     * @return a best matching internal Font
+     */
+    public Font getFontInstanceForAWTFont(java.awt.Font awtFont) {
+        String awtFontName = awtFont.getName();
+        String awtFontFamily = awtFont.getFamily();
+        String awtFontStyle = awtFont.isItalic() ? Font.STYLE_ITALIC : Font.STYLE_NORMAL;
+        int awtFontWeight = awtFont.isBold() ? Font.WEIGHT_BOLD : Font.WEIGHT_NORMAL;
+
+        FontTriplet matchedTriplet = null;
+        List/*<FontTriplet>*/ triplets = getTripletsForName(awtFontName);
+        if (!triplets.isEmpty()) {
+            Iterator it = triplets.iterator();
+            while (it.hasNext()) {
+                FontTriplet triplet = (FontTriplet)it.next();
+                boolean styleMatched = triplet.getStyle().equals(awtFontStyle);
+                boolean weightMatched = triplet.getWeight() == awtFontWeight;
+                if (styleMatched && weightMatched) {
+                    matchedTriplet = triplet;
+                    break;
+                }
+            }
+        }
+
+        // not matched on font name so do a lookup using family
+        if (matchedTriplet == null) {
+            if (awtFontFamily.equals("sanserif")) {
+                awtFontFamily = "sans-serif";
+            }
+            matchedTriplet = fontLookup(awtFontFamily, awtFontStyle, awtFontWeight);
+        }
+        int fontSize = Math.round(awtFont.getSize2D() * 1000);
+        return getFontInstance(matchedTriplet, fontSize);
+    }
+
     /**
      * Lookup a font.
      * <br>
@@ -345,7 +412,7 @@
 
     private List/*<FontTriplet>*/ fontLookup(String[] families, String style,
             int weight, boolean substitutable) {
-        List matchingTriplets = new java.util.ArrayList();
+        List/*<FontTriplet>*/ matchingTriplets = new java.util.ArrayList/*<FontTriplet>*/();
         FontTriplet triplet = null;
         for (int i = 0; i < families.length; i++) {
             triplet = fontLookup(families[i], style, weight, substitutable);
@@ -555,7 +622,7 @@
         List/*<FontTriplet>*/ foundTriplets = new java.util.ArrayList();
         for (Iterator iter = triplets.entrySet().iterator(); iter.hasNext();) {
             Map.Entry tripletEntry = (Map.Entry) iter.next();
-            if (fontName.equals(((String)tripletEntry.getValue()))) {
+            if (fontName.equals((tripletEntry.getValue()))) {
                 foundTriplets.add(tripletEntry.getKey());
             }
         }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontMetrics.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontMetrics.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontMetrics.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontMetrics.java Fri Nov 28 03:13:12 2008
@@ -23,6 +23,7 @@
 import java.util.Set;
 
 
+
 /**
  * Main interface for access to font metrics.
  */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontTriplet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontTriplet.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontTriplet.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontTriplet.java Fri Nov 28 03:13:12 2008
@@ -21,6 +21,7 @@
 
 import java.io.Serializable;
 
+
 /**
  * FontTriplet contains information on name, style and weight of one font
  */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontType.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontType.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontType.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontType.java Fri Nov 28 03:13:12 2008
@@ -19,12 +19,10 @@
 
 package org.apache.fop.fonts;
 
-import org.apache.avalon.framework.ValuedEnum;
-
 /**
  * This class enumerates all supported font types.
  */
-public class FontType extends ValuedEnum {
+public class FontType {
 
     /**
      * Collective identifier for "other" font types
@@ -51,12 +49,16 @@
      */
     public static final FontType TRUETYPE    = new FontType("TrueType", 5);
 
+    private final String name;
+    private final int value;
+
 
     /**
      * @see org.apache.avalon.framework.Enum#Enum(String)
      */
     protected FontType(String name, int value) {
-        super(name, value);
+        this.name = name;
+        this.value = value;
     }
 
 
@@ -107,4 +109,22 @@
         }
     }
 
+    /**
+     * Returns the name
+     *
+     * @return the name
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Returns the value
+     *
+     * @return the value
+     */
+    public int getValue() {
+        return value;
+    }
+
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUtil.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUtil.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontUtil.java Fri Nov 28 03:13:12 2008
@@ -19,6 +19,7 @@
 
 package org.apache.fop.fonts;
 
+
 /**
  * Font utilities.
  */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MultiByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MultiByteFont.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MultiByteFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MultiByteFont.java Fri Nov 28 03:13:12 2008
@@ -23,6 +23,7 @@
 import java.text.DecimalFormat;
 import java.util.Map;
 
+
 /**
  * Generic MultiByte (CID) font
  */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MutableFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MutableFont.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MutableFont.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/MutableFont.java Fri Nov 28 03:13:12 2008
@@ -23,6 +23,7 @@
 import java.util.Set;
 
 
+
 /**
  * This interface is used to set the values of a font during configuration time.
  */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java Fri Nov 28 03:13:12 2008
@@ -139,4 +139,9 @@
             }
         }
     }
+    
+    /** {@inheritDoc} */
+    public String toString() {
+        return getFullName();
+    }   
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/package.html
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/package.html?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/package.html (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/package.html Fri Nov 28 03:13:12 2008
@@ -1,3 +1,20 @@
+<!--
+  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.html 643433 2008-04-01 15:08:24Z acumiskey $ -->
 <HTML>
 <TITLE>org.apache.fop.fonts Package</TITLE>
 <BODY>

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java Fri Nov 28 03:13:12 2008
@@ -20,9 +20,7 @@
 package org.apache.fop.image.loader.batik;
 
 import java.awt.Dimension;
-import java.awt.Graphics2D;
 import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
 import java.util.Map;
 
 import org.apache.batik.bridge.BridgeContext;
@@ -36,6 +34,7 @@
 import org.apache.xmlgraphics.image.loader.Image;
 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.ImageProcessingHints;
 import org.apache.xmlgraphics.image.loader.XMLNamespaceEnabledImageFlavor;
 import org.apache.xmlgraphics.image.loader.impl.AbstractImageConverter;
@@ -58,7 +57,7 @@
     private static Log log = LogFactory.getLog(ImageConverterSVG2G2D.class);
 
     /** {@inheritDoc} */
-    public Image convert(Image src, Map hints) throws ImageException {
+    public Image convert(final Image src, Map hints) throws ImageException {
         checkSourceFlavor(src);
         final ImageXMLDOM svg = (ImageXMLDOM)src;
         if (!SVGDOMImplementation.SVG_NAMESPACE_URI.equals(svg.getRootNamespace())) {
@@ -85,28 +84,14 @@
         }
 
         //Create the painter
-        Graphics2DImagePainter painter = new Graphics2DImagePainter() {
-
-            public void paint(Graphics2D g2d, Rectangle2D area) {
-                // If no viewbox is defined in the svg file, a viewbox of 100x100 is
-                // assumed, as defined in SVGUserAgent.getViewportSize()
-                float iw = (float) ctx.getDocumentSize().getWidth();
-                float ih = (float) ctx.getDocumentSize().getHeight();
-                float w = (float) area.getWidth();
-                float h = (float) area.getHeight();
-                g2d.translate(area.getX(), area.getY());
-                g2d.scale(w / iw, h / ih);
-
-                root.paint(g2d);
-            }
-
-            public Dimension getImageSize() {
-                return new Dimension(svg.getSize().getWidthMpt(), svg.getSize().getHeightMpt());
-            }
-
-        };
-
-        ImageGraphics2D g2dImage = new ImageGraphics2D(src.getInfo(), painter);
+        int width = svg.getSize().getWidthMpt();
+        int height = svg.getSize().getHeightMpt();
+        Dimension imageSize = new Dimension(width, height);
+        Graphics2DImagePainter painter = createPainter(ctx, root, imageSize);
+
+        //Create g2d image
+        ImageInfo imageInfo = src.getInfo();
+        ImageGraphics2D g2dImage = new ImageGraphics2D(imageInfo, painter);
         return g2dImage;
     }
 
@@ -129,6 +114,19 @@
         };
     }
 
+    /**
+     * Creates a Graphics 2D image painter
+     *
+     * @param ctx the bridge context
+     * @param root the graphics node root
+     * @param imageSize the image size
+     * @return the newly created graphics 2d image painter
+     */
+    protected Graphics2DImagePainter createPainter(
+            BridgeContext ctx, GraphicsNode root, Dimension imageSize) {
+        return new Graphics2DImagePainterImpl(root, ctx, imageSize);
+    }
+
     /** {@inheritDoc} */
     public ImageFlavor getSourceFlavor() {
         return XMLNamespaceEnabledImageFlavor.SVG_DOM;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/TraitSetter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/TraitSetter.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/TraitSetter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/TraitSetter.java Fri Nov 28 03:13:12 2008
@@ -29,6 +29,7 @@
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonMarginBlock;
+import org.apache.fop.fo.properties.CommonMarginBlock;
 import org.apache.fop.fo.properties.CommonTextDecoration;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
 import org.apache.fop.fonts.Font;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java Fri Nov 28 03:13:12 2008
@@ -20,12 +20,12 @@
 package org.apache.fop.layoutmgr.inline;
 
 import org.apache.fop.fo.flow.PageNumber;
-import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.area.Trait;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontTriplet;
+import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.TextArea;
+import org.apache.fop.area.Trait;
 import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.TraitSetter;
 import org.apache.fop.traits.MinOptMax;

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFPaintingState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFPaintingState.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFPaintingState.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Nov 28 03:13:12 2008
@@ -0,0 +1,3 @@
+/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/pdf/PDFPaintingState.java:630874-721418
+/xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/pdf/PDFState.java:684572,688085,688696
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/PDFState.java:693433-698670,699739,704008-704909,705529-706135,706272-706276,706319-707083,707627,707631-708012,708192-708851

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/package.html
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/package.html?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/package.html (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/package.html Fri Nov 28 03:13:12 2008
@@ -1,3 +1,20 @@
+<!--
+  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.html 643433 2008-04-01 15:08:24Z acumiskey $ -->
 <HTML>
 <TITLE>org.apache.fop.pdf Package</TITLE>
 <BODY>

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractGenericSVGHandler.java Fri Nov 28 03:13:12 2008
@@ -21,26 +21,25 @@
 
 // Java
 import java.awt.Dimension;
-import java.awt.Graphics2D;
 import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
 import java.io.IOException;
 
-import org.w3c.dom.Document;
-
 import org.apache.batik.bridge.BridgeContext;
 import org.apache.batik.bridge.GVTBuilder;
 import org.apache.batik.dom.AbstractDocument;
 import org.apache.batik.dom.svg.SVGDOMImplementation;
 import org.apache.batik.gvt.GraphicsNode;
-
-import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
-import org.apache.xmlgraphics.util.QName;
-
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.events.EventBroadcaster;
 import org.apache.fop.fo.extensions.ExtensionElementMapping;
+import org.apache.fop.image.loader.batik.Graphics2DImagePainterImpl;
 import org.apache.fop.render.RendererContext.RendererContextWrapper;
+import org.apache.fop.render.afp.AFPGraphics2DAdapter;
 import org.apache.fop.svg.SVGEventProducer;
 import org.apache.fop.svg.SVGUserAgent;
+import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
+import org.apache.xmlgraphics.util.QName;
+import org.w3c.dom.Document;
 
 /**
  * Generic XML handler for SVG. Uses Apache Batik for SVG processing and simply paints to
@@ -54,6 +53,9 @@
     protected static final QName CONVERSION_MODE = new QName(
             ExtensionElementMapping.URI, null, "conversion-mode");
 
+    /** "bitmap" value for the "conversion-mode" extension attribute. */
+    protected static final String BITMAP = "bitmap";
+
     /** {@inheritDoc} */
     public void handleXML(RendererContext context,
                 Document doc, String ns) throws Exception {
@@ -64,65 +66,97 @@
     }
 
     /**
-     * Render the SVG document.
-     * @param context the renderer context
-     * @param doc the SVG document
-     * @throws IOException In case of an I/O error while painting the image
+     * Creates a graphics 2D image painter implementation
+     *
+     * @param root the batik graphics node root
+     * @param ctx the batik bridge context
+     * @param imageSize the image size
+     * @return a new graphics 2D image painter implementation
      */
-    protected void renderSVGDocument(final RendererContext context,
-            final Document doc) throws IOException {
-        updateRendererContext(context);
-        final RendererContextWrapper wrappedContext = RendererContext.wrapRendererContext(context);
-        int x = wrappedContext.getCurrentXPosition();
-        int y = wrappedContext.getCurrentYPosition();
+    protected Graphics2DImagePainter createGraphics2DImagePainter(
+            GraphicsNode root, BridgeContext ctx, Dimension imageSize) {
+        return new Graphics2DImagePainterImpl(root, ctx, imageSize);
+    }
 
-        //Prepare
-        SVGUserAgent ua = new SVGUserAgent(
-                context.getUserAgent(),
-                new AffineTransform());
+    /**
+     * Builds the GVT root
+     *
+     * @param rendererContext the renderer context
+     * @param ctx the batik bridge context
+     * @param doc the document
+     * @return a built GVT root tree
+     */
+    protected GraphicsNode buildGraphicsNode(
+            FOUserAgent userAgent, BridgeContext ctx, Document doc) {
         GVTBuilder builder = new GVTBuilder();
-        final BridgeContext ctx = new BridgeContext(ua);
-
-        //Build the GVT tree
         final GraphicsNode root;
         try {
             root = builder.build(ctx, doc);
         } catch (Exception e) {
-            SVGEventProducer eventProducer = SVGEventProducer.Provider.get(
-                    context.getUserAgent().getEventBroadcaster());
-            eventProducer.svgNotBuilt(this, e, getDocumentURI(doc));
-            return;
+            EventBroadcaster eventBroadcaster
+                = userAgent.getEventBroadcaster();
+            SVGEventProducer eventProducer = SVGEventProducer.Provider.get(eventBroadcaster);
+            final String uri = getDocumentURI(doc);
+            eventProducer.svgNotBuilt(this, e, uri);
+            return null;
         }
+        return root;
+    }
 
-        //Create the painter
-        Graphics2DImagePainter painter = new Graphics2DImagePainter() {
+    /**
+     * Returns the image size
+     * @param wrappedContext renderer context wrapper
+     *
+     * @return the image size
+     */
+    protected Dimension getImageSize(RendererContextWrapper wrappedContext) {
+        final int width = wrappedContext.getWidth();
+        final int height = wrappedContext.getHeight();
+        return new Dimension(width, height);
+    }
 
-            public void paint(Graphics2D g2d, Rectangle2D area) {
-                // If no viewbox is defined in the svg file, a viewbox of 100x100 is
-                // assumed, as defined in SVGUserAgent.getViewportSize()
-                float iw = (float) ctx.getDocumentSize().getWidth();
-                float ih = (float) ctx.getDocumentSize().getHeight();
-                float w = (float) area.getWidth();
-                float h = (float) area.getHeight();
-                g2d.scale(w / iw, h / ih);
-
-                root.paint(g2d);
-            }
-
-            public Dimension getImageSize() {
-                return new Dimension(wrappedContext.getWidth(), wrappedContext.getHeight());
-            }
+    /**
+     * 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 {
+        updateRendererContext(rendererContext);
 
-        };
+        //Prepare
+        FOUserAgent userAgent = rendererContext.getUserAgent();
+        SVGUserAgent svgUserAgent = new SVGUserAgent(userAgent, new AffineTransform());
+
+        //Create Batik BridgeContext
+        final BridgeContext bridgeContext = new BridgeContext(svgUserAgent);
+
+        //Build the GVT tree
+
+        final GraphicsNode root = buildGraphicsNode(userAgent, bridgeContext, doc);
+
+        // Create Graphics2DImagePainter
+        final RendererContextWrapper wrappedContext = RendererContext.wrapRendererContext(
+                rendererContext);
+        Dimension imageSize = getImageSize(wrappedContext);
+        final Graphics2DImagePainter painter = createGraphics2DImagePainter(root, bridgeContext, imageSize);
 
         //Let the painter paint the SVG on the Graphics2D instance
-        Graphics2DAdapter adapter = context.getRenderer().getGraphics2DAdapter();
-        adapter.paintImage(painter, context,
-                x, y, wrappedContext.getWidth(), wrappedContext.getHeight());
+        Graphics2DAdapter g2dAdapter = rendererContext.getRenderer().getGraphics2DAdapter();
+
+        //Paint the image
+        final int x = wrappedContext.getCurrentXPosition();
+        final int y = wrappedContext.getCurrentYPosition();
+        final int width = wrappedContext.getWidth();
+        final int height = wrappedContext.getHeight();
+        g2dAdapter.paintImage(painter, rendererContext, x, y, width, height);
     }
 
     /**
      * Gets the document URI from a Document instance if possible.
+     *
      * @param doc the Document
      * @return the URI or null
      */
@@ -138,6 +172,7 @@
     /**
      * Override this method to update the renderer context if it needs special settings for
      * certain conditions.
+     *
      * @param context the renderer context
      */
     protected void updateRendererContext(RendererContext context) {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java Fri Nov 28 03:13:12 2008
@@ -54,8 +54,8 @@
     protected BufferedImage paintToBufferedImage(
             org.apache.xmlgraphics.java2d.Graphics2DImagePainter painter,
              RendererContextWrapper context, int resolution, boolean gray, boolean withAlpha) {
-        int bmw = (int)Math.ceil(UnitConv.mpt2px(context.getWidth(), resolution));
-        int bmh = (int)Math.ceil(UnitConv.mpt2px(context.getHeight(), resolution));
+        int bmw = mpt2px(context.getWidth(), resolution);
+        int bmh = mpt2px(context.getHeight(), resolution);
         BufferedImage bi;
         if (gray) {
             if (withAlpha) {
@@ -102,6 +102,17 @@
         return bi;
     }
 
+    /**
+     * Converts millipoints to pixels
+     *
+     * @param unit the unit to convert in mpts
+     * @param resolution the target resolution
+     * @return the converted unit in pixels
+     */
+    protected int mpt2px(int unit, int resolution) {
+        return (int)Math.ceil(UnitConv.mpt2px(unit, resolution));
+    }
+
     private static BufferedImage createGrayBufferedImageWithAlpha(int width, int height) {
         BufferedImage bi;
         boolean alphaPremultiplied = true;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java Fri Nov 28 03:13:12 2008
@@ -26,13 +26,7 @@
 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.xmlgraphics.util.QName;
-
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
 import org.apache.fop.area.BlockViewport;
@@ -48,7 +42,10 @@
 import org.apache.fop.fo.extensions.ExtensionElementMapping;
 import org.apache.fop.fonts.FontMetrics;
 import org.apache.fop.traits.BorderProps;
+import org.apache.xmlgraphics.image.loader.ImageSize;
+import org.apache.xmlgraphics.util.QName;
 import org.apache.xmlgraphics.util.UnitConv;
+import org.w3c.dom.Document;
 
 /**
  * Abstract base class for renderers like PDF and PostScript where many painting operations
@@ -270,6 +267,11 @@
         drawBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd);
     }
 
+    private static final int BEFORE = 0;
+    private static final int END = 1;
+    private static final int AFTER = 2;
+    private static final int START = 3;
+
     /**
      * Draws borders.
      * @param borderRect the border rectangle
@@ -280,45 +282,46 @@
      */
     protected void drawBorders(Rectangle2D.Float borderRect,
             BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd) {
+        //TODO generalize each of the four conditions into using a parameterized drawBorder()
+        boolean[] border = new boolean[] {
+                (bpsBefore != null), (bpsEnd != null),
+                (bpsAfter != null), (bpsStart != null)};
         float startx = borderRect.x;
         float starty = borderRect.y;
         float width = borderRect.width;
         float height = borderRect.height;
-        boolean[] b = new boolean[] {
-            (bpsBefore != null), (bpsEnd != null),
-            (bpsAfter != null), (bpsStart != null)};
-        if (!b[0] && !b[1] && !b[2] && !b[3]) {
-            return;
-        }
-        float[] bw = new float[] {
-            (b[0] ? bpsBefore.width / 1000f : 0.0f),
-            (b[1] ? bpsEnd.width / 1000f : 0.0f),
-            (b[2] ? bpsAfter.width / 1000f : 0.0f),
-            (b[3] ? bpsStart.width / 1000f : 0.0f)};
+        float[] borderWidth = new float[] {
+            (border[BEFORE] ? bpsBefore.width / 1000f : 0.0f),
+            (border[END] ? bpsEnd.width / 1000f : 0.0f),
+            (border[AFTER] ? bpsAfter.width / 1000f : 0.0f),
+            (border[START] ? bpsStart.width / 1000f : 0.0f)};
         float[] clipw = new float[] {
             BorderProps.getClippedWidth(bpsBefore) / 1000f,
             BorderProps.getClippedWidth(bpsEnd) / 1000f,
             BorderProps.getClippedWidth(bpsAfter) / 1000f,
             BorderProps.getClippedWidth(bpsStart) / 1000f};
-        starty += clipw[0];
-        height -= clipw[0];
-        height -= clipw[2];
-        startx += clipw[3];
-        width -= clipw[3];
-        width -= clipw[1];
+        starty += clipw[BEFORE];
+        height -= clipw[BEFORE];
+        height -= clipw[AFTER];
+        startx += clipw[START];
+        width -= clipw[START];
+        width -= clipw[END];
 
         boolean[] slant = new boolean[] {
-            (b[3] && b[0]), (b[0] && b[1]), (b[1] && b[2]), (b[2] && b[3])};
+            (border[START] && border[BEFORE]),
+            (border[BEFORE] && border[END]),
+            (border[END] && border[AFTER]),
+            (border[AFTER] && border[START])};
         if (bpsBefore != null) {
             endTextObject();
 
             float sx1 = startx;
-            float sx2 = (slant[0] ? sx1 + bw[3] - clipw[3] : sx1);
+            float sx2 = (slant[BEFORE] ? sx1 + borderWidth[START] - clipw[START] : sx1);
             float ex1 = startx + width;
-            float ex2 = (slant[1] ? ex1 - bw[1] + clipw[1] : ex1);
-            float outery = starty - clipw[0];
-            float clipy = outery + clipw[0];
-            float innery = outery + bw[0];
+            float ex2 = (slant[END] ? ex1 - borderWidth[END] + clipw[END] : ex1);
+            float outery = starty - clipw[BEFORE];
+            float clipy = outery + clipw[BEFORE];
+            float innery = outery + borderWidth[BEFORE];
 
             saveGraphicsState();
             moveTo(sx1, clipy);
@@ -326,10 +329,10 @@
             float ex1a = ex1;
             if (bpsBefore.mode == BorderProps.COLLAPSE_OUTER) {
                 if (bpsStart != null && bpsStart.mode == BorderProps.COLLAPSE_OUTER) {
-                    sx1a -= clipw[3];
+                    sx1a -= clipw[START];
                 }
                 if (bpsEnd != null && bpsEnd.mode == BorderProps.COLLAPSE_OUTER) {
-                    ex1a += clipw[1];
+                    ex1a += clipw[END];
                 }
                 lineTo(sx1a, outery);
                 lineTo(ex1a, outery);
@@ -347,12 +350,12 @@
             endTextObject();
 
             float sy1 = starty;
-            float sy2 = (slant[1] ? sy1 + bw[0] - clipw[0] : sy1);
+            float sy2 = (slant[END] ? sy1 + borderWidth[BEFORE] - clipw[BEFORE] : sy1);
             float ey1 = starty + height;
-            float ey2 = (slant[2] ? ey1 - bw[2] + clipw[2] : ey1);
-            float outerx = startx + width + clipw[1];
-            float clipx = outerx - clipw[1];
-            float innerx = outerx - bw[1];
+            float ey2 = (slant[AFTER] ? ey1 - borderWidth[AFTER] + clipw[AFTER] : ey1);
+            float outerx = startx + width + clipw[END];
+            float clipx = outerx - clipw[END];
+            float innerx = outerx - borderWidth[END];
 
             saveGraphicsState();
             moveTo(clipx, sy1);
@@ -360,10 +363,10 @@
             float ey1a = ey1;
             if (bpsEnd.mode == BorderProps.COLLAPSE_OUTER) {
                 if (bpsBefore != null && bpsBefore.mode == BorderProps.COLLAPSE_OUTER) {
-                    sy1a -= clipw[0];
+                    sy1a -= clipw[BEFORE];
                 }
                 if (bpsAfter != null && bpsAfter.mode == BorderProps.COLLAPSE_OUTER) {
-                    ey1a += clipw[2];
+                    ey1a += clipw[AFTER];
                 }
                 lineTo(outerx, sy1a);
                 lineTo(outerx, ey1a);
@@ -380,12 +383,12 @@
             endTextObject();
 
             float sx1 = startx;
-            float sx2 = (slant[3] ? sx1 + bw[3] - clipw[3] : sx1);
+            float sx2 = (slant[START] ? sx1 + borderWidth[AFTER] - clipw[AFTER] : sx1);
             float ex1 = startx + width;
-            float ex2 = (slant[2] ? ex1 - bw[1] + clipw[1] : ex1);
-            float outery = starty + height + clipw[2];
-            float clipy = outery - clipw[2];
-            float innery = outery - bw[2];
+            float ex2 = (slant[AFTER] ? ex1 - borderWidth[END] + clipw[END] : ex1);
+            float outery = starty + height + clipw[AFTER];
+            float clipy = outery - clipw[AFTER];
+            float innery = outery - borderWidth[AFTER];
 
             saveGraphicsState();
             moveTo(ex1, clipy);
@@ -393,10 +396,10 @@
             float ex1a = ex1;
             if (bpsAfter.mode == BorderProps.COLLAPSE_OUTER) {
                 if (bpsStart != null && bpsStart.mode == BorderProps.COLLAPSE_OUTER) {
-                    sx1a -= clipw[3];
+                    sx1a -= clipw[START];
                 }
                 if (bpsEnd != null && bpsEnd.mode == BorderProps.COLLAPSE_OUTER) {
-                    ex1a += clipw[1];
+                    ex1a += clipw[END];
                 }
                 lineTo(ex1a, outery);
                 lineTo(sx1a, outery);
@@ -413,12 +416,12 @@
             endTextObject();
 
             float sy1 = starty;
-            float sy2 = (slant[0] ? sy1 + bw[0] - clipw[0] : sy1);
+            float sy2 = (slant[BEFORE] ? sy1 + borderWidth[BEFORE] - clipw[BEFORE] : sy1);
             float ey1 = sy1 + height;
-            float ey2 = (slant[3] ? ey1 - bw[2] + clipw[2] : ey1);
-            float outerx = startx - clipw[3];
-            float clipx = outerx + clipw[3];
-            float innerx = outerx + bw[3];
+            float ey2 = (slant[START] ? ey1 - borderWidth[AFTER] + clipw[AFTER] : ey1);
+            float outerx = startx - clipw[START];
+            float clipx = outerx + clipw[START];
+            float innerx = outerx + borderWidth[START];
 
             saveGraphicsState();
             moveTo(clipx, ey1);
@@ -426,10 +429,10 @@
             float ey1a = ey1;
             if (bpsStart.mode == BorderProps.COLLAPSE_OUTER) {
                 if (bpsBefore != null && bpsBefore.mode == BorderProps.COLLAPSE_OUTER) {
-                    sy1a -= clipw[0];
+                    sy1a -= clipw[BEFORE];
                 }
                 if (bpsAfter != null && bpsAfter.mode == BorderProps.COLLAPSE_OUTER) {
-                    ey1a += clipw[2];
+                    ey1a += clipw[AFTER];
                 }
                 lineTo(outerx, ey1a);
                 lineTo(outerx, sy1a);
@@ -451,10 +454,6 @@
      * rendered
      */
     protected void renderInlineAreaBackAndBorders(InlineArea area) {
-        float x = currentIPPosition / 1000f;
-        float y = (currentBPPosition + area.getOffset()) / 1000f;
-        float width = area.getIPD() / 1000f;
-        float height = area.getBPD() / 1000f;
         float borderPaddingStart = area.getBorderAndPaddingWidthStart() / 1000f;
         float borderPaddingBefore = area.getBorderAndPaddingWidthBefore() / 1000f;
         float bpwidth = borderPaddingStart
@@ -462,12 +461,15 @@
         float bpheight = borderPaddingBefore
                 + (area.getBorderAndPaddingWidthAfter() / 1000f);
 
+        float height = area.getBPD() / 1000f;
         if (height != 0.0f || bpheight != 0.0f && bpwidth != 0.0f) {
+            float x = currentIPPosition / 1000f;
+            float y = (currentBPPosition + area.getOffset()) / 1000f;
+            float width = area.getIPD() / 1000f;
             drawBackAndBorders(area, x, y - borderPaddingBefore
                                 , width + bpwidth
                                 , height + bpheight);
         }
-
     }
 
     private static final QName FOX_TRANSFORM
@@ -482,26 +484,24 @@
         int saveBP = currentBPPosition;
 
         CTM ctm = bv.getCTM();
-        int borderPaddingStart = bv.getBorderAndPaddingWidthStart();
         int borderPaddingBefore = bv.getBorderAndPaddingWidthBefore();
-        //This is the content-rect
-        float width = bv.getIPD() / 1000f;
-        float height = bv.getBPD() / 1000f;
 
-        if (bv.getPositioning() == Block.ABSOLUTE
-                || bv.getPositioning() == Block.FIXED) {
+        int positioning = bv.getPositioning();
+        if (positioning == Block.ABSOLUTE || positioning == Block.FIXED) {
 
             //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.
             List breakOutList = null;
-            if (bv.getPositioning() == Block.FIXED) {
+            if (positioning == Block.FIXED) {
                 breakOutList = breakOutOfStateStack();
             }
 
             AffineTransform positionTransform = new AffineTransform();
             positionTransform.translate(bv.getXOffset(), bv.getYOffset());
 
+            int borderPaddingStart = bv.getBorderAndPaddingWidthStart();
+
             //"left/"top" (bv.getX/YOffset()) specify the position of the content rectangle
             positionTransform.translate(-borderPaddingStart, -borderPaddingBefore);
 
@@ -513,39 +513,62 @@
                 positionTransform.concatenate(freeTransform);
             }
 
-            saveGraphicsState();
             //Viewport position
-            concatenateTransformationMatrix(UnitConv.mptToPt(positionTransform));
+            if (!positionTransform.isIdentity()) {
+                establishTransformationMatrix(positionTransform);
+            }
+
+            //This is the content-rect
+            float width = bv.getIPD() / 1000f;
+            float height = bv.getBPD() / 1000f;
 
             //Background and borders
-            float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f;
-            float bpheight = (borderPaddingBefore + bv.getBorderAndPaddingWidthAfter()) / 1000f;
-            drawBackAndBorders(bv, 0, 0, width + bpwidth, height + bpheight);
+            float borderPaddingWidth
+                = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f;
+            float borderPaddingHeight
+                = (borderPaddingBefore + bv.getBorderAndPaddingWidthAfter()) / 1000f;
+            drawBackAndBorders(bv, 0, 0, width + borderPaddingWidth, height + borderPaddingHeight);
 
             //Shift to content rectangle after border painting
             AffineTransform contentRectTransform = new AffineTransform();
             contentRectTransform.translate(borderPaddingStart, borderPaddingBefore);
-            concatenateTransformationMatrix(UnitConv.mptToPt(contentRectTransform));
+
+            if (!contentRectTransform.isIdentity()) {
+                establishTransformationMatrix(contentRectTransform);
+            }
 
             //Clipping
             if (bv.getClip()) {
                 clipRect(0f, 0f, width, height);
             }
 
-            saveGraphicsState();
             //Set up coordinate system for content rectangle
             AffineTransform contentTransform = ctm.toAffineTransform();
-            concatenateTransformationMatrix(UnitConv.mptToPt(contentTransform));
+            if (!contentTransform.isIdentity()) {
+                establishTransformationMatrix(contentTransform);
+            }
 
             currentIPPosition = 0;
             currentBPPosition = 0;
             renderBlocks(bv, children);
 
-            restoreGraphicsState();
-            restoreGraphicsState();
+            if (!contentTransform.isIdentity()) {
+                restoreGraphicsState();
+            }
+
+            if (!contentRectTransform.isIdentity()) {
+                restoreGraphicsState();
+            }
+
+            if (!positionTransform.isIdentity()) {
+                restoreGraphicsState();
+            }
 
-            if (breakOutList != null) {
-                restoreStateStackAfterBreakOut(breakOutList);
+            //For FIXED, we need to restore break out now we are done
+            if (positioning == Block.FIXED) {
+                if (breakOutList != null) {
+                    restoreStateStackAfterBreakOut(breakOutList);
+                }
             }
 
             currentIPPosition = saveIP;
@@ -598,8 +621,7 @@
         at.translate(0, block.getSpaceBefore());
 
         if (!at.isIdentity()) {
-            saveGraphicsState();
-            concatenateTransformationMatrix(UnitConv.mptToPt(at));
+            establishTransformationMatrix(at);
         }
 
         currentIPPosition = 0;
@@ -631,8 +653,7 @@
         at.translate(currentIPPosition, currentBPPosition);
 
         if (!at.isIdentity()) {
-            saveGraphicsState();
-            concatenateTransformationMatrix(UnitConv.mptToPt(at));
+            establishTransformationMatrix(at);
         }
 
         currentIPPosition = 0;
@@ -844,4 +865,16 @@
         renderDocument(doc, ns, pos, fo.getForeignAttributes());
     }
 
+    /**
+     * Establishes a new coordinate system with the given transformation matrix.
+     * The current graphics state is saved and the new coordinate system is concatenated.
+     * @param block
+     *
+     * @param at the transformation matrix
+     */
+    protected void establishTransformationMatrix(AffineTransform at) {
+        saveGraphicsState();
+        concatenateTransformationMatrix(UnitConv.mptToPt(at));
+    }
+
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/AbstractRenderer.java Fri Nov 28 03:13:12 2008
@@ -28,11 +28,8 @@
 import java.util.List;
 import java.util.Set;
 
-import org.w3c.dom.Document;
-
 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;
@@ -68,6 +65,7 @@
 import org.apache.fop.events.ResourceEventProducer;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fonts.FontInfo;
+import org.w3c.dom.Document;
 
 /**
  * Abstract base class for all renderers. The Abstract renderer does all the
@@ -504,7 +502,7 @@
      */
     protected void renderBlocks(Block parent, List blocks) {
         int saveIP = currentIPPosition;
-        int saveBP = currentBPPosition;
+//        int saveBP = currentBPPosition;
 
         // Calculate the position of the content rectangle.
         if (parent != null && !parent.getTraitAsBoolean(Trait.IS_VIEWPORT_AREA)) {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRenderer.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/PrintRenderer.java Fri Nov 28 03:13:12 2008
@@ -24,8 +24,6 @@
 import java.util.List;
 import java.util.Map;
 
-import org.w3c.dom.Document;
-
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Trait;
 import org.apache.fop.fonts.CustomFontCollection;
@@ -36,6 +34,7 @@
 import org.apache.fop.fonts.FontResolver;
 import org.apache.fop.fonts.FontTriplet;
 import org.apache.fop.fonts.base14.Base14FontCollection;
+import org.w3c.dom.Document;
 
 /** Abstract base class of "Print" type renderers.  */
 public abstract class PrintRenderer extends AbstractRenderer {
@@ -112,6 +111,14 @@
     }
 
     /**
+     * Instantiates a RendererContext for an image
+     * @return a newly created RendererContext.
+     */
+    protected RendererContext instantiateRendererContext() {
+        return new RendererContext(this, getMimeType());
+    }
+
+    /**
      * Creates a RendererContext for an image.
      * @param x the x coordinate (in millipoints)
      * @param y the y coordinate (in millipoints)
@@ -122,8 +129,7 @@
      */
     protected RendererContext createRendererContext(int x, int y, int width, int height,
             Map foreignAttributes) {
-        RendererContext context;
-        context = new RendererContext(this, getMimeType());
+        RendererContext context = instantiateRendererContext();
         context.setUserAgent(userAgent);
 
         context.setProperty(RendererContextConstants.WIDTH,

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererContext.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererContext.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/RendererContext.java Fri Nov 28 03:13:12 2008
@@ -20,10 +20,12 @@
 package org.apache.fop.render;
 
 //Java
+import java.util.Iterator;
 import java.util.Map;
 
-//FOP
 import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.fo.extensions.ExtensionElementMapping;
+import org.apache.xmlgraphics.util.QName;
 
 /**
  * The Render Context for external handlers. This provides a rendering context
@@ -31,21 +33,28 @@
  * render target.
  */
 public class RendererContext {
+    /** conversion-mode extension attribute */
+    protected static final QName CONVERSION_MODE = new QName(
+            ExtensionElementMapping.URI, null, "conversion-mode");
 
-    private String mime;
-    private AbstractRenderer renderer;
+    /** "bitmap" value for the "conversion-mode" extension attribute. */
+    protected static final String BITMAP = "bitmap";
+
+    private final String mime;
+    private final AbstractRenderer renderer;
     private FOUserAgent userAgent;
-    private Map props = new java.util.HashMap();
+
+    private final Map/*<String,Object>*/ props = new java.util.HashMap/*<String,Object>*/();
 
     /**
-     * Contructor for this class. It takes a MIME type as parameter.
+     * Constructor for this class. It takes a MIME type as parameter.
      *
-     * @param renderer The current renderer
-     * @param m  The MIME type of the output that's generated.
+     * @param renderer the current renderer
+     * @param mime the MIME type of the output that's generated.
      */
-    public RendererContext(AbstractRenderer renderer, String m) {
+    public RendererContext(AbstractRenderer renderer, String mime) {
         this.renderer = renderer;
-        this.mime = m;
+        this.mime = mime;
     }
 
     /**
@@ -113,6 +122,19 @@
         return wrapper;
     }
 
+    /** {@inheritDoc} **/
+    public String toString() {
+        StringBuffer stringBuffer = new StringBuffer("RendererContext{\n");
+        Iterator it = props.keySet().iterator();
+        while (it.hasNext()) {
+            String key = (String)it.next();
+            Object value = props.get(key);
+            stringBuffer.append("\t" + key + "=" + value + "\n");
+        }
+        stringBuffer.append("}");
+        return stringBuffer.toString();
+    }
+
     /**
      * Base class for a wrapper around RendererContext to access its properties in a type-safe,
      * renderer-specific way.
@@ -159,6 +181,19 @@
         public Map getForeignAttributes() {
             return (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES);
         }
+
+        /** {@inheritDoc} */
+        public String toString() {
+            return "RendererContextWrapper{"
+                + "userAgent=" + getUserAgent()
+                + "x=" + getCurrentXPosition()
+                + "y=" + getCurrentYPosition()
+                + "width=" + getWidth()
+                + "height=" + getHeight()
+                + "foreignAttributes=" + getForeignAttributes()
+            + "}";
+
+        }
     }
 }
 

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java
------------------------------------------------------------------------------
    svn:keywords = Revision Id

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Nov 28 03:13:12 2008
@@ -0,0 +1 @@
+/xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/render/afp/AFPForeignAttributeReader.java:684572,688085,688696

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java Fri Nov 28 03:13:12 2008
@@ -19,40 +19,87 @@
 
 package org.apache.fop.render.afp;
 
+import java.awt.Dimension;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
 import java.awt.image.BufferedImage;
 import java.io.IOException;
 
-import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
-
+import org.apache.fop.afp.AFPGraphics2D;
+import org.apache.fop.afp.AFPGraphicsObjectInfo;
+import org.apache.fop.afp.AFPPaintingState;
+import org.apache.fop.afp.AFPResourceManager;
 import org.apache.fop.render.AbstractGraphics2DAdapter;
 import org.apache.fop.render.RendererContext;
+import org.apache.fop.render.RendererContext.RendererContextWrapper;
+import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
 
 /**
  * Graphics2DAdapter implementation for AFP.
  */
 public class AFPGraphics2DAdapter extends AbstractGraphics2DAdapter {
 
+    private final AFPPaintingState paintingState;
+
     /**
      * Main constructor
+     *
+     * @param paintingState the AFP painting state
      */
-    public AFPGraphics2DAdapter() {
+    public AFPGraphics2DAdapter(AFPPaintingState paintingState) {
+        this.paintingState = paintingState;
     }
 
     /** {@inheritDoc} */
     public void paintImage(Graphics2DImagePainter painter,
-            RendererContext context,
+            RendererContext rendererContext,
             int x, int y, int width, int height) throws IOException {
-        RendererContext.RendererContextWrapper wrappedContext
-                = new RendererContext.RendererContextWrapper(context);
-        AFPRenderer afp = (AFPRenderer)context.getRenderer();
-        Boolean grayObj = (Boolean)context.getProperty(AFPRendererContextConstants.AFP_GRAYSCALE);
-        boolean gray = (grayObj != null ? grayObj.booleanValue() : false);
-
-        //Paint to a BufferedImage
-        int resolution = (int)Math.round(context.getUserAgent().getTargetResolution());
-        BufferedImage bi = paintToBufferedImage(painter, wrappedContext, resolution, gray, false);
 
-        afp.drawBufferedImage(bi, resolution, x, y, width, height);
+        AFPRendererContext afpRendererContext = (AFPRendererContext)rendererContext;
+        AFPInfo afpInfo = afpRendererContext.getInfo();
+
+        final boolean textAsShapes = false;
+        AFPGraphics2D g2d = afpInfo.createGraphics2D(textAsShapes);
+
+        paintingState.save();
+
+        //Fallback solution: Paint to a BufferedImage
+        if (afpInfo.paintAsBitmap()) {
+
+            // paint image
+            RendererContextWrapper rendererContextWrapper
+                = RendererContext.wrapRendererContext(rendererContext);
+            float targetResolution = rendererContext.getUserAgent().getTargetResolution();
+            int resolution = Math.round(targetResolution);
+            boolean colorImages = afpInfo.isColorSupported();
+            BufferedImage bufferedImage = paintToBufferedImage(
+                    painter, rendererContextWrapper, resolution, !colorImages, false);
+
+            // draw image
+            AffineTransform at = paintingState.getData().getTransform();
+            at.translate(x, y);
+            g2d.drawImage(bufferedImage, at, null);
+        } else {
+            AFPGraphicsObjectInfo graphicsObjectInfo = new AFPGraphicsObjectInfo();
+            graphicsObjectInfo.setPainter(painter);
+            graphicsObjectInfo.setGraphics2D(g2d);
+
+            // get the 'width' and 'height' attributes of the SVG document
+            Dimension imageSize = painter.getImageSize();
+            float imw = (float)imageSize.getWidth() / 1000f;
+            float imh = (float)imageSize.getHeight() / 1000f;
+
+            Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, imw, imh);
+            graphicsObjectInfo.setArea(area);
+            AFPResourceManager resourceManager = afpInfo.getResourceManager();
+            resourceManager.createObject(graphicsObjectInfo);
+        }
+
+        paintingState.restore();
     }
 
+    /** {@inheritDoc} */
+    protected int mpt2px(int unit, int resolution) {
+        return Math.round(paintingState.getUnitConverter().mpt2units(unit));
+    }
 }



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