From 83a0f66fb884afe3a6941102f176ddeea9dc6cfa Mon Sep 17 00:00:00 2001 From: Karen Lease Date: Fri, 10 Nov 2000 22:02:13 +0000 Subject: [PATCH] Initial version of new base property type classes git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193766 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fo/ColorTypeProperty.java | 87 ++++++++++++ src/org/apache/fop/fo/CondLengthProperty.java | 84 ++++++++++++ src/org/apache/fop/fo/EnumProperty.java | 106 +++++++++++++++ src/org/apache/fop/fo/LengthProperty.java | 127 ++++++++++++++++++ .../apache/fop/fo/LengthRangeProperty.java | 85 ++++++++++++ src/org/apache/fop/fo/NumberProperty.java | 115 ++++++++++++++++ src/org/apache/fop/fo/SpaceProperty.java | 88 ++++++++++++ src/org/apache/fop/fo/StringProperty.java | 95 +++++++++++++ 8 files changed, 787 insertions(+) create mode 100644 src/org/apache/fop/fo/ColorTypeProperty.java create mode 100644 src/org/apache/fop/fo/CondLengthProperty.java create mode 100644 src/org/apache/fop/fo/EnumProperty.java create mode 100644 src/org/apache/fop/fo/LengthProperty.java create mode 100644 src/org/apache/fop/fo/LengthRangeProperty.java create mode 100644 src/org/apache/fop/fo/NumberProperty.java create mode 100644 src/org/apache/fop/fo/SpaceProperty.java create mode 100644 src/org/apache/fop/fo/StringProperty.java diff --git a/src/org/apache/fop/fo/ColorTypeProperty.java b/src/org/apache/fop/fo/ColorTypeProperty.java new file mode 100644 index 000000000..6a32ff015 --- /dev/null +++ b/src/org/apache/fop/fo/ColorTypeProperty.java @@ -0,0 +1,87 @@ +/*-- $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.fo; + +import org.apache.fop.datatypes.ColorType; + +public class ColorTypeProperty extends Property { + + public static class Maker extends Property.Maker { + + public Maker(String propName) { + super(propName); + } + + protected Property convertProperty(Property p, PropertyList propertyList, + FObj fo) { + if (p instanceof ColorTypeProperty) + return p; + ColorType val = p.getColorType(); + if (val != null) + return new ColorTypeProperty(val); + return convertPropertyDatatype(p, propertyList, fo); + } + } + + private ColorType colorType; + + public ColorTypeProperty(ColorType colorType) { + this.colorType = colorType; + } + + // Can't convert to any other types + public ColorType getColorType() { + return this.colorType; + } + + public Object getObject() { return this.colorType; } + +} diff --git a/src/org/apache/fop/fo/CondLengthProperty.java b/src/org/apache/fop/fo/CondLengthProperty.java new file mode 100644 index 000000000..ed3654a14 --- /dev/null +++ b/src/org/apache/fop/fo/CondLengthProperty.java @@ -0,0 +1,84 @@ +/*-- $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.fo; + +import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.CondLength; + +public class CondLengthProperty extends LengthProperty { + + public static class Maker extends LengthProperty.Maker { + + public /* protected*/ Maker(String name) { + super(name); + } + + protected Property convertProperty(Property p, PropertyList propertyList, + FObj fo) { + if (p instanceof CondLengthProperty) + return p; + Length val = p.getLength(); + if (val != null) + return new CondLengthProperty(new CondLength(val)); + return convertPropertyDatatype(p, propertyList, fo); + } + } + + public CondLengthProperty(CondLength length) { + super(length); + } + + + public CondLength getCondLength() { + return (CondLength)super.getLength(); + } + +} diff --git a/src/org/apache/fop/fo/EnumProperty.java b/src/org/apache/fop/fo/EnumProperty.java new file mode 100644 index 000000000..c8979d804 --- /dev/null +++ b/src/org/apache/fop/fo/EnumProperty.java @@ -0,0 +1,106 @@ +/*-- $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.fo; + +import org.apache.fop.apps.FOPException; +import org.apache.fop.messaging.MessageHandler; + +public class EnumProperty extends Property { + + public static class Maker extends Property.Maker { + + protected Maker(String propName) { + super(propName); + } + + // set the Property from the String value + public Property make(PropertyList propertyList, String value, FObj fo) + throws FOPException + { + Property p = findConstant(value); + if (p == null) { + MessageHandler.errorln("WARNING: Unknown value for property '" + + getPropName() + "': " + value); + return make(propertyList); // return the default value + } + else { + return p; //makeProperty(v); + } + } + + protected Property findConstant(String value) { + return null; + } + + /*** + protected Property makeProperty(int v) { + return new EnumProperty(v); + } + ***/ + } + + private int value; + + public EnumProperty(int explicitValue) { + this.value = explicitValue; + } + + public int getEnum() { + return this.value; + } + + public Object getObject() { + // FIXME: return String value: property must reference maker + // return maker.getEnumValue(this.value); + return new Integer(this.value); + } + +} diff --git a/src/org/apache/fop/fo/LengthProperty.java b/src/org/apache/fop/fo/LengthProperty.java new file mode 100644 index 000000000..24866c449 --- /dev/null +++ b/src/org/apache/fop/fo/LengthProperty.java @@ -0,0 +1,127 @@ +/*-- $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.fo; + +import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.PercentLength; +import org.apache.fop.datatypes.TableColLength; +import org.apache.fop.fo.expr.Numeric; + +public class LengthProperty extends Property { + + public static class Maker extends Property.Maker { + + public /* protected*/ Maker(String name) { + super(name); + } + + /** + protected Property checkPropertyKeywords(String value) { + if (isAutoLengthAllowed() && value.equals("auto")) { + return new LengthProperty(Length.AUTO); + } + return null; + } + **/ + + protected boolean isAutoLengthAllowed() { + return false; + } + + protected Property convertProperty(Property p, PropertyList propertyList, + FObj fo) { + if (isAutoLengthAllowed()) { + String pval = p.getString(); + if (pval != null && pval.equals("auto")) + return new LengthProperty(Length.AUTO); + } + if (p instanceof LengthProperty) + return p; + Length val = p.getLength(); + if (val != null) + return new LengthProperty(val); + return convertPropertyDatatype(p, propertyList, fo); + } + } + + /* + public static Property.Maker maker(String prop) { + return new Maker(prop); + } + */ + + /** This object may be also be a subclass of Length, such + * as PercentLength, TableColLength. + */ + private Length length ; + + public LengthProperty(Length length) { + this.length = length; + //System.err.println("Set LengthProperty: " + length.toString()); + } + + public Numeric getNumeric() { + // Can't just do new Numeric(length) because it always uses + // the constructor for Length! + // Otherwise, must make each class know about Numeric... + // ie, return length.asNumeric(): cleaner + if (length instanceof PercentLength) + return new Numeric((PercentLength)length); + if (length instanceof TableColLength) + return new Numeric((TableColLength)length); + return new Numeric(length); + } + + public Length getLength() { return this.length; } + + public Object getObject() { return this.length; } + +} diff --git a/src/org/apache/fop/fo/LengthRangeProperty.java b/src/org/apache/fop/fo/LengthRangeProperty.java new file mode 100644 index 000000000..31a495d57 --- /dev/null +++ b/src/org/apache/fop/fo/LengthRangeProperty.java @@ -0,0 +1,85 @@ +/*-- $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.fo; + +import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.LengthRange; + +public class LengthRangeProperty extends Property { + + public static class Maker extends LengthProperty.Maker { + + protected Maker(String name) { + super(name); + } + + protected Property convertProperty(Property p, PropertyList propertyList, + FObj fo) { + Length val = p.getLength(); + if (val != null) + return new LengthRangeProperty(new LengthRange(val)); + return convertPropertyDatatype(p, propertyList, fo); + } + } + + private LengthRange lengthRange ; + + public LengthRangeProperty(LengthRange lengthRange) { + this.lengthRange = lengthRange; + } + + public LengthRange getLengthRange() { return this.lengthRange; } + + /* Question, should we allow this? */ + public Length getLength() { return this.lengthRange.getOptimum(); } + public Object getObject() { return this.lengthRange ; } + +} diff --git a/src/org/apache/fop/fo/NumberProperty.java b/src/org/apache/fop/fo/NumberProperty.java new file mode 100644 index 000000000..9c42ae02d --- /dev/null +++ b/src/org/apache/fop/fo/NumberProperty.java @@ -0,0 +1,115 @@ +/*-- $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.fo; + +import org.apache.fop.datatypes.ColorType; +import org.apache.fop.fo.expr.Numeric; + +public class NumberProperty extends Property { + + public static class Maker extends Property.Maker { + + public Maker(String propName) { + super(propName); + } + + protected Property convertProperty(Property p, PropertyList propertyList, + FObj fo) { + if (p instanceof NumberProperty) + return p; + Number val = p.getNumber(); + if (val != null) + return new NumberProperty(val); + return convertPropertyDatatype(p, propertyList, fo); + } + } + + private final Number number; + + public NumberProperty(Number number) { + this.number = number; + } + + public NumberProperty(double number) { + this.number = new Double(number); + } + + public NumberProperty(int number) { + this.number = new Integer(number); + } + + public Number getNumber() { + return this.number; + } + + /** + public Double getDouble() { + return new Double(this.number.doubleValue()); + } + + public Integer getInteger() { + return new Integer(this.number.intValue()); + } + **/ + + public Object getObject() { return this.number; } + + public Numeric getNumeric() { + return new Numeric(this.number); + } + + public ColorType getColorType() { + // Convert numeric value to color ??? + // Convert to hexadecimal and then try to make it into a color? + return new ColorType((float)0.0, (float)0.0, (float)0.0); + } + +} diff --git a/src/org/apache/fop/fo/SpaceProperty.java b/src/org/apache/fop/fo/SpaceProperty.java new file mode 100644 index 000000000..b92b49b57 --- /dev/null +++ b/src/org/apache/fop/fo/SpaceProperty.java @@ -0,0 +1,88 @@ +/*-- $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.fo; + +import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.Space; +import org.apache.fop.datatypes.LengthRange; + +public class SpaceProperty extends Property { + + public static class Maker extends LengthRangeProperty.Maker { + + protected Maker(String name) { + super(name); + } + + protected Property convertProperty(Property p, PropertyList propertyList, + FObj fo) { + Length val = p.getLength(); + if (val != null) + return new SpaceProperty(new Space(val)); + return convertPropertyDatatype(p, propertyList, fo); + } + } + + private Space space ; + + public SpaceProperty(Space space) { + this.space = space; + } + + public Space getSpace() { return this.space; } + + /* Question, should we allow this? */ + public Length getLength() { return this.space.getOptimum(); } + /* Space extends LengthRange */ + public LengthRange getLengthRange() { return this.space; } + public Object getObject() { return this.space; } + +} diff --git a/src/org/apache/fop/fo/StringProperty.java b/src/org/apache/fop/fo/StringProperty.java new file mode 100644 index 000000000..e270bcf90 --- /dev/null +++ b/src/org/apache/fop/fo/StringProperty.java @@ -0,0 +1,95 @@ +/*-- $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.fo; + + +public class StringProperty extends Property { + + public static class Maker extends Property.Maker { + + public Maker(String propName) { + super(propName); + } + + public Property make(PropertyList propertyList, String value, FObj fo) { + // Work around the fact that most String properties are not + // specified as actual String literals (with "" or '') since + // the attribute values themselves are Strings! + // If the value starts with ' or ", make sure it also ends with + // this character + // Otherwise, just take the whole value as the String + int vlen = value.length()-1; + if (vlen > 0) { + char q1 = value.charAt(0); + if (q1 == '"' || q1 == '\'') { + if (value.charAt(vlen) == q1) { + return new StringProperty(value.substring(1,vlen)); + } + System.err.println("Warning String-valued property starts with quote" + + " but doesn't end with quote: " + value); + // fall through and use the entire value, including first quote + } + } + return new StringProperty(value); + } + } // end String.Maker + + private String str ; + + public StringProperty(String str) { + this.str = str; + // System.err.println("Set StringProperty: " + str); + } + + public Object getObject() { return this.str; } + + public String getString() { return this.str; } +} -- 2.39.5