Setting layout after dragging nodes

When I drag nodes with multiple links attached to it some of the links merge into one. However once I call layout all nodes and links are placed correctly. I was wondering is there a way to layout just what has been dragged rather than calling layout on the entire graph in order to get the proper layout?

Thank you for your time

Well, yes and no.
Yes, you can do a partial layout by constructing your own JGoNetwork that your JGo…Layout uses.
But no, because that partial network will be laid out without consideration of any other nodes in your document, because the layout just won’t know about those other nodes.
But an exception to this is the force-directed autolayout, because you can have JGoForceDirectedAutoLayout.isFixed return true for the nodes you don’t want to allow to be moved. So you could do a partial force-directed autolayout.

The isFixed() takes a JGoNetworkNode as an argument my question is how would I go about obtaining this information in order to pass it to the method?

Thanks again

There’s an example in in LayoutDemo.

Sorry walter one more question. How would I determine inside the isFixed() which nodes are selected so that I know these will be allowed to move?


I would probably cache the is-the-node-selected information in the JGoNetworkNode’s UserData after you construct the JGoNetwork, before calling performLayout. That would be faster than constantly having to look at the getJGoObject() and looking it up in the view’s selection.
I suppose you could just call JGoNetworkNode.setNodeUserData to something not-null, and override isFixed to return true if getNodeUserData() != null.

But how would I know which nodes are selected in order for me to set JGoNetworkNode.setNodeUserData to something not-null? I mean would my Nodes haves to implement some type of mouse event listener in order to be aware that it has been selected?

Thanks again for all your time

No, I just meant that your UI event handling code (whether the action is caused by a menu item or a button or whatever) that constructs a JGoForceDirectedAutoLayout, does so using a JGoNetwork that you create explicitly from your whole document and then update according to the selection in your document’s view.
You shouldn’t need to subclass/override anything to do this.