Having regular links avoid one another

I was wondering if there was a way to have regular links avoid one another i.e. not having the ends collide into one another when the nodes are dragged?

Could you describe the situation more? What kind of ports/nodes/links are you talking about?

The nodes extend JGoBasicNode and the links extend JGoLabeledLink. I hope this is the information that you were looking for if not let me know. I would like to implement something like the Demo1.jar example where the basic nodes allow for multiple links to be inserted without having the links one on top of the other and also when the nodes are dragged the links do not collide. How would I implement something like that?

Well, you could setCubic(true) and setCurviness to different values.
Unless I still don’t understand what you want.

Not quite. Ok in the Demo1.jar if you select two basic nodes. You can attach as many links as you wish from one node to the other without having the links land on one another and also when the node is dragged the links do not collide into one. And the links are not curvy either. What I currently have for some reason drops the first link fine and then with the following links it drops them one on top of the other. I can drag them to seperate them however once I drag the node they once again become one.

I can’t get that behavior unless you edit the properties of each port to set “Valid Duplicate Links” to true on both ports, and then set “Cubic” to true and “Curviness” to different values for each of the links.
And if the links are not Cubic (i.e. Bezier curves), then the default behavior of JGoLink.calculateStroke would be the same for each link, which is why you see them superimposed on each other. You could try setting the AdjustingStyle property to avoid that routing behavior of calculateStroke, once you have separated the link paths. But for Orthogonal links I’m not sure that will really help.

Would it be possible for you to expand on “… once you have separated the link paths.”



In the calculateStroke method I have tried setting the setAdjustingStyle(JGoLink.XXXX) using AdjustingStyleCalculate, AdjustingStyleScale, AdjustingStyleStretch, AdjustingStyleEnd however for the most part the links remain the same unless I go ahead and drag and seperate the links.



Thank you for all your help walter

The AdjustingStyle property tells calculateStroke what it should do when it is called, typically because one of the link’s ports has moved.
You shouldn’t be setting AdjustingStyle from an override of calculateStroke (or one of its methods).
By “once you have separated the link paths” I meant after the user has reshaped the link, or after your application has modified the points of the link.
Anyway, I still don’t understand what (or how) you are getting the behavior in Demo1 that you claim. And if Demo1 is indeed giving you the behavior you want, why can’t you copy the relevant pieces of code?

Sorry realized my mistake with demo1 it does not do what I wished it to do