diff options
author | Jeremias Maerki <jeremias@apache.org> | 2003-03-07 10:47:51 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2003-03-07 10:47:51 +0000 |
commit | b6dc3aa0602b54985d16f36e92a60c7742e4159f (patch) | |
tree | 072be760fe808e7da5a657af4524700d57c4ed95 /examples/mathml/src/org | |
parent | c24aba310fa547801100871b2333636628518e7c (diff) | |
download | xmlgraphics-fop-b6dc3aa0602b54985d16f36e92a60c7742e4159f.tar.gz xmlgraphics-fop-b6dc3aa0602b54985d16f36e92a60c7742e4159f.zip |
Switched to long licence
Some general checkstyle fixing
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196043 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'examples/mathml/src/org')
3 files changed, 199 insertions, 24 deletions
diff --git a/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java b/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java index 066b7b54c..0df6088cb 100644 --- a/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java +++ b/examples/mathml/src/org/apache/fop/mathml/MathMLElement.java @@ -1,9 +1,53 @@ -/* $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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.mathml; import java.awt.Color; @@ -13,8 +57,11 @@ import java.awt.geom.Point2D; import org.apache.fop.fo.FONode; import org.apache.fop.apps.FOPException; +import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; -import org.w3c.dom.*; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + import org.xml.sax.Attributes; import org.apache.batik.svggen.SVGGraphics2D; @@ -23,21 +70,34 @@ import org.apache.batik.dom.svg.SVGDOMImplementation; import net.sourceforge.jeuclid.MathBase; import net.sourceforge.jeuclid.DOMMathBuilder; +/** + * Defines the top-level element for MathML. + */ public class MathMLElement extends MathMLObj { - Document svgDoc = null; - float width; - float height; - boolean converted = false; + private Document svgDoc = null; + private float width; + private float height; + private boolean converted = false; + + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public MathMLElement(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.FONode#handleAttrs(Attributes) + */ public void handleAttrs(Attributes attlist) throws FOPException { super.handleAttrs(attlist); createBasicDocument(); } + /** + * Converts the MathML to SVG. + */ public void convertToSVG() { try { if (!converted) { @@ -70,10 +130,14 @@ public class MathMLElement extends MathMLObj { } + /** + * Create the SVG from MathML. + * @return the DOM document containing SVG + */ public static Document createSVG(MathBase base) { DOMImplementation impl = - SVGDOMImplementation.getDOMImplementation(); + SVGDOMImplementation.getDOMImplementation(); String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; Document svgdocument = impl.createDocument(svgNS, "svg", null); @@ -104,11 +168,17 @@ public class MathMLElement extends MathMLObj { } + /** + * @see org.apache.fop.fo.XMLObj#getDocument() + */ public Document getDocument() { convertToSVG(); return doc; } + /** + * @see org.apache.fop.fo.XMLObj#getDocumentNamespace() + */ public String getDocumentNamespace() { if (svgDoc == null) { return MathMLElementMapping.URI; @@ -116,6 +186,9 @@ public class MathMLElement extends MathMLObj { return "http://www.w3.org/2000/svg"; } + /** + * @see org.apache.fop.fo.XMLObj#getDimension(Point2D) + */ public Point2D getDimension(Point2D view) { convertToSVG(); return new Point2D.Float(width, height); diff --git a/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.java b/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.java index f1f2b0fd3..c80a0c33c 100644 --- a/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.java +++ b/examples/mathml/src/org/apache/fop/mathml/MathMLElementMapping.java @@ -1,9 +1,53 @@ -/* $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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.mathml; import org.apache.fop.fo.FOTreeBuilder; @@ -18,8 +62,12 @@ import java.util.HashMap; import net.sourceforge.jeuclid.MathBase; import net.sourceforge.jeuclid.DOMMathBuilder; +/** + * This class provides the element mapping for FOP. + */ public class MathMLElementMapping implements ElementMapping { + /** MathML namespace */ public static final String URI = "http://www.w3.org/1998/Math/MathML"; private static HashMap foObjs = null; @@ -34,6 +82,9 @@ public class MathMLElementMapping implements ElementMapping { } } + /** + * @see org.apache.fop.fo.ElementMapping#addToBuilder(FOTreeBuilder) + */ public void addToBuilder(FOTreeBuilder builder) { setupMathML(); builder.addMapping(URI, foObjs); @@ -78,6 +129,7 @@ public class MathMLElementMapping implements ElementMapping { return info; } catch (Throwable t) { + /**@todo log that properly */ } return null; diff --git a/examples/mathml/src/org/apache/fop/mathml/MathMLObj.java b/examples/mathml/src/org/apache/fop/mathml/MathMLObj.java index f7f8d82ca..747fc62ca 100644 --- a/examples/mathml/src/org/apache/fop/mathml/MathMLObj.java +++ b/examples/mathml/src/org/apache/fop/mathml/MathMLObj.java @@ -1,9 +1,53 @@ -/* $Id$ - * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the - * LICENSE file included with these sources. - */ - +/* + * $Id$ + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999-2003 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.mathml; // FOP @@ -15,10 +59,16 @@ import org.apache.fop.fo.XMLObj; */ public class MathMLObj extends XMLObj { + /** + * @see org.apache.fop.fo.FONode#FONode(FONode) + */ public MathMLObj(FONode parent) { super(parent); } + /** + * @see org.apache.fop.fo.XMLObj#getNameSpace() + */ public String getNameSpace() { return MathMLElementMapping.URI; } |