Java Code Examples for com.lowagie.text.pdf.PdfPCell#setGrayFill()

The following examples show how to use com.lowagie.text.pdf.PdfPCell#setGrayFill() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PdfCounterRequestContextReport.java    From javamelody with Apache License 2.0 6 votes vote down vote up
private void writeRequests(List<CounterRequestContext> contexts)
		throws DocumentException, IOException {
	final PdfPCell defaultCell = getDefaultCell();
	final PdfPCell requestCell = new PdfPCell();
	final Paragraph phrase = new Paragraph("", cellFont);
	int margin = 0;
	for (final CounterRequestContext context : contexts) {
		writeRequest(context, requestCell, margin);
		margin += 5;
	}
	// on utilise ici PdfPCell et addElement pour que les propriétés
	// leading et indentationLeft des paragraphes soient prises en compte
	requestCell.addElement(phrase);
	requestCell.setGrayFill(defaultCell.getGrayFill());
	requestCell.setPaddingTop(defaultCell.getPaddingTop());
	addCell(requestCell);
}
 
Example 2
Source File: PdfRequestAndGraphDetailReport.java    From javamelody with Apache License 2.0 5 votes vote down vote up
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);
	}
	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 {
		final boolean hasChildren = !request.getChildRequestsExecutionsByRequestId().isEmpty();
		if (hasChildren) {
			addCell("");
		}
	}
	writeRequestValues(childRequest, allChildHitsDisplayed);
}
 
Example 3
Source File: PdfRuntimeDependenciesReport.java    From javamelody with Apache License 2.0 5 votes vote down vote up
@Override
void toPdf() throws DocumentException {
	final Map<String, Map<String, Integer>> runtimeDependencies = getRuntimeDependencies();
	if (runtimeDependencies.isEmpty()) {
		addToDocument(new Phrase(getString("Aucune_dependance"), normalFont));
		return;
	}
	addToDocument(new Phrase(getString("runtime_dependencies_desc"), normalFont));
	this.standardDeviation = getStandardDeviation(runtimeDependencies);
	this.calledBeans = getCalledBeans(runtimeDependencies);

	writeHeader();

	final List<String> callerBeans = new ArrayList<String>(runtimeDependencies.keySet());
	Collections.sort(callerBeans);
	final PdfPCell defaultCell = getDefaultCell();
	boolean odd = false;
	for (final String callerBean : callerBeans) {
		if (odd) {
			defaultCell.setGrayFill(0.97f);
		} else {
			defaultCell.setGrayFill(1);
		}
		odd = !odd; // NOPMD
		final Map<String, Integer> beanDependencies = runtimeDependencies.get(callerBean);
		writeBeanDependencies(callerBean, beanDependencies);
	}
	addToDocument(currentTable);
}
 
Example 4
Source File: PdfRuntimeDependenciesReport.java    From javamelody with Apache License 2.0 5 votes vote down vote up
private void writeHeader() throws DocumentException {
	final List<String> headers = new ArrayList<String>();
	headers.add("Beans");
	headers.addAll(calledBeans);
	final int[] relativeWidths = new int[headers.size()];
	Arrays.fill(relativeWidths, 0, headers.size(), 1);
	relativeWidths[0] = 4;

	final PdfPTable table = new PdfPTable(headers.size());
	table.setWidthPercentage(100);
	table.setWidths(relativeWidths);
	table.setHeaderRows(1);
	final PdfPCell defaultCell = table.getDefaultCell();
	defaultCell.setGrayFill(0.9f);
	defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER);
	defaultCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
	defaultCell.setPaddingLeft(0);
	defaultCell.setPaddingRight(0);
	for (final String header : headers) {
		table.addCell(new Phrase(header, boldCellFont));
		// pas la première entête de colonne
		defaultCell.setRotation(90);
	}
	defaultCell.setRotation(0);
	defaultCell.setPaddingLeft(2);
	defaultCell.setPaddingRight(2);
	currentTable = table;
}