diff options
author | Jeremias Maerki <jeremias@apache.org> | 2008-12-09 15:00:35 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2008-12-09 15:00:35 +0000 |
commit | a6ddced309701a1ca8d79a9e7bec3288afba2cc8 (patch) | |
tree | c3d2bcfe7277246d9a2acc3675721a99f4de5727 /src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java | |
parent | 9d339f0968314f0cfcc4a720628fed1845292ce1 (diff) | |
parent | f9d4720b99f5e0fb423b097d7207dfab446d911c (diff) | |
download | xmlgraphics-fop-a6ddced309701a1ca8d79a9e7bec3288afba2cc8.tar.gz xmlgraphics-fop-a6ddced309701a1ca8d79a9e7bec3288afba2cc8.zip |
Merge from Trunk revisions 719662 - 724689.
Conflict for ImageHandler interface resolved by renaming Trunk's ImageHandler to ImageHandlerBase and extending the other ImageHandler from that.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@724729 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java')
-rw-r--r-- | src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java index 12b269a44..99502096c 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java +++ b/src/java/org/apache/fop/render/java2d/Java2DSVGHandler.java @@ -20,6 +20,8 @@ package org.apache.fop.render.java2d; import java.awt.geom.AffineTransform; +import java.io.IOException; +import java.util.Map; import org.w3c.dom.Document; @@ -29,9 +31,11 @@ import org.apache.batik.gvt.GraphicsNode; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.image.loader.batik.BatikUtil; import org.apache.fop.render.AbstractGenericSVGHandler; import org.apache.fop.render.Renderer; import org.apache.fop.render.RendererContext; +import org.apache.fop.render.RendererContextConstants; import org.apache.fop.svg.SVGEventProducer; import org.apache.fop.svg.SVGUserAgent; @@ -66,6 +70,11 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler pdfi.height = ((Integer)context.getProperty(HEIGHT)).intValue(); pdfi.currentXPosition = ((Integer)context.getProperty(XPOS)).intValue(); pdfi.currentYPosition = ((Integer)context.getProperty(YPOS)).intValue(); + Map foreign = (Map)context.getProperty(RendererContextConstants.FOREIGN_ATTRIBUTES); + if (foreign != null + && BITMAP.equalsIgnoreCase((String)foreign.get(CONVERSION_MODE))) { + pdfi.paintAsBitmap = true; + } return pdfi; } @@ -83,6 +92,7 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler public int currentXPosition; /** see Java2D_YPOS */ public int currentYPosition; + public boolean paintAsBitmap; /** {@inheritDoc} */ public String toString() { @@ -91,7 +101,8 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler + "width = " + width + ", " + "height = " + height + ", " + "currentXPosition = " + currentXPosition + ", " - + "currentYPosition = " + currentYPosition + "}"; + + "currentYPosition = " + currentYPosition + ", " + + "paintAsBitmap = " + paintAsBitmap + "}"; } } @@ -103,17 +114,33 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler log.debug("renderSVGDocument(" + context + ", " + doc + ", " + info + ")"); } + // fallback paint as bitmap + if (info.paintAsBitmap) { + try { + super.renderSVGDocument(context, doc); + } catch (IOException ioe) { + SVGEventProducer eventProducer = SVGEventProducer.Provider.get( + context.getUserAgent().getEventBroadcaster()); + eventProducer.svgRenderingError(this, ioe, getDocumentURI(doc)); + } + return; + } + int x = info.currentXPosition; int y = info.currentYPosition; SVGUserAgent ua = new SVGUserAgent(context.getUserAgent(), new AffineTransform()); - GVTBuilder builder = new GVTBuilder(); BridgeContext ctx = new BridgeContext(ua); + //Cloning SVG DOM as Batik attaches non-thread-safe facilities (like the CSS engine) + //to it. + Document clonedDoc = BatikUtil.cloneSVGDocument(doc); + GraphicsNode root; try { - root = builder.build(ctx, doc); + GVTBuilder builder = new GVTBuilder(); + root = builder.build(ctx, clonedDoc); } catch (Exception e) { SVGEventProducer eventProducer = SVGEventProducer.Provider.get( context.getUserAgent().getEventBroadcaster()); @@ -126,8 +153,8 @@ public class Java2DSVGHandler extends AbstractGenericSVGHandler float iw = (float) ctx.getDocumentSize().getWidth() * 1000f; float ih = (float) ctx.getDocumentSize().getHeight() * 1000f; - float w = (float) info.width; - float h = (float) info.height; + float w = info.width; + float h = info.height; AffineTransform origTransform = info.state.getGraph().getTransform(); |