]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
data types for svg elements
authorKeiron Liddle <keiron@apache.org>
Tue, 11 Jul 2000 05:22:21 +0000 (05:22 +0000)
committerKeiron Liddle <keiron@apache.org>
Tue, 11 Jul 2000 05:22:21 +0000 (05:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193481 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/datatypes/PathData.java [new file with mode: 0644]
src/org/apache/fop/datatypes/PointsData.java [new file with mode: 0644]
src/org/apache/fop/datatypes/StyleData.java [new file with mode: 0644]
src/org/apache/fop/datatypes/TransformData.java [new file with mode: 0644]

diff --git a/src/org/apache/fop/datatypes/PathData.java b/src/org/apache/fop/datatypes/PathData.java
new file mode 100644 (file)
index 0000000..207e213
--- /dev/null
@@ -0,0 +1,302 @@
+/*-- $Id$ -- 
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+ 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache 
+ Software Foundation, please see <http://www.apache.org/>.
+ */
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.Property;
+import org.apache.fop.svg.PathPoint;
+import org.apache.fop.dom.svg.*;
+import org.w3c.dom.svg.*;
+
+import java.util.*;
+/**
+ * a PathData quantity in XSL
+ * This class parses the string of path data and create a list of
+ * object commands. It is up to renderers (or whatever) to interpret
+ * the command properly.
+ * eg. m at the start is an absolute moveto.
+ *
+ *
+ * @author Keiron Liddle <keiron@aftexsw.com>
+ */
+public class PathData {
+       Vector table = new Vector();
+
+       /**
+        * set the PathData given a particular String specifying PathData and units
+        */
+       public PathData (String len)
+       {
+               convert(len);
+       }
+
+       protected void convert(String len)
+       {
+               StringTokenizer st = new StringTokenizer(len, "MmLlHhVvCcSsQqTtAaZz", true);
+               /*
+                * If there are two numbers and no spaces then it is assumed that all
+                * numbers are the same number of chars (3), otherwise there is an error
+                * not mentioned in spec.
+                */
+               while(st.hasMoreTokens()) {
+                       String str = st.nextToken();
+                       int pos;
+                       if(str.equals("M")) {
+                               float[][] vals = getPoints(2, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_MOVETO_ABS, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("m")) {
+                               // if first element treat as M
+                               // otherwise treat as implicit lineto, this is handled by renderers
+                               float[][] vals = getPoints(2, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_MOVETO_REL, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("L")) {
+                               float[][] vals = getPoints(2, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_LINETO_ABS, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("l")) {
+                               float[][] vals = getPoints(2, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_LINETO_REL, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("H")) {
+                               float[][] vals = getPoints(1, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_LINETO_HORIZONTAL_ABS, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("h")) {
+                               float[][] vals = getPoints(1, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_LINETO_HORIZONTAL_REL, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("V")) {
+                               float[][] vals = getPoints(1, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_LINETO_VERTICAL_ABS, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("v")) {
+                               float[][] vals = getPoints(1, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_LINETO_VERTICAL_REL, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("C")) {
+                               float[][] vals = getPoints(6, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_CURVETO_CUBIC_ABS, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("c")) {
+                               float[][] vals = getPoints(6, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_CURVETO_CUBIC_REL, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("S")) {
+                               float[][] vals = getPoints(4, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("s")) {
+                               float[][] vals = getPoints(4, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_CURVETO_CUBIC_SMOOTH_REL, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("Q")) {
+                               float[][] vals = getPoints(4, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_CURVETO_QUADRATIC_ABS, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("q")) {
+                               float[][] vals = getPoints(4, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_CURVETO_QUADRATIC_REL, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("T")) {
+                               float[][] vals = getPoints(2, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("t")) {
+                               float[][] vals = getPoints(2, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("A")) {
+                               float[][] vals = getPoints(7, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_ARC_ABS, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("a")) {
+                               float[][] vals = getPoints(7, st);
+                               if(vals != null) {
+                                       for(int count = 0; count < vals.length; count++) {
+                                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_ARC_REL, vals[count]));
+                                       }
+                               }
+                       } else if(str.equals("Z") || str.equals("z")) {
+                               addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.SVG_PATHSEG_CLOSEPATH, null));
+                       }
+               }
+       }
+
+       public Vector getPath()
+       {
+               return table;
+       }
+
+       public String toString()
+       {
+               return "";
+       }
+
+       float[][] getPoints(int num, StringTokenizer st)
+       {
+               float[] set;
+               String str;
+               int pos;
+               float[][] ret = null;
+               if(st.hasMoreTokens()) {
+                       str = st.nextToken();
+                       str = str.trim();
+//                     pos = str.indexOf(" ");
+/*                     if((str.indexOf(" ") == -1) && (str.indexOf(",") == -1) && (str.indexOf("-") == -1)) {
+                               int length = str.length();
+                               if((length % num) != 0) {
+                                       // invalid number comb
+                               } else {
+                                       // how do we determine the length of a single number?
+                               }
+                       } else {*/
+                       {
+                               StringTokenizer pointtok = new StringTokenizer(str, " ,-\n\r\t", true);
+                               int count = 0;
+                               Vector values = new Vector();
+                               set = new float[num];
+                               boolean neg;
+                               while(pointtok.hasMoreTokens()) {
+                                       String point = null;
+                                       String delim = pointtok.nextToken();
+                                       if(delim.equals("-")) {
+                                               neg = true;
+                                               if(pointtok.hasMoreTokens()) {
+                                                       point = pointtok.nextToken();
+                                               } else {
+                                                       break;
+                                               }
+                                       } else {
+                                               neg = false;
+                                               if(delim.equals(" ") || delim.equals(",") || delim.equals("\r") || delim.equals("\n") || delim.equals("\t")) {
+                                                       continue;
+                                               }
+                                               point = delim;
+                                       }
+
+                                       float pd = Float.valueOf(point).floatValue();
+                                       if(neg)
+                                               pd = -pd;
+                                       set[count] = pd;
+                                       count++;
+                                       if(count == num) {
+                                               values.addElement(set);
+                                               set = new float[num];
+                                               count = 0;
+                                       }
+                               }
+                               count = 0;
+                               ret = new float[values.size()][];
+                               for(Enumeration e = values.elements(); e.hasMoreElements(); ) {
+                                       ret[count++] = (float[])e.nextElement();
+                               }
+                       }
+               }
+               return ret;
+       }
+
+       protected void addSVGPathSeg(SVGPathSeg pc)
+       {
+               table.addElement(pc);
+       }
+}
diff --git a/src/org/apache/fop/datatypes/PointsData.java b/src/org/apache/fop/datatypes/PointsData.java
new file mode 100644 (file)
index 0000000..8c09ea4
--- /dev/null
@@ -0,0 +1,97 @@
+/*-- $Id$ -- 
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+ 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache 
+ Software Foundation, please see <http://www.apache.org/>.
+ */
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.Property;
+import org.apache.fop.svg.PathPoint;
+
+import java.util.*;
+
+/*
+ *
+ *
+ * @author Keiron Liddle <keiron@aftexsw.com>
+ */
+public class PointsData {
+       Vector table = new Vector();
+
+       public PointsData (String len)
+       {
+               convert(len);
+       }
+
+       protected void convert(String len)
+       {
+               StringTokenizer st = new StringTokenizer(len, " \n\r\t");
+               while(st.hasMoreTokens()) {
+                       String str = st.nextToken().trim();
+                       int pos;
+                       pos = str.indexOf(",");
+                       if(pos != -1) {
+                               float x;
+                               float y;
+                               x = Float.valueOf(str.substring(0, pos).trim()).floatValue();
+                               y = Float.valueOf(str.substring(pos + 1, str.length()).trim()).floatValue();
+                               addPoint(new PathPoint(x, y));
+                       }
+               }
+       }
+
+       public Vector getPoints()
+       {
+               return table;
+       }
+
+       protected void addPoint(PathPoint pc)
+       {
+               table.addElement(pc);
+       }
+}
diff --git a/src/org/apache/fop/datatypes/StyleData.java b/src/org/apache/fop/datatypes/StyleData.java
new file mode 100644 (file)
index 0000000..dc620d0
--- /dev/null
@@ -0,0 +1,183 @@
+/*-- $Id$ -- 
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+ 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache 
+ Software Foundation, please see <http://www.apache.org/>.
+ */
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.Property;
+
+import org.apache.fop.dom.svg.*;
+
+import java.util.*;
+/**
+ * a StyleData quantity in XSL
+ *
+ * @author Keiron Liddle <keiron@aftexsw.com>
+ */
+public class StyleData {
+       Hashtable table = new Hashtable();
+
+       /**
+        * set the StyleData given a particular String specifying StyleData and units
+        */
+       public StyleData (String len) {
+               try {
+               convert(len);
+               } catch(Exception e) {
+                       e.printStackTrace();
+               }
+       }
+
+       protected void convert(String len) {
+               StringTokenizer st = new StringTokenizer(len, ";");
+               while(st.hasMoreTokens()) {
+                       String str = st.nextToken();
+                       int pos;
+                       pos = str.indexOf(":");
+                       if(pos != -1) {
+                               String type = str.substring(0, pos).trim();
+                               String value = str.substring(pos + 1, str.length()).trim();
+                               if(type.equals("stroke-width")) {
+                                       table.put(type, new SVGLengthImpl(value));
+                               } else if(type.equals("stroke")) {
+                                       if(value.startsWith("url(")) {
+                                               table.put(type, new String(value));
+                                       } else if(!value.equals("none")) {
+                                                       table.put(type, new ColorType(value));
+                                       }
+                               } else if(type.equals("color")) {
+//                                     if(!value.equals("none"))
+//                                             table.put("stroke", new ColorType(value));//??
+                                       table.put(type, new ColorType(value));//??
+                               } else if(type.equals("stroke-linecap")) {
+                                       table.put(type, value);
+                               } else if(type.equals("stroke-linejoin")) {
+                                       table.put(type, value);
+                               } else if(type.equals("stroke-miterlimit")) {
+                               } else if(type.equals("stroke-dasharray")) {
+                                       // array of space or comma separated numbers
+                                       Vector list = new Vector();
+                                       StringTokenizer array = new StringTokenizer(value, " ,");
+                                       while(array.hasMoreTokens()) {
+                                               String intstr = array.nextToken();
+                                               list.addElement(new Integer(Integer.parseInt(intstr)));
+                                       }
+                                       table.put(type, list);
+                               } else if(type.equals("stroke-dashoffset")) {
+                                       table.put(type, new SVGLengthImpl(value));
+                               } else if(type.equals("stroke-opacity")) {
+                               } else if(type.equals("fill")) {
+                                       if(value.startsWith("url(")) {
+                                               table.put(type, new String(value));
+                                       } else if(!value.equals("none")) {
+                                               table.put(type, new ColorType(value));
+                                       }
+//                                     else
+//                                             table.put(type, null);
+                               } else if(type.equals("fill-rule")) {
+                                       // nonzero
+                               } else if(type.equals("font")) {
+                                       table.put(type, value);
+                               } else if(type.equals("font-size")) {
+                                       table.put(type, new SVGLengthImpl(value));
+                               } else if(type.equals("font-family")) {
+                                       table.put(type, value);
+                               } else if(type.equals("font-weight")) {
+                                       table.put(type, value);
+                               } else if(type.equals("font-style")) {
+                                       table.put(type, value);
+                               } else if(type.equals("font-variant")) {
+                                       table.put(type, value);
+                               } else if(type.equals("font-stretch")) {
+                                       table.put(type, value);
+                               } else if(type.equals("font-size-adjust")) {
+                                       table.put(type, value);
+                               } else if(type.equals("letter-spacing")) {
+                                       table.put(type, new SVGLengthImpl(value));
+                               } else if(type.equals("word-spacing")) {
+                                       table.put(type, new SVGLengthImpl(value));
+                               } else if(type.equals("text-decoration")) {
+                                       table.put(type, value);
+                               } else if(type.equals("mask")) {
+                                       if(value.startsWith("url(")) {
+                                               value = value.substring(4, value.length() - 1);
+                                       }
+                                       table.put(type, value);
+                               } else if(type.equals("fill-opacity")) {
+//                                     table.put(type, new SVGLengthImpl(value));
+                               } else if(type.equals("opacity")) {
+//                                     table.put(type, new SVGLengthImpl(value));
+                               } else if(type.equals("filter")) {
+//                                     table.put(type, new Filter(value));
+                               } else if(type.equals("stop-color")) {
+                                       table.put(type, new ColorType(value));
+                               } else if(type.equals("marker-start")) {
+//                                     table.put(type, new URLType(value));
+                               } else if(type.equals("marker-mid")) {
+//                                     table.put(type, new URLType(value));
+                               } else if(type.equals("marker-end")) {
+//                                     table.put(type, new URLType(value));
+                               } else if(type.equals("text-antialiasing")) {
+//                                     boolean
+                               } else if(type.equals("stroke-antialiasing")) {
+//                                     boolean
+                               } else {
+                                       System.err.println("WARNING Unknown style element : " + type);
+                               }
+                       } else {
+                               System.err.println("WARNING Invalid style element " + str);
+                       }
+               }
+       }
+
+       public Hashtable getStyle()
+       {
+               return table;
+       }
+}
diff --git a/src/org/apache/fop/datatypes/TransformData.java b/src/org/apache/fop/datatypes/TransformData.java
new file mode 100644 (file)
index 0000000..f2147b7
--- /dev/null
@@ -0,0 +1,240 @@
+/*-- $Id$ -- 
+
+ ============================================================================
+                   The Apache Software License, Version 1.1
+ ============================================================================
+    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+ Redistribution and use in source and binary forms, with or without modifica-
+ tion, are permitted provided that the following conditions are met:
+ 1. Redistributions of  source code must  retain the above copyright  notice,
+    this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+ 3. The end-user documentation included with the redistribution, if any, must
+    include  the following  acknowledgment:  "This product includes  software
+    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
+    Alternately, this  acknowledgment may  appear in the software itself,  if
+    and wherever such third-party acknowledgments normally appear.
+ 4. The names "Fop" and  "Apache Software Foundation"  must not be used to
+    endorse  or promote  products derived  from this  software without  prior
+    written permission. For written permission, please contact
+    apache@apache.org.
+ 5. Products  derived from this software may not  be called "Apache", nor may
+    "Apache" appear  in their name,  without prior written permission  of the
+    Apache Software Foundation.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
+ APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
+ DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
+ ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
+ (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ This software  consists of voluntary contributions made  by many individuals
+ on  behalf of the Apache Software  Foundation and was  originally created by
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache 
+ Software Foundation, please see <http://www.apache.org/>.
+ */
+package org.apache.fop.datatypes;
+
+import org.apache.fop.fo.Property;
+
+import org.apache.fop.dom.svg.*;
+import org.apache.fop.dom.svg.SVGTransformImpl;
+
+import java.util.*;
+/**
+ * a TransformData quantity in XSL
+ *
+ * @author Keiron Liddle <keiron@aftexsw.com>
+ */
+public class TransformData {
+       Vector list = new Vector();
+
+       /**
+        * set the TransformData given a particular String specifying TransformData and units
+        */
+       public TransformData (String len) {
+               convert(len);
+       }
+
+       protected void convert(String len) {
+               StringTokenizer st = new StringTokenizer(len, "()");
+               // need to check for unbalanced brackets
+               while(st.hasMoreTokens()) {
+                       String str = st.nextToken();
+                       String type = str.trim();
+                       String value;
+                       if(st.hasMoreTokens()) {
+                               value = st.nextToken().trim();
+                               SVGTransformImpl transform = new SVGTransformImpl();
+                               if(type.equals("translate")) {
+                                       SVGLengthImpl xlen;
+                                       SVGLengthImpl ylen;
+                                       int pos = value.indexOf(",");
+                                       if(pos != -1) {
+                                               xlen = new SVGLengthImpl(value.substring(0, pos).trim());
+                                               ylen = new SVGLengthImpl(value.substring(pos + 1, value.length()).trim());
+                                       } else {
+                                               xlen = new SVGLengthImpl("0");
+                                               ylen = new SVGLengthImpl("0");
+                                       }
+                                       transform.setTranslate(xlen, ylen);
+                                       list.addElement(transform);
+                               } else if(type.equals("skewX")) {
+                                       SVGAngleImpl angle = new SVGAngleImpl();
+                                       angle.setValueAsString(value);
+                                       transform.setSkewX(angle);
+                                       list.addElement(transform);
+                               } else if(type.equals("skewY")) {
+                                       SVGAngleImpl angle = new SVGAngleImpl();
+                                       angle.setValueAsString(value);
+                                       transform.setSkewY(angle);
+                                       list.addElement(transform);
+                               } else if(type.equals("scale")) {
+                                       SVGNumberImpl xlen = new SVGNumberImpl();
+                                       SVGNumberImpl ylen = new SVGNumberImpl();
+                                       int pos = value.indexOf(",");
+                                       if(pos != -1) {
+                                               try {
+                                                       xlen.setValue((new Float(value.substring(0, pos).trim())).floatValue());
+                                               } catch(Exception e) {
+                                               }
+                                               try {
+                                                       ylen.setValue((new Float(value.substring(pos + 1, value.length()).trim()).floatValue()));
+                                               } catch(Exception e) {
+                                               }
+                                       }
+                                       transform.setScale(xlen, ylen);
+                                       list.addElement(transform);
+                               } else if(type.equals("rotate")) {
+                                       SVGAngleImpl angle = new SVGAngleImpl();
+                                       angle.setValueAsString(value);
+                                       transform.setRotate(angle);
+                                       list.addElement(transform);
+                               } else if(type.equals("matrix")) {
+                                       SVGMatrixImpl matrix = new SVGMatrixImpl();
+                                       StringTokenizer mt = new StringTokenizer(value, " ,\r\n-", true);
+                                       // need to handle negatives
+                                       String tok;
+                                       boolean neg = false;
+                                       if(mt.hasMoreTokens()) {
+                                               tok = mt.nextToken();
+                                               while(tok.equals(" ") || tok.equals(",") || tok.equals("\n") || tok.equals("\r") || tok.equals("-")) {
+                                                       if(tok.equals("-")) {
+                                                               neg = true;
+                                                       }
+                                                       if(!mt.hasMoreTokens())
+                                                               break;
+                                                       tok = mt.nextToken();
+                                               }
+                                               float floatVal = Float.valueOf(tok).floatValue();
+                                               if(neg)
+                                                       floatVal = -floatVal;
+                                               matrix.setA(floatVal);
+                                       }
+                                       if(mt.hasMoreTokens()) {
+                                               tok = mt.nextToken();
+                                               while(tok.equals(" ") || tok.equals(",") || tok.equals("\n") || tok.equals("\r") || tok.equals("-")) {
+                                                       if(tok.equals("-")) {
+                                                               neg = true;
+                                                       }
+                                                       if(!mt.hasMoreTokens())
+                                                               break;
+                                                       tok = mt.nextToken();
+                                               }
+                                               float floatVal = Float.valueOf(tok).floatValue();
+                                               if(neg)
+                                                       floatVal = -floatVal;
+                                               matrix.setB(floatVal);
+                                       }
+                                       if(mt.hasMoreTokens()) {
+                                               tok = mt.nextToken();
+                                               while(tok.equals(" ") || tok.equals(",") || tok.equals("\n") || tok.equals("\r") || tok.equals("-")) {
+                                                       if(tok.equals("-")) {
+                                                               neg = true;
+                                                       }
+                                                       if(!mt.hasMoreTokens())
+                                                               break;
+                                                       tok = mt.nextToken();
+                                               }
+                                               float floatVal = Float.valueOf(tok).floatValue();
+                                               if(neg)
+                                                       floatVal = -floatVal;
+                                               matrix.setC(floatVal);
+                                       }
+                                       if(mt.hasMoreTokens()) {
+                                               tok = mt.nextToken();
+                                               while(tok.equals(" ") || tok.equals(",") || tok.equals("\n") || tok.equals("\r") || tok.equals("-")) {
+                                                       if(tok.equals("-")) {
+                                                               neg = true;
+                                                       }
+                                                       if(!mt.hasMoreTokens())
+                                                               break;
+                                                       tok = mt.nextToken();
+                                               }
+                                               float floatVal = Float.valueOf(tok).floatValue();
+                                               if(neg)
+                                                       floatVal = -floatVal;
+                                               matrix.setD(floatVal);
+                                       }
+                                       SVGLengthImpl length;
+                                       if(mt.hasMoreTokens()) {
+                                               tok = mt.nextToken();
+                                               while(tok.equals(" ") || tok.equals(",") || tok.equals("\n") || tok.equals("\r") || tok.equals("-")) {
+                                                       if(tok.equals("-")) {
+                                                               neg = true;
+                                                       }
+                                                       if(!mt.hasMoreTokens())
+                                                               break;
+                                                       tok = mt.nextToken();
+                                               }
+                                               if(neg)
+                                                       tok = "-" + tok;
+                                               length = new SVGLengthImpl();
+                                               length.setValueAsString(tok);
+                                               matrix.setE(length);
+                                       }
+                                       if(mt.hasMoreTokens()) {
+                                               tok = mt.nextToken();
+                                               while(tok.equals(" ") || tok.equals(",") || tok.equals("\n") || tok.equals("\r") || tok.equals("-")) {
+                                                       if(tok.equals("-")) {
+                                                               neg = true;
+                                                       }
+                                                       if(!mt.hasMoreTokens())
+                                                               break;
+                                                       tok = mt.nextToken();
+                                               }
+                                               if(neg)
+                                                       tok = "-" + tok;
+                                               length = new SVGLengthImpl();
+                                               length.setValueAsString(tok);
+                                               matrix.setF(length);
+                                       }
+                                       transform.setMatrix(matrix);
+                                       list.addElement(transform);
+                               } else {
+                                       System.err.println("WARNING Unknown Transform type : " + type);
+                               }
+                       }
+               }
+       }
+
+       public Vector oldgetTransform()
+       {
+               return list;
+       }
+}