Example usage for com.itextpdf.text Element ALIGN_LEFT

List of usage examples for com.itextpdf.text Element ALIGN_LEFT

Introduction

In this page you can find the example usage for com.itextpdf.text Element ALIGN_LEFT.

Prototype

int ALIGN_LEFT

To view the source code for com.itextpdf.text Element ALIGN_LEFT.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

From source file:com.softwaremagico.tm.pdf.complete.fighting.ExperienceTable.java

License:Open Source License

protected ExperienceTable(CharacterPlayer characterPlayer) {
    super(WIDTHS);

    addCell(createLateralVerticalTitle(getTranslator().getTranslatedText("experience"), 1));
    if (characterPlayer != null) {
        PdfPCell cell = createElementLine("" + characterPlayer.getRemainginExperience() + "-", 50,
                FadingSunsTheme.EXPERIENCE_VALUE_FONT_SIZE);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setVerticalAlignment(Element.ALIGN_TOP);
        addCell(cell);/*from  w  w w.j a va 2 s .com*/
    } else {
        addCell(createEmptyElementLine(""));
    }

}

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  w w.  java 2 s . c om*/

    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.info.DescriptionTable.java

License:Open Source License

private PdfPCell createLine(CharacterPlayer characterPlayer, String tag) {
    Paragraph paragraph = new Paragraph();

    String text = getTranslatedTag(tag);
    // Spaces at the end are eliminated. For calculating width we can put
    // the characters in different order.
    float textWidth = FadingSunsTheme.getLineFont().getWidthPoint(text + " :",
            FadingSunsTheme.TABLE_LINE_FONT_SIZE);

    paragraph.add(new Paragraph(text + ": ",
            new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.TABLE_LINE_FONT_SIZE)));
    if (characterPlayer == null || characterPlayer.getInfo().getTranslatedParameter(tag) == null) {
        paragraph.add(new Paragraph(
                CellUtils.getSubStringFitsIn(GAP, FadingSunsTheme.getLineFont(),
                        FadingSunsTheme.TABLE_LINE_FONT_SIZE, COLUMN_WIDTH - textWidth),
                new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.TABLE_LINE_FONT_SIZE)));
    } else {// w w w  .j  av a 2s.  c om
        paragraph.add(new Paragraph(
                CellUtils.getSubStringFitsIn(characterPlayer.getInfo().getTranslatedParameter(tag),
                        FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.INFO_CONTENT_FONT_SIZE,
                        COLUMN_WIDTH - textWidth),
                new Font(FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.INFO_CONTENT_FONT_SIZE)));
    }

    PdfPCell cell = createEmptyElementLine("");
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setPhrase(paragraph);

    return cell;
}

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

License:Open Source License

public PropertiesTable(CharacterPlayer characterPlayer) {
    super(WIDTHS);

    addCell(createTitle(getTranslator().getTranslatedText("properties"),
            FadingSunsTheme.VERTICALTABLE_TITLE_FONT_SIZE));
    addCell(getCell(getMoney(characterPlayer), 0, 1, Element.ALIGN_LEFT));
    for (int i = 0; i < ROWS; i++) {
        addCell(createEmptyElementLine("______________________________________________"));
    }/*from w w w .  j a  v a2 s .co  m*/
}

From source file:com.softwaremagico.tm.pdf.complete.others.AnnotationsTable.java

License:Open Source License

protected static PdfPCell createSubtitleLine(String text) {
    PdfPCell cell = BaseElement.getCell(text, 1, 1, Element.ALIGN_LEFT, BaseColor.WHITE,
            FadingSunsTheme.getTitleFont(), FadingSunsTheme.ANNOTATIONS_SUBTITLE_FONT_SIZE);
    cell.setMinimumHeight(CELL_HEIGHT);/*from ww w.  java  2s.  c o m*/
    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);/*  ww  w  .j a v  a 2s.co  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.complete.skills.SkillsTable.java

License:Open Source License

protected static PdfPCell createSkillElement(CharacterPlayer characterPlayer, AvailableSkill skill,
        int fontSize, int maxColumnWidth) {
    PdfPCell cell = getCell(createSkillSufix(characterPlayer, skill, fontSize, maxColumnWidth), 0, 1,
            Element.ALIGN_LEFT, BaseColor.WHITE);
    cell.setMinimumHeight((MainSkillsTableFactory.HEIGHT / ROWS));
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    return cell;//from   w w w.j  a  v a 2 s.  c  o m
}

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

License:Open Source License

protected static PdfPCell createSkillElement(SkillDefinition skill, int fontSize, int maxColumnWidth) {
    PdfPCell cell = getCell(createSkillSufix(skill, fontSize, maxColumnWidth), 0, 1, Element.ALIGN_LEFT,
            BaseColor.WHITE);/*from   ww w.  j a  va 2s  .c  om*/
    cell.setMinimumHeight((MainSkillsTableFactory.HEIGHT / ROWS));
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    return cell;
}

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

License:Open Source License

protected static PdfPCell createSkillLine(String text, int fontSize) {
    PdfPCell cell = getCell(text, 0, 1, Element.ALIGN_LEFT, BaseColor.WHITE, FadingSunsTheme.getLineFont(),
            fontSize);//from   w w w . j  a  v a  2s .co m
    cell.setMinimumHeight((MainSkillsTableFactory.HEIGHT / ROWS));
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    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 {/*from   w  w  w.j  av a 2  s  . c  o  m*/
            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;
}