pt1.setX(pt2.getX() - Point2D.distance(pt2.getX(), pt2.getY(), br.getX(), (tl.getY() + br.getY()) / 2.));
pt2.setX(tl.getX() + (br.getX() - tl.getX()) * gradMidPt);
} else {
final IPoint cg = shape.getGravityCentre();
final ILine l2;
final ILine l;
pt1 = pt1.rotatePoint(cg, -angle);
pt2 = pt2.rotatePoint(cg, -angle);
l = ShapeFactory.createLine(pt1, pt2);
if (angle >= 0. && angle < Math.PI / 2.)
l2 = l.getPerpendicularLine(tl);
else
l2 = l.getPerpendicularLine(ShapeFactory.createPoint(tl.getX(), br.getY()));
pt1 = l.getIntersection(l2);
final double distance = Point2D.distance(cg.getX(), cg.getY(), pt1.getX(), pt1.getY());
l.setX1(pt1.getX());
l.setY1(pt1.getY());
final IPoint[] pts = l.findPoints(pt1, 2 * distance * gradMidPt);
pt2 = pts[0];
if (gradMidPt < 0.5)
pt1 = pt1.rotatePoint(shape.getGravityCentre(), Math.PI);
}