2014-02-19 33 views
0

在我的項目中,當我進行頂點分組時,默認情況下是在我的邊上添加一個虛線形狀。 我希望我可以在用戶可以互動的這個窗臺上添加一張圖片。JGRAPHX:如何更改一組頂點的樣式

例如:

未展開:

enter image description here

擴展:

enter image description here

回答

0

解決方案:

mxIGraphModel model = graph.getModel(); 
// start to change model 
model.beginUpdate(); 
mxGeometry geo = new mxGeometry(0, 0.5, PORT_DIAMETER, 
         PORT_DIAMETER); 
// Because the origin is at upper left corner, need to translate to 
// position the center of port correctly 
geo.setOffset(new mxPoint(-PORT_RADIUS, -PORT_RADIUS)); 
geo.setRelative(true); 

mxCell port = new mxCell(cell.getAttribute("label"), geo, 
         style); 
port.setVertex(true); 
//is not a port!!!!!!!! 
port.setConnectable(false); 
graph.addCell(port, cell); 
//send to back! 
graph.cellsOrdered(new Object[]{cell}, true); 
// end changes, generate the events and  update UndoManager 
       model.endUpdate(); 

Att, Alexandre。