public void refreshCurve() {
//        System.out.println("Curve refreshing");
		needsRefresh = false;

        double lengthx = end.x - start.x;
        double lengthy = end.y - start.y;
        double centerx = ((double) (start.x + end.x)) / 2.0;
        double centery = ((double) (start.y + end.y)) / 2.0;

        double length = Math.sqrt(lengthx * lengthx + lengthy * lengthy);
        double factorx = length == 0.0 ? 0.0 : lengthx / length;
        double factory = length == 0.0 ? 0.0 : lengthy / length;

        if (myTransition.getControl() == null){

            control.x = (int) (centerx + curvy * HEIGHT * factory);
            control.y = (int) (centery - curvy * HEIGHT * factorx);
            high.x = (int) (centerx + curvy * HEIGHT * factory / 2.0);
            high.y = (int) (centery - curvy * HEIGHT * factorx / 2.0);

        }
        else{
            control.x = (int) myTransition.getControl().x;
            control.y = (int) myTransition.getControl().y;

            //take the vector from the center to the control, and take half of that
            double xt = control.x - centerx;
            double yt = centery - control.y;

            high.x = (int) (centerx + xt / 2); 
            high.y = (int) (centery - yt / 2);
        }

            curve.setCurve((float) start.x, (float) start.y, (float) control.x,
                    (float) control.y, (float) end.x, (float) end.y);

            affineToText = new AffineTransform();
            affineToText.translate(high.x, high.y);
            affineToText.rotate(Math.atan2(lengthy, lengthx));
            if (end.x < start.x)
                affineToText.rotate(Math.PI);
	}