fourPoints[1] = parent;
fourPoints[2] = child;
fourPoints[3] = grandChild;
Shape shape = edge.getShape();
CubicCurve2D myCurve;
if (shape == null) {
myCurve = new CubicCurve2D.Double();
edge.setShape(myCurve);
} else {
myCurve = (CubicCurve2D)shape;
}
BezierSpline.computeOneSpline(grandParent, parent, child, grandChild, myCurve);
// 11. Now do some tweaking of the control points to ensure continuity.
// need to tweak the first control point to be collinear with the parent
// and the grandparent and have the same distance as the
// parent-grandparent
double parentGrandDist = grandParent.distance(parent);
Vector2D grandToParent = new Vector2D(grandParent, parent);
//System.out.println(grandToParent);
//now take the grandToParent vector, scale by parentGrandDistance, add
// it to the parent vector
Point2D collinShift = new Point2D.Double(parentGrandDist
* grandToParent.getNormalized().getX() + parent.getX(),
parentGrandDist * grandToParent.getNormalized().getY()
+ parent.getY());
//System.out.println("before: " + myCurve.getP1() + ", "
// +myCurve.getCtrlP1() + ", " + myCurve.getCtrlP2() + ", " +
// myCurve.getP2() );
myCurve.setCurve(myCurve.getP1(), collinShift, myCurve.getCtrlP2(),
myCurve.getP2());
GraphicsGems.checkNaN(myCurve.getP1());
GraphicsGems.checkNaN(myCurve.getP2());
GraphicsGems.checkNaN(myCurve.getCtrlP1());
GraphicsGems.checkNaN(myCurve.getCtrlP2());
//System.out.println("after: " + myCurve.getP1() + ", "
// +myCurve.getCtrlP1() + ", " + myCurve.getCtrlP2() + ", " +
// myCurve.getP2() );
//System.out.println("CollinShift dist: " +
// collinShift.distance(parent) + " and p-GP dist: " + parentGrandDist);
// 10. Need to set the previous control point for the child node
Node otherItem = edge.getSecondNode();
otherItem.setPrevControlPoint(myCurve.getCtrlP2());
//System.out.println("Prev Control Point for " +
// ((FlowNode)otherItem.getEntity()).toStringId() + " was set to prev
// control point: " + grandParent);
if ((m_additiveEdges) && (shiftPoint != null)) {
// 12. Now shift the bezier points to line up properly with the horizontal translation
// that takes into account the thickness of the curve. We do this by shifting
// the first two points of every bezier to get it to line up in the appropriate place
Point2D grandParentShift = new Point2D.Double(myCurve.getP1().getX()+shiftPoint.getX(),
myCurve.getP1().getY()+shiftPoint.getY());
Point2D parentShift = new Point2D.Double(myCurve.getCtrlP1().getX()+shiftPoint.getX(),
myCurve.getCtrlP1().getY()+shiftPoint.getY());
myCurve.setCurve(grandParentShift, parentShift, myCurve.getCtrlP2(), myCurve.getP2());
}
GraphicsGems.checkNaN(myCurve.getP1());
GraphicsGems.checkNaN(myCurve.getP2());
GraphicsGems.checkNaN(myCurve.getCtrlP1());
GraphicsGems.checkNaN(myCurve.getCtrlP2());
return displayWidth;
}