public static void drawBorderLine()

in fop-core/src/main/java/org/apache/fop/render/ps/PSGraphicsPainter.java [78:222]


    public static void drawBorderLine(PSGenerator gen,
            float x1, float y1, float x2, float y2, boolean horz,
            boolean startOrBefore, int style, Color col) 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:
            gen.useColor(col);
            if (horz) {
                float dashWidth = BorderPainter.dashWidthCalculator(w, h);
                if (dashWidth != 0) {
                    gen.useDash("[" + dashWidth + " " + BorderPainter.DASHED_BORDER_SPACE_RATIO
                            * dashWidth + "] 0");
                }
                gen.useLineCap(0);
                gen.useLineWidth(h);
                float ym = y1 + (h / 2);
                drawLine(gen, x1, ym, x2, ym);
            } else {
                float dashWidth = BorderPainter.dashWidthCalculator(h, w);
                if (dashWidth != 0) {
                    gen.useDash("[" + dashWidth + " " + BorderPainter.DASHED_BORDER_SPACE_RATIO
                            * dashWidth + "] 0");
                }
                gen.useLineCap(0);
                gen.useLineWidth(w);
                float xm = x1 + (w / 2);
                drawLine(gen, xm, y1, xm, y2);
            }
            break;
        case Constants.EN_DOTTED:
            gen.useColor(col);
            gen.useLineCap(1); //Rounded!
            if (horz) {
                float unit = Math.abs(2 * h);
                int rep = (int) (w / unit);
                if (rep % 2 == 0) {
                    rep++;
                }
                unit = w / rep;
                gen.useDash("[0 " + unit + "] 0");
                gen.useLineWidth(h);
                float ym = y1 + (h / 2);
                drawLine(gen, x1, ym, x2, ym);
            } else {
                float unit = Math.abs(2 * w);
                int rep = (int) (h / unit);
                if (rep % 2 == 0) {
                    rep++;
                }
                unit = h / rep;
                gen.useDash("[0 " + unit + "] 0");
                gen.useLineWidth(w);
                float xm = x1 + (w / 2);
                drawLine(gen, xm, y1, xm, y2);
            }
            break;
        case Constants.EN_DOUBLE:
            gen.useColor(col);
            gen.useDash(null);
            if (horz) {
                float h3 = h / 3;
                gen.useLineWidth(h3);
                float ym1 = y1 + (h3 / 2);
                float ym2 = ym1 + h3 + h3;
                drawLine(gen, x1, ym1, x2, ym1);
                drawLine(gen, x1, ym2, x2, ym2);
            } else {
                float w3 = w / 3;
                gen.useLineWidth(w3);
                float xm1 = x1 + (w3 / 2);
                float xm2 = xm1 + w3 + w3;
                drawLine(gen, xm1, y1, xm1, y2);
                drawLine(gen, xm2, y1, xm2, y2);
            }
            break;
        case Constants.EN_GROOVE:
        case Constants.EN_RIDGE:
            float colFactor = (style == Constants.EN_GROOVE ? 0.4f : -0.4f);
            gen.useDash(null);
            if (horz) {
                Color uppercol = ColorUtil.lightenColor(col, -colFactor);
                Color lowercol = ColorUtil.lightenColor(col, colFactor);
                float h3 = h / 3;
                gen.useLineWidth(h3);
                float ym1 = y1 + (h3 / 2);
                gen.useColor(uppercol);
                drawLine(gen, x1, ym1, x2, ym1);
                gen.useColor(col);
                drawLine(gen, x1, ym1 + h3, x2, ym1 + h3);
                gen.useColor(lowercol);
                drawLine(gen, 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;
                gen.useLineWidth(w3);
                float xm1 = x1 + (w3 / 2);
                gen.useColor(leftcol);
                drawLine(gen, xm1, y1, xm1, y2);
                gen.useColor(col);
                drawLine(gen, xm1 + w3, y1, xm1 + w3, y2);
                gen.useColor(rightcol);
                drawLine(gen, 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);
            gen.useDash(null);
            if (horz) {
                Color c = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
                gen.useLineWidth(h);
                float ym1 = y1 + (h / 2);
                gen.useColor(c);
                drawLine(gen, x1, ym1, x2, ym1);
            } else {
                Color c = ColorUtil.lightenColor(col, (startOrBefore ? 1 : -1) * colFactor);
                gen.useLineWidth(w);
                float xm1 = x1 + (w / 2);
                gen.useColor(c);
                drawLine(gen, xm1, y1, xm1, y2);
            }
            break;
        case Constants.EN_HIDDEN:
            break;
        default:
            gen.useColor(col);
            gen.useDash(null);
            gen.useLineCap(0);
            if (horz) {
                gen.useLineWidth(h);
                float ym = y1 + (h / 2);
                drawLine(gen, x1, ym, x2, ym);
            } else {
                gen.useLineWidth(w);
                float xm = x1 + (w / 2);
                drawLine(gen, xm, y1, xm, y2);
            }
        }
    }