1
我需要得到我的Id找到的mxCell的坐标(x,y),但是当我调用getGeometry()时,它给了我null并且在我得到NullPointerException之后。如何获取mxCell的坐标?
private double getX(String node){
mxCell cell = (mxCell) ((mxGraphModel)map.getGraph().getModel()).getCell(node);
mxGeometry geo = cell.getGeometry();//this line give me the null value
double x = geo.getX();//NullPointerException
return x;
}
map是包含所有图的mxGraphComponent。
我在想什么?
是的,我在找这个,谢谢! –
我还发现'void graph.selectVertices()'方法,如果只想查询顶点,这可能很有用。 – Johannes
它会导致一些问题,因为它必须由EDT完成,因为选择也是图形化的 –