Links overlapping when dragging nodes

Hello,

We are using currently JGo version 5.1.5. We have an issue where a pair of nodes may have several
links between them. When we perform a digraph layout, for example, the
links appear distinctly. see screenshot below…

However if we drag these nodes around the view, the links then overlap
each other (see screenshot below

  • the ‘IT systems’ node was not moved
    therefore it still has the distinct arrows coming into it)

Is there any way we can configure our view so that the links do not
overlap when we drag nodes around?

regards,
Paul.

Try setting the JGoLink AdjustingStyle to something like AdjustingStyleStretch or AdjustingStyleEnd. This will preserve the intermediate points added by the layered digraph autolayout algorithm while still adjusting the link to connect the newly moved JGoPorts.

  • Scott

hi Scott,

The AdjustingStyleStretch appears to give the desirable behaviour. Thanks very much for your help.

regards,
Paul.

[QUOTE=ssmith]

Try setting the JGoLink AdjustingStyle to something like AdjustingStyleStretch or AdjustingStyleEnd. This will preserve the intermediate points added by the layered digraph autolayout algorithm while still adjusting the link to connect the newly moved JGoPorts.

- Scott

[/quote]

Hello again,

We are now using the AdjustingStyleStretch Adjusting Style. If we have 2 nodes that are connected and we drag them around the outside of each other the links seem to get a little messed up… eg:

before dragging:

after dragging them around each other fairly randomly

notice that the arrows seem to be going in the opposite direction to the node they are connecting to… and then they ‘turn back’ towards them.

any ideas why this would be happening?

regards,
Paul.

You must have dragged the node so that the links were shrunk down to “nothing”. Then when the node was moved away again, the “condensed” link’s features were exaggerated when stretched.
Part of this problem results from integers being used for coordinates, instead of floating point numbers. When I get a chance I can see if there’s a work-around for this, probably by making JGoLink.adjustPoints smarter.

Hi Walter,

I just tested your theory and i think you’re right… It occurs when the nodes are moved into a position where the links shrink down to nothing.

If you manage to come up with a fix/workaround for this i’d love to hear about it.

thanks,
Paul.

Try overriding JGoLink.stretchPoints:
protected boolean stretchPoints(int startIndex, int nFx, int nFy, int endIndex, int nTx, int nTy) {
Point a = getPoint(startIndex);
Point b = getPoint(endIndex);
if (a.x == nFx && a.y == nFy && b.x == nTx && b.y == nTy) return true;
double Ax = a.x;
double Ay = a.y;
double Bx = b.x;
double By = b.y;
double L = ((Bx-Ax) * (Bx-Ax) + (By-Ay) * (By-Ay));
double Cx = nFx;
double Cy = nFy;
double Dx = nTx;
double Dy = nTy;
double M = 0;
double m2 = 1;
if (Dx-Cx != 0)
M = (Dy-Cy)/(Dx-Cx);
else
M = 9.9e9;
if (M != 0)
m2 = Math.sqrt(1+(1/(MM)));
setPoint(startIndex, nFx, nFy);
for (int i = startIndex+1; i < endIndex; i++) {
Point p = getPoint(i);
double Px = p.x;
double Py = p.y;
double Q = 0.5;
if (L != 0)
Q = ((Ax-Px) * (Ax-Bx) + (Ay-Py) * (Ay-By)) / L;
// find point on old line
double Vx = Ax + Q * (Bx-Ax);
double Vy = Ay + Q * (By-Ay);
// distance from P to point V, on old line
double dV = Math.sqrt((Px-Vx)
(Px-Vx) + (Py-Vy)(Py-Vy));
if (Py < M
(Px-Vx) + Vy)
dV = -dV;
if (M > 0)
dV = -dV;
// find point on new line
double Wx = Cx + Q * (Dx-Cx);
double Wy = Cy + Q * (Dy-Cy);
if (M != 0) {
// compute new point for P off of new line, distance dV from W
double x = Wx + dV/m2;
double y = Wy - (x-Wx)/M;
setPoint(i, (int)Math.rint(x), (int)Math.rint(y));
} else {
setPoint(i, (int)Math.rint(Wx), (int)Math.rint(Wy+dV));
}
}
setPoint(endIndex, nTx, nTy);
return true;
}

walter,

thanks a lot for that code… I’ve put it in place and it definitely improves the behaviour.

regards,
Paul.