Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何探索JGraphX对象(即查找边和节点)?_Java_Jgraphx - Fatal编程技术网

Java 如何探索JGraphX对象(即查找边和节点)?

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

我通过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());
现在我想做一些类似的事情:

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)
 }
收件人: