diff options
author | Keiron Liddle <keiron@apache.org> | 2000-11-29 03:22:02 +0000 |
---|---|---|
committer | Keiron Liddle <keiron@apache.org> | 2000-11-29 03:22:02 +0000 |
commit | 6d47baba0cf8c94d11bcff8fcacf1c4c049d8be0 (patch) | |
tree | 30a6896baf6749460eb101f9e65c6c8ac36246ae /src/org/apache/fop/svg | |
parent | 8f69bb7bd3a494c4fa046ef96851eff8fdcfa3d8 (diff) | |
download | xmlgraphics-fop-6d47baba0cf8c94d11bcff8fcacf1c4c049d8be0.tar.gz xmlgraphics-fop-6d47baba0cf8c94d11bcff8fcacf1c4c049d8be0.zip |
updated svg stuff for the latest java bindings
added some props for units, gradient etc.
jstyle'd
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193847 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/svg')
-rw-r--r-- | src/org/apache/fop/svg/ClipPath.java | 154 | ||||
-rw-r--r-- | src/org/apache/fop/svg/LinearGradient.java | 11 | ||||
-rw-r--r-- | src/org/apache/fop/svg/Pattern.java | 157 | ||||
-rw-r--r-- | src/org/apache/fop/svg/RadialGradient.java | 11 | ||||
-rw-r--r-- | src/org/apache/fop/svg/SVG.java | 2 | ||||
-rw-r--r-- | src/org/apache/fop/svg/SVGStringList.java | 81 | ||||
-rw-r--r-- | src/org/apache/fop/svg/Switch.java | 218 |
7 files changed, 282 insertions, 352 deletions
diff --git a/src/org/apache/fop/svg/ClipPath.java b/src/org/apache/fop/svg/ClipPath.java index 42a6f9e4a..65b5562a0 100644 --- a/src/org/apache/fop/svg/ClipPath.java +++ b/src/org/apache/fop/svg/ClipPath.java @@ -1,36 +1,36 @@ -/*-- $Id$ -- +/*-- $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 @@ -41,12 +41,12 @@ 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 + James Tauber <jtauber@jtauber.com>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. - + */ package org.apache.fop.svg; @@ -56,11 +56,13 @@ import org.apache.fop.fo.*; import org.apache.fop.layout.Area; import org.apache.fop.layout.FontState; import org.apache.fop.apps.FOPException; +import org.apache.fop.fo.properties.*; import org.apache.fop.dom.svg.*; import org.apache.fop.dom.svg.SVGArea; import org.w3c.dom.svg.SVGElement; +import org.w3c.dom.svg.*; /** * class representing svg:ClipPath pseudo flow object. @@ -68,63 +70,73 @@ import org.w3c.dom.svg.SVGElement; */ public class ClipPath extends SVGObj { - /** - * inner class for making ClipPath objects. - */ - public static class Maker extends FObj.Maker { - - /** - * make a ClipPath object. - * - * @param parent the parent formatting object - * @param propertyList the explicit properties of this object - * - * @return the ClipPath object - */ - public FObj make(FObj parent, PropertyList propertyList) throws FOPException - { - return new ClipPath(parent, propertyList); - } - } - - /** - * returns the maker for this object. - * - * @return the maker for ClipPath objects - */ - public static FObj.Maker maker() { - return new ClipPath.Maker(); - } - - /** - * constructs a ClipPath object (called by Maker). - * - * @param parent the parent formatting object - * @param propertyList the explicit properties of this object - */ - protected ClipPath(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "svg:clipPath"; - } - - SVGClipPathElementImpl clippath = new SVGClipPathElementImpl(); - - protected void addChild(FONode child) { - super.addChild(child); - if(child instanceof GraphicsCreator) { - GraphicsCreator gc = (GraphicsCreator)child; - SVGElement graph = gc.createGraphic(); - clippath.addElement(graph); -// graph.setParent(clippath); - } else { - // error - } - } - - public SVGElement createGraphic() - { - clippath.setStyle(((SVGStyle)this.properties.get("style")).getStyle()); - clippath.setId(this.properties.get("id").getString()); - return clippath; - } + /** + * inner class for making ClipPath objects. + */ + public static class Maker extends FObj.Maker { + + /** + * make a ClipPath object. + * + * @param parent the parent formatting object + * @param propertyList the explicit properties of this object + * + * @return the ClipPath object + */ + public FObj make(FObj parent, + PropertyList propertyList) throws FOPException { + return new ClipPath(parent, propertyList); + } + } + + /** + * returns the maker for this object. + * + * @return the maker for ClipPath objects + */ + public static FObj.Maker maker() { + return new ClipPath.Maker(); + } + + /** + * constructs a ClipPath object (called by Maker). + * + * @param parent the parent formatting object + * @param propertyList the explicit properties of this object + */ + protected ClipPath(FObj parent, PropertyList propertyList) { + super(parent, propertyList); + this.name = "svg:clipPath"; + } + + SVGClipPathElementImpl clippath = new SVGClipPathElementImpl(); + + protected void addChild(FONode child) { + super.addChild(child); + if (child instanceof GraphicsCreator) { + GraphicsCreator gc = (GraphicsCreator) child; + SVGElement graph = gc.createGraphic(); + clippath.addElement(graph); + // graph.setParent(clippath); + } else { + // error + } + } + + public SVGElement createGraphic() { + clippath.setStyle( + ((SVGStyle) this.properties.get("style")).getStyle()); + clippath.setId(this.properties.get("id").getString()); + switch ((this.properties.get("clipPathUnits")).getEnum()) { + case GenericUnits.Enums.USER_SPACE_ON_USE: + clippath.setClipPathUnits( new SVGAnimatedEnumerationImpl( + SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEONUSE)); + break; + case GenericUnits.Enums.OBJECT_BOUNDING_BOX: + clippath.setClipPathUnits( new SVGAnimatedEnumerationImpl( + SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)); + break; + } + return clippath; + } } diff --git a/src/org/apache/fop/svg/LinearGradient.java b/src/org/apache/fop/svg/LinearGradient.java index 7452ca75f..2f4be86ae 100644 --- a/src/org/apache/fop/svg/LinearGradient.java +++ b/src/org/apache/fop/svg/LinearGradient.java @@ -125,6 +125,9 @@ public class LinearGradient extends SVGObj { linear.setTransform( ((SVGTransform) this.properties.get("transform")). getTransform()); + linear.setGradientTransform( + ((SVGTransform) this.properties.get("gradientTransform")). + getTransform()); linear.setId(this.properties.get("id").getString()); String rf = this.properties.get("xlink:href").getString(); linear.setHref(new SVGAnimatedStringImpl(rf)); @@ -162,15 +165,11 @@ public class LinearGradient extends SVGObj { break; } switch ((this.properties.get("gradientUnits")).getEnum()) { - case GradientUnits.USER_SPACE: - linear.setGradientUnits( new SVGAnimatedEnumerationImpl( - SVGUnitTypes.SVG_UNIT_TYPE_USERSPACE)); - break; - case GradientUnits.USER_SPACE_ON_USE: + case GenericUnits.Enums.USER_SPACE_ON_USE: linear.setGradientUnits( new SVGAnimatedEnumerationImpl( SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEONUSE)); break; - case GradientUnits.OBJECT_BOUNDING_BOX: + case GenericUnits.Enums.OBJECT_BOUNDING_BOX: linear.setGradientUnits( new SVGAnimatedEnumerationImpl( SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)); break; diff --git a/src/org/apache/fop/svg/Pattern.java b/src/org/apache/fop/svg/Pattern.java index eebbdb3ec..5f3a852f2 100644 --- a/src/org/apache/fop/svg/Pattern.java +++ b/src/org/apache/fop/svg/Pattern.java @@ -1,36 +1,36 @@ -/*-- $Id$ -- +/*-- $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 @@ -41,12 +41,12 @@ 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 + James Tauber <jtauber@jtauber.com>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. - + */ package org.apache.fop.svg; @@ -68,47 +68,47 @@ import org.w3c.dom.svg.*; */ public class Pattern extends SVGObj { - /** - * inner class for making Pattern objects. - */ - public static class Maker extends FObj.Maker { - - /** - * make a Pattern object. - * - * @param parent the parent formatting object - * @param propertyList the explicit properties of this object - * - * @return the Pattern object - */ - public FObj make(FObj parent, PropertyList propertyList) throws FOPException - { - return new Pattern(parent, propertyList); - } - } - - /** - * returns the maker for this object. - * - * @return the maker for Pattern objects - */ - public static FObj.Maker maker() { - return new Pattern.Maker(); - } - - /** - * constructs a Pattern object (called by Maker). - * - * @param parent the parent formatting object - * @param propertyList the explicit properties of this object - */ - protected Pattern(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "svg:pattern"; - } + /** + * inner class for making Pattern objects. + */ + public static class Maker extends FObj.Maker { + + /** + * make a Pattern object. + * + * @param parent the parent formatting object + * @param propertyList the explicit properties of this object + * + * @return the Pattern object + */ + public FObj make(FObj parent, + PropertyList propertyList) throws FOPException { + return new Pattern(parent, propertyList); + } + } + + /** + * returns the maker for this object. + * + * @return the maker for Pattern objects + */ + public static FObj.Maker maker() { + return new Pattern.Maker(); + } + + /** + * constructs a Pattern object (called by Maker). + * + * @param parent the parent formatting object + * @param propertyList the explicit properties of this object + */ + protected Pattern(FObj parent, PropertyList propertyList) { + super(parent, propertyList); + this.name = "svg:pattern"; + } public SVGElement createGraphic() { - SVGPatternElementImpl pattern = new SVGPatternElementImpl(); + SVGPatternElementImpl pattern = new SVGPatternElementImpl(); String rf = this.properties.get("xlink:href").getString(); pattern.setHref(new SVGAnimatedStringImpl(rf)); SVGLength width = @@ -117,44 +117,45 @@ public class Pattern extends SVGObj { SVGLength height = ((SVGLengthProperty) this.properties.get("height")). getSVGLength(); - SVGLength x = - ((SVGLengthProperty) this.properties.get("x")). - getSVGLength(); + SVGLength x = ((SVGLengthProperty) this.properties.get("x")). + getSVGLength(); SVGLength y = ((SVGLengthProperty) this.properties.get("y")). - getSVGLength(); + getSVGLength(); pattern.setX(x == null ? null : new SVGAnimatedLengthImpl(x)); pattern.setY(y == null ? null : new SVGAnimatedLengthImpl(y)); - pattern.setWidth(width == null ? null : new SVGAnimatedLengthImpl(width)); - pattern.setHeight(height == null ? null : new SVGAnimatedLengthImpl(height)); - pattern.setPatternTransform(((SVGTransform) this.properties.get("transform")). + pattern.setWidth(width == null ? null : + new SVGAnimatedLengthImpl(width)); + pattern.setHeight(height == null ? null : + new SVGAnimatedLengthImpl(height)); + pattern.setPatternTransform( + ((SVGTransform) this.properties.get("transform")). getTransform()); pattern.setId(this.properties.get("id").getString()); - 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(); - if(impl != null) { - if(impl instanceof SVGElementImpl) - ((SVGElementImpl)impl).setClassName(new SVGAnimatedStringImpl(((FObj)child).getProperty("class").getString())); - pattern.appendChild(impl); - } - } - } - switch ((this.properties.get("gradientUnits")).getEnum()) { - case GradientUnits.USER_SPACE: - pattern.setPatternUnits( new SVGAnimatedEnumerationImpl( - SVGUnitTypes.SVG_UNIT_TYPE_USERSPACE)); - break; - case GradientUnits.USER_SPACE_ON_USE: + 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(); + if (impl != null) { + if (impl instanceof SVGElementImpl) + ((SVGElementImpl) impl).setClassName( + new SVGAnimatedStringImpl( + ((FObj) child).getProperty( + "class").getString())); + pattern.appendChild(impl); + } + } + } + switch ((this.properties.get("patternUnits")).getEnum()) { + case GenericUnits.Enums.USER_SPACE_ON_USE: pattern.setPatternUnits( new SVGAnimatedEnumerationImpl( SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEONUSE)); break; - case GradientUnits.OBJECT_BOUNDING_BOX: + case GenericUnits.Enums.OBJECT_BOUNDING_BOX: pattern.setPatternUnits( new SVGAnimatedEnumerationImpl( SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)); break; } - return pattern; + return pattern; } } diff --git a/src/org/apache/fop/svg/RadialGradient.java b/src/org/apache/fop/svg/RadialGradient.java index 395f0fceb..36a4770ee 100644 --- a/src/org/apache/fop/svg/RadialGradient.java +++ b/src/org/apache/fop/svg/RadialGradient.java @@ -125,6 +125,9 @@ public class RadialGradient extends SVGObj { radial.setTransform( ((SVGTransform) this.properties.get("transform")). getTransform()); + radial.setGradientTransform( + ((SVGTransform) this.properties.get("gradientTransform")). + getTransform()); radial.setId(this.properties.get("id").getString()); String rf = this.properties.get("xlink:href").getString(); radial.setHref(new SVGAnimatedStringImpl(rf)); @@ -150,15 +153,11 @@ public class RadialGradient extends SVGObj { radial.setFy(length == null ? null : new SVGAnimatedLengthImpl(length)); switch ((this.properties.get("gradientUnits")).getEnum()) { - case GradientUnits.USER_SPACE: - radial.setGradientUnits( new SVGAnimatedEnumerationImpl( - SVGUnitTypes.SVG_UNIT_TYPE_USERSPACE)); - break; - case GradientUnits.USER_SPACE_ON_USE: + case GenericUnits.Enums.USER_SPACE_ON_USE: radial.setGradientUnits( new SVGAnimatedEnumerationImpl( SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEONUSE)); break; - case GradientUnits.OBJECT_BOUNDING_BOX: + case GenericUnits.Enums.OBJECT_BOUNDING_BOX: radial.setGradientUnits( new SVGAnimatedEnumerationImpl( SVGUnitTypes.SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)); break; diff --git a/src/org/apache/fop/svg/SVG.java b/src/org/apache/fop/svg/SVG.java index 99df234ce..bbf2d3634 100644 --- a/src/org/apache/fop/svg/SVG.java +++ b/src/org/apache/fop/svg/SVG.java @@ -119,7 +119,7 @@ public class SVG extends FObj implements GraphicsCreator { SVGLength h = ((SVGLengthProperty) this.properties.get("height")). getSVGLength(); svgArea = new SVGSVGElementImpl(); - SVGAnimatedLength sal; + SVGAnimatedLengthImpl sal; if (w == null) w = new SVGLengthImpl(); sal = new SVGAnimatedLengthImpl(w); diff --git a/src/org/apache/fop/svg/SVGStringList.java b/src/org/apache/fop/svg/SVGStringList.java deleted file mode 100644 index 22bbb21fe..000000000 --- a/src/org/apache/fop/svg/SVGStringList.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 <jtauber@jtauber.com>. For more information on the Apache - Software Foundation, please see <http://www.apache.org/>. - - */ - -package org.apache.fop.svg; - -import org.apache.fop.dom.svg.*; - -import java.util.*; - -/** - * - */ -class SVGStringList extends SVGListImpl { - public SVGStringList(String str) - { - parseString(str); - } - - void parseString(String str) - { - StringTokenizer st = new StringTokenizer(str, ", \n\r\t:;"); - while(st.hasMoreTokens()) { - String item = st.nextToken(); - appendItem(item); - } - } - - public Object createItem() - { - return new String(); - } - -} diff --git a/src/org/apache/fop/svg/Switch.java b/src/org/apache/fop/svg/Switch.java index 486752f02..caece1c73 100644 --- a/src/org/apache/fop/svg/Switch.java +++ b/src/org/apache/fop/svg/Switch.java @@ -1,36 +1,36 @@ -/*-- $Id$ -- +/*-- $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 @@ -41,12 +41,12 @@ 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 + James Tauber <jtauber@jtauber.com>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. - + */ package org.apache.fop.svg; @@ -67,101 +67,101 @@ import org.w3c.dom.svg.*; */ public class Switch extends SVGObj { - /** - * inner class for making Line objects. - */ - public static class Maker extends FObj.Maker { - - /** - * make a Line object. - * - * @param parent the parent formatting object - * @param propertyList the explicit properties of this object - * - * @return the Line object - */ - public FObj make(FObj parent, PropertyList propertyList) throws FOPException - { - return new Switch(parent, propertyList); - } - } - - /** - * returns the maker for this object. - * - * @return the maker for Switch objects - */ - public static FObj.Maker maker() { - return new Switch.Maker(); - } - - /** - * constructs a Switch object (called by Maker). - * - * @param parent the parent formatting object - * @param propertyList the explicit properties of this object - */ - protected Switch(FObj parent, PropertyList propertyList) { - super(parent, propertyList); - this.name = "svg:switch"; - } - - public SVGElement createGraphic() - { - /* - * There are two options - * 1) add all children and select the correct one when rendering - * 2) select the correct one now and return it rather than a switch element - * Since renderers may have different ideas, leave it up to the renderer - * to select the correct one. - */ - String rf = this.properties.get("requiredFeatures").getString(); - String re = this.properties.get("requiredExtensions").getString(); - String sl = this.properties.get("systemLanguage").getString(); - SVGList strlist; - GraphicElement graphic; - graphic = new SVGSwitchElementImpl(); - if(!rf.equals("notpresent")) { - strlist = new SVGStringList(rf); - graphic.setRequiredFeatures(strlist); - } - if(!re.equals("notpresent")) { - strlist = new SVGStringList(re); - graphic.setRequiredExtensions(strlist); - } - if(!sl.equals("notpresent")) { - strlist = new SVGStringList(sl); - graphic.setSystemLanguage(strlist); - } - - 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(); - if(impl instanceof SVGTests) { - SVGTests testable = (SVGTests)impl; - rf = child.getProperty("requiredFeatures").getString(); - re = child.getProperty("requiredExtensions").getString(); - sl = child.getProperty("systemLanguage").getString(); - if(!rf.equals("notpresent")) { - strlist = new SVGStringList(rf); - testable.setRequiredFeatures(strlist); - } - if(!re.equals("notpresent")) { - strlist = new SVGStringList(re); - testable.setRequiredExtensions(strlist); - } - if(!sl.equals("notpresent")) { - strlist = new SVGStringList(sl); - testable.setSystemLanguage(strlist); - } - graphic.appendChild((GraphicElement)impl); - } - } else if(child instanceof Defs) { - } - } - - return graphic; - } + /** + * inner class for making Line objects. + */ + public static class Maker extends FObj.Maker { + + /** + * make a Line object. + * + * @param parent the parent formatting object + * @param propertyList the explicit properties of this object + * + * @return the Line object + */ + public FObj make(FObj parent, + PropertyList propertyList) throws FOPException { + return new Switch(parent, propertyList); + } + } + + /** + * returns the maker for this object. + * + * @return the maker for Switch objects + */ + public static FObj.Maker maker() { + return new Switch.Maker(); + } + + /** + * constructs a Switch object (called by Maker). + * + * @param parent the parent formatting object + * @param propertyList the explicit properties of this object + */ + protected Switch(FObj parent, PropertyList propertyList) { + super(parent, propertyList); + this.name = "svg:switch"; + } + + public SVGElement createGraphic() { + /* + * There are two options + * 1) add all children and select the correct one when rendering + * 2) select the correct one now and return it rather than a switch element + * Since renderers may have different ideas, leave it up to the renderer + * to select the correct one. + */ + String rf = this.properties.get("requiredFeatures").getString(); + String re = this.properties.get("requiredExtensions").getString(); + String sl = this.properties.get("systemLanguage").getString(); + SVGStringListImpl strlist; + GraphicElement graphic; + graphic = new SVGSwitchElementImpl(); + if (!rf.equals("notpresent")) { + strlist = new SVGStringListImpl(rf); + graphic.setRequiredFeatures(strlist); + } + if (!re.equals("notpresent")) { + strlist = new SVGStringListImpl(re); + graphic.setRequiredExtensions(strlist); + } + if (!sl.equals("notpresent")) { + strlist = new SVGStringListImpl(sl); + graphic.setSystemLanguage(strlist); + } + + 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(); + if (impl instanceof GraphicElement) { + GraphicElement testable = (GraphicElement) impl; + rf = child.getProperty("requiredFeatures").getString(); + re = child.getProperty( + "requiredExtensions").getString(); + sl = child.getProperty("systemLanguage").getString(); + if (!rf.equals("notpresent")) { + strlist = new SVGStringListImpl(rf); + testable.setRequiredFeatures(strlist); + } + if (!re.equals("notpresent")) { + strlist = new SVGStringListImpl(re); + testable.setRequiredExtensions(strlist); + } + if (!sl.equals("notpresent")) { + strlist = new SVGStringListImpl(sl); + testable.setSystemLanguage(strlist); + } + graphic.appendChild((GraphicElement) impl); + } + } else if (child instanceof Defs) { + } + } + + return graphic; + } } |