List of usage examples for com.itextpdf.text Paragraph add
@Override public boolean add(Element o)
Element
to the Paragraph
. 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);//from www .j a va2s . c o 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);//from ww w . j av a2s .c o m 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 {//from w w w . j a v a2s .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)))); }//from w w w .j a v a 2 s . 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.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 ww w .j a v a 2 s . c o m*/ 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 w w w . java 2s.c o 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; }
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));/*from w w w. ja v a 2 s . c o m*/ } 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.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 a v a2 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; }
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 . j av a 2 s . 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); }