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.

Close

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

Help
Kevin
2012-10-12
2013-05-29
  • Kevin
    Kevin
    2012-10-12

    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: RadialTreeLayout.run() 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 RadialTreeLayout.run(), adding the line "g.getSpanningTree(n);" before calling calcAngularWidth(…).

    I believe a similar problem affects NodeLinkTreeLayout.

     
  • Kevin
    Kevin
    2012-10-12

    I found where the spanning tree is getting clobbered.  RadialTreeLayout.run() 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
    Kevin
    2012-10-12

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

     

  • Anonymous
    2012-10-15

    I compared Kevin's issue to the

    RadialGraphView
    

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

    TreeRootAction
    

    ).

    Kevin, did you use

    layout.setLayoutRoot(n)
    

    ?

    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 

    g.getSpanningTree(n)
    

    returns immediately.

    Please make a pull request at https://github.com/prefuse/Prefuse