From: Keiron Liddle Date: Fri, 15 Sep 2000 00:13:37 +0000 (+0000) Subject: handles symbol with viewbox X-Git-Tag: pre-columns~184 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=833b847e448559075a57f9c609aec3c3cc5ebbb6;p=xmlgraphics-fop.git handles symbol with viewbox git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193696 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/svg/Symbol.java b/src/org/apache/fop/svg/Symbol.java index 8a859dadd..5463055ff 100644 --- a/src/org/apache/fop/svg/Symbol.java +++ b/src/org/apache/fop/svg/Symbol.java @@ -59,6 +59,11 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.dom.svg.*; import org.apache.fop.dom.svg.SVGArea; + +import org.w3c.dom.svg.*; + +import java.util.StringTokenizer; + /** * */ @@ -102,4 +107,50 @@ public class Symbol extends SVGObj { super(parent, propertyList); this.name = "svg:symbol"; } + + public SVGElement createGraphic() + { + String box = this.properties.get("viewBox").getString(); + StringTokenizer st = new StringTokenizer(box, " "); + float x = 0; + float y = 0; + float width = 0; + float height = 0; + try { + if(st.hasMoreTokens()) { + x = Float.parseFloat(st.nextToken()); + } + if(st.hasMoreTokens()) { + y = Float.parseFloat(st.nextToken()); + } + if(st.hasMoreTokens()) { + width = Float.parseFloat(st.nextToken()); + } + if(st.hasMoreTokens()) { + height = Float.parseFloat(st.nextToken()); + } + } catch(Exception e) { + } + SVGRect rect = new SVGRectImpl(); + rect.setX(x); + rect.setY(y); + rect.setWidth(width); + rect.setHeight(height); + SVGSymbolElementImpl graphic; + graphic = new SVGSymbolElementImpl(); + String id = this.properties.get("id").getString(); + graphic.setId(id); + graphic.setViewBox(new SVGAnimatedRectImpl(rect)); + + int numChildren = this.children.size(); + for (int i = 0; i < numChildren; i++) { + FONode child = (FONode) children.elementAt(i); + if(child instanceof GraphicsCreator) { + SVGElement impl = ((GraphicsCreator)child).createGraphic(); + graphic.appendChild(impl); + } + } + + return graphic; + } }