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完成,因爲選擇也是圖形化的 –