Circle Layout doesn't update when adding

2012-01-25
2013-05-29
  • glass_knife

    glass_knife - 2012-01-25

    I am trying to use a circle layout, and it works fine to layout the initial graph, but after the GUI launches, if I add other nodes they are always placed in the upper left-hand corner.  The only way I have found to make it work is to create a brand new Layout object for every new vertex and/or edge.  Is that right?  It seems like there should be a much simpler way to reset or refresh the layout. 

    If I use the example code AddNodeDemo, but change the initial layout from the FRLayout to a CircleLayout, the demo no longer works.

    Has anyone had this problem?

     
  • Joshua O'Madadhain

    You are correct: CircleLayout is a static layout.

    If you think about it, adding one vertex to a CircleLayout requires recalculating all the positions anyway, so there's no computational advantage to trying to update the layout as opposed to just creating a new one.

    Joshua

     
  • glass_knife

    glass_knife - 2012-01-26

    OK, that makes sense.  Why it is causing me trouble is simple this:

    I am looking for the steps needed to add a node to the graph, reguardless of what layout the use has selected.  I would prefer to just have an algorithm that works no mater what layout is selected, rather than different steps based on the type of layout.

    Is there a correct way to handel updating the graph so that no matter what layout is used, it will work?  It seemes counter-intuitive to create a new layout when adding a vertex or an edge, because some layouts do not require that.

    Would it be correct to just make a new layout, and then use the animator to transition from one to another? 

     
  • glass_knife

    glass_knife - 2012-01-26

    Also, I see the same behavior switching between SpringLayout and SpringLayout2.  Is SpringLayout2 also a static layout?

    If I change the Layout in the AddNodeDemo from SpringLayout to SpringLayout2, is also doesn't work.

     
  • Joshua O'Madadhain

    No, there is not a single way to handle updating the graph regardless of the type of layout.  At some point we may refactor the Layout type system so that it's possible to tell programmatically whether a layout is static or (at least potentially) dynamic.

    SpringLayout2 is not static.  Not sure exactly what behavior you're seeing there; can you be more specific?

    Joshua

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks