Adding Link Points Dynamically

I am drawing links dynamically and adding the points to the link as it gets placed on the view. For some reason the view never shows the extra points or doesn’t route the link along the points.

Point pt = new Point(rgp.getX(), rgp.getY());
link.insertPoint(1, pt);

and then I call calculatestroke after it gets added to the view. Is this correct?

JGoLink.calculateStroke() will tend to modify or replace all of the points in the stroke. If the conditions are right, the AdjustableStyle will cause some of the points to be modified; otherwise they will be completely reset according to the defaults for that kind of link.
Try not to call calculateStroke() during or after trying to set some or all of the points. That includes not moving either of the ports, of course.

Thanks that works not calling calculateStroke(). .
On another note I just wanted to say thanks for all your help. You have been a great resource when I couldn’t figure stuff out.

So if I switch from straight to curved lines, how do I get the link to redraw the line without wiping out the points?

Calling JGoStroke.setCubic with a new value will cause the stroke to be redrawn either as a Bezier curve or as a sequence of straight lines. That’s true even if you don’t modify any points, including by calling calculateStroke or by calling removeAllPoints.
But note that many sets of stroke points cannot be drawn as cubic curves–particularly if there aren’t at least four points. In fact, even straight lines can’t be drawn if there aren’t at least two points.
I believe JGoStroke will do the best it can given its circumstances. If you haven’t specified enough points for a cubic/Bezier curve, it tries to draw straight lines. If there aren’t enough points for a straight line, it doesn’t draw anything.

I actually am doing that already.
public void isRouteCurved(boolean curvy) {
if (curvy) {
setCubic(true);
setCurviness(10);
} else {
setCurviness(0);
setCubic(false);
}
calculateStroke();
}
this is just a property on my type for convience. I am extending from JLabeldLink.