package com.mxgraph.readXml;
public class SourceXml {
private String name;
private String title;
private String type;
private String property;
private String id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getProperty() {
return property;
}
public void setProperty(String property) {
this.property = property;
}
}
package com.mxgraph.readXml;public class Location {private String nodeName; private double width; private double height; private double valueX; private double valueY; public String getNodeName() { return nodeName; } public void setNodeName(String nodeName) { this.nodeName = nodeName; } public double getWidth() { return width; } public void setWidth(double width) { this.width = width; } public double getHeight() { return height; } public void setHeight(double height) { this.height = height; } public double getValueX() { return valueX; } public void setValueX(double valueX) { this.valueX = valueX; } public double getValueY() { return valueY; } public void setValueY(double valueY) { this.valueY = valueY; } @Override public String toString() { return "Location [height=" + height + ", nodeName=" + nodeName + ", valueX=" + valueX + ", valueY=" + valueY + ", width=" + width + "]"; } }
package com.mxgraph.readXml;
public class MxcellXml {
private String id;
private String edge;
private String parent;
private String source;
private String target;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getEdge() {
return edge;
}
public void setEdge(String edge) {
this.edge = edge;
}
public String getParent() {
return parent;
}
public void setParent(String parent) {
this.parent = parent;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
}
package com.mxgraph.readXml;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
public class MxgrapReadXml {
public static Map<String, SourceXml> maps;
static {
maps = new HashMap<String, SourceXml>();
}
public static void main(String[] args) {
Map<String, SourceXml> readSource= readSource("mxgraphnew.xml");
Map<String, MxcellXml> readMxcell= readMxcell("mxgraphnew.xml");
ArrayList<String> firstNode=firstNode("mxgraphnew.xml");
Map<String, SourceXml> firstSource=firstSource("mxgraphnew.xml");
ArrayList<String> lastNode=lastNode("mxgraphnew.xml", "7");
Map<String, SourceXml> lastSource=lastSource("mxgraphnew.xml", "7");
ArrayList<String> nextNode=nextNode("mxgraphnew.xml", "3");
Map<String, SourceXml> nextSource=nextSource("mxgraphnew.xml", "3");
System.out.println("首节点id");
//首节点id点
for(String s:firstNode) {
System.out.print(s+",");
}
System.out.println();
System.out.println();
System.out.println("上一个节id");
//上一个节id
for(String s:lastNode) {
System.out.print(s+",");
}
System.out.println();
System.out.println();
System.out.println("mxcell实例");
//mxcell实例化
for(String s:readMxcell.keySet()) {
MxcellXml mxcellXml=readMxcell.get(s);
System.out.println(s+","+mxcellXml.getTarget());