题
我一直在使用JGraphX显示一些数据(简单的离散的图表)和我想知道如何去做的以下事情的JGraphX图书馆:
- 让所有不可移动的边缘,但仍然允许的用户创建一个边缘两个顶点之间
- 让所有的顶点和边不可编辑(他们无法编辑上显示他们)
- 我怎么选择的顶点或边缘,在任何给定的时间?
- 使所有顶点的框unresizable用户
- 我怎么修改色的每个顶点的盒子吗?
谢谢,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});
不隶属于 StackOverflow