List of usage examples for com.itextpdf.text Font Font
public Font(final FontFamily family, final float size)
From source file:com.softwaremagico.tm.pdf.complete.events.FooterEvent.java
License:Open Source License
/** * Adds a footer to every page//from w w w . j a va 2s. c o m * * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(com.itextpdf.text.pdf.PdfWriter, * com.itextpdf.text.Document) */ @Override public void onEndPage(PdfWriter writer, Document document) { if (writer.getPageNumber() % 2 == 0) { PdfContentByte cb = writer.getDirectContent(); Phrase footer = new Phrase( "Created using 'Think Machine'" + (Version.getVersion() != null ? " v" + Version.getVersion() : ""), new Font(FadingSunsTheme.getFooterFont(), FadingSunsTheme.FOOTER_FONT_SIZE)); ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, footer, (document.right() - document.left()) / 2 + document.leftMargin(), document.bottom() + 20, 0); } }
From source file:com.softwaremagico.tm.pdf.complete.events.PartyFooterEvent.java
License:Open Source License
/** * Adds a footer to every page//w w w. j a v a 2 s. c o m * * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(com.itextpdf.text.pdf.PdfWriter, * com.itextpdf.text.Document) */ @Override public void onEndPage(PdfWriter writer, Document document) { PdfContentByte cb = writer.getDirectContent(); Phrase footer = new Phrase( party.getPartyName() + " - Created using 'Think Machine'" + (Version.getVersion() != null ? " v" + Version.getVersion() : ""), new Font(FadingSunsTheme.getFooterFont(), FadingSunsTheme.FOOTER_FONT_SIZE)); ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, footer, (document.right() - document.left()) / 2 + document.leftMargin(), document.bottom() + bottomMargin, 0); }
From source file:com.softwaremagico.tm.pdf.complete.fighting.ArmourTable.java
License:Open Source License
public ArmourTable(CharacterPlayer characterPlayer) throws InvalidXmlElementException { super(WIDTHS); getDefaultCell().setBorder(0);/*w ww . ja va 2s. co m*/ addCell(createLateralVerticalTitle(getTranslator().getTranslatedText("armor"), ROWS + 1)); PdfPCell nameCell; if (characterPlayer == null || characterPlayer.getArmour() == null) { nameCell = createEmptyElementLine(GAP); } else { nameCell = createElementLine(characterPlayer.getArmour().getName(), NAME_COLUMN_WIDTH, FadingSunsTheme.ARMOUR_CONTENT_FONT_SIZE); } nameCell.setColspan(WIDTHS.length); nameCell.setMinimumHeight(20); addCell(nameCell); PdfPCell protectionCell; if (characterPlayer == null || characterPlayer.getArmour() == null) { protectionCell = createEmptyElementLine(getTranslator().getTranslatedText("armorRating") + ": ____ " + getTranslator().getTranslatedText("diceAbbreviature")); } else { Paragraph paragraph = new Paragraph(); paragraph.add(new Paragraph(getTranslator().getTranslatedText("armorRating") + ": ", new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.TABLE_LINE_FONT_SIZE))); paragraph.add(new Paragraph(characterPlayer.getArmour().getProtection() + " ", new Font(FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.ARMOUR_CONTENT_FONT_SIZE))); paragraph.add(new Paragraph(getTranslator().getTranslatedText("diceAbbreviature"), new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.TABLE_LINE_FONT_SIZE))); protectionCell = createEmptyElementLine(""); protectionCell.setPhrase(paragraph); } protectionCell.setColspan(WIDTHS.length); addCell(protectionCell); PdfPCell malusCell; if (characterPlayer == null || characterPlayer.getArmour() == null) { malusCell = createEmptyElementLine(getTranslator().getTranslatedText("strengthAbbreviature") + ":__ " + getTranslator().getTranslatedText("dexterityAbbreviature") + ":__ " + getTranslator().getTranslatedText("enduranceAbbreviature") + ":__ " + getTranslator().getTranslatedText("iniciativeAbbreviature") + ":__"); } else { Paragraph paragraph = new Paragraph(); paragraph.add(new Paragraph(getTranslator().getTranslatedText("strengthAbbreviature") + ":", new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.TABLE_LINE_FONT_SIZE))); paragraph.add(new Paragraph( characterPlayer.getArmour().getStandardPenalizations().getStrengthModification() + " ", new Font(FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.ARMOUR_CONTENT_FONT_SIZE))); paragraph.add(new Paragraph(" " + getTranslator().getTranslatedText("dexterityAbbreviature") + ":", new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.TABLE_LINE_FONT_SIZE))); paragraph.add(new Paragraph( characterPlayer.getArmour().getStandardPenalizations().getDexterityModification() + " ", new Font(FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.ARMOUR_CONTENT_FONT_SIZE))); paragraph.add(new Paragraph(" " + getTranslator().getTranslatedText("enduranceAbbreviature") + ":", new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.TABLE_LINE_FONT_SIZE))); paragraph.add(new Paragraph( characterPlayer.getArmour().getStandardPenalizations().getEnduranceModification() + " ", new Font(FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.ARMOUR_CONTENT_FONT_SIZE))); paragraph.add(new Paragraph(" " + getTranslator().getTranslatedText("iniciativeAbbreviature") + ":", new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.TABLE_LINE_FONT_SIZE))); paragraph.add(new Paragraph( characterPlayer.getArmour().getStandardPenalizations().getEnduranceModification() + " ", new Font(FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.ARMOUR_CONTENT_FONT_SIZE))); malusCell = createEmptyElementLine(""); malusCell.setPhrase(paragraph); } malusCell.setColspan(WIDTHS.length); addCell(malusCell); if (characterPlayer == null || characterPlayer.getArmour() == null) { addCell(getArmourProperty(getTranslator().getTranslatedText("armorHardAbbreviature"), false)); addCell(getArmourProperty(getTranslator().getTranslatedText("armorFireAbbreviature"), false)); addCell(getArmourProperty(getTranslator().getTranslatedText("armorLaserAbbreviature"), false)); addCell(getArmourProperty(getTranslator().getTranslatedText("armorPlasmAbbreviature"), false)); addCell(getArmourProperty(getTranslator().getTranslatedText("armorShockAbbreviature"), false)); addCell(getArmourProperty(getTranslator().getTranslatedText("armorImpactAbbreviature"), false)); } else { addCell(getArmourProperty(getTranslator().getTranslatedText("armorHardAbbreviature"), characterPlayer.getArmour().getDamageTypes().contains( DamageTypeFactory.getInstance().getElement("hard", characterPlayer.getLanguage())))); addCell(getArmourProperty(getTranslator().getTranslatedText("armorFireAbbreviature"), characterPlayer.getArmour().getDamageTypes().contains( DamageTypeFactory.getInstance().getElement("fire", characterPlayer.getLanguage())))); addCell(getArmourProperty(getTranslator().getTranslatedText("armorLaserAbbreviature"), characterPlayer.getArmour().getDamageTypes().contains( DamageTypeFactory.getInstance().getElement("laser", characterPlayer.getLanguage())))); addCell(getArmourProperty(getTranslator().getTranslatedText("armorPlasmAbbreviature"), characterPlayer.getArmour().getDamageTypes().contains( DamageTypeFactory.getInstance().getElement("plasma", characterPlayer.getLanguage())))); addCell(getArmourProperty(getTranslator().getTranslatedText("armorShockAbbreviature"), characterPlayer.getArmour().getDamageTypes().contains( DamageTypeFactory.getInstance().getElement("shock", characterPlayer.getLanguage())))); addCell(getArmourProperty(getTranslator().getTranslatedText("armorImpactAbbreviature"), characterPlayer.getArmour().getDamageTypes().contains( DamageTypeFactory.getInstance().getElement("impact", characterPlayer.getLanguage())))); } }
From source file:com.softwaremagico.tm.pdf.complete.fighting.ShieldTable.java
License:Open Source License
public ShieldTable(CharacterPlayer characterPlayer) { super(WIDTHS); getDefaultCell().setBorder(0);// w ww . j a va 2 s .c om addCell(createLateralVerticalTitle(getTranslator().getTranslatedText("shield"), ROWS + 1)); PdfPCell nameCell; if (characterPlayer == null || characterPlayer.getShield() == null) { nameCell = createEmptyElementLine(GAP, NAME_COLUMN_WIDTH); } else { nameCell = createElementLine(characterPlayer.getShield().getName(), NAME_COLUMN_WIDTH, FadingSunsTheme.SHIELD_CONTENT_FONT_SIZE); } nameCell.setColspan(WIDTHS.length); nameCell.setMinimumHeight(20); addCell(nameCell); addCell(getShieldRange(characterPlayer)); if (characterPlayer == null || characterPlayer.getShield() == null) { addCell(createEmptyElementLine(getTranslator().getTranslatedText("shieldHits") + ": " + GAP, HITS_COLUMN_WIDTH)); } else { Paragraph paragraph = new Paragraph(); paragraph.add(new Paragraph(getTranslator().getTranslatedText("shieldHits") + ": ", new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.TABLE_LINE_FONT_SIZE))); paragraph.add(new Paragraph(characterPlayer.getShield().getHits() + " ", new Font(FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.SHIELD_CONTENT_FONT_SIZE))); PdfPCell protectionCell = createEmptyElementLine(""); protectionCell.setPhrase(paragraph); addCell(protectionCell); } addCell(createEmptyElementLine("___________________")); addCell(createEmptyElementLine("___________________")); }
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 ww. j av a2 s .c o m 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
private Paragraph getMoney(CharacterPlayer characterPlayer) { Paragraph paragraph = new Paragraph(); paragraph.add(new Paragraph(getTranslator().getTranslatedText("firebirds"), new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.TABLE_LINE_FONT_SIZE))); String moneyText = ""; float usedWidth = 0; if (characterPlayer != null) { moneyText = " " + characterPlayer.getMoney() + "- "; usedWidth = FadingSunsTheme.getHandwrittingFont().getWidthPoint(moneyText, FadingSunsTheme.TABLE_LINE_FONT_SIZE - 1); paragraph.add(new Paragraph(moneyText, new Font(FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.getHandWrittingFontSize(FadingSunsTheme.TABLE_LINE_FONT_SIZE - 1)))); }// ww w .j a va 2s. c o m moneyText = CellUtils.getSubStringFitsIn("____________________________________________", FadingSunsTheme.getLineFont(), FadingSunsTheme.TABLE_LINE_FONT_SIZE, 138 - usedWidth); paragraph.add(new Paragraph(moneyText, new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.TABLE_LINE_FONT_SIZE))); return paragraph; }
From source file:com.softwaremagico.tm.pdf.complete.skills.CounterTable.java
License:Open Source License
private PdfPCell createCircle() { PdfPCell cell = createValue("O", new Font(FadingSunsTheme.getTitleFont(), FadingSunsTheme.CHARACTERISTICS_TITLE_FONT_SIZE), Element.ALIGN_MIDDLE); return cell;//from w w w.j a v a 2s . c o m }
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 w w w . j a v a 2 s. c om*/ // 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
private static Paragraph createSkillSufix(CharacterPlayer characterPlayer, AvailableSkill availableSkill, int fontSize, int maxColumnWidth) { if (availableSkill == null) { return new Paragraph(" "); }//from w w w.ja va 2s . c om Paragraph paragraph = new Paragraph(); // Add number first to calculate length. if (availableSkill.getSpecialization() != null // This two skills are special. || availableSkill.getId().equalsIgnoreCase(SkillDefinition.PLANETARY_LORE_ID) || availableSkill.getId().equalsIgnoreCase(SkillDefinition.FACTORION_LORE_ID)) { if (availableSkill.getSkillDefinition().isLimitedToFaction()) { paragraph.add(createSpecializedSkill(characterPlayer, availableSkill, FadingSunsTheme.getLineItalicFont(), fontSize, maxColumnWidth)); } else { paragraph.add(createSpecializedSkill(characterPlayer, availableSkill, FadingSunsTheme.getLineFont(), fontSize, maxColumnWidth)); } } else { if (availableSkill.getSkillDefinition().isLimitedToFaction()) { paragraph.add(new Paragraph(availableSkill.getName(), new Font(FadingSunsTheme.getLineItalicFont(), fontSize))); } else { paragraph.add( new Paragraph(availableSkill.getName(), new Font(FadingSunsTheme.getLineFont(), fontSize))); } } // Put number at the end. if (availableSkill.getSkillDefinition().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(CharacterPlayer characterPlayer, AvailableSkill availableSkill, BaseFont font, int fontSize, int maxColumnWidth) { Paragraph paragraph = new Paragraph(); float usedWidth = font.getWidthPoint( availableSkill.getName() + " []" + (availableSkill.getSkillDefinition().isNatural() ? DEFAULT_NATURAL_SKILL_VALUE : ""), fontSize);/*from www . j a v a2 s. co m*/ paragraph.add(new Paragraph(availableSkill.getName() + " [", new Font(font, fontSize))); if (characterPlayer != null && characterPlayer.getSelectedSkill(availableSkill) == null) { if (availableSkill.getSpecialization() != null && availableSkill.getSpecialization().getName() != null) { paragraph.add(new Paragraph( CellUtils.getSubStringFitsIn(availableSkill.getSpecialization().getName(), FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.getHandWrittingFontSize(fontSize), maxColumnWidth - usedWidth), new Font(FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.getHandWrittingFontSize(fontSize)))); } else { paragraph.add(new Paragraph(CellUtils.getSubStringFitsIn(DEFAULT_WHITE_SPACES, font, fontSize, maxColumnWidth - usedWidth), new Font(font, fontSize))); } } else { paragraph.add(new Paragraph( CellUtils.getSubStringFitsIn( characterPlayer != null ? characterPlayer.getSelectedSkill(availableSkill).getName() .replace(availableSkill.getName(), "").replace("[", "").replace("]", "").trim() : DEFAULT_WHITE_SPACES, FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.getHandWrittingFontSize(fontSize), maxColumnWidth - usedWidth), new Font(FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.getHandWrittingFontSize(fontSize)))); } paragraph.add(new Paragraph("]", new Font(font, fontSize))); return paragraph; }