Howto orthogonal links snap to straight?


Users tend to complain about the fact that it’s sometimes pretty hard
to get an orthogonal link look straight when dragging a node around.

How could some kind of snap mechanism be implemented which gets into
effect whenever an orthogonal link is redrawn as straight line while
dragging a connected node around?


Are you saying that the problem is that ports aren’t always positioned on a grid? If you position the ports on all your nodes to be at the desired distances, then this shouldn’t be a problem.


No, in this case I consider the grid turned off.

When I connect two nodes orthogonally and I move one node to make the link look straight, this often becomoes tedious, escpecially when the view is zoomed out.

This is what you get most of the times:

So, what I’d like to implement is a function, that when I move the selected node, it kinda sticks a bit and resists a bit when its in the position where the link looks straight or it may kinda snap to that position.

people tend to want not to only connect nodes but to let it look good. Also the look is a piece of the puzzle htat may help when we’re doing product presentations.


I was suggesting that you could use the grid to help, if you made sure the ports were always “on the grid”. Since you seem to have the ports always be at the middle of each side (just my guess), you could try calling JGoView.setGridSpot(JGoObject.Center) and make sure the grid cell width and height are suitably small for your purposes. You can call JGoView.snapObject to make sure any nodes you add programmatically are positioned OK.
In many other circumstances you’re not going to be able to satisfy your requirement. For example, if the ports were always at the corners, and users could resize the nodes, it’s impossible to get all the ports to line up nicely.