use of com.lowagie.text.Paragraph in project charts by vaadin.
the class PdfExportDemo method createHeaderCell.
private PdfPCell createHeaderCell(String caption) throws BadElementException {
Chunk chunk = new Chunk(caption, captionFont);
Paragraph p = new Paragraph(chunk);
p.add(Chunk.NEWLINE);
p.add(Chunk.NEWLINE);
PdfPCell cell = new PdfPCell(p);
cell.setBorder(0);
cell.setBorderWidthBottom(1);
cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
return cell;
}
use of com.lowagie.text.Paragraph in project vcell by virtualcell.
the class ITextWriter method writeReactions.
// each reaction has its own table, ordered by the structures.
protected void writeReactions(Chapter physioChapter, Model model) throws DocumentException {
if (model == null) {
return;
}
Paragraph reactionParagraph = new Paragraph();
reactionParagraph.add(new Chunk("Structures and Reactions Diagram").setLocalDestination(model.getName()));
Section reactionDiagramSection = physioChapter.addSection(reactionParagraph, physioChapter.numberDepth() + 1);
try {
addImage(reactionDiagramSection, encodeJPEG(generateDocReactionsImage(model, null)));
} catch (Exception e) {
e.printStackTrace();
throw new DocumentException(e.getClass().getName() + ": " + e.getMessage());
}
for (int i = 0; i < model.getNumStructures(); i++) {
ReactionStep[] reactionSteps = model.getReactionSteps();
ReactionStep rs = null;
Table modifierTable = null;
Table reactionTable = null;
boolean firstTime = true;
Section reactStructSection = null;
for (int j = 0; j < reactionSteps.length; j++) {
if (reactionSteps[j].getStructure() == model.getStructure(i)) {
// can also use structureName1.equals(structureName2)
if (firstTime) {
Paragraph linkParagraph = new Paragraph();
linkParagraph.add(new Chunk("Reaction(s) in " + model.getStructure(i).getName()).setLocalDestination(model.getStructure(i).getName()));
reactStructSection = physioChapter.addSection(linkParagraph, physioChapter.numberDepth() + 1);
firstTime = false;
}
rs = reactionSteps[j];
String type;
if (rs instanceof SimpleReaction) {
type = "Reaction";
} else {
type = "Flux";
}
// write Reaction equation as a table
// Get the image arrow cell depending on type of reactionStep : MassAction => double arrow, otherwise, forward arrow
boolean bReversible = false;
if (rs.getKinetics() instanceof MassActionKinetics) {
bReversible = true;
}
Cell arrowImageCell = getReactionArrowImageCell(bReversible);
// Get reactants and products strings
ReactionCanvas rc = new ReactionCanvas();
rc.setReactionStep(rs);
ReactionCanvasDisplaySpec rcdSpec = rc.getReactionCanvasDisplaySpec();
String reactants = rcdSpec.getLeftText();
String products = rcdSpec.getRightText();
// Create table and add cells for reactants, arrow(s) images, products
int[] widths = { 8, 1, 8 };
reactionTable = getTable(3, 100, 0, 2, 2);
// Add reactants as cell
Cell tableCell = createCell(reactants, getBold());
tableCell.setHorizontalAlignment(Cell.ALIGN_RIGHT);
tableCell.setBorderColor(Color.white);
reactionTable.addCell(tableCell);
// add arrow(s) image as cell
if (arrowImageCell != null) {
arrowImageCell.setHorizontalAlignment(Cell.ALIGN_CENTER);
arrowImageCell.setBorderColor(Color.white);
reactionTable.addCell(arrowImageCell);
}
// add products as cell
tableCell = createCell(products, getBold());
tableCell.setBorderColor(Color.white);
reactionTable.addCell(tableCell);
// reactionTable.setBorderColor(Color.white);
reactionTable.setWidths(widths);
// Identify modifiers,
ReactionParticipant[] rpArr = rs.getReactionParticipants();
Vector<ReactionParticipant> modifiersVector = new Vector<ReactionParticipant>();
for (int k = 0; k < rpArr.length; k += 1) {
if (rpArr[k] instanceof Catalyst) {
modifiersVector.add(rpArr[k]);
}
}
// Write the modifiers in a separate table, if present
if (modifiersVector.size() > 0) {
modifierTable = getTable(1, 50, 0, 1, 1);
modifierTable.addCell(createCell("Modifiers List", getBold(DEF_HEADER_FONT_SIZE), 1, 1, Element.ALIGN_CENTER, true));
StringBuffer modifierNames = new StringBuffer();
for (int k = 0; k < modifiersVector.size(); k++) {
modifierNames.append(((Catalyst) modifiersVector.elementAt(k)).getName() + "\n");
}
modifierTable.addCell(createCell(modifierNames.toString().trim(), getFont()));
modifiersVector.removeAllElements();
}
Section reactionSection = reactStructSection.addSection(type + " " + rs.getName(), reactStructSection.numberDepth() + 1);
// Annotation
VCMetaData vcMetaData = rs.getModel().getVcMetaData();
if (vcMetaData.getFreeTextAnnotation(rs) != null) {
Table annotTable = getTable(1, 100, 1, 3, 3);
annotTable.addCell(createCell("Reaction Annotation", getBold(DEF_HEADER_FONT_SIZE), 1, 1, Element.ALIGN_CENTER, true));
annotTable.addCell(createCell(vcMetaData.getFreeTextAnnotation(rs), getFont()));
reactionSection.add(annotTable);
// reactionSection.add(new Paragraph("\""+rs.getAnnotation()+"\""));
}
// reaction table
if (reactionTable != null) {
reactionSection.add(reactionTable);
// re-set reactionTable
reactionTable = null;
}
if (modifierTable != null) {
reactionSection.add(modifierTable);
modifierTable = null;
}
// Write kinetics parameters, etc. in a table
writeKineticsParams(reactionSection, rs);
}
}
}
}
use of com.lowagie.text.Paragraph in project activityinfo by bedatadriven.
the class ThemeHelper method columnHeaderCell.
public static Cell columnHeaderCell(String label, boolean leaf, int hAlign) throws BadElementException {
Paragraph para = new Paragraph(label);
para.setFont(new Font(Font.HELVETICA, BODY_FONT_SIZE, Font.NORMAL, Color.WHITE));
Cell cell = new Cell();
cell.addElement(para);
cell.setHorizontalAlignment(hAlign);
cell.setHeader(true);
cell.setVerticalAlignment(Cell.ALIGN_BOTTOM);
cell.setBackgroundColor(BLUE3);
cell.setBorderWidth(0);
return cell;
}
use of com.lowagie.text.Paragraph in project activityinfo by bedatadriven.
the class ThemeHelper method legendTitle.
public static Paragraph legendTitle(String title) {
Paragraph para = new Paragraph(title);
para.setFont(new Font(Font.TIMES_ROMAN, BODY_FONT_SIZE, Font.BOLD, BLUE2));
para.setSpacingBefore(BODY_FONT_SIZE);
return para;
}
use of com.lowagie.text.Paragraph in project activityinfo by bedatadriven.
the class ThemeHelper method reportTitle.
public static Paragraph reportTitle(String title) {
Paragraph para = new Paragraph(title);
para.setFont(new Font(Font.TIMES_ROMAN, TITLE_FONT_SIZE, Font.NORMAL, BLUE));
para.setSpacingAfter(15);
return para;
}
Aggregations