* The corner radius to use for the path.
* @return A path surrounding the given rectangles and uses the given
* corner-radius.
*/
private Path createPath(Rectangle topOutside, Rectangle rightOutside, Rectangle bottomOutside, int corner) {
Path path = new Path(null);
// currently we assume, that the inner corner radius is always half the outer corner radius
int innerCorner = corner / 2;
// first shrink all rectangles by the half line-width, so that painting remains inside the given 'outside' rectangles
Rectangle top = FigureUtil.getAdjustedRectangle(topOutside, 1.0, (int) (getDeclaration().getPadLineWidth() * getZoomLevel()));
Rectangle right = FigureUtil.getAdjustedRectangle(rightOutside, 1.0, (int) (getDeclaration().getPadLineWidth() * getZoomLevel()));
Rectangle bottom = FigureUtil.getAdjustedRectangle(bottomOutside, 1.0,
(int) (getDeclaration().getPadLineWidth() * getZoomLevel()));
// differenciate the pad styles
boolean hasTop = top != null;
boolean hasRight = right != null;
boolean hasStandardTop = hasTop && getDeclaration().getTopPadStyle().equals(PadStyle.STANDARD);
boolean hasStandardRight = hasRight && getDeclaration().getRightPadStyle().equals(PadStyle.STANDARD);
boolean hasAppendageTop = hasTop && getDeclaration().getTopPadStyle().equals(PadStyle.APPENDAGE);
boolean hasAppendageRight = hasRight && getDeclaration().getRightPadStyle().equals(PadStyle.APPENDAGE);
// create path
if (hasStandardTop) {
// curved line around top(top-right) -> top(top-left) -> top(bottom-left)
path.addArc(top.getTopRight().x - corner, top.getTopRight().y, corner, corner, 0, 90);
path.addArc(top.getTopLeft().x, top.getTopLeft().y, corner, corner, 90, 90);
path.addArc(top.getBottomLeft().x, top.getBottomLeft().y - corner, corner, corner, 180, 90);
} else if (hasAppendageTop) {
// curved line around top(top-left) -> top(bottom-left)
int appendageCorner = Math.min(corner, top.height * 2); // adjust for small sizes
path.addArc(top.getTopLeft().x, top.getTopLeft().y, appendageCorner, appendageCorner, 90, 90);
path.lineTo(top.getBottomLeft().x, top.getBottomLeft().y);
} else { // !hasTop
// curved line around right(top-left)
path.addArc(right.getTopLeft().x, right.getTopLeft().y, corner, corner, 90, 90);
}
if (hasTop && hasRight) {
// inside open curve connecting top and right
path.addArc(right.getLeft().x - innerCorner, top.getBottom().y, innerCorner, innerCorner, 90, -90);
}
if (hasStandardRight) {
if (bottom == null) {
// curved line around right(bottom-left)
path.addArc(right.getBottomLeft().x, right.getBottomLeft().y - corner, corner, corner, 180, 90);
} else {
// inside open curve connection right and bottom
path.addArc(right.getLeft().x - innerCorner, bottom.getTop().y - innerCorner, innerCorner, innerCorner, 0, -90);
// curved line around bottom(top-left) -> bottom(bottom-left) -> bottom(bottom-right)
path.addArc(bottom.getTopLeft().x, bottom.getTopLeft().y, corner, corner, 90, 90);
path.addArc(bottom.getBottomLeft().x, bottom.getBottomLeft().y - corner, corner, corner, 180, 90);
path.addArc(bottom.getBottomRight().x - corner, bottom.getBottomRight().y - corner, corner, corner, 270, 90);
// outside open curve connection bottom and right
path.addArc(bottom.getRight().x, right.getBottom().y, corner, corner, 180, -90);
}
// curved line around right(bottom-right) -> right(top-right)
path.addArc(right.getBottomRight().x - corner, right.getBottomRight().y - corner, corner, corner, 270, 90);
path.addArc(right.getTopRight().x - corner, right.getTopRight().y, corner, corner, 0, 90);
} else if (hasAppendageRight) {
// curved line around right(bottom-left) -> right(bottom-right)
int appendageCorner = Math.min(corner, right.width * 2); // adjust for small sizes
path.lineTo(right.getBottomLeft().x, right.getBottomLeft().y);
path.addArc(right.getBottomRight().x - appendageCorner, right.getBottomRight().y - appendageCorner, appendageCorner,
appendageCorner, 270, 90);
} else { // !hasRight
// close curved rectangle around top (bottom-right)
path.addArc(top.getBottomRight().x - corner, top.getBottomRight().y - corner, corner, corner, 270, 90);
}
if (hasStandardTop && hasStandardRight) {
// outside open curve connecting right and top (appendages have direct line)
path.addArc(top.getRight().x, right.getTop().y - corner, corner, corner, 270, -90);
}
path.close();
return path;
}