com.mxgraph.reader
Class mxDomOutputParser
java.lang.Object
com.mxgraph.reader.mxDomOutputParser
public class mxDomOutputParser
- extends Object
public static void main(String[] args)
{
try
{
String filename = Test.class.getResource(
"/com/mxgraph/online/exported.xml").getPath();
String xml = mxUtils.readFile(filename);
System.out.println("xml=" + xml);
Document doc = mxUtils.parseXml(xml);
Element root = doc.getDocumentElement();
int width = Integer.parseInt(root.getAttribute("width"));
int height = Integer.parseInt(root.getAttribute("height"));
System.out.println("width=" + width + " height=" + height);
BufferedImage img = mxUtils.createBufferedImage(width, height,
Color.WHITE);
Graphics2D g2 = img.createGraphics();
mxUtils.setAntiAlias(g2, true, true);
mxDomOutputParser reader = new mxDomOutputParser(
new mxGraphicsExportCanvas(g2));
reader.read((Element) root.getFirstChild().getNextSibling());
ImageIO.write(img, "PNG", new File(
"C:\\Users\\Gaudenz\\Desktop\\test.png"));
}
catch (Exception e)
{
e.printStackTrace();
}
}
// -------------
Document doc = mxUtils.parseXml(xml);
Element root = doc.getDocumentElement();
mxDomOutputParser reader = new mxDomOutputParser(canvas);
reader.read(root.getFirstChild());
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
canvas
protected mxICanvas2D canvas
handlers
protected transient Map<String,mxDomOutputParser.IElementHandler> handlers
mxDomOutputParser
public mxDomOutputParser(mxICanvas2D canvas)
read
public void read(Node node)
initHandlers
protected void initHandlers()
getValue
protected String getValue(Element elt,
String name,
String defaultValue)
- Returns the given attribute value or an empty string.
Copyright (c) 2010 Gaudenz Alder, David Benson. All rights reserved.