in fop-core/src/main/java/org/apache/fop/render/pdf/PDFGraphicsPainter.java [59:193]
private void drawBorderLine2(float x1, float y1, float x2, float y2, boolean horz,
boolean startOrBefore, int style, Color col) {
float w = x2 - x1;
float h = y2 - y1;
float colFactor;
switch (style) {
case Constants.EN_DASHED:
generator.setColor(col);
if (horz) {
float dashedWidth = BorderPainter.dashWidthCalculator(w, h);
if (dashedWidth != 0) {
float ym = y1 + (h / 2);
generator.setDashLine(dashedWidth, dashedWidth * BorderPainter.DASHED_BORDER_SPACE_RATIO)
.setLineWidth(h)
.strokeLine(x1, ym, x2, ym);
}
} else {
float dashedWidth = BorderPainter.dashWidthCalculator(h, w);
if (dashedWidth != 0) {
float xm = x1 + (w / 2);
generator.setDashLine(dashedWidth, dashedWidth * BorderPainter.DASHED_BORDER_SPACE_RATIO)
.setLineWidth(w)
.strokeLine(xm, y1, xm, y2);
}
}
break;
case Constants.EN_DOTTED:
generator.setColor(col).setRoundCap();
if (horz) {
float unit = Math.abs(2 * h);
int rep = (int) (w / unit);
if (rep % 2 == 0) {
rep++;
}
unit = w / rep;
float ym = y1 + (h / 2);
generator.setDashLine(0, unit)
.setLineWidth(h)
.strokeLine(x1, ym, x2, ym);
} else {
float unit = Math.abs(2 * w);
int rep = (int) (h / unit);
if (rep % 2 == 0) {
rep++;
}
unit = h / rep;
float xm = x1 + (w / 2);
generator.setDashLine(0, unit)
.setLineWidth(w)
.strokeLine(xm, y1, xm, y2);
}
break;
case Constants.EN_DOUBLE:
generator.setColor(col)
.setSolidLine();
if (horz) {
float h3 = h / 3;
float ym1 = y1 + (h3 / 2);
float ym2 = ym1 + h3 + h3;
generator.setLineWidth(h3)
.strokeLine(x1, ym1, x2, ym1)
.strokeLine(x1, ym2, x2, ym2);
} else {
float w3 = w / 3;
float xm1 = x1 + (w3 / 2);
float xm2 = xm1 + w3 + w3;
generator.setLineWidth(w3)
.strokeLine(xm1, y1, xm1, y2)
.strokeLine(xm2, y1, xm2, y2);
}
break;
case Constants.EN_GROOVE:
case Constants.EN_RIDGE:
colFactor = (style == Constants.EN_GROOVE ? 0.4f : -0.4f);
generator.setSolidLine();
if (horz) {
Color uppercol = ColorUtil.lightenColor(col, -colFactor);
Color lowercol = ColorUtil.lightenColor(col, colFactor);
float h3 = h / 3;
float ym1 = y1 + (h3 / 2);
generator.setLineWidth(h3)
.setColor(uppercol)
.strokeLine(x1, ym1, x2, ym1)
.setColor(col)
.strokeLine(x1, ym1 + h3, x2, ym1 + h3)
.setColor(lowercol)
.strokeLine(x1, ym1 + h3 + h3, x2, ym1 + h3 + h3);
} else {
Color leftcol = ColorUtil.lightenColor(col, -colFactor);
Color rightcol = ColorUtil.lightenColor(col, colFactor);
float w3 = w / 3;
float xm1 = x1 + (w3 / 2);
generator.setLineWidth(w3)
.setColor(leftcol)
.strokeLine(xm1, y1, xm1, y2)
.setColor(col)
.strokeLine(xm1 + w3, y1, xm1 + w3, y2)
.setColor(rightcol)
.strokeLine(xm1 + w3 + w3, y1, xm1 + w3 + w3, y2);
}
break;
case Constants.EN_INSET:
case Constants.EN_OUTSET:
colFactor = (style == Constants.EN_OUTSET ? 0.4f : -0.4f);
generator.setSolidLine();
Color c = col;
if (horz) {
c = ColorUtil.lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
float ym1 = y1 + (h / 2);
generator.setLineWidth(h)
.setColor(c)
.strokeLine(x1, ym1, x2, ym1);
} else {
c = ColorUtil.lightenColor(c, (startOrBefore ? 1 : -1) * colFactor);
float xm1 = x1 + (w / 2);
generator.setLineWidth(w)
.setColor(c)
.strokeLine(xm1, y1, xm1, y2);
}
break;
case Constants.EN_HIDDEN:
break;
default:
generator.setColor(col).setSolidLine();
if (horz) {
float ym = y1 + (h / 2);
generator.setLineWidth(h)
.strokeLine(x1, ym, x2, ym);
} else {
float xm = x1 + (w / 2);
generator.setLineWidth(w)
.strokeLine(xm, y1, xm, y2);
}
}
}