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

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

Introduction

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

Prototype

public void addElement(Element element) 

Source Link

Document

Adds an iText element to the cell.

Usage

From source file:com.softwaremagico.tm.pdf.complete.elements.BaseElement.java

License:Open Source License

public static PdfPCell createBigSeparator(int width) {
    float[] widths = { 1f };
    PdfPTable table = new PdfPTable(widths);
    table.setWidthPercentage(width);// w w w  . j a  v a  2  s . c  o  m
    table.addCell(createWhiteSeparator());
    table.addCell(createBlackSeparator());
    table.addCell(createWhiteSeparator());

    PdfPCell cell = new PdfPCell();
    cell.addElement(table);
    setCellProperties(cell);

    return cell;
}

From source file:com.softwaremagico.tm.pdf.complete.info.CharacterBasicsCompleteTableFactory.java

License:Open Source License

private static PdfPCell getFirstColumnTable(CharacterPlayer characterPlayer) {
    float[] widths = { 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);/*from   ww  w  .j  a v  a  2 s  .com*/

    table.addCell(createField(characterPlayer, "name", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));
    table.addCell(createField(characterPlayer, "player", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));
    table.addCell(createField(characterPlayer, "gender", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));
    table.addCell(createField(characterPlayer, "age", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));

    PdfPCell cell = new PdfPCell();
    setCellProperties(cell);

    cell.addElement(table);

    return cell;
}

From source file:com.softwaremagico.tm.pdf.complete.info.CharacterBasicsCompleteTableFactory.java

License:Open Source License

private static PdfPCell getSecondColumnTable(CharacterPlayer characterPlayer) {
    float[] widths = { 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);//from www  .ja va  2 s  . com

    table.addCell(createField(characterPlayer, "race", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));
    table.addCell(createField(characterPlayer, "planet", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));
    table.addCell(createField(characterPlayer, "faction", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));
    table.addCell(createField(characterPlayer, "rank", FadingSunsTheme.CHARACTER_BASICS_FONT_SIZE));

    PdfPCell cell = new PdfPCell();
    setCellProperties(cell);

    cell.addElement(table);

    return cell;
}

From source file:com.softwaremagico.tm.pdf.complete.info.CharacterBasicsTableFactory.java

License:Open Source License

protected static PdfPCell createField(CharacterPlayer characterPlayer, String tag, int fontSize) {
    float[] widths = { 0.7f, 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);//from w  ww.  ja  v  a  2s.  com

    table.addCell(getCell(getTranslatedTag(tag), Element.ALIGN_RIGHT, fontSize));
    if (characterPlayer == null) {
        table.addCell(getCell(LINE, Element.ALIGN_LEFT, fontSize));
    } else {
        if (tag.equals("name")) {
            table.addCell(getHandwrittingCell(characterPlayer.getNameRepresentation(), Element.ALIGN_LEFT,
                    fontSize - 1));
        } else if (tag.equals("race")) {
            if (characterPlayer.getRace() != null) {
                table.addCell(getHandwrittingCell(characterPlayer.getRace().getName(), Element.ALIGN_LEFT,
                        fontSize - 1));
            } else {
                table.addCell(getHandwrittingCell("", Element.ALIGN_LEFT, fontSize - 1));
            }
        } else if (tag.equals("faction")) {
            if (characterPlayer.getFaction() != null) {
                table.addCell(getHandwrittingCell(characterPlayer.getFaction().getName(), Element.ALIGN_LEFT,
                        fontSize - 1));
            } else {
                table.addCell(getHandwrittingCell("", Element.ALIGN_LEFT, fontSize - 1));
            }
        } else if (tag.equals("rank")) {
            try {
                if (characterPlayer.getRank() != null) {
                    table.addCell(
                            getHandwrittingCell(characterPlayer.getRank(), Element.ALIGN_LEFT, fontSize - 1));
                } else {
                    table.addCell(getHandwrittingCell("", Element.ALIGN_LEFT, fontSize - 1));
                }
            } catch (InvalidXmlElementException e) {
                PdfExporterLog.errorMessage(CharacterBasicsTableFactory.class.getName(), e);
            }
        } else if (tag.equals("planet")) {
            if (characterPlayer.getInfo().getPlanet() != null) {
                table.addCell(getHandwrittingCell(characterPlayer.getInfo().getPlanet().getName(),
                        Element.ALIGN_LEFT, fontSize - 1));
            } else {
                table.addCell(getHandwrittingCell("", Element.ALIGN_LEFT, fontSize - 1));
            }
        } else if (tag.equals("gender")) {
            table.addCell(getHandwrittingCell(characterPlayer.getInfo().getTranslatedParameter(tag),
                    Element.ALIGN_LEFT, fontSize - 1));
        } else {
            table.addCell(getHandwrittingCell(characterPlayer.getInfo().getTranslatedParameter(tag),
                    Element.ALIGN_LEFT, fontSize - 1));
        }
    }

    PdfPCell cell = new PdfPCell();
    cell.addElement(table);
    setCellProperties(cell);
    cell.setMinimumHeight(20);

    return cell;
}

From source file:com.softwaremagico.tm.pdf.complete.skills.CompleteSkillsTable.java

License:Open Source License

private static PdfPCell getFirstColumnTable(CharacterPlayer characterPlayer, String language,
        Stack<PdfPCell> learnedSkillsRows) throws InvalidXmlElementException {
    float[] widths = { 4f, 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);//from  w  ww. java 2  s  .co  m

    table.addCell(createTitle(getTranslator().getTranslatedText("naturalSkills"),
            FadingSunsTheme.SKILLS_TITLE_FONT_SIZE));

    if (characterPlayer == null) {
        for (AvailableSkill skill : AvailableSkillsFactory.getInstance().getNaturalSkills(language)) {
            table.addCell(createSkillElement(characterPlayer, skill, FadingSunsTheme.SKILLS_LINE_FONT_SIZE,
                    MAX_SKILL_COLUMN_WIDTH));
            table.addCell(createSkillLine(SKILL_VALUE_GAP, FadingSunsTheme.SKILLS_LINE_FONT_SIZE));
        }
    } else {
        for (AvailableSkill skill : characterPlayer.getNaturalSkills()) {
            table.addCell(createSkillElement(characterPlayer, skill, FadingSunsTheme.SKILLS_LINE_FONT_SIZE,
                    MAX_SKILL_COLUMN_WIDTH));
            table.addCell(createSkillValue(characterPlayer.getSkillTotalRanks(skill),
                    characterPlayer.isSkillSpecial(skill) || characterPlayer.hasSkillTemporalModificator(skill),
                    characterPlayer.hasSkillModificator(skill), FadingSunsTheme.SKILLS_LINE_FONT_SIZE));
        }
    }

    table.addCell(createTitle(getTranslator().getTranslatedText("learnedSkills"),
            FadingSunsTheme.SKILLS_TITLE_FONT_SIZE));
    int totalRows = Math.min(getTotalLearnedSkillsToShow(language), ROWS - (2 * TITLE_ROWSPAN)
            - SkillsDefinitionsFactory.getInstance().getNaturalSkills(language).size());

    for (int i = 0; i < totalRows; i++) {
        // Two columns: skill and value.
        table.addCell(learnedSkillsRows.pop());
        table.addCell(learnedSkillsRows.pop());
    }

    PdfPCell cell = new PdfPCell();
    setCellProperties(cell);

    cell.addElement(table);
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    return cell;
}

From source file:com.softwaremagico.tm.pdf.complete.skills.CompleteSkillsTable.java

License:Open Source License

private static PdfPCell getSecondColumnTable(CharacterPlayer characterPlayer, String language,
        Stack<PdfPCell> learnedSkillsRows) throws InvalidXmlElementException {
    float[] widths = { 4f, 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);//from  w  w w.  j  av a  2 s  . c  om
    PdfPCell cell = new PdfPCell();
    setCellProperties(cell);

    for (int i = 0; i < ROWS; i++) {
        // Two columns: skill and value.
        table.addCell(learnedSkillsRows.pop());
        table.addCell(learnedSkillsRows.pop());
    }

    cell.addElement(table);
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    return cell;
}

From source file:com.softwaremagico.tm.pdf.complete.skills.CompleteSkillsTable.java

License:Open Source License

private static PdfPCell getThirdColumnTable(CharacterPlayer characterPlayer, String language,
        Stack<PdfPCell> learnedSkillsRows) throws InvalidXmlElementException {
    float[] widths = { 4f, 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);/*from  w  ww  .j  av  a  2 s . c o  m*/
    PdfPCell cell = new PdfPCell();
    setCellProperties(cell);

    for (int i = 0; i < ROWS - OCCULTISM_ROWS; i++) {
        // Two columns: skill and value.
        table.addCell(learnedSkillsRows.pop());
        table.addCell(learnedSkillsRows.pop());
    }

    // Add Occultism table
    PdfPTable occultismTable = new OccultismTable(characterPlayer, language);
    PdfPCell occulstimCell = new PdfPCell();
    // setCellProperties(occulstimCell);
    // occulstimCell.setRowspan(widths.length);
    occulstimCell.setRowspan(OCCULTISM_ROWS);
    occulstimCell.setColspan(2);
    occulstimCell.addElement(occultismTable);
    occulstimCell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    occulstimCell.setPadding(0);
    table.addCell(occulstimCell);

    cell.addElement(table);
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    return cell;
}

From source file:com.softwaremagico.tm.pdf.complete.skills.occultism.OccultismTable.java

License:Open Source License

private PdfPCell createContent(CharacterPlayer characterPlayer, String language)
        throws InvalidXmlElementException {
    float[] widths = { 3f, 1f, 1f, 3f };
    PdfPTable table = new PdfPTable(widths);
    BaseElement.setTablePropierties(table);
    table.getDefaultCell().setBorder(0);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);

    for (OccultismType occulstimType : OccultismTypeFactory.getInstance().getElements(language)) {
        PdfPCell psiqueTitleCell = new PdfPCell(new Phrase(occulstimType.getName(),
                new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.CHARACTERISTICS_LINE_FONT_SIZE)));
        psiqueTitleCell.setBorder(0);/*from www.jav  a  2s. c  o  m*/
        // psiTitleCell.setMinimumHeight(30);
        psiqueTitleCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(psiqueTitleCell);

        if (characterPlayer == null) {
            table.addCell(createRectangle());
            table.addCell(createRectangle());
        } else {
            table.addCell(createRectangle(characterPlayer.getPsiqueLevel(occulstimType)));
            table.addCell(createRectangle(characterPlayer.getDarkSideLevel(occulstimType)));
        }

        PdfPCell darkSideTitleCell = new PdfPCell(new Phrase(occulstimType.getDarkSideName(),
                new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.CHARACTERISTICS_LINE_FONT_SIZE)));
        darkSideTitleCell.setBorder(0);
        darkSideTitleCell.setHorizontalAlignment(Element.ALIGN_LEFT);
        table.addCell(darkSideTitleCell);

    }

    PdfPCell cell = new PdfPCell();
    cell.addElement(table);
    cell.setPadding(0);
    BaseElement.setCellProperties(cell);

    return cell;
}

From source file:com.softwaremagico.tm.pdf.small.characteristics.CharacteristicsColumn.java

License:Open Source License

private PdfPCell createContent(CharacterPlayer characterPlayer, List<CharacteristicDefinition> content) {
    float[] widths = { 4f, 1f };
    PdfPTable table = new PdfPTable(widths);
    BaseElement.setTablePropierties(table);
    table.getDefaultCell().setBorder(0);

    for (CharacteristicDefinition characteristic : content) {
        Paragraph paragraph = new Paragraph();
        paragraph.add(new Paragraph(getTranslator().getTranslatedText(characteristic.getId()),
                new Font(FadingSunsTheme.getLineFont(),
                        FadingSunsTheme.CHARACTER_SMALL_CHARACTERISTICS_LINE_FONT_SIZE)));
        paragraph.add(new Paragraph(" (", new Font(FadingSunsTheme.getLineFont(),
                FadingSunsTheme.CHARACTER_SMALL_CHARACTERISTICS_LINE_FONT_SIZE)));
        if (characterPlayer == null) {
            paragraph.add(new Paragraph(GAP, new Font(FadingSunsTheme.getLineFont(),
                    FadingSunsTheme.CHARACTER_SMALL_CHARACTERISTICS_LINE_FONT_SIZE)));
        } else {/* w  w  w. j a va 2s .  c  om*/
            paragraph.add(
                    new Paragraph(characterPlayer.getStartingValue(characteristic.getCharacteristicName()) + "",
                            new Font(FadingSunsTheme.getHandwrittingFont(),
                                    FadingSunsTheme.getHandWrittingFontSize(
                                            FadingSunsTheme.CHARACTER_SMALL_CHARACTERISTICS_LINE_FONT_SIZE))));
        }
        paragraph.add(new Paragraph(")", new Font(FadingSunsTheme.getLineFont(),
                FadingSunsTheme.CHARACTER_SMALL_CHARACTERISTICS_LINE_FONT_SIZE)));

        PdfPCell characteristicTitle = new PdfPCell(paragraph);
        characteristicTitle.setBorder(0);
        characteristicTitle.setMinimumHeight(ROW_HEIGHT / content.size());
        table.addCell(characteristicTitle);

        // Rectangle
        if (characterPlayer == null) {
            table.addCell(createCharacteristicLine(SKILL_VALUE_GAP));
        } else {
            table.addCell(getHandwrittingCell(getCharacteristicValueRepresentation(characterPlayer,
                    characteristic.getCharacteristicName()), Element.ALIGN_LEFT));
        }
    }

    PdfPCell cell = new PdfPCell();
    cell.addElement(table);
    BaseElement.setCellProperties(cell);

    return cell;
}

From source file:com.softwaremagico.tm.pdf.small.info.CharacterBasicsReducedTableFactory.java

License:Open Source License

private static PdfPCell getFirstColumnTable(CharacterPlayer characterPlayer) {
    float[] widths = { 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);//from  w ww  .j ava  2 s. c  o m

    table.addCell(createField(characterPlayer, "name", FadingSunsTheme.CHARACTER_SMALL_BASICS_FONT_SIZE));
    table.addCell(createField(characterPlayer, "gender", FadingSunsTheme.CHARACTER_SMALL_BASICS_FONT_SIZE));
    table.addCell(createField(characterPlayer, "age", FadingSunsTheme.CHARACTER_SMALL_BASICS_FONT_SIZE));

    PdfPCell cell = new PdfPCell();
    setCellProperties(cell);

    cell.addElement(table);

    return cell;
}