我正在使用jgraphx 1.12.0.2,並試圖從代碼中重新排列圖形的頂點。代碼看起來像這樣:使用JGraphX移動單元格
Object[] roots = graph.getChildCells(graph.getDefaultParent(), true, false);
graph.getModel().beginUpdate();
for (int i = 0; i < roots.length; i++) {
Object[] root = {roots[i]};
graph.moveCells(root, i * 10 + 5, 50);
/* these two lines were added because I thought they might help with the problem */
/* with or without them, the result is the same */
graph.getView().clear(root, true, true);
graph.getView().validate();
}
graph.refresh();
graph.getModel().endUpdate();
問題是,當然,單元不會移動到指定的位置。可能是什麼問題呢?
謝謝!
你的代碼適合我。我唯一的問題,邊緣不能正常移動。 – Marco