dy = CommonUtil.rnd(target.getY() - p.getY());
if (index > 0)
{
// if index is not the first segment, we adjust the endpoint of the previous segment
CubicCurve2D prev = (CubicCurve2D) segments.get(index - 1);
p = prev.getCtrlP2();
p.setLocation(p.getX() + dx, p.getY() + dy);
prev.setCurve(prev.getP1(), prev.getCtrlP1(), p, target);
basicSetCtrlPoint(index, LEFT_CONTROLPOINT, p);
}
if (index < segments.size())
{
// likewise, if we are not the last segment, we adjust the position of the one after us
CubicCurve2D next = (CubicCurve2D) segments.get(index);
p = next.getCtrlP1();
p.setLocation(p.getX() + dx, p.getY() + dy);
next.setCurve(target, p, next.getCtrlP2(), next.getP2());
basicSetCtrlPoint(index, RIGHT_CONTROLPOINT, p);
}
changed();