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?
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.
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?
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.
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?
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.