diff options
author | Keiron Liddle <keiron@apache.org> | 2002-03-21 09:28:43 +0000 |
---|---|---|
committer | Keiron Liddle <keiron@apache.org> | 2002-03-21 09:28:43 +0000 |
commit | bdad2c98ddc9a202fae49f48181cc06ff73a92ce (patch) | |
tree | 6a856745e573394c963fd893e0750bbee7983c8f | |
parent | 3bd01156bddd9eea6c73205511d3d1c4db38b613 (diff) | |
download | xmlgraphics-fop-bdad2c98ddc9a202fae49f48181cc06ff73a92ce.tar.gz xmlgraphics-fop-bdad2c98ddc9a202fae49f48181cc06ff73a92ce.zip |
updated to changes in batik api
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194711 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/org/apache/fop/svg/PDFAElementBridge.java | 1 | ||||
-rw-r--r-- | src/org/apache/fop/svg/PDFImageElementBridge.java | 1 | ||||
-rw-r--r-- | src/org/apache/fop/svg/PDFTextElementBridge.java | 7 | ||||
-rw-r--r-- | src/org/apache/fop/svg/PDFTranscoder.java | 5 | ||||
-rw-r--r-- | src/org/apache/fop/svg/SVGElement.java | 94 | ||||
-rw-r--r-- | src/org/apache/fop/svg/SVGUserAgent.java | 15 |
6 files changed, 37 insertions, 86 deletions
diff --git a/src/org/apache/fop/svg/PDFAElementBridge.java b/src/org/apache/fop/svg/PDFAElementBridge.java index dfc79bf74..c441dc46e 100644 --- a/src/org/apache/fop/svg/PDFAElementBridge.java +++ b/src/org/apache/fop/svg/PDFAElementBridge.java @@ -12,7 +12,6 @@ import java.awt.geom.AffineTransform; import org.apache.batik.bridge.*; -import org.apache.batik.css.HiddenChildElementSupport; import org.apache.batik.gvt.CompositeGraphicsNode; import org.apache.batik.gvt.GraphicsNode; diff --git a/src/org/apache/fop/svg/PDFImageElementBridge.java b/src/org/apache/fop/svg/PDFImageElementBridge.java index 7bfb7a1fb..3d0e30f38 100644 --- a/src/org/apache/fop/svg/PDFImageElementBridge.java +++ b/src/org/apache/fop/svg/PDFImageElementBridge.java @@ -12,7 +12,6 @@ import java.awt.geom.AffineTransform; import org.apache.batik.bridge.*; -import org.apache.batik.css.HiddenChildElementSupport; import org.apache.batik.gvt.CompositeGraphicsNode; import org.apache.batik.gvt.GraphicsNode; diff --git a/src/org/apache/fop/svg/PDFTextElementBridge.java b/src/org/apache/fop/svg/PDFTextElementBridge.java index 7d9aee21d..f00ac0061 100644 --- a/src/org/apache/fop/svg/PDFTextElementBridge.java +++ b/src/org/apache/fop/svg/PDFTextElementBridge.java @@ -10,7 +10,6 @@ package org.apache.fop.svg; import org.apache.batik.gvt.TextNode; import org.apache.batik.bridge.*; -import org.apache.batik.css.CSSOMReadOnlyStyleDeclaration; import org.apache.batik.gvt.CompositeGraphicsNode; import org.apache.batik.gvt.GraphicsNode; @@ -59,12 +58,8 @@ public class PDFTextElementBridge extends SVGTextElementBridge { * applied to the text. */ private boolean isSimple(BridgeContext ctx, Element element, GraphicsNode node) { - CSSOMReadOnlyStyleDeclaration cssDecl - = CSSUtilities.getComputedStyle(element); - UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, element); - // Font size, in user space units. - float fs = TextUtilities.convertFontSize(element, ctx, cssDecl, uctx); + float fs = TextUtilities.convertFontSize(element).floatValue(); if(((int)fs) != fs) { return false; } diff --git a/src/org/apache/fop/svg/PDFTranscoder.java b/src/org/apache/fop/svg/PDFTranscoder.java index f2f1cd7c1..733f854da 100644 --- a/src/org/apache/fop/svg/PDFTranscoder.java +++ b/src/org/apache/fop/svg/PDFTranscoder.java @@ -41,10 +41,10 @@ import org.apache.batik.bridge.UserAgent; import org.apache.batik.bridge.UserAgentAdapter; import org.apache.batik.bridge.ViewBox; -import org.apache.batik.dom.svg.DefaultSVGContext; import org.apache.batik.dom.svg.SAXSVGDocumentFactory; import org.apache.batik.dom.svg.SVGDOMImplementation; import org.apache.batik.dom.svg.SVGOMDocument; +import org.apache.batik.dom.svg.SVGContext; import org.apache.batik.dom.util.DocumentFactory; import org.apache.batik.ext.awt.image.GraphicsUtil; @@ -163,9 +163,6 @@ public class PDFTranscoder extends XMLAbstractTranscoder { SVGSVGElement root = svgDoc.getRootElement(); // initialize the SVG document with the appropriate context String parserClassname = (String)hints.get(KEY_XML_PARSER_CLASSNAME); - DefaultSVGContext svgCtx = new DefaultSVGContext(); - svgCtx.setPixelToMM(userAgent.getPixelToMM()); - ((SVGOMDocument)document).setSVGContext(svgCtx); /*boolean stroke = true; if (hints.containsKey(KEY_STROKE_TEXT)) { diff --git a/src/org/apache/fop/svg/SVGElement.java b/src/org/apache/fop/svg/SVGElement.java index 7b34c1f8a..9a4d0579d 100644 --- a/src/org/apache/fop/svg/SVGElement.java +++ b/src/org/apache/fop/svg/SVGElement.java @@ -30,8 +30,6 @@ import org.apache.batik.gvt.renderer.*; import org.apache.batik.gvt.filter.*; import org.apache.batik.gvt.event.*; import org.apache.batik.bridge.UnitProcessor; -import org.apache.batik.css.value.ImmutableFloat; -import org.apache.batik.css.CSSOMReadOnlyValue; import org.apache.batik.util.SVGConstants; import org.w3c.dom.DOMImplementation; @@ -45,6 +43,7 @@ import java.util.List; import java.util.ArrayList; import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; import java.awt.Dimension; /** @@ -67,22 +66,15 @@ public class SVGElement extends SVGObj { init(); } - public Point2D getDimension(Point2D view) { + public Point2D getDimension(final Point2D view) { // TODO - change so doesn't hold onto fo,area tree Element svgRoot = element; /* create an SVG area */ /* if width and height are zero, get the bounds of the content. */ - FOPSVGContext dc = new FOPSVGContext(); - dc.svgRoot = element; - dc.cwauto = (view.getX() == -1); - dc.chauto = (view.getY() == -1); - dc.cwidth = (float)view.getX(); - dc.cheight = (float)view.getY(); - ((SVGOMDocument)doc).setSVGContext(dc); try { - String baseDir = userAgent.getBaseDirectory(); + String baseDir = userAgent.getBaseURL(); if(baseDir != null) { ((SVGOMDocument)doc).setURLObject(new URL(baseDir)); } @@ -91,12 +83,28 @@ public class SVGElement extends SVGObj { } Element e = ((SVGDocument)doc).getRootElement(); + final float ptmm = userAgent.getPixelToMM(); + SVGContext dc = new SVGContext() { + public float getPixelToMM() { + return ptmm; + } + + public Rectangle2D getBBox() { + return new Rectangle2D.Double(0, 0, view.getX(), view.getY()); + } + + public AffineTransform getCTM() { + return new AffineTransform(); + } + }; + ((SVGOMElement)e).setSVGContext(dc); //if(!e.hasAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI, "xmlns")) { e.setAttributeNS(XMLSupport.XMLNS_NAMESPACE_URI, "xmlns", SVGDOMImplementation.SVG_NAMESPACE_URI); //} - Point2D p2d = getSize(12 /* font size */, svgRoot); + Point2D p2d = getSize(12 /* font size */, svgRoot, userAgent.getPixelToMM()); + ((SVGOMElement)e).setSVGContext(null); return p2d; } @@ -111,10 +119,10 @@ public class SVGElement extends SVGObj { buildTopLevel(doc, element); } - public static Point2D getSize(int size, Element svgRoot) { + public static Point2D getSize(int size, Element svgRoot, float ptmm) { String str; UnitProcessor.Context ctx; - ctx = new PDFUnitContext(size, svgRoot); + ctx = new PDFUnitContext(size, svgRoot, ptmm); str = svgRoot.getAttributeNS(null, SVGConstants.SVG_WIDTH_ATTRIBUTE); if (str.length() == 0) str = "100%"; float width = UnitProcessor.svgHorizontalLengthToUserSpace @@ -137,7 +145,9 @@ public class SVGElement extends SVGObj { /** The element. */ protected Element e; protected int fontSize; - public PDFUnitContext(int size, Element e) { + float pixeltoMM; + + public PDFUnitContext(int size, Element e, float ptmm) { this.e = e; this.fontSize = size; } @@ -162,8 +172,7 @@ public class SVGElement extends SVGObj { * Returns the pixel to mm factor. */ public float getPixelToMM() { - return 0.264583333333333333333f; - // 72 dpi + return pixeltoMM; } /** @@ -176,10 +185,8 @@ public class SVGElement extends SVGObj { /** * Returns the font-size value. */ - public CSSPrimitiveValue getFontSize() { - return new CSSOMReadOnlyValue - (new ImmutableFloat(CSSPrimitiveValue.CSS_PT, - fontSize)); + public float getFontSize() { + return fontSize; } /** @@ -205,48 +212,3 @@ public class SVGElement extends SVGObj { } } -class FOPSVGContext extends DefaultSVGContext { - public boolean cwauto; - public boolean chauto; - public float cwidth; - public float cheight; - public Element svgRoot; - - public float getPixelToMM() { - // 72 dpi - return 0.35277777777777777778f; - } - - public float getViewportWidth(Element e) throws IllegalStateException { - if(e == svgRoot) { - if(!cwauto) { - return cwidth; - } - } - return super.getViewportWidth(e); - } - - public float getViewportHeight(Element e) throws IllegalStateException { - if(e == svgRoot) { - if(!chauto) { - return cheight; - } - } - return super.getViewportHeight(e); - } - - public List getDefaultFontFamilyValue() { - return FONT_FAMILY; - } - - public final static List FONT_FAMILY; - static { - FONT_FAMILY = new ArrayList(); - FONT_FAMILY.add("Helvetica"); - FONT_FAMILY.add("Times"); - FONT_FAMILY.add("Courier"); - FONT_FAMILY.add("sans-serif"); - FONT_FAMILY.add("serif"); - } -} - diff --git a/src/org/apache/fop/svg/SVGUserAgent.java b/src/org/apache/fop/svg/SVGUserAgent.java index d7d9cc023..cbd4af29d 100644 --- a/src/org/apache/fop/svg/SVGUserAgent.java +++ b/src/org/apache/fop/svg/SVGUserAgent.java @@ -7,6 +7,8 @@ package org.apache.fop.svg; +import org.apache.fop.fo.FOUserAgent; + import org.apache.log.Logger; import org.apache.batik.bridge.*; @@ -34,16 +36,15 @@ import java.awt.Dimension; public class SVGUserAgent extends UserAgentAdapter { AffineTransform currentTransform = null; Logger log; + FOUserAgent userAgent; /** * Creates a new SVGUserAgent. */ - public SVGUserAgent(AffineTransform at) { + public SVGUserAgent(FOUserAgent ua, AffineTransform at) { currentTransform = at; - } - - public void setLogger(Logger logger) { - log = logger; + userAgent = ua; + log = userAgent.getLogger(); } /** @@ -79,9 +80,7 @@ public class SVGUserAgent extends UserAgentAdapter { * Returns a customized the pixel to mm factor. */ public float getPixelToMM() { - // this is set to 72dpi as the values in fo are 72dpi - return 0.35277777777777777778f; // 72 dpi - // return 0.26458333333333333333333333333333f; // 96dpi + return userAgent.getPixelToMM(); } /** |