use of com.lowagie.text.Chunk in project vcell by virtualcell.
the class ITextWriter method writeStructure.
protected void writeStructure(Model model, Structure struct, Table structTable) throws DocumentException {
// If this structure has any reactions in it, add its name as a hyperlink to the reactions' list.
if (hasReactions(model, struct)) {
Paragraph linkParagraph = new Paragraph();
Font linkFont;
try {
BaseFont fontBaseFont = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
linkFont = new Font(fontBaseFont, DEF_FONT_SIZE, Font.NORMAL, new java.awt.Color(0, 0, 255));
} catch (Exception e) {
linkFont = getFont();
e.printStackTrace();
}
linkParagraph.add(new Chunk(struct.getName(), linkFont).setLocalGoto(struct.getName()));
Cell structLinkCell = new Cell(linkParagraph);
structLinkCell.setBorderWidth(1);
structLinkCell.setHorizontalAlignment(Element.ALIGN_LEFT);
structTable.addCell(structLinkCell);
} else {
structTable.addCell(createCell(struct.getName(), getFont()));
}
StructureTopology structTopology = model.getStructureTopology();
if (struct instanceof Membrane) {
structTable.addCell(createCell("Membrane", getFont()));
Feature outsideFeature = structTopology.getOutsideFeature((Membrane) struct);
Feature insideFeature = structTopology.getInsideFeature((Membrane) struct);
structTable.addCell(createCell((insideFeature != null ? insideFeature.getName() : "N/A"), getFont()));
structTable.addCell(createCell((outsideFeature != null ? outsideFeature.getName() : "N/A"), getFont()));
} else {
structTable.addCell(createCell("Feature", getFont()));
String outsideStr = "N/A", insideStr = "N/A";
Membrane enclosingMem = (Membrane) structTopology.getParentStructure(struct);
if (enclosingMem != null) {
outsideStr = enclosingMem.getName();
}
// To do: retrieve the 'child' membrane here...
structTable.addCell(createCell(insideStr, getFont()));
structTable.addCell(createCell(outsideStr, getFont()));
}
}
use of com.lowagie.text.Chunk in project charts by vaadin.
the class PdfExportDemo method writePdfContent.
private void writePdfContent() throws DocumentException, IOException {
Paragraph caption = new Paragraph();
caption.add(new Chunk("Vaadin Charts Export Demo PDF", captionFont));
document.add(caption);
Paragraph br = new Paragraph(Chunk.NEWLINE);
document.add(br);
Paragraph paragraph = new Paragraph();
paragraph.add(new Chunk("This PDF is rendered with iText 2.1.7.", normalFont));
document.add(paragraph);
paragraph = new Paragraph();
paragraph.add(new Chunk("Chart below is originally an SVG image created with Vaadin Charts and rendered with help of Batik SVG Toolkit.", normalFont));
document.add(paragraph);
document.add(createSvgImage(writer.getDirectContent(), 400, 400));
document.add(createExampleTable());
}
use of com.lowagie.text.Chunk in project charts by vaadin.
the class PdfExportDemo method createCell.
private PdfPCell createCell(String value) throws BadElementException {
PdfPCell cell = new PdfPCell(new Phrase(new Chunk(value, normalFont)));
cell.setBorder(0);
cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
return cell;
}
use of com.lowagie.text.Chunk in project activityinfo by bedatadriven.
the class ItextMapRenderer method addPieChartDescription.
private void addPieChartDescription(MapReportElement element, Cell descriptionCell, PiechartMapLayer layer) throws BadElementException, IOException {
for (Slice slice : layer.getSlices()) {
IndicatorDTO indicator = element.getContent().getIndicatorById(slice.getIndicatorId());
Color color = ColorUtil.colorFromString(slice.getColor());
ItextGraphic sliceImage = renderSlice(imageCreator, color, 10);
Chunk box = new Chunk(sliceImage.toItextImage(), 0, 0);
Chunk description = new Chunk(indicator.getName());
Phrase phrase = new Phrase();
phrase.add(box);
phrase.add(description);
Paragraph paragraph = new Paragraph(phrase);
descriptionCell.add(paragraph);
}
}
Aggregations