in fop-core/src/main/java/org/apache/fop/render/java2d/Java2DRenderer.java [570:719]
public static void drawBorderLine(Rectangle2D.Float lineRect,
boolean horz, boolean startOrBefore, int style, Color col, Graphics2D g2d) {
float x1 = lineRect.x;
float y1 = lineRect.y;
float x2 = x1 + lineRect.width;
float y2 = y1 + lineRect.height;
float w = lineRect.width;
float h = lineRect.height;
if ((w < 0) || (h < 0)) {
log.error("Negative extent received. Border won't be painted.");
return;
}
switch (style) {
case Constants.EN_DASHED:
g2d.setColor(col);
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);
BasicStroke s = new BasicStroke(h, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER, 10.0f, new float[] {unit}, 0);
g2d.setStroke(s);
g2d.draw(new Line2D.Float(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);
BasicStroke s = new BasicStroke(w, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER, 10.0f, new float[] {unit}, 0);
g2d.setStroke(s);
g2d.draw(new Line2D.Float(xm, y1, xm, y2));
}
break;
case Constants.EN_DOTTED:
g2d.setColor(col);
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);
BasicStroke s = new BasicStroke(h, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_MITER, 10.0f, new float[] {0, unit}, 0);
g2d.setStroke(s);
g2d.draw(new Line2D.Float(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);
BasicStroke s = new BasicStroke(w, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_MITER, 10.0f, new float[] {0, unit}, 0);
g2d.setStroke(s);
g2d.draw(new Line2D.Float(xm, y1, xm, y2));
}
break;
case Constants.EN_DOUBLE:
g2d.setColor(col);
if (horz) {
float h3 = h / 3;
float ym1 = y1 + (h3 / 2);
float ym2 = ym1 + h3 + h3;
BasicStroke s = new BasicStroke(h3);
g2d.setStroke(s);
g2d.draw(new Line2D.Float(x1, ym1, x2, ym1));
g2d.draw(new Line2D.Float(x1, ym2, x2, ym2));
} else {
float w3 = w / 3;
float xm1 = x1 + (w3 / 2);
float xm2 = xm1 + w3 + w3;
BasicStroke s = new BasicStroke(w3);
g2d.setStroke(s);
g2d.draw(new Line2D.Float(xm1, y1, xm1, y2));
g2d.draw(new Line2D.Float(xm2, y1, xm2, y2));
}
break;
case Constants.EN_GROOVE:
case Constants.EN_RIDGE:
float colFactor = (style == EN_GROOVE ? 0.4f : -0.4f);
if (horz) {
Color uppercol = ColorUtil.lightenColor(col, -colFactor);
Color lowercol = ColorUtil.lightenColor(col, colFactor);
float h3 = h / 3;
float ym1 = y1 + (h3 / 2);
g2d.setStroke(new BasicStroke(h3));
g2d.setColor(uppercol);
g2d.draw(new Line2D.Float(x1, ym1, x2, ym1));
g2d.setColor(col);
g2d.draw(new Line2D.Float(x1, ym1 + h3, x2, ym1 + h3));
g2d.setColor(lowercol);
g2d.draw(new Line2D.Float(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);
g2d.setStroke(new BasicStroke(w3));
g2d.setColor(leftcol);
g2d.draw(new Line2D.Float(xm1, y1, xm1, y2));
g2d.setColor(col);
g2d.draw(new Line2D.Float(xm1 + w3, y1, xm1 + w3, y2));
g2d.setColor(rightcol);
g2d.draw(new Line2D.Float(xm1 + w3 + w3, y1, xm1 + w3 + w3, y2));
}
break;
case Constants.EN_INSET:
case Constants.EN_OUTSET:
colFactor = (style == EN_OUTSET ? 0.4f : -0.4f);
if (horz) {
col = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
g2d.setStroke(new BasicStroke(h));
float ym1 = y1 + (h / 2);
g2d.setColor(col);
g2d.draw(new Line2D.Float(x1, ym1, x2, ym1));
} else {
col = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
float xm1 = x1 + (w / 2);
g2d.setStroke(new BasicStroke(w));
g2d.setColor(col);
g2d.draw(new Line2D.Float(xm1, y1, xm1, y2));
}
break;
case Constants.EN_HIDDEN:
break;
default:
g2d.setColor(col);
if (horz) {
float ym = y1 + (h / 2);
g2d.setStroke(new BasicStroke(h));
g2d.draw(new Line2D.Float(x1, ym, x2, ym));
} else {
float xm = x1 + (w / 2);
g2d.setStroke(new BasicStroke(w));
g2d.draw(new Line2D.Float(xm, y1, xm, y2));
}
}
}