我需要获取我通过他的 ID 找到的 mxCell 的坐标(x,y),但是当我在其上调用 getGeometry() 时,它给了我 null 并且在我得到 NullPointerException 之后。
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。
我错过了什么?