Package com.mxgraph.reader
Class mxDomOutputParser
- java.lang.Object
-
- com.mxgraph.reader.mxDomOutputParser
-
public class mxDomOutputParser extends java.lang.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());
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
mxDomOutputParser.IElementHandler
-
Field Summary
Fields Modifier and Type Field Description protected mxICanvas2D
canvas
protected java.util.Map<java.lang.String,mxDomOutputParser.IElementHandler>
handlers
-
Constructor Summary
Constructors Constructor Description mxDomOutputParser(mxICanvas2D canvas)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
getValue(org.w3c.dom.Element elt, java.lang.String name, java.lang.String defaultValue)
Returns the given attribute value or an empty string.protected void
initHandlers()
void
read(org.w3c.dom.Node node)
-
-
-
Field Detail
-
canvas
protected mxICanvas2D canvas
-
handlers
protected transient java.util.Map<java.lang.String,mxDomOutputParser.IElementHandler> handlers
-
-
Constructor Detail
-
mxDomOutputParser
public mxDomOutputParser(mxICanvas2D canvas)
-
-