diff options
author | Karen Lease <klease@apache.org> | 2001-05-16 20:49:38 +0000 |
---|---|---|
committer | Karen Lease <klease@apache.org> | 2001-05-16 20:49:38 +0000 |
commit | 92eae99485ec3c3e6892f47847464b4caf6906d3 (patch) | |
tree | d996f83489910e20720fc754c3c15e77cfdc7fed /src/org/apache/fop | |
parent | db31be12a1969d7eadb8ce001c3b7e61b6e381bf (diff) | |
download | xmlgraphics-fop-92eae99485ec3c3e6892f47847464b4caf6906d3.tar.gz xmlgraphics-fop-92eae99485ec3c3e6892f47847464b4caf6906d3.zip |
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
Diffstat (limited to 'src/org/apache/fop')
-rw-r--r-- | src/org/apache/fop/svg/SVG.java | 37 |
1 files changed, 37 insertions, 0 deletions
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(); |