Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


Bug & fix, or maybe I'm doing somet...

  • Kevin

    I ran into some problems with RadialTreeLayout.  Searching these forums turned up a few questions that sounded similar, but no solutions.

    I believe I've tracked down the problem, but I'm not sure my fix is the cleanest one.

    Long story short: calls RadialTreeLayout.calcAngularWidth(NodeItem, int).  If the NodeItem parameter has children, calcAngularWidth(…) should have the side effect of setting RadialTreeLayout.m_maxDepth > 0.  But it wasn't, because n.getChildCount() was returning 0 even when it should have returned > 0.

    The reason n.getChildCount() always returns 0 is because the VisualGraph's spanning tree is getting reset somewhere.  The spanning tree must be rooted at n for getChildCount() to return the correct value.  I haven't figured out where this is happening, but I know this: rebuilding the spanning tree with n as its root immediately before running an ActionList whose first action is the RadialTreeLayout does not fix the problem.  The only thing I've found that works is modifying, adding the line "g.getSpanningTree(n);" before calling calcAngularWidth(…).

    I believe a similar problem affects NodeLinkTreeLayout.

  • Kevin

    I found where the spanning tree is getting clobbered. calls initSchema(…) which modifies the nodes table, firing an event which is received by the Graph's listener.   This eventually calls Graph.updateDegrees(int, int, int, int) which sets m_spanning = null.

  • Kevin

    TL;DR: RadialTreeLayout only works if its layout root is the first node in the graph.  Fix it by adding "g.getSpanningTree(n);" to between the calls to initSchema(…) and calcAngularWidth(…).


  • Anonymous

    I compared Kevin's issue to the


    demo and found that the demo sets the spanning tree directly (subclass



    Kevin, did you use



    Apparently, the spanning tree is not built in that case, but is needed to compute the layout.

    Kevin's bugfix looks correct.
    If the spanning tree with the right root exists, the 


    returns immediately.

    Please make a pull request at