Example usage for com.lowagie.text.pdf PdfContentByte setMiterLimit

List of usage examples for com.lowagie.text.pdf PdfContentByte setMiterLimit

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfContentByte setMiterLimit.

Prototype


public void setMiterLimit(float miterLimit) 

Source Link

Document

Changes the Miter limit.

Usage

From source file:org.xhtmlrenderer.pdf.ITextOutputDevice.java

License:Open Source License

private void setStrokeDiff(Stroke newStroke, Stroke oldStroke) {
    PdfContentByte cb = _currentPage;
    if (newStroke == oldStroke)
        return;/*from  w  w w .j a  v a 2s .  c  o  m*/
    if (!(newStroke instanceof BasicStroke))
        return;
    BasicStroke nStroke = (BasicStroke) newStroke;
    boolean oldOk = (oldStroke instanceof BasicStroke);
    BasicStroke oStroke = null;
    if (oldOk)
        oStroke = (BasicStroke) oldStroke;
    if (!oldOk || nStroke.getLineWidth() != oStroke.getLineWidth())
        cb.setLineWidth(nStroke.getLineWidth());
    if (!oldOk || nStroke.getEndCap() != oStroke.getEndCap()) {
        switch (nStroke.getEndCap()) {
        case BasicStroke.CAP_BUTT:
            cb.setLineCap(0);
            break;
        case BasicStroke.CAP_SQUARE:
            cb.setLineCap(2);
            break;
        default:
            cb.setLineCap(1);
        }
    }
    if (!oldOk || nStroke.getLineJoin() != oStroke.getLineJoin()) {
        switch (nStroke.getLineJoin()) {
        case BasicStroke.JOIN_MITER:
            cb.setLineJoin(0);
            break;
        case BasicStroke.JOIN_BEVEL:
            cb.setLineJoin(2);
            break;
        default:
            cb.setLineJoin(1);
        }
    }
    if (!oldOk || nStroke.getMiterLimit() != oStroke.getMiterLimit())
        cb.setMiterLimit(nStroke.getMiterLimit());
    boolean makeDash;
    if (oldOk) {
        if (nStroke.getDashArray() != null) {
            if (nStroke.getDashPhase() != oStroke.getDashPhase()) {
                makeDash = true;
            } else if (!java.util.Arrays.equals(nStroke.getDashArray(), oStroke.getDashArray())) {
                makeDash = true;
            } else
                makeDash = false;
        } else if (oStroke.getDashArray() != null) {
            makeDash = true;
        } else
            makeDash = false;
    } else {
        makeDash = true;
    }
    if (makeDash) {
        float dash[] = nStroke.getDashArray();
        if (dash == null)
            cb.setLiteral("[]0 d\n");
        else {
            cb.setLiteral('[');
            int lim = dash.length;
            for (int k = 0; k < lim; ++k) {
                cb.setLiteral(dash[k]);
                cb.setLiteral(' ');
            }
            cb.setLiteral(']');
            cb.setLiteral(nStroke.getDashPhase());
            cb.setLiteral(" d\n");
        }
    }
}