2
我有使用JGraph(T)库的一些问题。 我需要更改默认选择视图,例如:默认背景为橙色,如果选择顶点然后添加绿色边框,我可以更改此可视化策略以将背景更改为所选元素上的Color.BLUE。 我尝试执行跟随代码:对同一选择OBJ文件JGraph(T)图元素选择定制
GraphSelectionModel graphSelectionModel = new DefaultGraphSelectionModel(jGraph);
graphSelectionModel.setSelectionMode(GraphSelectionModel.MULTIPLE_GRAPH_SELECTION);
graphSelectionModel.addGraphSelectionListener(new GraphSelectionListener()
{
HashMap oldestCellsAndAttrs = new HashMap();
@Override
public void valueChanged(GraphSelectionEvent e)
{
jGraph.getModel().beginUpdate();
m_jgAdapter.edit(oldestCellsAndAttrs, null, null, null);
oldestCellsAndAttrs.clear();
Map cellAndAttrs = new HashMap();
for (Object obj : e.getCells())
{
DefaultGraphCell cell = (DefaultGraphCell) obj;
oldestCellsAndAttrs.put(cell, JGraphModelAdapter.createDefaultVertexAttributes());
Map attrs = cell.getAttributes();
GraphConstants.setBackground(attrs, Color.BLUE);
cellAndAttrs.put(cell, attrs);
}
m_jgAdapter.edit(cellAndAttrs, null, null, null);
jGraph.getModel().endUpdate();
}
});
fillGraph(tree, g);
layout(g, m_jgAdapter, jGraph);
setSize(3 * width/4, height);
jGraph.setSelectionModel(graphSelectionModel);
这种变化BKG,但经过非选择不返回。 是否存在默认解决此问题?