List of usage examples for com.lowagie.text Element ALIGN_TOP
int ALIGN_TOP
To view the source code for com.lowagie.text Element ALIGN_TOP.
Click Source Link
From source file:org.unitime.timetable.export.PDFPrinter.java
License:Open Source License
@Override public void printLine(String... fields) { PdfPCellEvent setLineDashEvent = new PdfPCellEvent() { @Override//from w ww .j ava 2s . c o m public void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvas) { PdfContentByte cb = canvas[PdfPTable.LINECANVAS]; cb.setLineDash(new float[] { 2, 2 }, 0); } }; for (int idx = 0; idx < fields.length; idx++) { if (iHiddenColumns.contains(idx)) continue; String f = fields[idx]; if (f == null || f.isEmpty() || (iCheckLast && f.equals(iLastLine == null || idx >= iLastLine.length ? null : iLastLine[idx]))) f = ""; boolean number = sNumber.matcher(f).matches(); Font font = PdfFont.getFont(); Phrase p = new Phrase(f, PdfFont.getSmallFont()); PdfPCell cell = new PdfPCell(p); cell.setBorder(iLastLine == null ? Rectangle.TOP : Rectangle.NO_BORDER); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(number ? Element.ALIGN_RIGHT : Element.ALIGN_LEFT); cell.setPaddingBottom(4f); cell.setCellEvent(setLineDashEvent); if (number) cell.setPaddingRight(10f); iTable.addCell(cell); float width = 0; if (f.indexOf('\n') >= 0) { for (StringTokenizer s = new StringTokenizer(f, "\n"); s.hasMoreTokens();) width = Math.max(width, font.getBaseFont().getWidthPoint(s.nextToken(), font.getSize())); } else width = Math.max(width, font.getBaseFont().getWidthPoint(f, font.getSize())); iMaxWidth[idx] = Math.max(iMaxWidth[idx], width + (number ? 10 : 0)); } iLastLine = fields; }
From source file:org.unitime.timetable.webutil.pdf.PdfEventTableBuilder.java
License:Open Source License
public PdfPCell createCell() { PdfPCell cell = new PdfPCell(); cell.setBorderColor(Color.BLACK); cell.setPadding(3);//from ww w . ja v a 2 s . co m cell.setBorderWidth(0); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(iBgColor); if (iUnderline) cell.setBorderWidthBottom(1); if (iOverline) cell.setBorderWidthTop(0.5f); return cell; }
From source file:org.unitime.timetable.webutil.pdf.PdfEventTableBuilder.java
License:Open Source License
public void addText(PdfPCell cell, String text, boolean bold, boolean italic, int orientation, Color color, boolean newLine) { if (text == null) return;/* w w w . j a v a 2 s .co m*/ if (cell.getPhrase() == null) { Chunk ch = new Chunk(text, PdfFont.getSmallFont(bold, italic, color)); cell.setPhrase(new Paragraph(ch)); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(orientation); } else { cell.getPhrase() .add(new Chunk((newLine ? "\n" : "") + text, PdfFont.getSmallFont(bold, italic, color))); } }
From source file:org.unitime.timetable.webutil.pdf.PdfInstructionalOfferingTableBuilder.java
License:Open Source License
public PdfPCell createCell() { PdfPCell cell = new PdfPCell(); cell.setBorderColor(sBorderColor);//from w w w. j a va 2 s. co m cell.setPadding(3); cell.setBorderWidth(0); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(iBgColor); return cell; }
From source file:org.unitime.timetable.webutil.pdf.PdfInstructionalOfferingTableBuilder.java
License:Open Source License
public void addText(PdfPCell cell, String text, boolean bold, boolean italic, int orientation, Color color, boolean newLine) { if (text == null) return;//w w w.j a va 2 s. c om if (cell.getPhrase() == null) { Chunk ch = new Chunk(text, PdfFont.getFont(bold, italic, color)); cell.setPhrase(new Paragraph(ch)); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(orientation); } else { cell.getPhrase().add(new Chunk((newLine ? "\n" : "") + text, PdfFont.getFont(bold, italic, color))); } }
From source file:org.unitime.timetable.webutil.pdf.PdfInstructionalOfferingTableBuilder.java
License:Open Source License
private PdfPCell pdfBuildTimePrefCell(ClassAssignmentProxy classAssignment, PreferenceGroup prefGroup, boolean isEditable) { Color color = (isEditable ? sEnableColor : sDisableColor); Assignment a = null;//from w w w. j a va 2 s . c om if (getDisplayTimetable() && isShowTimetable() && classAssignment != null && prefGroup instanceof Class_) { try { a = classAssignment.getAssignment((Class_) prefGroup); } catch (Exception e) { Debug.error(e); } } PdfPCell cell = createCell(); for (Iterator i = prefGroup.effectivePreferences(TimePref.class).iterator(); i.hasNext();) { TimePref tp = (TimePref) i.next(); RequiredTimeTable rtt = tp.getRequiredTimeTable(a == null ? null : a.getTimeLocation()); if (getGridAsText()) { addText(cell, rtt.getModel().toString().replaceAll(", ", "\n"), false, false, Element.ALIGN_LEFT, color, true); } else { try { rtt.getModel().setDefaultSelection(getDefaultTimeGridSize()); if (rtt.getModel().isExactTime()) { addText(cell, rtt.exactTime(false), false, false, Element.ALIGN_LEFT, color, true); } else { java.awt.Image awtImage = rtt.createBufferedImage(getTimeVertival()); Image img = Image.getInstance(awtImage, Color.WHITE); Chunk ck = new Chunk(img, 0, 0); if (cell.getPhrase() == null) { cell.setPhrase(new Paragraph(ck)); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(Element.ALIGN_LEFT); } else { cell.getPhrase().add(ck); } } } catch (Exception e) { e.printStackTrace(); } } } return cell; }
From source file:org.unitime.timetable.webutil.PdfWebTable.java
License:Open Source License
private PdfPCell createCell() { PdfPCell cell = new PdfPCell(); cell.setBorderColor(Color.BLACK); cell.setPadding(3);/*from w w w. j av a 2s . com*/ cell.setBorderWidth(0); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(Element.ALIGN_CENTER); return cell; }
From source file:org.unitime.timetable.webutil.PdfWebTable.java
License:Open Source License
private float addImage(PdfPCell cell, String name) { try {/* w ww . j a va2s . c om*/ java.awt.Image awtImage = (java.awt.Image) iImages.get(name); if (awtImage == null) return 0; Image img = Image.getInstance(awtImage, Color.WHITE); Chunk ck = new Chunk(img, 0, 0); if (cell.getPhrase() == null) { cell.setPhrase(new Paragraph(ck)); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(Element.ALIGN_CENTER); } else { cell.getPhrase().add(ck); } return awtImage.getWidth(null); } catch (Exception e) { return 0; } }
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.j a v a 2 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.PdfExamGridTable.java
License:Open Source License
public PdfPCell createCell() { PdfPCell cell = new PdfPCell(); cell.setBorderColor(sBorderColor);//from w ww . j a v a 2 s. co m cell.setPadding(3); cell.setBorderWidth(0); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorderWidthTop(1); cell.setBorderWidthBottom(1); cell.setBorderWidthLeft(1); cell.setBorderWidthRight(1); return cell; }