[hmath-commits] org.hartmath.tex2mml/src/org/hartmath/tex2mml/reflection/convert Mathbf.java,NONE,1.
Status: Pre-Alpha
Brought to you by:
jsurfer
|
From: <js...@us...> - 2004-02-15 14:38:16
|
Update of /cvsroot/hmath/org.hartmath.tex2mml/src/org/hartmath/tex2mml/reflection/convert In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9158/src/org/hartmath/tex2mml/reflection/convert Added Files: Mathbf.java Hat.java Bar.java Mathcal.java Ul.java Mathsf.java Dot.java Vec.java Ddot.java Text.java Mbox.java Mathtt.java Mathfrak.java Log Message: Initial TeX to MathML module --- NEW FILE: Mathbf.java --- package org.hartmath.tex2mml.reflection.convert; import org.hartmath.tex2mml.IRowConverter; import org.hartmath.tex2mml.Row; import org.hartmath.tex2mml.TeX2MathMLFactory; public class Mathbf implements IRowConverter { /* * (non-Javadoc) * * @see org.hartmath.tex2mml.IRowConverter#convert(java.lang.StringBuffer, org.hartmath.tex2mml.Row, * org.hartmath.tex2mml.TeX2MathMLFactory) */ public boolean convert(StringBuffer buf, Row row, TeX2MathMLFactory f) { if (row.size() == 1) { f.tagStart(buf, "mstyle", "fontweight=\"bold\""); row.get(0).convert(f, buf); f.tagEnd(buf, "mstyle"); return true; } return false; } } --- NEW FILE: Hat.java --- package org.hartmath.tex2mml.reflection.convert; import org.hartmath.tex2mml.IRowConverter; import org.hartmath.tex2mml.Row; import org.hartmath.tex2mml.TeX2MathMLFactory; public class Hat implements IRowConverter { /* * (non-Javadoc) * * @see org.hartmath.tex2mml.IRowConverter#convert(java.lang.StringBuffer, org.hartmath.tex2mml.Row, * org.hartmath.tex2mml.TeX2MathMLFactory) */ public boolean convert(StringBuffer buf, Row row, TeX2MathMLFactory f) { if (row.size() == 1) { f.tagStart(buf, "mover"); row.get(0).convert(f, buf); f.tagStart(buf, "mo"); buf.append(TeX2MathMLFactory.toEntity('\u005E')); // '^' f.tagEnd(buf, "mo"); f.tagEnd(buf, "mover"); return true; } return false; } } --- NEW FILE: Bar.java --- package org.hartmath.tex2mml.reflection.convert; import org.hartmath.tex2mml.IRowConverter; import org.hartmath.tex2mml.Row; import org.hartmath.tex2mml.TeX2MathMLFactory; public class Bar implements IRowConverter { /* * (non-Javadoc) * * @see org.hartmath.tex2mml.IRowConverter#convert(java.lang.StringBuffer, org.hartmath.tex2mml.Row, * org.hartmath.tex2mml.TeX2MathMLFactory) */ public boolean convert(StringBuffer buf, Row row, TeX2MathMLFactory f) { if (row.size() == 1) { f.tagStart(buf, "mover"); row.get(0).convert(f, buf); f.tagStart(buf, "mo"); buf.append(TeX2MathMLFactory.toEntity('\u00AF')); // f.tagEnd(buf, "mo"); f.tagEnd(buf, "mover"); return true; } return false; } } --- NEW FILE: Mathcal.java --- package org.hartmath.tex2mml.reflection.convert; import org.hartmath.tex2mml.IRowConverter; import org.hartmath.tex2mml.Identifier; import org.hartmath.tex2mml.Node; import org.hartmath.tex2mml.Row; import org.hartmath.tex2mml.TeX2MathMLFactory; public class Mathcal implements IRowConverter { public final static int[] MATHCAL_CODES = { 0xEF35, 0x212C, 0xEF36, 0xEF37, 0x2130, 0x2131, 0xEF38, 0x210B, 0x2110, 0xEF39, 0xEF3A, 0x2112, 0x2133, 0xEF3B, 0xEF3C, 0xEF3D, 0xEF3E, 0x211B, 0xEF3F, 0xEF40, 0xEF41, 0xEF42, 0xEF43, 0xEF44, 0xEF45, 0xEF46 }; /* * (non-Javadoc) * * @see org.hartmath.tex2mml.IRowConverter#convert(java.lang.StringBuffer, org.hartmath.tex2mml.Row, * org.hartmath.tex2mml.TeX2MathMLFactory) */ public boolean convert(StringBuffer buf, Row row, TeX2MathMLFactory f) { if (row.size() == 1) { Node temp = row.get(0); if (temp instanceof Identifier) { String st = temp.getOutput(); StringBuffer newst = new StringBuffer(); for (int j = 0; j < st.length(); j++) if (st.charAt(j) > 64 && st.charAt(j) < 91) { newst.append(TeX2MathMLFactory.toEntity(MATHCAL_CODES[st.charAt(j) - 65])); } else { newst.append(st.charAt(j)); } f.tagStart(buf, temp.getTag()); buf.append(newst.toString()); f.tagEnd(buf, temp.getTag()); return true; } } return false; } } --- NEW FILE: Ul.java --- package org.hartmath.tex2mml.reflection.convert; import org.hartmath.tex2mml.IRowConverter; import org.hartmath.tex2mml.Row; import org.hartmath.tex2mml.TeX2MathMLFactory; public class Ul implements IRowConverter { /* * (non-Javadoc) * * @see org.hartmath.tex2mml.IRowConverter#convert(java.lang.StringBuffer, org.hartmath.tex2mml.Row, * org.hartmath.tex2mml.TeX2MathMLFactory) */ public boolean convert(StringBuffer buf, Row row, TeX2MathMLFactory f) { if (row.size() == 1) { f.tagStart(buf, "munder"); row.get(0).convert(f, buf); f.tagStart(buf, "mo"); buf.append(TeX2MathMLFactory.toEntity('\u0332')); // '^' f.tagEnd(buf, "mo"); f.tagEnd(buf, "munder"); return true; } return false; } } --- NEW FILE: Mathsf.java --- package org.hartmath.tex2mml.reflection.convert; import org.hartmath.tex2mml.IRowConverter; import org.hartmath.tex2mml.Identifier; import org.hartmath.tex2mml.Node; import org.hartmath.tex2mml.Row; import org.hartmath.tex2mml.TeX2MathMLFactory; public class Mathsf implements IRowConverter { /* * (non-Javadoc) * * @see org.hartmath.tex2mml.IRowConverter#convert(java.lang.StringBuffer, org.hartmath.tex2mml.Row, * org.hartmath.tex2mml.TeX2MathMLFactory) */ public boolean convert(StringBuffer buf, Row row, TeX2MathMLFactory f) { if (row.size() == 1) { f.tagStart(buf, "mstyle", "fontfamily=\"sans-serif\""); row.get(0).convert(f, buf); f.tagEnd(buf, "mstyle"); return true; } return false; } } --- NEW FILE: Dot.java --- package org.hartmath.tex2mml.reflection.convert; import org.hartmath.tex2mml.IRowConverter; import org.hartmath.tex2mml.Row; import org.hartmath.tex2mml.TeX2MathMLFactory; public class Dot implements IRowConverter { /* * (non-Javadoc) * * @see org.hartmath.tex2mml.IRowConverter#convert(java.lang.StringBuffer, org.hartmath.tex2mml.Row, * org.hartmath.tex2mml.TeX2MathMLFactory) */ public boolean convert(StringBuffer buf, Row row, TeX2MathMLFactory f) { if (row.size() == 1) { f.tagStart(buf, "mover"); row.get(0).convert(f, buf); f.tagStart(buf, "mo"); buf.append("."); // '^' f.tagEnd(buf, "mo"); f.tagEnd(buf, "mover"); return true; } return false; } } --- NEW FILE: Vec.java --- package org.hartmath.tex2mml.reflection.convert; import org.hartmath.tex2mml.IRowConverter; import org.hartmath.tex2mml.Row; import org.hartmath.tex2mml.TeX2MathMLFactory; public class Vec implements IRowConverter { /* * (non-Javadoc) * * @see org.hartmath.tex2mml.IRowConverter#convert(java.lang.StringBuffer, org.hartmath.tex2mml.Row, * org.hartmath.tex2mml.TeX2MathMLFactory) */ public boolean convert(StringBuffer buf, Row row, TeX2MathMLFactory f) { if (row.size() == 1) { f.tagStart(buf, "mover"); row.get(0).convert(f, buf); f.tagStart(buf, "mo"); buf.append(TeX2MathMLFactory.toEntity('\u2192')); // '^' f.tagEnd(buf, "mo"); f.tagEnd(buf, "mover"); return true; } return false; } } --- NEW FILE: Ddot.java --- package org.hartmath.tex2mml.reflection.convert; import org.hartmath.tex2mml.IRowConverter; import org.hartmath.tex2mml.Row; import org.hartmath.tex2mml.TeX2MathMLFactory; public class Ddot implements IRowConverter { /* * (non-Javadoc) * * @see org.hartmath.tex2mml.IRowConverter#convert(java.lang.StringBuffer, org.hartmath.tex2mml.Row, * org.hartmath.tex2mml.TeX2MathMLFactory) */ public boolean convert(StringBuffer buf, Row row, TeX2MathMLFactory f) { if (row.size() == 1) { f.tagStart(buf, "mover"); row.get(0).convert(f, buf); f.tagStart(buf, "mo"); buf.append(".."); // '^' f.tagEnd(buf, "mo"); f.tagEnd(buf, "mover"); return true; } return false; } } --- NEW FILE: Text.java --- package org.hartmath.tex2mml.reflection.convert; import org.hartmath.tex2mml.IRowConverter; import org.hartmath.tex2mml.Row; import org.hartmath.tex2mml.TeX2MathMLFactory; public class Text implements IRowConverter { /* * (non-Javadoc) * * @see org.hartmath.tex2mml.IRowConverter#convert(java.lang.StringBuffer, org.hartmath.tex2mml.Row, * org.hartmath.tex2mml.TeX2MathMLFactory) */ public boolean convert(StringBuffer buf, Row row, TeX2MathMLFactory f) { if (row.size() == 1) { f.tagStart(buf, "mtext"); buf.append(row.get(0).getOutput()); f.tagEnd(buf, "mtext"); return true; } return false; } } --- NEW FILE: Mbox.java --- package org.hartmath.tex2mml.reflection.convert; import org.hartmath.tex2mml.IRowConverter; import org.hartmath.tex2mml.Row; import org.hartmath.tex2mml.TeX2MathMLFactory; public class Mbox implements IRowConverter { /* * (non-Javadoc) * * @see org.hartmath.tex2mml.IRowConverter#convert(java.lang.StringBuffer, org.hartmath.tex2mml.Row, * org.hartmath.tex2mml.TeX2MathMLFactory) */ public boolean convert(StringBuffer buf, Row row, TeX2MathMLFactory f) { if (row.size() == 1) { f.tagStart(buf, "mbox"); row.get(0).convert(f, buf); f.tagEnd(buf, "mbox"); return true; } return false; } } --- NEW FILE: Mathtt.java --- package org.hartmath.tex2mml.reflection.convert; import org.hartmath.tex2mml.IRowConverter; import org.hartmath.tex2mml.Row; import org.hartmath.tex2mml.TeX2MathMLFactory; public class Mathtt implements IRowConverter { /* * (non-Javadoc) * * @see org.hartmath.tex2mml.IRowConverter#convert(java.lang.StringBuffer, org.hartmath.tex2mml.Row, * org.hartmath.tex2mml.TeX2MathMLFactory) */ public boolean convert(StringBuffer buf, Row row, TeX2MathMLFactory f) { if (row.size() == 1) { f.tagStart(buf, "mstyle", "fontfamily=\"monospace\""); row.get(0).convert(f, buf); f.tagEnd(buf, "mstyle"); return true; } return false; } } --- NEW FILE: Mathfrak.java --- package org.hartmath.tex2mml.reflection.convert; import org.hartmath.tex2mml.IRowConverter; import org.hartmath.tex2mml.Identifier; import org.hartmath.tex2mml.Node; import org.hartmath.tex2mml.Row; import org.hartmath.tex2mml.TeX2MathMLFactory; public class Mathfrak implements IRowConverter { public final static int[] MATHFRAK_CODES = { 0xEF5D, 0xEF5E, 0x212D, 0xEF5F, 0xEF60, 0xEF61, 0xEF62, 0x210C, 0x2111, 0xEF63, 0xEF64, 0xEF65, 0xEF66, 0xEF67, 0xEF68, 0xEF69, 0xEF6A, 0x211C, 0xEF6B, 0xEF6C, 0xEF6D, 0xEF6E, 0xEF6F, 0xEF70, 0xEF71, 0x2128 }; /* * (non-Javadoc) * * @see org.hartmath.tex2mml.IRowConverter#convert(java.lang.StringBuffer, org.hartmath.tex2mml.Row, * org.hartmath.tex2mml.TeX2MathMLFactory) */ public boolean convert(StringBuffer buf, Row row, TeX2MathMLFactory f) { if (row.size() == 1) { Node temp = row.get(0); if (temp instanceof Identifier) { String st = temp.getOutput(); StringBuffer newst = new StringBuffer(); for (int j = 0; j < st.length(); j++) if (st.charAt(j) > 64 && st.charAt(j) < 91) { newst.append(TeX2MathMLFactory.toEntity(MATHFRAK_CODES[st.charAt(j) - 65])); } else { newst.append(st.charAt(j)); } f.tagStart(buf, temp.getTag()); buf.append(newst.toString()); f.tagEnd(buf, temp.getTag()); return true; } } return false; } } |