Muhammad Asaduzzaman
Muhammad Asaduzzaman

Reputation: 1241

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?

Upvotes: 1

Views: 813

Answers (1)

Joshua O&#39;Madadhain
Joshua O&#39;Madadhain

Reputation: 2704

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.

Upvotes: 1

Related Questions