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 [6/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/ps/extensions/PSExtensionElementMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java Fri Nov 28 03:13:12 2008
@@ -42,8 +42,8 @@
             foObjs.put(PSSetupCodeElement.ELEMENT, new PSSetupCodeMaker());
             foObjs.put(PSPageSetupCodeElement.ELEMENT, new PSPageSetupCodeMaker());
             foObjs.put(PSSetPageDeviceElement.ELEMENT, new PSSetPageDeviceMaker());
-            foObjs.put(PSCommentBeforeElement.ELEMENT, new PSCommentBeforeMaker());
-            foObjs.put(PSCommentAfterElement.ELEMENT, new PSCommentAfterMaker());
+            foObjs.put(PSCommentBefore.ELEMENT, new PSCommentBeforeMaker());
+            foObjs.put(PSCommentAfter.ELEMENT, new PSCommentAfterMaker());
         }
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/GraphicsConfiguration.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/GraphicsConfiguration.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/GraphicsConfiguration.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/GraphicsConfiguration.java Fri Nov 28 03:13:12 2008
@@ -17,7 +17,6 @@
 
 /* $Id$ */
 
-
 package org.apache.fop.svg;
 
 import java.awt.image.VolatileImage;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFBridgeContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFBridgeContext.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFBridgeContext.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFBridgeContext.java Fri Nov 28 03:13:12 2008
@@ -20,30 +20,20 @@
 package org.apache.fop.svg;
 
 import java.awt.geom.AffineTransform;
-import java.lang.reflect.Constructor;
 
-import org.apache.batik.bridge.Bridge;
 import org.apache.batik.bridge.BridgeContext;
 import org.apache.batik.bridge.DocumentLoader;
+import org.apache.batik.bridge.SVGTextElementBridge;
 import org.apache.batik.bridge.UserAgent;
-
+import org.apache.batik.gvt.TextPainter;
+import org.apache.fop.fonts.FontInfo;
 import org.apache.xmlgraphics.image.loader.ImageManager;
 import org.apache.xmlgraphics.image.loader.ImageSessionContext;
 
-import org.apache.fop.fonts.FontInfo;
-
 /**
  * BridgeContext which registers the custom bridges for PDF output.
  */
-public class PDFBridgeContext extends BridgeContext {
-
-    /** The font list. */
-    private final FontInfo fontInfo;
-
-    private final ImageManager imageManager;
-    private final ImageSessionContext imageSessionContext;
-
-    private AffineTransform linkTransform;
+public class PDFBridgeContext extends AbstractFOPBridgeContext {
 
     /**
      * Constructs a new bridge context.
@@ -53,18 +43,16 @@
      *                 in which case text is painted as shapes
      * @param linkTransform AffineTransform to properly place links,
      *                      may be null
+     * @param imageManager an image manager
+     * @param imageSessionContext an image session context
+     * @param linkTransform AffineTransform to properly place links,
+     *                      may be null
      */
-    public PDFBridgeContext(UserAgent userAgent,
-                            DocumentLoader loader,
-                            FontInfo fontInfo,
-                            ImageManager imageManager,
-                            ImageSessionContext imageSessionContext,
-                            AffineTransform linkTransform) {
-        super(userAgent, loader);
-        this.fontInfo = fontInfo;
-        this.imageManager = imageManager;
-        this.imageSessionContext = imageSessionContext;
-        this.linkTransform = linkTransform;
+    public PDFBridgeContext(UserAgent userAgent, DocumentLoader documentLoader,
+            FontInfo fontInfo, ImageManager imageManager,
+            ImageSessionContext imageSessionContext,
+            AffineTransform linkTransform) {
+        super(userAgent, documentLoader, fontInfo, imageManager, imageSessionContext, linkTransform);
     }
 
     /**
@@ -72,19 +60,12 @@
      * @param userAgent the user agent
      * @param fontInfo the font list for the text painter, may be null
      *                 in which case text is painted as shapes
-     * @param linkTransform AffineTransform to properly place links,
-     *                      may be null
+     * @param imageManager an image manager
+     * @param imageSessionContext an image session context
      */
-    public PDFBridgeContext(UserAgent userAgent,
-                            FontInfo fontInfo,
-                            ImageManager imageManager,
-                            ImageSessionContext imageSessionContext,
-                            AffineTransform linkTransform) {
-        super(userAgent);
-        this.fontInfo = fontInfo;
-        this.imageManager = imageManager;
-        this.imageSessionContext = imageSessionContext;
-        this.linkTransform = linkTransform;
+    public PDFBridgeContext(UserAgent userAgent, FontInfo fontInfo,
+            ImageManager imageManager, ImageSessionContext imageSessionContext) {
+        super(userAgent, fontInfo, imageManager, imageSessionContext);
     }
 
     /**
@@ -92,41 +73,15 @@
      * @param userAgent the user agent
      * @param fontInfo the font list for the text painter, may be null
      *                 in which case text is painted as shapes
+     * @param imageManager an image manager
+     * @param imageSessionContext an image session context
+     * @param linkTransform AffineTransform to properly place links,
+     *                      may be null
      */
-    public PDFBridgeContext(UserAgent userAgent,
-                            FontInfo fontInfo,
-                            ImageManager imageManager,
-                            ImageSessionContext imageSessionContext) {
-        this(userAgent, fontInfo, imageManager, imageSessionContext, null);
-    }
-
-    /**
-     * Returns the ImageManager to be used by the ImageElementBridge.
-     * @return the image manager
-     */
-    public ImageManager getImageManager() {
-        return this.imageManager;
-    }
-
-    /**
-     * Returns the ImageSessionContext to be used by the ImageElementBridge.
-     * @return the image session context
-     */
-    public ImageSessionContext getImageSessionContext() {
-        return this.imageSessionContext;
-    }
-
-    private void putPDFElementBridgeConditional(String className, String testFor) {
-        try {
-            Class.forName(testFor);
-            //if we get here the test class is available
-
-            Class clazz = Class.forName(className);
-            Constructor constructor = clazz.getConstructor(new Class[] {FontInfo.class});
-            putBridge((Bridge)constructor.newInstance(new Object[] {fontInfo}));
-        } catch (Throwable t) {
-            //simply ignore (bridges instantiated over this method are optional)
-        }
+    public PDFBridgeContext(SVGUserAgent userAgent, FontInfo fontInfo,
+            ImageManager imageManager, ImageSessionContext imageSessionContext,
+            AffineTransform linkTransform) {
+        super(userAgent, fontInfo, imageManager, imageSessionContext, linkTransform);
     }
 
     /** {@inheritDoc} */
@@ -134,23 +89,24 @@
         super.registerSVGBridges();
 
         if (fontInfo != null) {
-            PDFTextElementBridge textElementBridge = new PDFTextElementBridge(fontInfo);
+            TextPainter textPainter = new PDFTextPainter(fontInfo);
+            SVGTextElementBridge textElementBridge = new PDFTextElementBridge(textPainter);
             putBridge(textElementBridge);
 
             //Batik flow text extension (may not always be available)
             //putBridge(new PDFBatikFlowTextElementBridge(fontInfo);
-            putPDFElementBridgeConditional(
+            putElementBridgeConditional(
                     "org.apache.fop.svg.PDFBatikFlowTextElementBridge",
                     "org.apache.batik.extension.svg.BatikFlowTextElementBridge");
 
             //SVG 1.2 flow text support
             //putBridge(new PDFSVG12TextElementBridge(fontInfo)); //-->Batik 1.7
-            putPDFElementBridgeConditional(
+            putElementBridgeConditional(
                     "org.apache.fop.svg.PDFSVG12TextElementBridge",
                     "org.apache.batik.bridge.svg12.SVG12TextElementBridge");
 
             //putBridge(new PDFSVGFlowRootElementBridge(fontInfo));
-            putPDFElementBridgeConditional(
+            putElementBridgeConditional(
                     "org.apache.fop.svg.PDFSVGFlowRootElementBridge",
                     "org.apache.batik.bridge.svg12.SVGFlowRootElementBridge");
         }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java Fri Nov 28 03:13:12 2008
@@ -19,30 +19,30 @@
 
 package org.apache.fop.svg;
 
-import org.apache.fop.Version;
-import org.apache.fop.pdf.PDFDocument;
-import org.apache.fop.pdf.PDFFilterList;
-import org.apache.fop.pdf.PDFPage;
-import org.apache.fop.pdf.PDFStream;
-import org.apache.fop.pdf.PDFState;
-import org.apache.fop.pdf.PDFNumber;
-import org.apache.fop.pdf.PDFResources;
-import org.apache.fop.pdf.PDFColor;
-import org.apache.fop.pdf.PDFAnnotList;
-import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.fonts.FontSetup;
-
-import java.awt.Graphics;
-import java.awt.Font;
 import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics;
 import java.awt.Shape;
 import java.awt.font.FontRenderContext;
 import java.awt.font.GlyphVector;
 import java.awt.geom.AffineTransform;
-import java.io.OutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.io.StringWriter;
 
+import org.apache.fop.Version;
+import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontSetup;
+import org.apache.fop.pdf.PDFAnnotList;
+import org.apache.fop.pdf.PDFColor;
+import org.apache.fop.pdf.PDFDocument;
+import org.apache.fop.pdf.PDFFilterList;
+import org.apache.fop.pdf.PDFNumber;
+import org.apache.fop.pdf.PDFPage;
+import org.apache.fop.pdf.PDFPaintingState;
+import org.apache.fop.pdf.PDFResources;
+import org.apache.fop.pdf.PDFStream;
+
 /**
  * This class is a wrapper for the <tt>PDFGraphics2D</tt> that
  * is used to create a full document around the pdf rendering from
@@ -52,7 +52,7 @@
  */
 public class PDFDocumentGraphics2D extends PDFGraphics2D {
 
-    private PDFContext pdfContext;
+    private final PDFContext pdfContext;
 
     private int width;
     private int height;
@@ -296,7 +296,7 @@
             throw new IllegalStateException("Close page first before starting another");
         }
         //Start page
-        graphicsState = new PDFState();
+        paintingState = new PDFPaintingState();
         if (this.initialTransform == null) {
             //Save initial transformation matrix
             this.initialTransform = getTransform();
@@ -322,7 +322,7 @@
         pageRef = page.referencePDF();
 
         AffineTransform at = new AffineTransform(1.0, 0.0, 0.0, -1.0,
-                                                 0.0, (double)height);
+                                                 0.0, height);
         currentStream.write("1 0 0 -1 0 " + height + " cm\n");
         if (svgWidth != 0) {
             double scaleX = width / svgWidth;
@@ -340,7 +340,7 @@
             scale(1 / s, 1 / s);
         }
         // Remember the transform we installed.
-        graphicsState.concatenate(at);
+        paintingState.concatenate(at);
 
         pdfContext.increasePageCount();
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java Fri Nov 28 03:13:12 2008
@@ -59,19 +59,9 @@
 import org.apache.batik.ext.awt.RenderingHintsKeyExt;
 import org.apache.batik.gvt.GraphicsNode;
 import org.apache.batik.gvt.PatternPaint;
-
-import org.apache.xmlgraphics.image.loader.ImageInfo;
-import org.apache.xmlgraphics.image.loader.ImageSize;
-import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
-import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG;
-import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
-import org.apache.xmlgraphics.java2d.AbstractGraphics2D;
-import org.apache.xmlgraphics.java2d.GraphicContext;
-
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontSetup;
-import org.apache.fop.fonts.FontTriplet;
 import org.apache.fop.pdf.BitmapImage;
 import org.apache.fop.pdf.PDFAnnotList;
 import org.apache.fop.pdf.PDFColor;
@@ -83,16 +73,23 @@
 import org.apache.fop.pdf.PDFImageXObject;
 import org.apache.fop.pdf.PDFLink;
 import org.apache.fop.pdf.PDFNumber;
+import org.apache.fop.pdf.PDFPaintingState;
 import org.apache.fop.pdf.PDFPattern;
 import org.apache.fop.pdf.PDFResourceContext;
 import org.apache.fop.pdf.PDFResources;
-import org.apache.fop.pdf.PDFState;
 import org.apache.fop.pdf.PDFText;
 import org.apache.fop.pdf.PDFXObject;
 import org.apache.fop.render.pdf.ImageRawCCITTFaxAdapter;
 import org.apache.fop.render.pdf.ImageRawJPEGAdapter;
 import org.apache.fop.render.pdf.ImageRenderedAdapter;
 import org.apache.fop.util.ColorExt;
+import org.apache.xmlgraphics.image.loader.ImageInfo;
+import org.apache.xmlgraphics.image.loader.ImageSize;
+import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
+import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG;
+import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
+import org.apache.xmlgraphics.java2d.AbstractGraphics2D;
+import org.apache.xmlgraphics.java2d.GraphicContext;
 
 /**
  * PDF Graphics 2D.
@@ -103,8 +100,7 @@
  * @version $Id$
  * @see org.apache.batik.ext.awt.g2d.AbstractGraphics2D
  */
-public class PDFGraphics2D extends AbstractGraphics2D {
-
+public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHandler {
     private static final AffineTransform IDENTITY_TRANSFORM = new AffineTransform();
 
     /** The number of decimal places. */
@@ -129,9 +125,9 @@
     protected String pageRef;
 
     /**
-     * the current state of the pdf graphics
+     * The PDF painting state
      */
-    protected PDFState graphicsState;
+    protected PDFPaintingState paintingState;
 
     /**
      * The PDF graphics state level that this svg is being drawn into.
@@ -200,7 +196,7 @@
         currentFontSize = size;
         fontInfo = fi;
         pageRef = pref;
-        graphicsState = new PDFState();
+        paintingState = new PDFPaintingState();
     }
 
     /**
@@ -226,7 +222,7 @@
         this.currentFontSize = g.currentFontSize;
         this.fontInfo = g.fontInfo;
         this.pageRef = g.pageRef;
-        this.graphicsState = g.graphicsState;
+        this.paintingState = g.paintingState;
         this.currentStream = g.currentStream;
         this.nativeCount = g.nativeCount;
         this.outputStream = g.outputStream;
@@ -266,9 +262,9 @@
      *
      * @param state the PDF state
      */
-    public void setPDFState(PDFState state) {
-        graphicsState = state;
-        baseLevel = graphicsState.getStackLevel();
+    public void setPaintingState(PDFPaintingState state) {
+        paintingState = state;
+        baseLevel = paintingState.getStackLevel();
     }
 
     /**
@@ -369,7 +365,7 @@
      * @return the transformation matrix that established the basic user space for this document
      */
     protected AffineTransform getBaseTransform() {
-        AffineTransform at = new AffineTransform(graphicsState.getTransform());
+        AffineTransform at = new AffineTransform(paintingState.getTransform());
         return at;
     }
 
@@ -417,7 +413,7 @@
      * @param width the width to draw the image
      * @param height the height to draw the image
      */
-    void addNativeImage(org.apache.xmlgraphics.image.loader.Image image, float x, float y,
+    public void addNativeImage(org.apache.xmlgraphics.image.loader.Image image, float x, float y,
                              float width, float height) {
         preparePainting();
         String key = image.getInfo().getOriginalURI();
@@ -518,10 +514,14 @@
             g.setBackground(new Color(1, 1, 1, 0));
             g.setPaint(new Color(1, 1, 1, 0));
             g.fillRect(0, 0, width, height);
-            g.clip(new Rectangle(0, 0, buf.getWidth(), buf.getHeight()));
+
+            int imageWidth = buf.getWidth();
+            int imageHeight = buf.getHeight();
+            g.clip(new Rectangle(0, 0, imageWidth, imageHeight));
             g.setComposite(gc.getComposite());
 
-            if (!g.drawImage(img, 0, 0, buf.getWidth(), buf.getHeight(), observer)) {
+            boolean drawn = g.drawImage(img, 0, 0, imageWidth, imageHeight, observer);
+            if (!drawn) {
                 return false;
             }
             g.dispose();
@@ -602,13 +602,13 @@
         trans.getMatrix(tranvals);
 
         Shape imclip = getClip();
-        boolean newClip = graphicsState.checkClip(imclip);
-        boolean newTransform = graphicsState.checkTransform(trans)
+        boolean newClip = paintingState.checkClip(imclip);
+        boolean newTransform = paintingState.checkTransform(trans)
                                && !trans.isIdentity();
 
         if (newClip || newTransform) {
             currentStream.write("q\n");
-            graphicsState.push();
+            paintingState.save();
             if (newTransform) {
                 concatMatrix(tranvals);
             }
@@ -625,7 +625,7 @@
         applyColor(c, true);
 
         Paint paint = getPaint();
-        if (graphicsState.setPaint(paint)) {
+        if (paintingState.setPaint(paint)) {
             if (!applyPaint(paint, false)) {
                 // Stroke the shape and use it to 'clip'
                 // the paint contents.
@@ -634,7 +634,7 @@
 
                 if (newClip || newTransform) {
                     currentStream.write("Q\n");
-                    graphicsState.pop();
+                    paintingState.restore();
                 }
                 return;
             }
@@ -646,7 +646,7 @@
         doDrawing(false, true, false);
         if (newClip || newTransform) {
             currentStream.write("Q\n");
-            graphicsState.pop();
+            paintingState.restore();
         }
     }
 
@@ -1324,7 +1324,7 @@
         if (ovFontState == null) {
             java.awt.Font gFont = getFont();
             fontTransform = gFont.getTransform();
-            fontState = getInternalFontForAWTFont(gFont);
+            fontState = fontInfo.getFontInstanceForAWTFont(gFont);
         } else {
             fontState = fontInfo.getFontInstance(
                     ovFontState.getFontTriplet(), ovFontState.getFontSize());
@@ -1380,7 +1380,7 @@
             if (!useMultiByte) {
                 if (ch > 127) {
                     currentStream.write("\\");
-                    currentStream.write(Integer.toOctalString((int)ch));
+                    currentStream.write(Integer.toOctalString(ch));
                 } else {
                     switch (ch) {
                     case '(':
@@ -1397,8 +1397,8 @@
             }
 
             if (kerningAvailable && (i + 1) < l) {
-                addKerning(currentStream, (new Integer((int)ch)),
-                           (new Integer((int)fontState.mapChar(s.charAt(i + 1)))),
+                addKerning(currentStream, (new Integer(ch)),
+                           (new Integer(fontState.mapChar(s.charAt(i + 1)))),
                            kerning, startText, endText);
             }
 
@@ -1426,7 +1426,7 @@
                 vals.put(PDFGState.GSTATE_ALPHA_STROKE, new Float(strokeAlpha / 255f));
             }
             PDFGState gstate = pdfDoc.getFactory().makeGState(
-                    vals, graphicsState.getGState());
+                    vals, paintingState.getGState());
             resourceContext.addGState(gstate);
             currentStream.write("/" + gstate.getName() + " gs\n");
         }
@@ -1438,7 +1438,7 @@
      */
     protected void updateCurrentFont(Font font) {
         String name = font.getFontName();
-        float size = (float)font.getFontSize() / 1000f;
+        float size = font.getFontSize() / 1000f;
 
         //Only update if necessary
         if ((!name.equals(this.currentFontName))
@@ -1453,19 +1453,10 @@
      * Returns a suitable internal font given an AWT Font instance.
      * @param awtFont the AWT font
      * @return the internal Font
+     * @deprecated use FontInfo.getFontInstanceForAWTFont(java.awt.Font awtFont) instead
      */
     protected Font getInternalFontForAWTFont(java.awt.Font awtFont) {
-        Font fontState;
-        String n = awtFont.getFamily();
-        if (n.equals("sanserif")) {
-            n = "sans-serif";
-        }
-        float siz = awtFont.getSize2D();
-        String style = awtFont.isItalic() ? "italic" : "normal";
-        int weight = awtFont.isBold() ? Font.WEIGHT_BOLD : Font.WEIGHT_NORMAL;
-        FontTriplet triplet = fontInfo.fontLookup(n, style, weight);
-        fontState = fontInfo.getFontInstance(triplet, (int)(siz * 1000 + 0.5));
-        return fontState;
+        return fontInfo.getFontInstanceForAWTFont(awtFont);
     }
 
     /**
@@ -1617,13 +1608,13 @@
         trans.getMatrix(tranvals);
 
         Shape imclip = getClip();
-        boolean newClip = graphicsState.checkClip(imclip);
-        boolean newTransform = graphicsState.checkTransform(trans)
+        boolean newClip = paintingState.checkClip(imclip);
+        boolean newTransform = paintingState.checkTransform(trans)
                                && !trans.isIdentity();
 
         if (newClip || newTransform) {
             currentStream.write("q\n");
-            graphicsState.push();
+            paintingState.save();
             if (newTransform) {
                 concatMatrix(tranvals);
             }
@@ -1640,14 +1631,14 @@
         applyColor(c, false);
 
         Paint paint = getPaint();
-        if (graphicsState.setPaint(paint)) {
+        if (paintingState.setPaint(paint)) {
             if (!applyPaint(paint, true)) {
                 // Use the shape to 'clip' the paint contents.
                 applyUnknownPaint(paint, s);
 
                 if (newClip || newTransform) {
                     currentStream.write("Q\n");
-                    graphicsState.pop();
+                    paintingState.restore();
                 }
                 return;
             }
@@ -1660,7 +1651,7 @@
                   iter.getWindingRule() == PathIterator.WIND_EVEN_ODD);
         if (newClip || newTransform) {
             currentStream.write("Q\n");
-            graphicsState.pop();
+            paintingState.restore();
         }
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphicsConfiguration.java Fri Nov 28 03:13:12 2008
@@ -26,6 +26,7 @@
 import java.awt.geom.AffineTransform;
 import java.awt.image.BufferedImage;
 
+
 /**
  * Our implementation of the class that returns information about
  * roughly what we can handle and want to see (alpha for example).

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFImageElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFImageElementBridge.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFImageElementBridge.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFImageElementBridge.java Fri Nov 28 03:13:12 2008
@@ -19,36 +19,14 @@
 
 package org.apache.fop.svg;
 
-import java.awt.Graphics2D;
-import java.awt.Shape;
-import java.awt.geom.Rectangle2D;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.svg.SVGDocument;
-
-import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.bridge.SVGImageElementBridge;
-import org.apache.batik.gvt.AbstractGraphicsNode;
-import org.apache.batik.gvt.GraphicsNode;
-import org.apache.batik.util.ParsedURL;
-
-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.ImageManager;
-import org.apache.xmlgraphics.image.loader.ImageSessionContext;
-import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
-import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
-import org.apache.xmlgraphics.image.loader.impl.ImageRawJPEG;
-import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
 
 /**
- * Bridge class for the &lt;image> element when jpeg images.
+ * PDF Image Element Bridge class for the &lt;image> element when jpeg images.
  *
  * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
  */
-public class PDFImageElementBridge extends SVGImageElementBridge {
+public class PDFImageElementBridge extends AbstractFOPImageElementBridge {
 
     /**
      * Constructs a new bridge for the &lt;image> element.
@@ -60,210 +38,9 @@
                                                 ImageFlavor.RAW_CCITTFAX,
                                                 ImageFlavor.GRAPHICS2D,
                                                 ImageFlavor.XML_DOM};
-    /**
-     * Create the raster image node.
-     * THis checks if it is a jpeg file and creates a jpeg node
-     * so the jpeg can be inserted directly into the pdf document.
-     * @param ctx the bridge context
-     * @param imageElement the svg element for the image
-     * @param purl the parsed url for the image resource
-     * @return a new graphics node
-     */
-    protected GraphicsNode createImageGraphicsNode
-                (BridgeContext ctx, Element imageElement, ParsedURL purl) {
-        PDFBridgeContext pdfCtx = (PDFBridgeContext)ctx;
-
-        ImageManager manager = pdfCtx.getImageManager();
-        ImageSessionContext sessionContext = pdfCtx.getImageSessionContext();
-        try {
-            ImageInfo info = manager.getImageInfo(purl.toString(), sessionContext);
-            Image image = manager.getImage(info, supportedFlavors, sessionContext);
-
-            //TODO color profile overrides aren't handled, yet!
-            //ICCColorSpaceExt colorspaceOverride = extractColorSpace(e, ctx);
-            AbstractGraphicsNode specializedNode = null;
-            if (image instanceof ImageXMLDOM) {
-                ImageXMLDOM xmlImage = (ImageXMLDOM)image;
-                if (xmlImage.getDocument() instanceof SVGDocument) {
-                    return createSVGImageNode(ctx, imageElement,
-                            (SVGDocument)xmlImage.getDocument());
-                } else {
-                    //Convert image to Graphics2D
-                    image = manager.convertImage(xmlImage,
-                            new ImageFlavor[] {ImageFlavor.GRAPHICS2D});
-                }
-            }
-            if (image instanceof ImageRawJPEG) {
-                specializedNode = new LoaderImageNode(image, ctx, imageElement, purl);
-            } else if (image instanceof ImageRawCCITTFax) {
-                specializedNode = new LoaderImageNode(image, ctx, imageElement, purl);
-            } else if (image instanceof ImageGraphics2D) {
-                ImageGraphics2D g2dImage = (ImageGraphics2D)image;
-                specializedNode = new Graphics2DNode(g2dImage);
-            } else {
-                ctx.getUserAgent().displayError(
-                        new ImageException("Cannot convert an image to a usable format: " + purl));
-            }
-
-            Rectangle2D imgBounds = getImageBounds(ctx, imageElement);
-            Rectangle2D bounds = specializedNode.getPrimitiveBounds();
-            float [] vb = new float[4];
-            vb[0] = 0; // x
-            vb[1] = 0; // y
-            vb[2] = (float) bounds.getWidth(); // width
-            vb[3] = (float) bounds.getHeight(); // height
-
-            // handles the 'preserveAspectRatio', 'overflow' and 'clip'
-            // and sets the appropriate AffineTransform to the image node
-            initializeViewport(ctx, imageElement, specializedNode, vb, imgBounds);
-            return specializedNode;
-        } catch (Exception e) {
-            ctx.getUserAgent().displayError(e);
-        }
-
-        return superCreateGraphicsNode(ctx, imageElement, purl);
-    }
-
-    /**
-     * Calls the superclass' createImageGraphicNode() method to create the normal GraphicsNode.
-     * @param ctx the bridge context
-     * @param imageElement the image element
-     * @param purl the parsed URL
-     * @return the newly created graphics node
-     * @see org.apache.batik.bridge.SVGImageElementBridge#createGraphicsNode(BridgeContext, Element)
-     */
-    protected GraphicsNode superCreateGraphicsNode
-            (BridgeContext ctx, Element imageElement, ParsedURL purl) {
-        return super.createImageGraphicsNode(ctx, imageElement, purl);
-    }
-
-
-    /**
-     * An image node for natively handled Image instance.
-     * This holds a natively handled image so that it can be drawn into
-     * the PDFGraphics2D.
-     */
-    public class LoaderImageNode extends AbstractGraphicsNode {
-
-        private Image image;
-        private BridgeContext ctx;
-        private Element imageElement;
-        private ParsedURL purl;
-        private GraphicsNode origGraphicsNode = null;
-
-        /**
-         * Create a new image node for drawing natively handled images
-         * into PDF graphics.
-         * @param image the JPEG image
-         * @param ctx the bridge context
-         * @param imageElement the SVG image element
-         * @param purl the URL to the image
-         */
-        public LoaderImageNode(Image image, BridgeContext ctx,
-                           Element imageElement, ParsedURL purl) {
-            this.image = image;
-            this.ctx  = ctx;
-            this.imageElement = imageElement;
-            this.purl = purl;
-        }
-
-        /** {@inheritDoc} */
-        public Shape getOutline() {
-            return getPrimitiveBounds();
-        }
-
-        /** {@inheritDoc} */
-        public void primitivePaint(Graphics2D g2d) {
-            if (g2d instanceof PDFGraphics2D) {
-                PDFGraphics2D pdfg = (PDFGraphics2D) g2d;
-                float x = 0;
-                float y = 0;
-                try {
-                    float width = image.getSize().getWidthPx();
-                    float height = image.getSize().getHeightPx();
-                    pdfg.addNativeImage(image, x, y, width, height);
-                } catch (Exception e) {
-                    ctx.getUserAgent().displayError(e);
-                }
-            } else {
-                // Not going directly into PDF so use
-                // original implementation so filters etc work.
-                if (origGraphicsNode == null) {
-                    // Haven't constructed baseclass Graphics Node,
-                    // so do so now.
-                    origGraphicsNode
-                        = PDFImageElementBridge.this.superCreateGraphicsNode
-                            (ctx,  imageElement, purl);
-                }
-                origGraphicsNode.primitivePaint(g2d);
-            }
-        }
-
-        /** {@inheritDoc} */
-        public Rectangle2D getGeometryBounds() {
-            return getPrimitiveBounds();
-        }
-
-        /** {@inheritDoc} */
-        public Rectangle2D getPrimitiveBounds() {
-            return new Rectangle2D.Double(0, 0,
-                       image.getSize().getWidthPx(),
-                       image.getSize().getHeightPx());
-        }
-
-        /** {@inheritDoc} */
-        public Rectangle2D getSensitiveBounds() {
-            //No interactive features, just return primitive bounds
-            return getPrimitiveBounds();
-        }
-
-    }
-
-    /**
-     * A node that holds a Graphics2D image.
-     */
-    public class Graphics2DNode extends AbstractGraphicsNode {
-
-        private ImageGraphics2D image;
-
-        /**
-         * Create a new Graphics2D node.
-         * @param g2d the Graphics2D image
-         */
-        public Graphics2DNode(ImageGraphics2D g2d) {
-            this.image = g2d;
-        }
-
-        /** {@inheritDoc} */
-        public Shape getOutline() {
-            return getPrimitiveBounds();
-        }
-
-        /** {@inheritDoc} */
-        public void primitivePaint(Graphics2D g2d) {
-            int width = image.getSize().getWidthPx();
-            int height = image.getSize().getHeightPx();
-            Rectangle2D area = new Rectangle2D.Double(0, 0, width, height);
-            image.getGraphics2DImagePainter().paint(g2d, area);
-        }
-
-        /** {@inheritDoc} */
-        public Rectangle2D getGeometryBounds() {
-            return getPrimitiveBounds();
-        }
-
-        /** {@inheritDoc} */
-        public Rectangle2D getPrimitiveBounds() {
-            return new Rectangle2D.Double(0, 0,
-                    image.getSize().getWidthPx(),
-                    image.getSize().getHeightPx());
-        }
-
-        /** {@inheritDoc} */
-        public Rectangle2D getSensitiveBounds() {
-            //No interactive features, just return primitive bounds
-            return getPrimitiveBounds();
-        }
 
+    /** {@inheritDoc} */
+    protected ImageFlavor[] getSupportedFlavours() {
+        return supportedFlavors;
     }
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextElementBridge.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextElementBridge.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextElementBridge.java Fri Nov 28 03:13:12 2008
@@ -19,13 +19,7 @@
 
 package org.apache.fop.svg;
 
-import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.bridge.SVGTextElementBridge;
-import org.apache.batik.gvt.GraphicsNode;
-import org.apache.batik.gvt.TextNode;
 import org.apache.batik.gvt.TextPainter;
-import org.apache.fop.fonts.FontInfo;
-import org.w3c.dom.Element;
 
 /**
  * Bridge class for the &lt;text> element.
@@ -34,41 +28,15 @@
  *
  * @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
  */
-public class PDFTextElementBridge extends SVGTextElementBridge {
-
-    private PDFTextPainter pdfTextPainter;
+public class PDFTextElementBridge extends AbstractFOPTextElementBridge {
 
     /**
      * Constructs a new bridge for the &lt;text> element.
-     * @param fi the font information
-     */
-    public PDFTextElementBridge(FontInfo fi) {
-        pdfTextPainter = new PDFTextPainter(fi);
-    }
-
-    /**
-     * Create a text element bridge.
-     * This set the text painter on the node if the text is simple.
-     * @param ctx the bridge context
-     * @param e the svg element
-     * @return the text graphics node created by the super class
+     *
+     * @param textPainter the text painter to use
      */
-    public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) {
-        GraphicsNode node = super.createGraphicsNode(ctx, e);
-        if (node != null) {
-            //Set our own text painter
-            ((TextNode)node).setTextPainter(getTextPainter());
-        }
-        return node;
+    public PDFTextElementBridge(TextPainter textPainter) {
+        super(textPainter);
     }
-
-    /**
-     * Returns the TextPainter instance used by this bridge.
-     * @return the text painter
-     */
-    public TextPainter getTextPainter() {
-        return pdfTextPainter;
-    }
-
 }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java Fri Nov 28 03:13:12 2008
@@ -43,7 +43,6 @@
 import org.apache.batik.gvt.text.GVTAttributedCharacterIterator;
 import org.apache.batik.gvt.text.TextPaintInfo;
 import org.apache.batik.gvt.text.TextSpanLayout;
-
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontTriplet;
@@ -63,8 +62,8 @@
 
     private static final boolean DEBUG = false;
 
-    private boolean strokeText = false;
-    private FontInfo fontInfo;
+    private final boolean strokeText = false;
+    private final FontInfo fontInfo;
 
     /**
      * Create a new PDF text painter with the given font information.
@@ -280,7 +279,7 @@
         Float fontSize = (Float) aci.getAttribute(TextAttribute.SIZE);
 
         String style = ((posture != null) && (posture.floatValue() > 0.0))
-                       ? "italic" : "normal";
+                       ? Font.STYLE_ITALIC : Font.STYLE_NORMAL;
         int weight = ((taWeight != null)
                        &&  (taWeight.floatValue() > 1.0)) ? Font.WEIGHT_BOLD
                        : Font.WEIGHT_NORMAL;

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=721430&r1=721429&r2=721430&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Fri Nov 28 03:13:12 2008
@@ -53,6 +53,18 @@
 
   <changes>
     <release version="FOP Trunk" date="TBD">
+      <action context="Renderers" dev="AC" importance="high" type="add">
+        AFP Output: An AFPGraphics2D implementation which provides the ability to use Batik to drive the production of AFP Graphics (GOCA) output from SVG.
+      </action>
+      <action context="Renderers" dev="AC" importance="high" type="add">
+        AFP Output: Resource group leveling, external streaming, and de-duplication of images and graphics using IncludeObject and ResourceGroup.
+      </action>
+      <action context="Renderers" dev="AC" importance="high" type="add">
+        AFP Output: Native image embedding support (e.g. JPEG, GIF, TIFF) using ObjectContainer and a MOD:CA Registry implementation.
+      </action>
+      <action context="Fonts" dev="AC" type="fix">
+        More robust AFP font parsing, although it is still in need of some rework in the future.
+      </action>
       <action context="Images" dev="JM" type="add" fixes-bug="41657">
         Added support for SVG 1.2 functionality inside fo:instream-foreign-object.
       </action>
@@ -156,10 +168,6 @@
         offer an implementation for addCharacters() should take care to make
         similar modifications in their code !!</em>
       </action>
-      <!-- change reverted, to be added back later
-      <action context="Renderers" dev="AC" importance="high" type="add">
-        Added SVG support for AFP (GOCA).
-      </action -->
       <action context="Renderers" dev="JM" type="add" fixes-bug="45115" due-to="Martin Edge">
         Added a PCL-specific extension attribute on simple-page-master for controlling
         the simplex/duplex mode.



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