Search in sources :

Example 16 with Paragraph

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;
}
Also used : PdfPCell(com.lowagie.text.pdf.PdfPCell) Chunk(com.lowagie.text.Chunk) Paragraph(com.lowagie.text.Paragraph)

Example 17 with Paragraph

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);
            }
        }
    }
}
Also used : Table(com.lowagie.text.Table) SimpleReaction(cbit.vcell.model.SimpleReaction) ReactionCanvasDisplaySpec(cbit.vcell.model.ReactionCanvasDisplaySpec) ReactionCanvas(cbit.vcell.model.ReactionCanvas) Chunk(com.lowagie.text.Chunk) Section(com.lowagie.text.Section) DocumentException(com.lowagie.text.DocumentException) ExpressionException(cbit.vcell.parser.ExpressionException) Paragraph(com.lowagie.text.Paragraph) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) DocumentException(com.lowagie.text.DocumentException) ReactionStep(cbit.vcell.model.ReactionStep) MassActionKinetics(cbit.vcell.model.MassActionKinetics) Cell(com.lowagie.text.Cell) ReactionParticipant(cbit.vcell.model.ReactionParticipant) Vector(java.util.Vector) Catalyst(cbit.vcell.model.Catalyst)

Example 18 with Paragraph

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;
}
Also used : Cell(com.lowagie.text.Cell) Font(com.lowagie.text.Font) Paragraph(com.lowagie.text.Paragraph)

Example 19 with Paragraph

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;
}
Also used : Font(com.lowagie.text.Font) Paragraph(com.lowagie.text.Paragraph)

Example 20 with Paragraph

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;
}
Also used : Font(com.lowagie.text.Font) Paragraph(com.lowagie.text.Paragraph)

Aggregations

Paragraph (com.lowagie.text.Paragraph)43 Font (com.lowagie.text.Font)14 DocumentException (com.lowagie.text.DocumentException)13 Color (java.awt.Color)13 Document (com.lowagie.text.Document)12 Chunk (com.lowagie.text.Chunk)11 Cell (com.lowagie.text.Cell)9 Phrase (com.lowagie.text.Phrase)7 Section (com.lowagie.text.Section)7 PdfPCell (com.lowagie.text.pdf.PdfPCell)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 List (java.util.List)7 ArrayList (java.util.ArrayList)6 Table (com.lowagie.text.Table)5 DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)5 ListItem (com.lowagie.text.ListItem)4 PdfPTable (com.lowagie.text.pdf.PdfPTable)4 IOException (java.io.IOException)4 ServletOutputStream (javax.servlet.ServletOutputStream)4 ExpressionException (cbit.vcell.parser.ExpressionException)3