List of usage examples for com.lowagie.text.pdf PdfPCell getLeading
public float getLeading()
From source file:net.bull.javamelody.internal.web.pdf.PdfRequestAndGraphDetailReport.java
License:Apache License
private void writeRequest(CounterRequest childRequest, float executionsByRequest, boolean allChildHitsDisplayed) throws IOException, DocumentException { final PdfPCell defaultCell = getDefaultCell(); defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT); final Paragraph paragraph = new Paragraph(defaultCell.getLeading() + cellFont.getSize()); if (executionsByRequest != -1) { paragraph.setIndentationLeft(5); }// ww w . ja va2s . c o m final Counter parentCounter = getCounterByRequestId(childRequest); if (parentCounter != null && parentCounter.getIconName() != null) { paragraph.add(new Chunk(getSmallImage(parentCounter.getIconName()), 0, -1)); } paragraph.add(new Phrase(childRequest.getName(), cellFont)); final PdfPCell requestCell = new PdfPCell(); requestCell.addElement(paragraph); requestCell.setGrayFill(defaultCell.getGrayFill()); requestCell.setPaddingTop(defaultCell.getPaddingTop()); addCell(requestCell); defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT); if (executionsByRequest != -1) { addCell(nbExecutionsFormat.format(executionsByRequest)); } else { addCell(""); } writeRequestValues(childRequest, allChildHitsDisplayed); }
From source file:org.areasy.common.doclet.document.Inherited.java
License:Open Source License
/** * Prints inherited methods and fields from superclasses * * @param supercls class source to get inherited fields and methods for. * @param show SHOW_METHODS or SHOW_FIELDS * @throws Exception/*from ww w .j ava 2 s .c o m*/ */ public static void print(ClassDoc supercls, int show) throws Exception { String type; FieldDoc[] fields = supercls.fields(); Arrays.sort(fields); if (supercls.isInterface()) type = "interface"; else type = "class"; // Create cell for additional spacing below PdfPCell spacingCell = new PdfPCell(); spacingCell.addElement(new Chunk(" ")); spacingCell.setFixedHeight((float) 4.0); spacingCell.setBorder(Rectangle.BOTTOM + Rectangle.LEFT + Rectangle.RIGHT); spacingCell.setBorderColor(Color.gray); if ((fields.length > 0) && (show == SHOW_FIELDS)) { Document.instance().add(new Paragraph((float) 6.0, " ")); PdfPTable table = new PdfPTable(1); table.setWidthPercentage((float) 100); Paragraph newLine = new Paragraph(); newLine.add(new Chunk("Fields inherited from " + type + " ", Fonts.getFont(TEXT_FONT, BOLD, 10))); newLine.add(new LinkPhrase(supercls.qualifiedTypeName(), null, 10, false)); table.addCell(new CustomPdfPCell(newLine, COLOR_INHERITED_SUMMARY)); Paragraph paraList = new Paragraph(); for (int i = 0; i < fields.length; i++) { paraList.add(new LinkPhrase(fields[i].qualifiedName(), fields[i].name(), 10, false)); if (i != (fields.length - 1)) paraList.add(new Chunk(", ", Fonts.getFont(TEXT_FONT, BOLD, 12))); } PdfPCell contentCell = new CellBorderPadding(paraList); float leading = (float) contentCell.getLeading() + (float) 1.1; contentCell.setLeading(leading, leading); table.addCell(contentCell); table.addCell(spacingCell); Document.instance().add(table); } MethodDoc[] meth = supercls.methods(); Arrays.sort(meth); if ((meth.length > 0) && (show == SHOW_METHODS)) { Document.instance().add(new Paragraph((float) 6.0, " ")); PdfPTable table = new CustomPdfPTable(); Paragraph newLine = new Paragraph(); newLine.add(new Chunk("Methods inherited from " + type + " ", Fonts.getFont(TEXT_FONT, BOLD, 10))); newLine.add(new LinkPhrase(supercls.qualifiedTypeName(), null, 10, false)); table.addCell(new CustomPdfPCell(newLine, COLOR_INHERITED_SUMMARY)); Paragraph paraList = new Paragraph(); for (int i = 0; i < meth.length; i++) { String methodLabel = meth[i].name(); // Do not list static initializers like "<clinit>" if (!methodLabel.startsWith("<")) { paraList.add(new LinkPhrase(supercls.qualifiedTypeName() + "." + meth[i].name(), meth[i].name(), 10, false)); if (i != (meth.length - 1)) paraList.add(new Chunk(", ", Fonts.getFont(CODE_FONT, 10))); } } PdfPCell contentCell = new CellBorderPadding(paraList); float leading = (float) contentCell.getLeading() + (float) 1.1; contentCell.setLeading(leading, leading); table.addCell(contentCell); table.addCell(spacingCell); Document.instance().add(table); } // Print inherited interfaces / class methods and fields recursively ClassDoc supersupercls = null; if (supercls.isClass()) supersupercls = supercls.superclass(); if (supersupercls != null) { String className = supersupercls.qualifiedName(); if (ifClassMustBePrinted(className)) Inherited.print(supersupercls, show); } ClassDoc[] interfaces = supercls.interfaces(); for (int i = 0; i < interfaces.length; i++) { supersupercls = interfaces[i]; String className = supersupercls.qualifiedName(); if (ifClassMustBePrinted(className)) Inherited.print(supersupercls, show); } }