in fop-core/src/main/java/org/apache/fop/render/AbstractPathOrientedRenderer.java [386:556]
protected void drawBorders(Rectangle2D.Float borderRect,
BorderProps bpsTop, BorderProps bpsBottom, BorderProps bpsLeft, BorderProps bpsRight,
Color innerBackgroundColor) {
//TODO generalize each of the four conditions into using a parameterized drawBorder()
boolean[] border = new boolean[] {
(bpsTop != null), (bpsRight != null),
(bpsBottom != null), (bpsLeft != null)};
float startx = borderRect.x;
float starty = borderRect.y;
float width = borderRect.width;
float height = borderRect.height;
float[] borderWidth = new float[] {
(border[TOP] ? bpsTop.width / 1000f : 0.0f),
(border[RIGHT] ? bpsRight.width / 1000f : 0.0f),
(border[BOTTOM] ? bpsBottom.width / 1000f : 0.0f),
(border[LEFT] ? bpsLeft.width / 1000f : 0.0f)};
float[] clipw = new float[] {
BorderProps.getClippedWidth(bpsTop) / 1000f,
BorderProps.getClippedWidth(bpsRight) / 1000f,
BorderProps.getClippedWidth(bpsBottom) / 1000f,
BorderProps.getClippedWidth(bpsLeft) / 1000f};
starty += clipw[TOP];
height -= clipw[TOP];
height -= clipw[BOTTOM];
startx += clipw[LEFT];
width -= clipw[LEFT];
width -= clipw[RIGHT];
boolean[] slant = new boolean[] {
(border[LEFT] && border[TOP]),
(border[TOP] && border[RIGHT]),
(border[RIGHT] && border[BOTTOM]),
(border[BOTTOM] && border[LEFT])};
if (bpsTop != null) {
endTextObject();
float sx1 = startx;
float sx2 = (slant[TOP] ? sx1 + borderWidth[LEFT] - clipw[LEFT] : sx1);
float ex1 = startx + width;
float ex2 = (slant[RIGHT] ? ex1 - borderWidth[RIGHT] + clipw[RIGHT] : ex1);
float outery = starty - clipw[TOP];
float clipy = outery + clipw[TOP];
float innery = outery + borderWidth[TOP];
saveGraphicsState();
moveTo(sx1, clipy);
float sx1a = sx1;
float ex1a = ex1;
if (isCollapseOuter(bpsTop)) {
if (isCollapseOuter(bpsLeft)) {
sx1a -= clipw[LEFT];
}
if (isCollapseOuter(bpsRight)) {
ex1a += clipw[RIGHT];
}
lineTo(sx1a, outery);
lineTo(ex1a, outery);
}
lineTo(ex1, clipy);
lineTo(ex2, innery);
lineTo(sx2, innery);
closePath();
clip();
drawBorderLine(sx1a, outery, ex1a, innery, true, true,
bpsTop.style, bpsTop.color);
restoreGraphicsState();
}
if (bpsRight != null) {
endTextObject();
float sy1 = starty;
float sy2 = (slant[RIGHT] ? sy1 + borderWidth[TOP] - clipw[TOP] : sy1);
float ey1 = starty + height;
float ey2 = (slant[BOTTOM] ? ey1 - borderWidth[BOTTOM] + clipw[BOTTOM] : ey1);
float outerx = startx + width + clipw[RIGHT];
float clipx = outerx - clipw[RIGHT];
float innerx = outerx - borderWidth[RIGHT];
saveGraphicsState();
moveTo(clipx, sy1);
float sy1a = sy1;
float ey1a = ey1;
if (isCollapseOuter(bpsRight)) {
if (isCollapseOuter(bpsTop)) {
sy1a -= clipw[TOP];
}
if (isCollapseOuter(bpsBottom)) {
ey1a += clipw[BOTTOM];
}
lineTo(outerx, sy1a);
lineTo(outerx, ey1a);
}
lineTo(clipx, ey1);
lineTo(innerx, ey2);
lineTo(innerx, sy2);
closePath();
clip();
drawBorderLine(innerx, sy1a, outerx, ey1a, false, false,
bpsRight.style, bpsRight.color);
restoreGraphicsState();
}
if (bpsBottom != null) {
endTextObject();
float sx1 = startx;
float sx2 = (slant[LEFT] ? sx1 + borderWidth[LEFT] - clipw[LEFT] : sx1);
float ex1 = startx + width;
float ex2 = (slant[BOTTOM] ? ex1 - borderWidth[RIGHT] + clipw[RIGHT] : ex1);
float outery = starty + height + clipw[BOTTOM];
float clipy = outery - clipw[BOTTOM];
float innery = outery - borderWidth[BOTTOM];
saveGraphicsState();
moveTo(ex1, clipy);
float sx1a = sx1;
float ex1a = ex1;
if (isCollapseOuter(bpsBottom)) {
if (isCollapseOuter(bpsLeft)) {
sx1a -= clipw[LEFT];
}
if (isCollapseOuter(bpsRight)) {
ex1a += clipw[RIGHT];
}
lineTo(ex1a, outery);
lineTo(sx1a, outery);
}
lineTo(sx1, clipy);
lineTo(sx2, innery);
lineTo(ex2, innery);
closePath();
clip();
drawBorderLine(sx1a, innery, ex1a, outery, true, false,
bpsBottom.style, bpsBottom.color);
restoreGraphicsState();
}
if (bpsLeft != null) {
endTextObject();
float sy1 = starty;
float sy2 = (slant[TOP] ? sy1 + borderWidth[TOP] - clipw[TOP] : sy1);
float ey1 = sy1 + height;
float ey2 = (slant[LEFT] ? ey1 - borderWidth[BOTTOM] + clipw[BOTTOM] : ey1);
float outerx = startx - clipw[LEFT];
float clipx = outerx + clipw[LEFT];
float innerx = outerx + borderWidth[LEFT];
saveGraphicsState();
moveTo(clipx, ey1);
float sy1a = sy1;
float ey1a = ey1;
if (isCollapseOuter(bpsLeft)) {
if (isCollapseOuter(bpsTop)) {
sy1a -= clipw[TOP];
}
if (isCollapseOuter(bpsBottom)) {
ey1a += clipw[BOTTOM];
}
lineTo(outerx, ey1a);
lineTo(outerx, sy1a);
}
lineTo(clipx, sy1);
lineTo(innerx, sy2);
lineTo(innerx, ey2);
closePath();
clip();
drawBorderLine(outerx, sy1a, innerx, ey1a, false, true, bpsLeft.style, bpsLeft.color);
restoreGraphicsState();
}
}