Open toddharrison opened 7 years ago
can you throw that into a github project so that we can try it out?
Ok, This is only a guess.
The problem is that viewer.enableAutoLayout()
is "replaying" all the graph events so that the newly created layout algorithm can be aware of all the nodes and edges of the graph. In the mean time you plugged the graphicGraph back to the "real" graph with a pipe. So each time you re-enable the layout, you also send all the graphic graph's events back to the original graph that itself already has those nodes and edges. Hence the IdAlreadyInUseException.
Perhaps viewer.enableAutoLayout()
should be reworked, but iI thing it was meant to be used only once in le life time of the visualisation.
In the mean time you can prevent the original graph from receiving elements-related event and only listen to attribute-related events. Use :
pipe.addAttributeSink(graph);
instead of
pipe.addSink(graph);
I have created a new graph and registered a pump so that I am notified when a user clicks on a node using something like this:
I also have a toggle that turns on and off auto layout, like so:
Everything works fine until I toggle the auto layout off and then on again. When I toggle it on again I get the following exception:
It seems to be trying to add a node again, just by changing the auto layout to be true. I also receive this exception if I startup my application and do not specify
viewer.enableAutoLayout();
before creating the ViewerPipe, as above.