GoLinks, which at any case shouldn't overlap nodes

Hello Walter.

I have some questions, about GoLinks and how to customize them so they fit my requirements.

I’m making trying to realize a graphical notation, where the most important rule is, that nodes do not overlap with each other and with links. I already solved the nodes part, now I by the links part.

My links called here relationships must support the following actions: 1. Make new relationship

2. Relink relationship

3. Reshape relationship path

4. Delete

In the implementation of these functionalities I ran into some problems. Hopefully you can help me in some way.

1. Problem:

I have the set the AvoidsNodes = true so that when I do the 1.Make a new relationship action the link goes around any nodes.

When I intend to draw a link form Source to Target it looks like this:


When I actually draw it, it looks like this:![|401x111](upload://93YzZ6F884ZJQiTVhwYR7i4TEMG.jpeg)

Which is ok. Now I now, that when I move a node, the link won’t automatically change, so I must call the CalculateStroke() method. When I move the Must be allowed node one grid box to the left, the link route changes, appropriately:


But if I move the node even closer to the Source node, the CalculateStroke() method, which is for sure called won’t give the expected result instead, this happens:


Which isn’t good at all, because there is overlapping in the diagram. How can I fix this? Why won’t the link be rerouted from the upper edge of the Source node? I use GoBoxNode as the parent of my nodes. I also set LinkPointsSpread = true and IsValidDuplicateLinks = true at the Port of my nodes.

2. Problem:

When I want to do the 3. Reshape relationship path action I encounter a problem, so that the middle section of my orthogonal link can be moved on any of the 2 nodes, which it connects.

Original shape:


Reshaped path (of course invalid considering my requirements):


How could I forbid the relocation outside the in-between nodes area? I know I will have to override the DoResizing(GoInputState evttype) method in my custom ResizingTool , but unfortunately I don’t have clue what to do there, could you point me in the right direction?

3. Problem:

I have problems by 2. Relink relationship action.


It just won’t work. I investigate and copied a RelinkingTool from the MovableLinkApp demo. Then I’ve overridden the DoRelink(IGoLink oldlink, IGoPort fromPort, IGoPort toPort) method, to see what went on. But when I wanted to relink (by dragging the diamond next to the Temporary target) the relationship that connects the Source and the Temporary target to the Final target node the program never reached the DoRelink method. Then I investigated a little more and found out that when I try to drag the diamond, the program goes into the DoResizing(GoInputState evttype) method in my custom ResizingTool, which is very odd.

Here I really don’t what to do, have you any suggestions?

That’s all for now, thank you for your time and effort.
Have a nice day!

  1. Two comments.
(a) If you are using 2.5 or later, you can set GoDocument.RoutingTime to be GoRoutingTime.AfterNodesDragged. That will automatically cause links to be rerouted if a node is dragged to overlap an AvoidsNodes link. So you don't have to have the code that apparently you have implemented to call CalculateStroke at various times.
(b) The situation you show is really one where the middle node is overlapping the first one, as far as the node-avoidance routing algorithm is concerned. So it treats the middle node as if it were part of the first node -- the link just keeps going straight until it exits that middle/overlapping node.
2. No, you don't need to customize the resizing tool. You just need to override GoLink.DoResize. If the new point is in a node, do nothing. If the adjacent points would be in a node, do nothing. Otherwise, call the base method.
Hmmm, that isn't quite enough. You also need to check whether both segments (on either side of the point being moved) might cross over any nodes. The method PickObjectsInRectangle (of GoLayer if all your nodes are in one layer, or of GoDocument otherwise) might be useful to you for reducing the number of nodes to consider when checking each segment for any intersections.
3. I don't understand what your problem is. Are you saying that the user cannot relink at all? You might want to remove all your custom tools, to avoid any confusion.