Connecting nodes


#1

Hi,

I want to connect two nodes directly, I mean, with no link between them.
The connection is only valid when it’s made on the ports.
I also want to be able to move the two nodes when I drag one of them…
Is this possible?
How will this change the layout algo.?


#2

Well, JGo is very much oriented around using JGoLinks as the implementation of the “link/edge/arc” graph concept.
So you’ll need to implement your own notion of “connection”, presumably as references between two instances of your JGoArea subclass that has been extended to remember and manage such references. This is basically reimplementing the logical functionality of port and links, but not their appearance and behavior as JGoObjects. Hmmm, I suppose you could just use invisible JGoLinks instead. But you’ll need to establish mechanisms to create such links and remove them when appropriate.
Then you’ll need to override JGoView.computeEffectiveSelection to extend the JGoSelection with the additional objects you want to drag along. Presumably this involves recursive walks looking for things that are connected to already selected areas.
(Sorry, but I don’t think there’s an example of this in the current kit.)
For doing an automatic layout, you’ll need to customize the JGoNetwork to treat each set of connected areas as a single JGoNetworkNode, connected logically by the union of JGoNetworkLinks that represent the real JGoLinks that you are still using.
Of course if you don’t really have any true JGoLinks, it wouldn’t make much sense to try to do an automatic layout. If connections are based on the relative positions of two areas, you wouldn’t want an automatic layout to mess those up.