List of usage examples for com.itextpdf.text.pdf PdfPCell setHorizontalAlignment
public void setHorizontalAlignment(int horizontalAlignment)
From source file:com.softwaremagico.tm.pdf.complete.elements.CustomPdfTable.java
License:Open Source License
protected PdfPCell createRectangle(String value) { if (value == null) { return createRectangle(); }/*from ww w.j a v a 2s. com*/ PdfPCell box = new PdfPCell(new Paragraph(value, new Font(FadingSunsTheme.getHandwrittingFont(), FadingSunsTheme.HANDWRITTING_DEFAULT_FONT_SIZE))); box.setVerticalAlignment(Element.ALIGN_MIDDLE); box.setHorizontalAlignment(Element.ALIGN_CENTER); box.setMinimumHeight(15); box.setBorder(0); box.setCellEvent( new CellCompleteBoxEvent(new Border[] { Border.TOP, Border.BOTTOM, Border.LEFT, Border.RIGHT })); return box; }
From source file:com.softwaremagico.tm.pdf.complete.elements.CustomPdfTable.java
License:Open Source License
protected PdfPCell getCell(Paragraph paragraph, int border, int colspan, int align) { PdfPCell cell = new PdfPCell(paragraph); cell.setColspan(colspan);//from www . j ava 2s . co m cell.setBorderWidth(border); cell.setHorizontalAlignment(align); return cell; }
From source file:com.softwaremagico.tm.pdf.complete.elements.LateralHeaderPdfPTable.java
License:Open Source License
protected PdfPCell createLateralVerticalTitle(String title, int rowspan) { Font font = new Font(FadingSunsTheme.getTitleFont(), getTitleFontSize()); font.setColor(BaseColor.WHITE);/*ww w . j a v a 2 s . co m*/ Phrase content = new Phrase(title, font); PdfPCell titleCell = new PdfPCell(content); titleCell.setPadding(0); titleCell.setRowspan(rowspan); titleCell.setRotation(90); titleCell.setHorizontalAlignment(Element.ALIGN_CENTER); // titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE); titleCell.setBackgroundColor(BaseColor.BLACK); return titleCell; }
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 ww . ja va2 s. co m*/ } else { 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 w w .j a va2 s . co 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.skills.CounterTable.java
License:Open Source License
protected PdfPCell createValue(String text, Font font, int alignment) { Phrase content = new Phrase(text, font); PdfPCell circleCell = new PdfPCell(content); // Not putting correctly the "o" at the center of the cell. // http://stackoverflow.com/questions/5554553/itext-pdftable-cell-vertical-alignment circleCell.setPaddingTop(-4f);// w w w. ja v a 2 s. c o m circleCell.setHorizontalAlignment(Element.ALIGN_CENTER); circleCell.setVerticalAlignment(alignment); circleCell.setBorder(0); // Some position corrections. circleCell.setMinimumHeight((MainSkillsTableFactory.HEIGHT / CIRCLES) + 1.3f); return circleCell; }
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.ja va 2 s . 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.CharacteristicsTableFactory.java
License:Open Source License
public static PdfPTable getCharacteristicsBasicsTable(CharacterPlayer characterPlayer) { float[] widths = { 1f, 1f }; PdfPTable table = new PdfPTable(widths); setTablePropierties(table);/*from w w w . j a va 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 createValue(String text, Font font, int alignment) { Phrase content = new Phrase(text, font); PdfPCell circleCell = new PdfPCell(content); // Not putting correctly the "o" at the center of the cell. // http://stackoverflow.com/questions/5554553/itext-pdftable-cell-vertical-alignment circleCell.setPaddingTop(paddingTop); circleCell.setHorizontalAlignment(Element.ALIGN_CENTER); circleCell.setVerticalAlignment(alignment); circleCell.setBorder(0);//from w w w. j a va 2s .c o m circleCell.setMinimumHeight(20); return circleCell; }
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);/* w w w. j a v a 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); }