Example usage for com.itextpdf.text Font Font

List of usage examples for com.itextpdf.text Font Font

Introduction

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

Prototype


public Font(final FontFamily family, final float size) 

Source Link

Document

Constructs a Font.

Usage

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

License:Open Source License

private static Paragraph createSkillSufix(SkillDefinition skillDefinition, int fontSize, int maxColumnWidth) {
    Paragraph paragraph = new Paragraph();
    // Add number first to calculate length.
    if (skillDefinition.isSpecializable()) {
        if (skillDefinition.isLimitedToFaction()) {
            paragraph.add(createSpecializedSkill(skillDefinition, FadingSunsTheme.getLineItalicFont(), fontSize,
                    maxColumnWidth));//w w  w  .  j a  v  a2  s  . com
        } else {
            paragraph.add(createSpecializedSkill(skillDefinition, FadingSunsTheme.getLineFont(), fontSize,
                    maxColumnWidth));
        }
    } else {
        if (skillDefinition.isLimitedToFaction()) {
            paragraph.add(new Paragraph(skillDefinition.getName(),
                    new Font(FadingSunsTheme.getLineItalicFont(), fontSize)));
        } else {
            paragraph.add(new Paragraph(skillDefinition.getName(),
                    new Font(FadingSunsTheme.getLineFont(), fontSize)));
        }
    }
    // Put number at the end.
    if (skillDefinition.isNatural()) {
        paragraph.add(
                new Paragraph(DEFAULT_NATURAL_SKILL_VALUE, new Font(FadingSunsTheme.getLineFont(), fontSize)));
    }

    return paragraph;
}

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

License:Open Source License

private static Paragraph createSpecializedSkill(SkillDefinition skillDefinition, BaseFont font, int fontSize,
        int maxColumnWidth) {
    Paragraph paragraph = new Paragraph();
    float usedWidth = font.getWidthPoint(skillDefinition.getName() + " []"
            + (skillDefinition.isNatural() ? DEFAULT_NATURAL_SKILL_VALUE : ""), fontSize);
    paragraph.add(new Paragraph(skillDefinition.getName() + " [", new Font(font, fontSize)));
    paragraph.add(new Paragraph(
            CellUtils.getSubStringFitsIn(DEFAULT_WHITE_SPACES, font, fontSize, maxColumnWidth - usedWidth),
            new Font(font, fontSize)));
    paragraph.add(new Paragraph("]", new Font(font, fontSize)));
    return paragraph;
}

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

License:Open Source License

public VitalityTable(CharacterPlayer characterPlayer) {
    super(WIDTHS);
    addedCircle = 0;/* www.j a v a 2 s .c o m*/
    addCell(createLateralVerticalTitle(getTranslator().getTranslatedText("vitality"), TITLE_SPAN));
    for (int i = 0; i < TITLE_SPAN; i++) {
        addCell(getCircle(characterPlayer));
        addedCircle++;
    }
    addCell(space(CIRCLES - TITLE_SPAN - MODIFICATORS_SPAN));
    for (int i = 0; i < CIRCLES - TITLE_SPAN - MODIFICATORS_SPAN; i++) {
        addCell(getCircle(characterPlayer));
        addedCircle++;
    }

    for (int i = 1; i <= MODIFICATORS_SPAN; i++) {
        addCell(createValue("-" + (i * 2),
                new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.CHARACTERISTICS_TITLE_FONT_SIZE - 6),
                Element.ALIGN_MIDDLE));
        addCell(getCircle(characterPlayer));
        addedCircle++;
    }
}

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 {//  ww  w.j a v a  2 s.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.characteristics.CharacteristicsTableFactory.java

License:Open Source License

public static PdfPTable getCharacteristicsBasicsTable(CharacterPlayer characterPlayer) {
    float[] widths = { 1f, 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);/*from ww  w. j a  v  a 2s  .c om*/
    table.getDefaultCell().setBorder(0);

    Phrase content = new Phrase(getTranslator().getTranslatedText("characteristics"),
            new Font(FadingSunsTheme.getTitleFont(), FadingSunsTheme.CHARACTER_SMALL_TITLE_FONT_SIZE));
    PdfPCell titleCell = new PdfPCell(content);
    setCellProperties(titleCell);
    titleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    titleCell.setColspan(widths.length);
    titleCell.setFixedHeight(30);
    table.addCell(titleCell);
    table.getDefaultCell().setPadding(0);

    for (CharacteristicType type : CharacteristicType.values()) {
        table.addCell(new CharacteristicsColumn(characterPlayer, type,
                CharacteristicsDefinitionFactory.getInstance().getAll(type, Translator.getLanguage())));
    }

    return table;
}

From source file:com.softwaremagico.tm.pdf.small.counters.CounterTable.java

License:Open Source License

protected PdfPCell createCircle() {
    PdfPCell cell = createValue("O",
            new Font(FadingSunsTheme.getTitleFont(), FadingSunsTheme.CHARACTER_COUNTER_POINT_SIZE),
            Element.ALIGN_MIDDLE);
    return cell;//  www .j a va2  s  .c om
}

From source file:com.softwaremagico.tm.pdf.small.counters.VitalityTable.java

License:Open Source License

public VitalityTable(CharacterPlayer characterPlayer) {
    super(characterPlayer);

    getDefaultCell().setBorder(0);/*from  ww  w  .  java2 s.  c o  m*/

    Font font = new Font(FadingSunsTheme.getTitleFont(), FadingSunsTheme.CHARACTER_VITALITY_TITLE_FONT_SIZE);
    Phrase content = new Phrase(getTranslator().getTranslatedText("vitality"), font);
    PdfPCell titleCell = new PdfPCell(content);
    titleCell.setBorder(0);
    titleCell.setPaddingRight(0);
    titleCell.setPaddingTop(paddingTop);
    titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    addCell(titleCell);

    addedCircle = 0;

    for (int i = 0; i < getNumberOfCircles(); i++) {
        addCell(getCircle());
        addedCircle++;
    }

}

From source file:com.softwaremagico.tm.pdf.small.counters.VitalityTable.java

License:Open Source License

@Override
protected PdfPCell createCircle() {
    if (addedCircle >= 5) {
        return super.createCircle();
    }/*  w w  w.j  a v  a2  s  .c om*/

    PdfPCell cell = createValue("-" + (10 - addedCircle * 2), new Font(FadingSunsTheme.getLineFontBold(),
            FadingSunsTheme.CHARACTER_VITALITY_PENALTIES_TITLE_FONT_SIZE), Element.ALIGN_MIDDLE);
    cell.setPaddingTop(0f);
    cell.setPaddingRight(-2f);
    return cell;
}

From source file:com.softwaremagico.tm.pdf.small.counters.WyrdTable.java

License:Open Source License

public WyrdTable(CharacterPlayer characterPlayer) {
    super(characterPlayer);

    getDefaultCell().setBorder(0);//from ww w.j av a  2 s. c  o m

    Font font = new Font(FadingSunsTheme.getTitleFont(), FadingSunsTheme.CHARACTER_VITALITY_TITLE_FONT_SIZE);
    Phrase content = new Phrase(getTranslator().getTranslatedText("wyrd"), font);
    PdfPCell titleCell = new PdfPCell(content);
    titleCell.setBorder(0);
    titleCell.setPaddingTop(paddingTop);
    titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    addCell(titleCell);

    addedCircle = 0;

    for (int i = 0; i < getNumberOfCircles(); i++) {
        addCell(getCircle());
        addedCircle++;
    }

}

From source file:com.softwaremagico.tm.pdf.small.fighting.ArmourTable.java

License:Open Source License

public ArmourTable(CharacterPlayer characterPlayer) {
    super(new float[] { 2.2f, 3 });
    getDefaultCell().setBorder(0);//from w  w w.ja va  2s  .  c o  m

    // Armor
    Font font = new Font(FadingSunsTheme.getTitleFont(), FadingSunsTheme.CHARACTER_SMALL_ARMOR_TITLE_FONT_SIZE);
    Phrase content = new Phrase(getTranslator().getTranslatedText("armor"), font);
    PdfPCell titleCell = new PdfPCell(content);
    titleCell.setBorder(0);
    addCell(titleCell);

    PdfPCell nameCell;
    if (characterPlayer == null) {
        nameCell = CustomPdfTable.createEmptyElementLine(GAP, NAME_COLUMN_WIDTH);
    } else if (characterPlayer.getArmour() == null) {
        nameCell = createElementLine("", NAME_COLUMN_WIDTH);
    } else {
        nameCell = createElementLine(characterPlayer.getArmour().getName() + "("
                + characterPlayer.getArmour().getProtection() + "d)", NAME_COLUMN_WIDTH,
                FadingSunsTheme.ARMOUR_CONTENT_FONT_SIZE - 1);
    }
    nameCell.setBorder(0);
    nameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    addCell(nameCell);

    // Shield
    addCell(getShieldRange(characterPlayer));

    Paragraph paragraph = new Paragraph();
    paragraph.add(new Paragraph(getTranslator().getTranslatedText("shieldHits") + ": ",
            new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.ARMOUR_CONTENT_FONT_SIZE)));
    if (characterPlayer != null && characterPlayer.getShield() != null) {
        paragraph.add(new Paragraph(characterPlayer.getShield().getHits() + "-",
                new Font(FadingSunsTheme.getHandwrittingFont(),
                        FadingSunsTheme.getHandWrittingFontSize(FadingSunsTheme.ARMOUR_CONTENT_FONT_SIZE))));
    }
    PdfPCell shieldCell = new PdfPCell(paragraph);
    shieldCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    shieldCell.setBorder(0);
    addCell(shieldCell);
}