in fop-core/src/main/java/org/apache/fop/render/java2d/Java2DGraphicsPainter.java [63:209]
public void drawBorderLine(int x1, int y1, int x2, int y2,
boolean horz, boolean startOrBefore, int style, Color color)
throws IOException {
float w = x2 - x1;
float h = y2 - y1;
if ((w < 0) || (h < 0)) {
log.error("Negative extent received. Border won't be painted.");
return;
}
switch (style) {
case Constants.EN_DASHED:
getG2D().setColor(color);
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);
getG2D().setStroke(s);
getG2D().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);
getG2D().setStroke(s);
getG2D().draw(new Line2D.Float(xm, y1, xm, y2));
}
break;
case Constants.EN_DOTTED:
getG2D().setColor(color);
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);
getG2D().setStroke(s);
getG2D().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);
getG2D().setStroke(s);
getG2D().draw(new Line2D.Float(xm, y1, xm, y2));
}
break;
case Constants.EN_DOUBLE:
getG2D().setColor(color);
if (horz) {
float h3 = h / 3;
float ym1 = y1 + (h3 / 2);
float ym2 = ym1 + h3 + h3;
BasicStroke s = new BasicStroke(h3);
getG2D().setStroke(s);
getG2D().draw(new Line2D.Float(x1, ym1, x2, ym1));
getG2D().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);
getG2D().setStroke(s);
getG2D().draw(new Line2D.Float(xm1, y1, xm1, y2));
getG2D().draw(new Line2D.Float(xm2, y1, xm2, y2));
}
break;
case Constants.EN_GROOVE:
case Constants.EN_RIDGE:
float colFactor = (style == Constants.EN_GROOVE ? 0.4f : -0.4f);
if (horz) {
Color uppercol = ColorUtil.lightenColor(color, -colFactor);
Color lowercol = ColorUtil.lightenColor(color, colFactor);
float h3 = h / 3;
float ym1 = y1 + (h3 / 2);
getG2D().setStroke(new BasicStroke(h3));
getG2D().setColor(uppercol);
getG2D().draw(new Line2D.Float(x1, ym1, x2, ym1));
getG2D().setColor(color);
getG2D().draw(new Line2D.Float(x1, ym1 + h3, x2, ym1 + h3));
getG2D().setColor(lowercol);
getG2D().draw(new Line2D.Float(x1, ym1 + h3 + h3, x2, ym1 + h3 + h3));
} else {
Color leftcol = ColorUtil.lightenColor(color, -colFactor);
Color rightcol = ColorUtil.lightenColor(color, colFactor);
float w3 = w / 3;
float xm1 = x1 + (w3 / 2);
getG2D().setStroke(new BasicStroke(w3));
getG2D().setColor(leftcol);
getG2D().draw(new Line2D.Float(xm1, y1, xm1, y2));
getG2D().setColor(color);
getG2D().draw(new Line2D.Float(xm1 + w3, y1, xm1 + w3, y2));
getG2D().setColor(rightcol);
getG2D().draw(new Line2D.Float(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);
if (horz) {
color = ColorUtil.lightenColor(color, (startOrBefore ? 1 : -1) * colFactor);
getG2D().setStroke(new BasicStroke(h));
float ym1 = y1 + (h / 2);
getG2D().setColor(color);
getG2D().draw(new Line2D.Float(x1, ym1, x2, ym1));
} else {
color = ColorUtil.lightenColor(color, (startOrBefore ? 1 : -1) * colFactor);
float xm1 = x1 + (w / 2);
getG2D().setStroke(new BasicStroke(w));
getG2D().setColor(color);
getG2D().draw(new Line2D.Float(xm1, y1, xm1, y2));
}
break;
case Constants.EN_HIDDEN:
break;
default:
getG2D().setColor(color);
if (horz) {
float ym = y1 + (h / 2);
getG2D().setStroke(new BasicStroke(h));
getG2D().draw(new Line2D.Float(x1, ym, x2, ym));
} else {
float xm = x1 + (w / 2);
getG2D().setStroke(new BasicStroke(w));
getG2D().draw(new Line2D.Float(xm, y1, xm, y2));
}
}
}