Collapse a jung node based on node selection
I am trying to collapse all the children of a vertex when a user clicks on it. But the problem is that, every time I tried to do so, I got the following error:
Tree must not contain edu.ics.jung.graph.DelegateForest@17510d96
The code is given below:
public void graphClicked(MyNode v, MouseEvent me)
{
Collection<MyNode> childrens = graph.getChildren(v);
Collection picked = new Hashset(childrens);
if(picked.size开发者_运维问答>1)
{
Graph ingraph = this.radialLayout.getGraph();
Graph clusterGraph = collapser.getClusterGraph(graph,childrens);
Graph g = collapser.collapse(ingraph,clustergraph); //The error report points on this line
.
.
.
}
}
I am using a Forest
with RadialLayout
.
Can anyone help me? How can I solve the problem?
Check out the tree node collapse and vertex collapse demos here:
http://jung.sourceforge.net/applet/index.html
The source for each of these is included in the distribution files.
精彩评论