| 1 |
/* JLaTeXMathElementMapping.java |
| 2 |
* ========================================================================= |
| 3 |
* This file is part of the JLaTeXMath Library - http://forge.scilab.org/jlatexmath |
| 4 |
* |
| 5 |
* Copyright (C) 2010 DENIZET Calixte |
| 6 |
* |
| 7 |
* This program is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; either version 2 of the License, or (at |
| 10 |
* your option) any later version. |
| 11 |
* |
| 12 |
* This program is distributed in the hope that it will be useful, but |
| 13 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
* General Public License for more details. |
| 16 |
* |
| 17 |
* A copy of the GNU General Public License can be found in the file |
| 18 |
* LICENSE.txt provided with the source distribution of this program (see |
| 19 |
* the META-INF directory in the source jar). This license can also be |
| 20 |
* found on the GNU website at http://www.gnu.org/licenses/gpl.html. |
| 21 |
* |
| 22 |
* If you did not receive a copy of the GNU General Public License along |
| 23 |
* with this program, contact the lead developer, or write to the Free |
| 24 |
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 25 |
* 02110-1301, USA. |
| 26 |
* |
| 27 |
* Linking this library statically or dynamically with other modules |
| 28 |
* is making a combined work based on this library. Thus, the terms |
| 29 |
* and conditions of the GNU General Public License cover the whole |
| 30 |
* combination. |
| 31 |
* |
| 32 |
* As a special exception, the copyright holders of this library give you |
| 33 |
* permission to link this library with independent modules to produce |
| 34 |
* an executable, regardless of the license terms of these independent |
| 35 |
* modules, and to copy and distribute the resulting executable under terms |
| 36 |
* of your choice, provided that you also meet, for each linked independent |
| 37 |
* module, the terms and conditions of the license of that module. |
| 38 |
* An independent module is a module which is not derived from or based |
| 39 |
* on this library. If you modify this library, you may extend this exception |
| 40 |
* to your version of the library, but you are not obliged to do so. |
| 41 |
* If you do not wish to do so, delete this exception statement from your |
| 42 |
* version. |
| 43 |
* |
| 44 |
*/ |
| 45 |
|
| 46 |
/* This file is largely inspired by files wrote by Jeremias Maerki, |
| 47 |
* for the fop plugin of barcode4j available at |
| 48 |
* http://barcode4j.sourceforge.net/ |
| 49 |
*/ |
| 50 |
|
| 51 |
package org.scilab.forge.jlatexmath.fop; |
| 52 |
|
| 53 |
import java.util.HashMap; |
| 54 |
|
| 55 |
import org.apache.fop.fo.ElementMapping; |
| 56 |
import org.apache.fop.fo.FONode; |
| 57 |
import org.w3c.dom.DOMImplementation; |
| 58 |
|
| 59 |
/** |
| 60 |
* This class provides the element mapping for FOP. |
| 61 |
*/ |
| 62 |
public class JLaTeXMathElementMapping extends ElementMapping { |
| 63 |
|
| 64 |
public JLaTeXMathElementMapping() { |
| 65 |
this.namespaceURI = JLaTeXMathObj.JLATEXMATH_NS; |
| 66 |
} |
| 67 |
|
| 68 |
public DOMImplementation getDOMImplementation() { |
| 69 |
return ElementMapping.getDefaultDOMImplementation(); |
| 70 |
} |
| 71 |
|
| 72 |
protected void initialize() { |
| 73 |
if (this.foObjs == null) { |
| 74 |
this.foObjs = new HashMap(); |
| 75 |
this.foObjs.put("latex", new JLMEMaker()); |
| 76 |
this.foObjs.put(ElementMapping.DEFAULT, new JLMMaker()); |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
public final class JLMMaker extends ElementMapping.Maker { |
| 81 |
private JLMMaker() { } |
| 82 |
public FONode make(final FONode parent) { |
| 83 |
return new JLaTeXMathObj(parent); |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
public final class JLMEMaker extends ElementMapping.Maker { |
| 88 |
private JLMEMaker() { } |
| 89 |
public FONode make(final FONode parent) { |
| 90 |
return new JLaTeXMathElement(parent); |
| 91 |
} |
| 92 |
} |
| 93 |
} |