String node
参数应映射到单元格的
id
.
基本上,您可以选择所有单元格,获取它们并对其进行迭代。因为JGraph中的几乎所有内容都是
Object
private double getXForCell(String id) {
double res = -1;
graph.clearSelection();
graph.selectAll();
Object[] cells = graph.getSelectionCells();
for (Object object : cells) {
mxCell cell = (mxCell) object;
if (id.equals(cell.getId())) {
res = cell.getGeometry().getX();
}
}
graph.clearSelection();
return res;
}
你不妨检查一下
cell.isVertex()
getGeometry()
,因为其在边缘上的实现不同。
编辑:遵循你的方法,以下内容对我也适用。看起来你需要额外的演员阵容
(mxCell)
mxGraphModel graphModel = (mxGraphModel) graph.getModel();
return ((mxCell) graphModel.getCell(id)).getGeometry().getX();