3
我一直在使用JGraphX顯示一些數據(簡單的離散圖形),我想知道如何與JGraphX庫做以下事情:定製JGraphX
- 讓所有的邊不動,但仍允許用戶在兩個頂點之間創建邊緣
- 使所有頂點和邊不可編輯(它們不能編輯它們上顯示的內容)
- 如何在任何給定時間獲取選定的頂點或邊?
- 使所有的頂點框對用戶來說是不可估量的
- 如何修改每個頂點框的顏色?
謝謝,ExtremeCoder
我一直在使用JGraphX顯示一些數據(簡單的離散圖形),我想知道如何與JGraphX庫做以下事情:定製JGraphX
謝謝,ExtremeCoder
下面是一個例子:
mxGraph graph = new mxGraph()
{
// Make all edges unmovable
public boolean isCellMovable(Object cell)
{
return !getModel().isEdge(cell);
}
// Make all vertex boxes unresizable
public boolean isCellResizable(Object cell)
{
return !getModel().isVertex(cell);
}
};
// Make all vertices and edges uneditable
graph.setCellsEditable(false);
// Make all edges unbendable
graph.setCellsBendable(false);
// Get the selected vertex or edge
System.out.println(graph.getSelectionCell());
// To insert a vertex with a given color:
Object v1 = graph.insertVertex(parent, null, "Hello",
20, 20, 80, 30, "fillColor=#FF0000;");
// To modify the color of a vertex:
graph.setCellStyles(mxConstants.STYLE_FILLCOLOR, "#00FF00", new Object[]{v1});