From 9006cc78b543749371ee5895ca3d4a6d6d711c5e Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Thu, 1 Mar 2001 02:16:27 +0000 Subject: [PATCH] no longer required git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_17_0_batikSVG@194106 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/datatypes/PathData.java | 302 ------------------ src/org/apache/fop/datatypes/StyleData.java | 81 ----- .../apache/fop/datatypes/TransformData.java | 228 ------------- 3 files changed, 611 deletions(-) delete mode 100644 src/org/apache/fop/datatypes/PathData.java delete mode 100644 src/org/apache/fop/datatypes/StyleData.java delete mode 100644 src/org/apache/fop/datatypes/TransformData.java diff --git a/src/org/apache/fop/datatypes/PathData.java b/src/org/apache/fop/datatypes/PathData.java deleted file mode 100644 index bdb91cf63..000000000 --- a/src/org/apache/fop/datatypes/PathData.java +++ /dev/null @@ -1,302 +0,0 @@ -/*-- $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 . For more information on the Apache - Software Foundation, please see . - - */ -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 - */ -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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.PATHSEG_ARC_REL, vals[count])); - } - } - } else if(str.equals("Z") || str.equals("z")) { - addSVGPathSeg(new SVGPathSegImpl(SVGPathSeg.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/StyleData.java b/src/org/apache/fop/datatypes/StyleData.java deleted file mode 100644 index c1c2548bc..000000000 --- a/src/org/apache/fop/datatypes/StyleData.java +++ /dev/null @@ -1,81 +0,0 @@ -/*-- $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 . For more information on the Apache - Software Foundation, please see . - - */ -package org.apache.fop.datatypes; - -import org.apache.fop.fo.Property; -import org.apache.fop.messaging.MessageHandler; - -import org.apache.fop.dom.svg.*; -import org.apache.fop.dom.css.*; - -import org.w3c.dom.css.*; - -import java.util.*; -/** - * a StyleData quantity in XSL - * - * @author Keiron Liddle - */ -public class StyleData { - CSSStyleDeclaration styleDec = new CSSStyleDeclarationImpl(); - - /** - * set the StyleData given a particular String specifying StyleData and units - */ - public StyleData (String str) { - styleDec.setCssText(str); - } - - public CSSStyleDeclaration getStyle() - { - return styleDec; - } -} diff --git a/src/org/apache/fop/datatypes/TransformData.java b/src/org/apache/fop/datatypes/TransformData.java deleted file mode 100644 index 067712b37..000000000 --- a/src/org/apache/fop/datatypes/TransformData.java +++ /dev/null @@ -1,228 +0,0 @@ -/*-- $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 . For more information on the Apache - Software Foundation, please see . - - */ -package org.apache.fop.datatypes; - -import org.apache.fop.fo.Property; -import org.apache.fop.messaging.MessageHandler; - -import org.apache.fop.dom.svg.*; -import org.apache.fop.dom.svg.SVGTransformImpl; - -import org.w3c.dom.svg.*; - -import java.util.*; -/** - * a TransformData quantity in XSL - * - * @author Keiron Liddle - * modified Nov 14,2000 Mike Crowe - */ -public class TransformData { - SVGAnimatedTransformListImpl trans; - - /** - * set the TransformData given a particular String specifying TransformData and units - */ - public TransformData (String len) { - convert(len); - } - - - /** - * The following is taken from CR-SVG-20000802 7.6, Transform Attribute - * The value of the transform attribute is a , which is - * defined as a list of transform definitions, which are applied in the - * order provided. The individual transform definitions are separated by - * whitespace and/or a comma. The available types of transform - * definitions include: - * - * matrix( ), which specifies a transformation in the - * form of a transformation matrix of six values. - * matrix(a,b,c,d,e,f) is equivalent to applying the transformation matrix - * [a b c d e f]. - * - * translate( []), which specifies a translation by tx and ty. - * - * scale( []), which specifies a scale operation by sx and sy. If - * is not provided, it is assumed to be equal to . - * - * rotate( [ ]), which specifies a rotation by - * degrees about a given point. - * If optional parameters and are not supplied, the rotate is about - * the origin of the current user coordinate system. The - * operation corresponds to the matrix [cos(a) sin(a) -sin(a) cos(a) 0 0]. - * If optional parameters and are supplied, the rotate is about the - * point (, ). The operation represents the - * equivalent of the following specification: translate(, ) - * rotate() translate(-, -). - * - * skewX(), which specifies a skew transformation along the - * x-axis. - * skewY(), which specifies a skew transformation along the - * y-axis. - */ - protected void convert(String len) { - Vector list = new Vector(); - 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(); - SVGTransform transform = new SVGTransformImpl(); - - if (type.equals("matrix")) { - SVGMatrix matrix = new SVGMatrixImpl(); - StringTokenizer mt = - new StringTokenizer(value, " ,\r\n-", true); - if (mt.hasMoreTokens()) - matrix.setA(extractValue(mt)); - if (mt.hasMoreTokens()) - matrix.setB(extractValue(mt)); - if (mt.hasMoreTokens()) - matrix.setC(extractValue(mt)); - if (mt.hasMoreTokens()) - matrix.setD(extractValue(mt)); - if (mt.hasMoreTokens()) - matrix.setE(extractValue(mt)); - if (mt.hasMoreTokens()) - matrix.setF(extractValue(mt)); - transform.setMatrix(matrix); - list.addElement(transform); - } else if (type.equals("translate")) { - float xlen = 0; - float ylen = 0; - StringTokenizer mt = - new StringTokenizer(value, " ,\r\n-", true); - if (mt.hasMoreTokens()) - xlen = extractValue(mt); - if (mt.hasMoreTokens()) - ylen = extractValue(mt); - - transform.setTranslate(xlen, ylen); - list.addElement(transform); - } else if (type.equals("scale")) { - float xlen = 0; - float ylen = 0; - StringTokenizer mt = - new StringTokenizer(value, " ,\r\n-", true); - - if (mt.hasMoreTokens()) - xlen = extractValue(mt); - if (mt.hasMoreTokens()) - ylen = extractValue(mt); - else - ylen = xlen; - - transform.setScale(xlen, ylen); - list.addElement(transform); - } else if (type.equals("rotate")) { - SVGAngleImpl angle = new SVGAngleImpl(); - angle.setValueAsString(value); - - transform.setRotate(angle.getValue(), 0, 0); - list.addElement(transform); - } else if (type.equals("skewX")) { - SVGAngleImpl angle = new SVGAngleImpl(); - angle.setValueAsString(value); - - transform.setSkewX(angle.getValue()); - list.addElement(transform); - } else if (type.equals("skewY")) { - SVGAngleImpl angle = new SVGAngleImpl(); - angle.setValueAsString(value); - - transform.setSkewY(angle.getValue()); - list.addElement(transform); - - } else { - MessageHandler.errorln( - "WARNING: Unknown Transform type : " + type); - } - - } - } - if (list != null) { - SVGTransformList stl = new SVGTransformListImpl(); - for (Enumeration e = list.elements(); e.hasMoreElements();) { - stl.appendItem((SVGTransform) e.nextElement()); - } - trans = new SVGAnimatedTransformListImpl(); - trans.setBaseVal(stl); - } - } - - private float extractValue(StringTokenizer mt) { - String tok = mt.nextToken(); - boolean neg = false; - 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; - SVGLengthImpl length = new SVGLengthImpl(); - length.setValueAsString(tok); - return(length.getValue()); - } - - - public SVGAnimatedTransformList getTransform() { - return trans; - } -} -- 2.39.5