From 92eae99485ec3c3e6892f47847464b4caf6906d3 Mon Sep 17 00:00:00 2001 From: Karen Lease Date: Wed, 16 May 2001 20:49:38 +0000 Subject: PR: Submitted by: Aaron Optimizer Digulla via Jeroen de Zwart Add viewBox support to svg element. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194248 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/svg/SVG.java | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/org/apache/fop') diff --git a/src/org/apache/fop/svg/SVG.java b/src/org/apache/fop/svg/SVG.java index 1d52fed3b..afa9ab336 100644 --- a/src/org/apache/fop/svg/SVG.java +++ b/src/org/apache/fop/svg/SVG.java @@ -64,6 +64,9 @@ import org.w3c.dom.svg.*; import org.w3c.dom.svg.SVGLength; import org.apache.fop.dom.svg.SVGArea; + +import java.util.StringTokenizer; + /** * class representing svg:svg pseudo flow object. */ @@ -119,6 +122,40 @@ public class SVG extends FObj implements GraphicsCreator { SVGLength h = ((SVGLengthProperty) this.properties.get("height")). getSVGLength(); svgArea = new SVGSVGElementImpl(); + { + String box = this.properties.get("viewBox").getString(); + if (box != "") { + StringTokenizer st = new StringTokenizer(box, " "); + float x = 0; + float y = 0; + float width = 0; + float height = 0; + try { + if(st.hasMoreTokens()) { + x = Double.valueOf(st.nextToken()).floatValue(); + } + if(st.hasMoreTokens()) { + y = Double.valueOf(st.nextToken()).floatValue(); + } + if(st.hasMoreTokens()) { + width = Double.valueOf(st.nextToken()).floatValue(); + } + if(st.hasMoreTokens()) { + height = Double.valueOf(st.nextToken()).floatValue(); + } + } catch(Exception e) { + } + SVGRect rect = new SVGRectImpl(); + rect.setX(x); + rect.setY(y); + rect.setWidth(width); + rect.setHeight(height); + svgArea.setViewBox (new SVGAnimatedRectImpl (rect)); + } else { + svgArea.setViewBox (null); + } + } + SVGAnimatedLengthImpl sal; if (w == null) w = new SVGLengthImpl(); -- cgit v1.2.3