Java 如何探索JGraphX对象(即查找边和节点)?
我通过xml字符串获取图形,因此首先我将其转换为mxGraph对象:Java 如何探索JGraphX对象(即查找边和节点)?,java,jgraphx,Java,Jgraphx,我通过xml字符串获取图形,因此首先我将其转换为mxGraph对象: mxGraph newGraph = new mxGraph(); org.w3c.dom.Node node = mxXmlUtils.parseXml(xml); mxCodec decoder = new mxCodec(node.getOwnerDocument()); decoder.decode(node.getFirstChild(),newGraph.getModel()); 现在我想做一些类似的事情: fo
mxGraph newGraph = new mxGraph();
org.w3c.dom.Node node = mxXmlUtils.parseXml(xml);
mxCodec decoder = new mxCodec(node.getOwnerDocument());
decoder.decode(node.getFirstChild(),newGraph.getModel());
现在我想做一些类似的事情:
for Edge edge newGraph.getAllEdges()
System.out.println(edge.src+" "+edge.dst);
然而getallEdges返回对象,我找不到任何Edge类…这对我来说似乎很奇怪
newGraph.clearSelection();
newGraph.selectAll();
Object[] cells = newGraph.getSelectionCells(); //here you have all cells
for (Object c : cells) {
mxCell cell = (mxCell) c; //cast
if (cell.isVertex()) { //isVertex
//todo
}else{ //is not a vertex, so u can get source and target
//todo
cell.getChildCount(); //Returns the number of child cells. (edges)
cell.getChildAt(x); //Returns the child at the specified index. (target)
}
收件人: