Example usage for com.itextpdf.text.pdf PdfTemplate fillStroke

List of usage examples for com.itextpdf.text.pdf PdfTemplate fillStroke

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfTemplate fillStroke.

Prototype


public void fillStroke() 

Source Link

Document

Fills the path using the non-zero winding number rule to determine the region to fill and strokes it.

Usage

From source file:se.billes.pdf.renderer.request.factory.CellBlockEvent.java

License:Open Source License

public PdfPCellEvent createEvent(final Block block) {
    return new PdfPCellEvent() {
        public void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvas) {

            float radiusInPs = SizeFactory.millimetersToPostscriptPoints(block.getRadius());
            PdfContentByte cb = canvas[PdfPTable.LINECANVAS];
            PdfTemplate template = cb.createTemplate(rect.getWidth(), rect.getHeight());
            template.roundRectangle(0, 0, rect.getWidth(), rect.getHeight(), radiusInPs);
            template.clip();/*from ww  w.  j  a  v  a2  s  .c  o  m*/
            template.newPath();

            if (block.getBaseColor() != null) {
                template.setColorFill(block.getBaseColor());
            }

            Border border = block.getBorder();

            if (border != null) {
                template.setLineWidth(SizeFactory.millimetersToPostscriptPoints(border.getThickness()));
                template.setColorStroke(border.getBaseColor());
            }

            template.roundRectangle(0, 0, rect.getWidth(), rect.getHeight(), radiusInPs);

            if (block.getBaseColor() != null || border != null) {
                if (block.getBaseColor() != null && border != null) {
                    template.fillStroke();
                } else if (block.getBaseColor() != null) {
                    template.fill();
                } else {

                    template.stroke();
                }
            }
            cb.addTemplate(template, rect.getLeft(), rect.getBottom());
        }
    };
}