Hi,
You could copy point coordinates from original link's ControlPoints to new link's ControlPoints. This should be done automatically if you use the DiagramLink(prototype, src, dest) constructor.
You can offset the cloned links using some vector math, adding normal left-hand or right-hand vector to each of their points:
import com.mindfusion.common.Vector;
void offsetPoints(DiagramLink link, float dist)
{
Point2D.Float[] points = link.getControlPoints().getArray();
int last = points.length - 1;
Vector current = normal(points[0], points[1], dist);
link.getControlPoints().set(0, Vector.add(current, points[0]));
for (int i = 1; i < last; i++)
{
Vector next = normal(points[i], points[i + 1], dist);
Vector nv = Vector.add(current, next);
link.getControlPoints().set(i, Vector.add(nv, points[i]));
current = next;
}
link.getControlPoints().set(last, Vector.add(current, points[last]));
link.updateFromPoints();
}
Vector normal(Point2D p1, Point2D p2, float len)
{
Vector v = new Vector(p1, p2);
return Vector.divide(
Vector.left(v),
v.length() / len);
}
I hope that helps,
Stoyan