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

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

Introduction

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

Prototype

public void setHorizontalAlignment(int horizontalAlignment) 

Source Link

Document

Sets the horizontal alignment for the cell.

Usage

From source file:com.softwaremagico.tm.pdf.small.traits.BlessingTable.java

License:Open Source License

public BlessingTable(CharacterPlayer characterPlayer) {
    super(WIDTHS);
    getDefaultCell().setBorder(0);/*from   w  w w.j  a  va  2s .  c o m*/

    addCell(createTitle(getTranslator().getTranslatedText("blessingTable"),
            FadingSunsTheme.CHARACTER_SMALL_BLESSING_TITLE_FONT_SIZE));

    addCell(createSubtitleLine("+/-", FadingSunsTheme.CHARACTER_SMALL_TRAITS_FONT_SIZE));
    addCell(createSubtitleLine(getTranslator().getTranslatedText("blessingTableTrait"),
            FadingSunsTheme.CHARACTER_SMALL_TRAITS_FONT_SIZE));
    addCell(createSubtitleLine(getTranslator().getTranslatedText("blessingTableSituation"),
            FadingSunsTheme.CHARACTER_SMALL_TRAITS_FONT_SIZE));

    int added = 0;
    if (characterPlayer != null) {
        for (Blessing blessing : characterPlayer.getAllBlessings()) {
            Iterator<Bonification> it = blessing.getBonifications().iterator();
            while (it.hasNext()) {
                Bonification bonification = it.next();
                addCell(createElementLine(bonification.getBonification(), BONIFICATION_COLUMN_WIDTH,
                        FadingSunsTheme.CHARACTER_SMALL_TRAITS_FONT_SIZE));
                PdfPCell nameCell = createElementLine(
                        bonification.getAffects() != null ? bonification.getAffects().getName() : "",
                        TRAIT_COLUMN_WIDTH, FadingSunsTheme.CHARACTER_SMALL_TRAITS_FONT_SIZE);
                nameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
                addCell(nameCell);
                PdfPCell descriptionCell = createElementLine(bonification.getSituation(),
                        SITUATION_COLUMN_WIDTH, FadingSunsTheme.CHARACTER_SMALL_TRAITS_FONT_SIZE);
                descriptionCell.setHorizontalAlignment(Element.ALIGN_LEFT);
                addCell(descriptionCell);
                added++;
            }
        }
    }

    if (characterPlayer == null) {
        for (int i = added; i < ROWS; i++) {
            addCell(createEmptyElementLine(GAP, BONIFICATION_COLUMN_WIDTH));
            addCell(createEmptyElementLine(GAP, TRAIT_COLUMN_WIDTH));
            addCell(createEmptyElementLine(GAP, SITUATION_COLUMN_WIDTH));
        }
    } else {
        for (int i = added; i < ROWS; i++) {
            for (int j = 0; j < WIDTHS.length; j++) {
                addCell(createEmptyElementLine(FadingSunsTheme.CHARACTER_SMALL_TABLE_LINE_FONT_SIZE));
            }
        }
    }
}

From source file:com.solidmaps.webapp.report.EnableCompanyRequerimentFederalPDF.java

private void insertCell(PdfPTable table, String text, Integer colSpan) {

     if (text == null) {
         text = "";
     }/*from w ww . j  a  v  a  2s .c  o  m*/

     // create a new cell with the specified Text and Font
     PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_PARAGRAPH));
     // set the cell alignment
     // in case there is no text and you wan to create an empty row
     if (text.trim().equalsIgnoreCase("")) {
         cell.setMinimumHeight(10f);
     }

     cell.setHorizontalAlignment(Element.ALIGN_LEFT);
     cell.setColspan(colSpan);
     cell.setPadding(5f);

     // add the call to the table
     table.addCell(cell);
 }

From source file:com.solidmaps.webapp.report.EnableCompanyRequerimentFederalPDF.java

private void insertCellAlteracao(PdfPTable table, String text) {

     if (text == null) {
         text = "";
     }/*from  ww w .  j av a  2  s  .  co m*/

     // create a new cell with the specified Text and Font
     PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_HEADER));
     // set the cell alignment
     // in case there is no text and you wan to create an empty row
     if (text.trim().equalsIgnoreCase("")) {
         cell.setMinimumHeight(10f);
     }

     cell.setHorizontalAlignment(Element.ALIGN_CENTER);
     cell.setColspan(2);
     cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
     cell.setBorderWidth(2);
     cell.setPadding(3f);

     // add the call to the table
     table.addCell(cell);
 }

From source file:com.solidmaps.webapp.report.EnableCompanyRequerimentFederalPDF.java

private void insertCellAlteracaoOption(PdfPTable table, String number, String text, Boolean selected) {

     String fullText = "";
     if (selected) {
         fullText += number + " |X|" + " " + text;
     } else {/*from  www . ja va 2s.  c om*/
         fullText += number + " |  |" + " " + text;
     }

     if (StringUtils.isBlank(number) && StringUtils.isBlank(text)) {
         fullText = "";
     }

     // create a new cell with the specified Text and Font
     PdfPCell cell = new PdfPCell(new Phrase(fullText.trim(), FONT_PARAGRAPH));
     // set the cell alignment
     // in case there is no text and you wan to create an empty row
     if (fullText.trim().equalsIgnoreCase("")) {
         cell.setMinimumHeight(10f);
     }

     cell.setHorizontalAlignment(Element.ALIGN_LEFT);
     cell.setBorder(Rectangle.RIGHT);
     cell.setPaddingTop(10f);
     cell.setPaddingBottom(10f);
     cell.setPaddingLeft(10f);
     cell.setPaddingRight(10f);

     // add the call to the table
     table.addCell(cell);
 }

From source file:com.solidmaps.webapp.report.EnableCompanyRequerimentFederalPDF.java

private void insertHeaderCell(PdfPTable table, String text, Integer colSpan) {

     if (text == null) {
         text = "";
     }/*from   www  .ja v a  2s . co  m*/

     // create a new cell with the specified Text and Font
     PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_HEADER));
     // set the cell alignment
     // in case there is no text and you wan to create an empty row
     if (text.trim().equalsIgnoreCase("")) {
         cell.setMinimumHeight(10f);
     }

     cell.setVerticalAlignment(Element.ALIGN_CENTER);
     cell.setHorizontalAlignment(Element.ALIGN_CENTER);
     cell.setColspan(colSpan);
     cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
     cell.setBorderWidth(2);
     cell.setPadding(3f);

     // add the call to the table
     table.addCell(cell);
 }

From source file:com.solidmaps.webapp.report.LicenseCivilIncludeProductPDF.java

License:Open Source License

private void insertCell(PdfPTable table, String text, int align, Font font, boolean border) {

    if (text == null) {
        text = "";
    }//w  w w .  j ava  2s .  c o m

    // create a new cell with the specified Text and Font
    PdfPCell cell = new PdfPCell(new Phrase(text.trim(), font));
    // set the cell alignment
    cell.setHorizontalAlignment(align);
    // in case there is no text and you wan to create an empty row
    if (text.trim().equalsIgnoreCase("")) {
        cell.setMinimumHeight(10f);
    }

    if (!border) {
        cell.setBorder(Rectangle.NO_BORDER);
    }

    // add the call to the table
    table.addCell(cell);
}

From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java

private void insertCell(PdfPTable table, String text, Integer colSpan) {

    if (text == null) {
        text = "";
    }/* w  ww.j  a va 2s .  co  m*/

    // create a new cell with the specified Text and Font
    PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_PARAGRAPH));
    // set the cell alignment
    // in case there is no text and you wan to create an empty row
    if (text.trim().equalsIgnoreCase("")) {
        cell.setMinimumHeight(10f);
    }

    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setColspan(colSpan);
    cell.setPadding(5f);

    // add the call to the table
    table.addCell(cell);
}

From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java

private void insertCellProtocol(PdfPTable table, LicensePFEntity license) {

    PdfPTable tableProtocol = new PdfPTable(1);
    tableProtocol.setWidthPercentage(100f);

    Paragraph officialPhrase = new Paragraph("USO OFICIAL" + SEPARATOR, FONT_PARAGRAPH);
    officialPhrase.setAlignment(Element.ALIGN_LEFT);

    Paragraph protocolPhrase = new Paragraph("ETIQUETA PROTOCOLO" + SEPARATOR_DOUBLE + SEPARATOR_DOUBLE
            + SEPARATOR_DOUBLE + SEPARATOR_DOUBLE + SEPARATOR_DOUBLE + SEPARATOR, FONT_PROTOCOL);
    protocolPhrase.setAlignment(Element.ALIGN_LEFT);

    Paragraph obsPhrase = new Paragraph("Observao Importante!" + SEPARATOR, FONT_HEADER);

    Paragraph obsStringPhrase = new Paragraph(
            "Protocolar este Anexo somente quando no conjugado com a alterao efetiva ou a renovao da licena.",
            FONT_PARAGRAPH);/*from w  ww.j a va 2s .c o  m*/

    Paragraph fullPhrase = new Paragraph();
    fullPhrase.add(officialPhrase);
    fullPhrase.add(protocolPhrase);
    fullPhrase.add(obsPhrase);
    fullPhrase.add(obsStringPhrase);

    PdfPCell cell = new PdfPCell(fullPhrase);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setPadding(5f);

    tableProtocol.addCell(cell);

    PdfPCell cellProtocol = new PdfPCell(tableProtocol);
    cellProtocol.setColspan(2);

    table.addCell(cellProtocol);
    table.addCell(this.createCellEtiqueta(license));
}

From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java

private void insertCellAlteracao(PdfPTable table, String text) {

    if (text == null) {
        text = "";
    }//from   w  ww  .  java2 s . c  o  m

    // create a new cell with the specified Text and Font
    PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_HEADER));
    // set the cell alignment
    // in case there is no text and you wan to create an empty row
    if (text.trim().equalsIgnoreCase("")) {
        cell.setMinimumHeight(10f);
    }

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setColspan(2);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);

    // add the call to the table
    table.addCell(cell);
}

From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java

private void insertCellAlteracaoOption(PdfPTable table, String number, String text, Boolean selected) {

    String fullText = "";
    if (selected) {
        fullText += number + " |X|" + " " + text;
    } else {// w  w w  .ja va 2  s  .c  o m
        fullText += number + " |  |" + " " + text;
    }

    if (StringUtils.isBlank(number) && StringUtils.isBlank(text)) {
        fullText = "";
    }

    // create a new cell with the specified Text and Font
    PdfPCell cell = new PdfPCell(new Phrase(fullText.trim(), FONT_PARAGRAPH));
    // set the cell alignment
    // in case there is no text and you wan to create an empty row
    if (fullText.trim().equalsIgnoreCase("")) {
        cell.setMinimumHeight(10f);
    }

    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setColspan(2);
    cell.setBorder(Rectangle.RIGHT);
    cell.setPaddingTop(10f);
    cell.setPaddingBottom(10f);
    cell.setPaddingLeft(25f);
    cell.setPaddingRight(25f);

    // add the call to the table
    table.addCell(cell);
}