]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
handles symbol with viewbox
authorKeiron Liddle <keiron@apache.org>
Fri, 15 Sep 2000 00:13:37 +0000 (00:13 +0000)
committerKeiron Liddle <keiron@apache.org>
Fri, 15 Sep 2000 00:13:37 +0000 (00:13 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193696 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/svg/Symbol.java

index 8a859daddb792d74a40007328d1d9398c230b999..5463055ff3b3f43a321b85682596a5d4065144ed 100644 (file)
@@ -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;
+       }
 }