Example of MathML display by
using Figue (Step by Step)
Import the usual figue packages.
|
import figue.*;
import figue.box.*;
import figue.resource.*;
import figue.io.xml.Utility;
|
Import the xerces java parser packag
|
import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.SAXException;
import org.w3c.dom.Document; |
Import the java package
|
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import java.lang.reflect.*;
import java.io.IOException; |
Create a xerces java parser
|
try {
parser = new org.apache.xerces.parsers.DOMParser();
// specifying validation
boolean validate = true;
parser.setFeature("http://xml.org/sax/features/validation", validate);
boolean nameSpaceProcessing = true;
parser.setFeature("http://xml.org/sax/features/namespaces", nameSpaceProcessing);
}
catch (SAXException e ) {
e.printStackTrace();
}
|
Create a Figue facade and init the resources for it (font, color ...)
|
_facade = new AWTFacade();
initResources();
|
Get the edited MathML text and parse it afterwards. We have a three different forms of input data of
|
String text = textArea.getText();
try {
doc=Utility.xercesParseXMLStringReader(text,"/net/home/hnaciri/THESE/implementation/test_figue/dtd/dtdMathML/mmlents/mathml.dtd",parser);
}
catch (SAXException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
|
Build a FIGUE facade from MathML Element
|
Utility.buildFacade( _facade, doc.getDocumentElement(),"MathML");
|
Display a facade
|
_facade.buildInit(null);
_facade.buildComplete();
|
|