Example usage for com.itextpdf.text.pdf PdfPCell setUseVariableBorders

List of usage examples for com.itextpdf.text.pdf PdfPCell setUseVariableBorders

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPCell setUseVariableBorders.

Prototype

public void setUseVariableBorders(final boolean useVariableBorders) 

Source Link

Document

Sets a parameter indicating if the rectangle has variable borders

Usage

From source file:net.digitstar.vanadio.helpers.PdfHelper.java

License:Apache License

public static PdfPCell newCell(CellStyle style) {
    PdfPCell cell = new PdfPCell();
    if (style != null) {
        if (style.getNestedTable() != null) {
            cell = new PdfPCell(style.getNestedTable());
            style.setNestedTable(null);//from w w  w  .  j a v a 2  s  . c om
        } else if (style.getImage() != null) {
            cell = new PdfPCell(style.getImage(), style.isFitImage());
            style.setImage(null);
        } else if (style.getText() != null) {
            cell = new PdfPCell(style.getText());
            style.setText((String) null);
        }

        cell.setColspan(style.getColspan());
        cell.setRowspan(style.getRowspan());

        cell.setMinimumHeight(style.getMinimumHeight());
        cell.setFixedHeight(style.getFixedHeight());

        cell.setNoWrap(style.isNoWrap());

        cell.setRotation(style.getRotation().getValue());

        style = Alignment.assign(style);

        cell.setHorizontalAlignment(style.getHorizAlign().getValue());
        cell.setVerticalAlignment(style.getVertAlign().getValue());

        cell.setUseVariableBorders(style.isUseVariableBorders());
        cell.setUseBorderPadding(style.isUseBorderPadding());

        if (!style.getBorderWidth().isAllSideEqual()) {
            cell.setBorderWidthBottom(style.getBorderWidth().getBottom());
            cell.setBorderWidthLeft(style.getBorderWidth().getLeft());
            cell.setBorderWidthRight(style.getBorderWidth().getRight());
            cell.setBorderWidthTop(style.getBorderWidth().getTop());
        } else {
            cell.setBorderWidth(style.getBorderWidth().getValue());
        }

        cell.setPaddingBottom(style.getPadding().getBottom());
        cell.setPaddingLeft(style.getPadding().getLeft());
        cell.setPaddingRight(style.getPadding().getRight());
        cell.setPaddingTop(style.getPadding().getTop());

        cell.setBorderColorBottom(style.getBorderColor().getBottom());
        cell.setBorderColorLeft(style.getBorderColor().getLeft());
        cell.setBorderColorRight(style.getBorderColor().getRight());
        cell.setBorderColorTop(style.getBorderColor().getTop());

        cell.setBorder(style.getBorder().getValue());

        cell.setBackgroundColor(style.getBackgroundColor());
        if (style.getGreyFill() >= 0) {
            cell.setGrayFill(style.getGreyFill());
        }
    }
    return cell;
}

From source file:printers.AbstractHorariosPrinter.java

License:Open Source License

private PdfPCell createCeldaHorarioItem(HorarioItem h, int fila, int columna, int numColumnas, int numFilas) {
    Paragraph p;/*ww w  .  j  av  a 2s  .c o  m*/
    PdfPCell c;
    if (!h.isHuecoLibre()) {

        p = getParagraphForAsignatura(h);
        c = new PdfPCell(p);
        c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        c.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        //Color col = h.getAsignatura().getColorEnTablaDeHorarios();
        Color col = h.getTramo().getColorEnTablaDeHorarios();
        c.setBackgroundColor(new BaseColor(col.getRed(), col.getGreen(), col.getBlue()));
        c.setPadding(5);
        c.setBorderColor(BaseColor.BLACK);
        c.setBorderWidth(1);
        c.setUseBorderPadding(false);
        c.setUseVariableBorders(true);

    } else {
        p = new Paragraph("");//"C"+h.getNumcasilla()+" D"+h.getDiaSemana()+" "+h.getRangoHoras().getInicio());
        c = new PdfPCell(p);
        c.setUseVariableBorders(true);
        c.setBorderColor(BaseColor.LIGHT_GRAY);
        c.setBorderWidth(.3F);
        //            c.setBorder(Rectangle.NO_BORDER);
        if (columna == numColumnas - 1) {
            c.setBorderColorRight(BaseColor.BLACK);
        }
        //            if (fila == numFilas - 1) {
        //                c.setBorder(Rectangle.BOTTOM);
        //            }
        //            if ((columna == numColumnas - 1) && (fila == numFilas - 1)) {
        //                c.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT);
        //            }
    }

    if (h.getNumeroDeCasillasQueOcupa() > 1) {
        c.setRowspan(h.getNumeroDeCasillasQueOcupa());

    }

    return c;
}