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?
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.
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.
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.
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.
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; }