Search in sources :

Example 36 with Paragraph

use of com.lowagie.text.Paragraph in project OpenClinica by OpenClinica.

the class DownloadDiscrepancyNote method createTableThreadHeader.

private Table createTableThreadHeader(DiscrepancyNoteThread discNoteThread) throws BadElementException {
    Table table = new Table(2);
    table.setTableFitsPage(true);
    table.setCellsFitPage(true);
    table.setBorderWidth(1);
    table.setBorderColor(new java.awt.Color(0, 0, 0));
    table.setPadding(4);
    table.setSpacing(4);
    if (discNoteThread == null || discNoteThread.getLinkedNoteList().isEmpty()) {
        return table;
    }
    // Get information for the header; the resolution status, however, has to be the latest
    // resolution status for the DN thread
    DiscrepancyNoteBean dnBean = discNoteThread.getLinkedNoteList().getFirst();
    DiscrepancyNoteUtil discUtil = new DiscrepancyNoteUtil();
    String latestResolutionStatus = discUtil.getResolutionStatusName(discNoteThread.getLinkedNoteList().getFirst().getResolutionStatusId());
    StringBuilder content = new StringBuilder("");
    if (dnBean != null) {
        if (!"".equalsIgnoreCase(dnBean.getEntityName())) {
            content.append("Item field name/value: ");
            content.append(dnBean.getEntityName());
            if (!"".equalsIgnoreCase(dnBean.getEntityValue())) {
                content.append(" = ");
                content.append(dnBean.getEntityValue());
            }
        }
        Paragraph para = new Paragraph(content.toString(), new Font(Font.HELVETICA, 14, Font.BOLD, new Color(0, 0, 0)));
        Cell cell = new Cell(para);
        cell.setHeader(true);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        cell.setColspan(2);
        table.addCell(cell);
        table.endHeaders();
        // Add at least three more rows of data -- dnBean.getSubjectName()
        // row 1
        cell = createCell("Study Subject", dnBean.getSubjectName());
        table.addCell(cell);
        cell = createCell("Study Event", dnBean.getEventName());
        table.addCell(cell);
        // row 2
        cell = createCell("Study Event Date", dnBean.getEventStart() + "");
        table.addCell(cell);
        StringBuilder tmpStrBuilder = new StringBuilder("CRF: ");
        tmpStrBuilder.append(dnBean.getCrfName());
        tmpStrBuilder.append("\n");
        tmpStrBuilder.append("Status: ");
        tmpStrBuilder.append(dnBean.getCrfStatus());
        content.append(dnBean.getCrfName());
        cell = new Cell(new Paragraph(tmpStrBuilder.toString(), new Font(Font.HELVETICA, 14, Font.BOLD, new Color(0, 0, 0))));
        table.addCell(cell);
        // row 3
        cell = createCell("Type", discUtil.getResolutionStatusTypeName(dnBean.getDiscrepancyNoteTypeId()));
        table.addCell(cell);
        cell = createCell("Resolution Status", latestResolutionStatus);
        table.addCell(cell);
        cell = createCell("Number of notes", discNoteThread.getLinkedNoteList().size() + "");
        table.addCell(cell);
        cell = createCell("Discrepancy Note ID", dnBean.getId() + "");
        table.addCell(cell);
        cell = createCell("Days Open", dnBean.getAge() + "");
        table.addCell(cell);
        String daysSinceUpdated = escapeQuotesInCSV(dnBean.getDays() + "");
        cell = createCell("Days Since Updated", daysSinceUpdated.equals("0") ? "" : daysSinceUpdated + "");
        table.addCell(cell);
    }
    return table;
}
Also used : Color(java.awt.Color) Table(com.lowagie.text.Table) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) Color(java.awt.Color) DiscrepancyNoteUtil(org.akaza.openclinica.service.DiscrepancyNoteUtil) Cell(com.lowagie.text.Cell) Font(com.lowagie.text.Font) Paragraph(com.lowagie.text.Paragraph)

Example 37 with Paragraph

use of com.lowagie.text.Paragraph in project OpenClinica by OpenClinica.

the class DownloadDiscrepancyNote method serializeListToPDF.

public void serializeListToPDF(String content, OutputStream stream) {
    ServletOutputStream servletStream = (ServletOutputStream) stream;
    Document pdfDoc = new Document();
    try {
        PdfWriter.getInstance(pdfDoc, servletStream);
        pdfDoc.open();
        pdfDoc.add(new Paragraph(content));
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    pdfDoc.close();
}
Also used : ServletOutputStream(javax.servlet.ServletOutputStream) DocumentException(com.lowagie.text.DocumentException) Document(com.lowagie.text.Document) Paragraph(com.lowagie.text.Paragraph)

Example 38 with Paragraph

use of com.lowagie.text.Paragraph in project vcell by virtualcell.

the class PDFWriter method writeHorizontalLine.

/**
 * PDF implementation.
 */
protected void writeHorizontalLine() throws DocumentException {
    document.add(new Paragraph("\n"));
    Graphic graphic = new Graphic();
    graphic.setHorizontalLine(1, 75);
    document.add(graphic);
    document.add(new Paragraph("\n"));
}
Also used : Graphic(com.lowagie.text.Graphic) Paragraph(com.lowagie.text.Paragraph)

Example 39 with Paragraph

use of com.lowagie.text.Paragraph 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()));
    }
}
Also used : StructureTopology(cbit.vcell.model.Model.StructureTopology) Color(java.awt.Color) BaseFont(com.lowagie.text.pdf.BaseFont) Membrane(cbit.vcell.model.Membrane) Chunk(com.lowagie.text.Chunk) Cell(com.lowagie.text.Cell) Feature(cbit.vcell.model.Feature) BaseFont(com.lowagie.text.pdf.BaseFont) Font(com.lowagie.text.Font) DocumentException(com.lowagie.text.DocumentException) ExpressionException(cbit.vcell.parser.ExpressionException) Paragraph(com.lowagie.text.Paragraph)

Example 40 with Paragraph

use of com.lowagie.text.Paragraph in project vcell by virtualcell.

the class ITextWriter method writeGeom.

// Section used can be a chapter or a section of one, based on the document type.
protected void writeGeom(Section container, Geometry geom, GeometryContext geomCont) throws Exception {
    try {
        Section geomSection = container.addSection("Geometry: " + geom.getName(), container.numberDepth() + 1);
        if (geom.getDimension() == 0) {
            Paragraph p = new Paragraph(new Phrase("Non spatial geometry."));
            p.setAlignment(Paragraph.ALIGN_CENTER);
            geomSection.add(p);
            return;
        }
        ByteArrayOutputStream bos = generateGeometryImage(geom);
        com.lowagie.text.Image geomImage = com.lowagie.text.Image.getInstance(java.awt.Toolkit.getDefaultToolkit().createImage(bos.toByteArray()), null);
        geomImage.setAlignment(Table.ALIGN_LEFT);
        geomSection.add(geomImage);
        // addImage(geomSection, bos);
        Table geomTable = getTable(2, 50, 1, 2, 2);
        geomTable.setAlignment(Table.ALIGN_LEFT);
        Extent extent = geom.getExtent();
        String extentStr = "(" + extent.getX() + ", " + extent.getY() + ", " + extent.getZ() + ")";
        Origin origin = geom.getOrigin();
        String originStr = "(" + origin.getX() + ", " + origin.getY() + ", " + origin.getZ() + ")";
        geomTable.addCell(createCell("Size", getFont()));
        geomTable.addCell(createCell(extentStr, getFont()));
        geomTable.addCell(createCell("Origin", getFont()));
        geomTable.addCell(createCell(originStr, getFont()));
        geomSection.add(geomTable);
    } catch (Exception e) {
        System.err.println("Unable to add geometry image to report.");
        e.printStackTrace();
    }
}
Also used : Origin(org.vcell.util.Origin) Table(com.lowagie.text.Table) Extent(org.vcell.util.Extent) Phrase(com.lowagie.text.Phrase) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SimulationContext(cbit.vcell.mapping.SimulationContext) GeometryContext(cbit.vcell.mapping.GeometryContext) ReactionContext(cbit.vcell.mapping.ReactionContext) Section(com.lowagie.text.Section) DocumentException(com.lowagie.text.DocumentException) ExpressionException(cbit.vcell.parser.ExpressionException) 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