List of usage examples for com.lowagie.text Font getSize
public float getSize()
From source file:org.unitime.timetable.webutil.PdfWebTable.java
License:Open Source License
public static float getWidth(String text, boolean bold, boolean italic) { Font font = PdfFont.getFont(bold, italic); float width = 0; if (text.indexOf('\n') >= 0) { for (StringTokenizer s = new StringTokenizer(text, "\n"); s.hasMoreTokens();) width = Math.max(width, font.getBaseFont().getWidthPoint(s.nextToken(), font.getSize())); } else//from ww w. java 2 s.c o m width = Math.max(width, font.getBaseFont().getWidthPoint(text, font.getSize())); return width; }
From source file:org.unitime.timetable.webutil.PdfWebTable.java
License:Open Source License
public static float getWidthOfLastLine(String text, boolean bold, boolean italic) { Font font = PdfFont.getFont(bold, italic); float width = 0; if (text.indexOf('\n') >= 0) { for (StringTokenizer s = new StringTokenizer(text, "\n"); s.hasMoreTokens();) width = font.getBaseFont().getWidthPoint(s.nextToken(), font.getSize()); } else/*from www .j av a 2 s . c o m*/ width = Math.max(width, font.getBaseFont().getWidthPoint(text, font.getSize())); return width; }
From source file:org.unitime.timetable.webutil.PdfWebTable.java
License:Open Source License
private float addText(PdfPCell cell, String text, boolean bold, boolean italic, boolean underline, Color color, Color bgColor) {//w w w. java2 s .c o m Font font = PdfFont.getFont(bold, italic, underline, color); Chunk chunk = new Chunk(text, font); if (bgColor != null) chunk.setBackground(bgColor); if (cell.getPhrase() == null) { cell.setPhrase(new Paragraph(chunk)); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(Element.ALIGN_CENTER); } else { cell.getPhrase().add(chunk); } float width = 0; if (text.indexOf('\n') >= 0) { for (StringTokenizer s = new StringTokenizer(text, "\n"); s.hasMoreTokens();) width = Math.max(width, font.getBaseFont().getWidthPoint(s.nextToken(), font.getSize())); } else width = Math.max(width, font.getBaseFont().getWidthPoint(text, font.getSize())); return width; }
From source file:org.unitime.timetable.webutil.timegrid.PdfTimetableGridTable.java
License:Open Source License
public void addTextVertical(PdfPCell cell, String text, boolean bold) throws Exception { if (text == null) return;//from www . jav a 2 s .c o m if (text.indexOf("<span") >= 0) text = text.replaceAll("</span>", "").replaceAll("<span .*>", ""); Font font = PdfFont.getFont(bold); BaseFont bf = font.getBaseFont(); float width = bf.getWidthPoint(text, font.getSize()); PdfTemplate template = iWriter.getDirectContent().createTemplate(2 * font.getSize() + 4, width); template.beginText(); template.setColorFill(Color.BLACK); template.setFontAndSize(bf, font.getSize()); template.setTextMatrix(0, 2); template.showText(text); template.endText(); template.setWidth(width); template.setHeight(font.getSize() + 2); //make an Image object from the template Image img = Image.getInstance(template); img.setRotationDegrees(270); //embed the image in a Chunk Chunk ck = new Chunk(img, 0, 0); if (cell.getPhrase() == null) { cell.setPhrase(new Paragraph(ck)); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); } else { cell.getPhrase().add(ck); } }
From source file:uk.ac.ox.oucs.vle.resources.PDFWriter.java
License:Educational Community License
private PdfPCell headCell(String name, Font font) { PdfPCell pdfCell = new PdfPCell(new Phrase(name, font)); pdfCell.setMinimumHeight(font.getSize() * 2f); pdfCell.setHorizontalAlignment(Element.ALIGN_LEFT); pdfCell.setVerticalAlignment(Element.ALIGN_CENTER); pdfCell.setPaddingBottom(font.getSize() * 0.5f); pdfCell.setPaddingTop(font.getSize() * 0.5f); pdfCell.setPaddingLeft(font.getSize()); pdfCell.setPaddingRight(font.getSize()); return pdfCell; }
From source file:vjmol.VJMol.java
License:GNU General Public License
public void setPref(JComponent comp, Font font, Color color, Color fgColor, Color bgColor, Color bgColor2) { int nCompCount = comp.getComponentCount(); for (int i = 0; i < nCompCount; i++) { Component comp2 = comp.getComponent(i); if (comp2 instanceof JComponent) setPref((JComponent) comp2, font, color, fgColor, bgColor, bgColor2); comp2.setFont(font);//from w ww . j a va 2s .c o m comp2.setForeground(color); if (!comp2.equals(m_pnlVJmolBtn)) comp2.setBackground(bgColor); } comp.setFont(font); comp.setForeground(color); if (comp.equals(m_pnlVJmolBtn)) comp.setBackground(bgColor2); else comp.setBackground(bgColor); if (comp.equals(this)) { int r = 255 - bgColor2.getRed(); int g = 255 - bgColor2.getGreen(); int b = 255 - bgColor2.getBlue(); if (fgColor == null) { fgColor = new Color(r, g, b); if (r == 255 && g == 255 && b == 255) fgColor = Color.yellow; } displayControl.setMeasureFont(font); displayControl.setLabelFontSize(font.getSize()); setfgColor(fgColor); m_bgColor = bgColor2; displayControl.setColorBackground(bgColor2); } }