Example usage for com.lowagie.text.pdf PdfPCell PdfPCell

List of usage examples for com.lowagie.text.pdf PdfPCell PdfPCell

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfPCell PdfPCell.

Prototype

public PdfPCell() 

Source Link

Document

Constructs an empty PdfPCell.

Usage

From source file:org.jsondoc.springmvc.pdf.PdfExportView.java

License:Open Source License

public File getPdfFile(String filename) {
    try {//from  www  .j  a v a2 s .c om
        File file = new File(filename + "-v" + jsonDoc.getVersion() + FILE_EXTENSION);
        FileOutputStream fileout = new FileOutputStream(file);
        Document document = new Document();
        PdfWriter.getInstance(document, fileout);

        // Header
        HeaderFooter header = new HeaderFooter(new Phrase("Copyright "
                + Calendar.getInstance().get(Calendar.YEAR) + " Paybay Networks - All rights reserved"), false);
        header.setBorder(Rectangle.NO_BORDER);
        header.setAlignment(Element.ALIGN_LEFT);
        document.setHeader(header);

        // Footer
        HeaderFooter footer = new HeaderFooter(new Phrase("Page "), true);
        footer.setBorder(Rectangle.NO_BORDER);
        footer.setAlignment(Element.ALIGN_CENTER);
        document.setFooter(footer);

        document.open();

        //init documentation
        apiDocs = buildApiDocList();
        apiMethodDocs = buildApiMethodDocList(apiDocs);

        Phrase baseUrl = new Phrase("Base url: " + jsonDoc.getBasePath());
        document.add(baseUrl);
        document.add(Chunk.NEWLINE);
        document.add(Chunk.NEWLINE);

        int pos = 1;
        for (ApiMethodDoc apiMethodDoc : apiMethodDocs) {
            Phrase phrase = new Phrase(/*"Description: " + */apiMethodDoc.getDescription());
            document.add(phrase);
            document.add(Chunk.NEWLINE);

            PdfPTable table = new PdfPTable(2);
            table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
            table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
            table.setWidthPercentage(100);

            table.setWidths(new int[] { 50, 200 });

            // HEADER CELL START TABLE
            table.addCell(ITextUtils.getHeaderCell("URL"));
            table.addCell(ITextUtils.getHeaderCell("<baseUrl> " + apiMethodDoc.getPath()));
            table.completeRow();

            // FIRST CELL
            table.addCell(ITextUtils.getCell("Http Method", 0));
            table.addCell(ITextUtils.getCell(apiMethodDoc.getVerb().name(), pos));
            pos++;
            table.completeRow();

            // PRODUCES
            if (!apiMethodDoc.getProduces().isEmpty()) {
                table.addCell(ITextUtils.getCell("Produces", 0));
                table.addCell(ITextUtils.getCell(buildApiMethodProduces(apiMethodDoc), pos));
                pos++;
                table.completeRow();
            }

            // CONSUMES
            if (!apiMethodDoc.getConsumes().isEmpty()) {
                table.addCell(ITextUtils.getCell("Consumes", 0));
                table.addCell(ITextUtils.getCell(buildApiMethodConsumes(apiMethodDoc), pos));
                pos++;
                table.completeRow();
            }

            // HEADERS
            if (!apiMethodDoc.getHeaders().isEmpty()) {
                table.addCell(ITextUtils.getCell("Request headers", 0));

                PdfPTable pathParamsTable = new PdfPTable(3);
                pathParamsTable.setWidths(new int[] { 30, 20, 40 });

                pathParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                pathParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

                for (ApiHeaderDoc apiHeaderDoc : apiMethodDoc.getHeaders()) {
                    PdfPCell boldCell = new PdfPCell();
                    Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD);
                    boldCell.setPhrase(new Phrase(apiHeaderDoc.getName(), fontbold));
                    boldCell.getPhrase().setFont(new Font(Font.BOLD));
                    boldCell.setBorder(Rectangle.NO_BORDER);
                    pathParamsTable.addCell(boldCell);

                    PdfPCell paramCell = new PdfPCell();

                    StringBuilder builder = new StringBuilder();

                    for (String value : apiHeaderDoc.getAllowedvalues())
                        builder.append(value).append(", ");

                    paramCell.setPhrase(new Phrase("Allowed values: " + builder.toString()));
                    paramCell.setBorder(Rectangle.NO_BORDER);

                    pathParamsTable.addCell(paramCell);

                    paramCell.setPhrase(new Phrase(apiHeaderDoc.getDescription()));

                    pathParamsTable.addCell(paramCell);
                    pathParamsTable.completeRow();
                }

                PdfPCell bluBorderCell = new PdfPCell(pathParamsTable);
                bluBorderCell.setBorder(Rectangle.NO_BORDER);
                bluBorderCell.setBorderWidthRight(1f);
                bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR);

                table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos));
                pos++;
                table.completeRow();
            }

            // PATH PARAMS
            if (!apiMethodDoc.getPathparameters().isEmpty()) {
                table.addCell(ITextUtils.getCell("Path params", 0));

                PdfPTable pathParamsTable = new PdfPTable(3);
                pathParamsTable.setWidths(new int[] { 30, 15, 40 });

                pathParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                pathParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

                for (ApiParamDoc apiParamDoc : apiMethodDoc.getPathparameters()) {
                    PdfPCell boldCell = new PdfPCell();
                    Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD);
                    boldCell.setPhrase(new Phrase(apiParamDoc.getName(), fontbold));
                    boldCell.getPhrase().setFont(new Font(Font.BOLD));
                    boldCell.setBorder(Rectangle.NO_BORDER);
                    pathParamsTable.addCell(boldCell);

                    PdfPCell paramCell = new PdfPCell();
                    paramCell.setPhrase(new Phrase(apiParamDoc.getJsondocType().getOneLineText()));
                    paramCell.setBorder(Rectangle.NO_BORDER);

                    pathParamsTable.addCell(paramCell);

                    paramCell.setPhrase(new Phrase(apiParamDoc.getDescription()));

                    pathParamsTable.addCell(paramCell);
                    pathParamsTable.completeRow();
                }

                PdfPCell bluBorderCell = new PdfPCell(pathParamsTable);
                bluBorderCell.setBorder(Rectangle.NO_BORDER);
                bluBorderCell.setBorderWidthRight(1f);
                bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR);

                table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos));
                pos++;
                table.completeRow();
            }

            // QUERY PARAMS
            if (!apiMethodDoc.getQueryparameters().isEmpty()) {
                table.addCell(ITextUtils.getCell("Query params", 0));

                PdfPTable queryParamsTable = new PdfPTable(3);
                queryParamsTable.setWidths(new int[] { 30, 15, 40 });

                queryParamsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
                queryParamsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

                for (ApiParamDoc apiParamDoc : apiMethodDoc.getQueryparameters()) {
                    PdfPCell boldCell = new PdfPCell();
                    Font fontbold = FontFactory.getFont("Times-Roman", 12, Font.BOLD);
                    boldCell.setPhrase(new Phrase(apiParamDoc.getName(), fontbold));
                    boldCell.getPhrase().setFont(new Font(Font.BOLD));
                    boldCell.setBorder(Rectangle.NO_BORDER);
                    queryParamsTable.addCell(boldCell);

                    PdfPCell paramCell = new PdfPCell();
                    paramCell.setPhrase(new Phrase(apiParamDoc.getJsondocType().getOneLineText()));
                    paramCell.setBorder(Rectangle.NO_BORDER);

                    queryParamsTable.addCell(paramCell);

                    paramCell.setPhrase(new Phrase(
                            apiParamDoc.getDescription() + ", mandatory: " + apiParamDoc.getRequired()));

                    queryParamsTable.addCell(paramCell);
                    queryParamsTable.completeRow();
                }

                PdfPCell bluBorderCell = new PdfPCell(queryParamsTable);
                bluBorderCell.setBorder(Rectangle.NO_BORDER);
                bluBorderCell.setBorderWidthRight(1f);
                bluBorderCell.setBorderColorRight(Colors.CELL_BORDER_COLOR);

                table.addCell(ITextUtils.setOddEvenStyle(bluBorderCell, pos));
                pos++;
                table.completeRow();
            }

            // BODY OBJECT
            if (null != apiMethodDoc.getBodyobject()) {
                table.addCell(ITextUtils.getCell("Body object:", 0));
                String jsonObject = buildJsonFromTemplate(apiMethodDoc.getBodyobject().getJsondocTemplate());
                table.addCell(ITextUtils.getCell(jsonObject, pos));
                pos++;
                table.completeRow();
            }

            // RESPONSE OBJECT
            table.addCell(ITextUtils.getCell("Json response:", 0));
            table.addCell(
                    ITextUtils.getCell(apiMethodDoc.getResponse().getJsondocType().getOneLineText(), pos));
            pos++;
            table.completeRow();

            // RESPONSE STATUS CODE
            table.addCell(ITextUtils.getCell("Status code:", 0));
            table.addCell(ITextUtils.getCell(apiMethodDoc.getResponsestatuscode(), pos));
            pos++;
            table.completeRow();

            table.setSpacingAfter(10f);
            table.setSpacingBefore(5f);
            document.add(table);
        }

        document.close();
        return file;
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:org.kuali.kfs.module.ar.report.service.impl.ContractsGrantsInvoiceReportServiceImpl.java

License:Open Source License

/**
 * this method generated the actual pdf for the Contracts & Grants LOC Review Document.
 *
 * @param os/*  ww  w.  j  a  v a 2 s . c  o m*/
 * @param LOCDocument
 */
protected void generateLOCReviewInPdf(OutputStream os,
        ContractsGrantsLetterOfCreditReviewDocument locDocument) {
    try {
        Document document = new Document(
                new Rectangle(ArConstants.LOCReviewPdf.LENGTH, ArConstants.LOCReviewPdf.WIDTH));
        PdfWriter.getInstance(document, os);
        document.open();

        Paragraph header = new Paragraph();
        Paragraph text = new Paragraph();
        Paragraph title = new Paragraph();

        // Lets write the header
        header.add(new Paragraph(configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_TITLE),
                ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT));
        if (StringUtils.isNotEmpty(locDocument.getLetterOfCreditFundGroupCode())) {
            header.add(new Paragraph(
                    configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_FUND_GROUP_CODE)
                            + locDocument.getLetterOfCreditFundGroupCode(),
                    ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT));
        }
        if (StringUtils.isNotEmpty(locDocument.getLetterOfCreditFundCode())) {
            header.add(new Paragraph(
                    configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_FUND_CODE)
                            + locDocument.getLetterOfCreditFundCode(),
                    ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT));
        }
        header.add(new Paragraph(KFSConstants.BLANK_SPACE));
        header.setAlignment(Element.ALIGN_CENTER);
        title.add(new Paragraph(
                configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_NUMBER)
                        + locDocument.getDocumentNumber(),
                ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));
        Person person = getPersonService()
                .getPerson(locDocument.getFinancialSystemDocumentHeader().getInitiatorPrincipalId());
        // writing the Document details
        title.add(new Paragraph(
                configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_APP_DOC_STATUS)
                        + locDocument.getFinancialSystemDocumentHeader().getApplicationDocumentStatus(),
                ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));
        title.add(
                new Paragraph(
                        configService.getPropertyValueAsString(
                                ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_INITIATOR) + person.getName(),
                        ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));
        title.add(new Paragraph(
                configService
                        .getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_CREATE_DATE)
                        + getDateTimeService().toDateString(
                                locDocument.getFinancialSystemDocumentHeader().getWorkflowCreateDate()),
                ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT));

        title.add(new Paragraph(KFSConstants.BLANK_SPACE));
        title.setAlignment(Element.ALIGN_RIGHT);

        text.add(new Paragraph(
                configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_SUBHEADER_AWARDS),
                ArConstants.PdfReportFonts.LOC_REVIEW_SMALL_BOLD));
        text.add(new Paragraph(KFSConstants.BLANK_SPACE));

        document.add(header);
        document.add(title);
        document.add(text);
        PdfPTable table = new PdfPTable(11);
        table.setTotalWidth(ArConstants.LOCReviewPdf.RESULTS_TABLE_WIDTH);
        // fix the absolute width of the table
        table.setLockedWidth(true);

        // relative col widths in proportions - 1/11
        float[] widths = new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f };
        table.setWidths(widths);
        table.setHorizontalAlignment(0);
        addAwardHeaders(table);
        if (CollectionUtils.isNotEmpty(locDocument.getHeaderReviewDetails())
                && CollectionUtils.isNotEmpty(locDocument.getAccountReviewDetails())) {
            for (ContractsGrantsLetterOfCreditReviewDetail item : locDocument.getHeaderReviewDetails()) {
                table.addCell(Long.toString(item.getProposalNumber()));
                table.addCell(item.getAwardDocumentNumber());
                table.addCell(item.getAgencyNumber());
                table.addCell(item.getCustomerNumber());
                table.addCell(getDateTimeService().toDateString(item.getAwardBeginningDate()));
                table.addCell(getDateTimeService().toDateString(item.getAwardEndingDate()));
                table.addCell(
                        contractsGrantsBillingUtilityService.formatForCurrency(item.getAwardBudgetAmount()));
                table.addCell(
                        contractsGrantsBillingUtilityService.formatForCurrency(item.getLetterOfCreditAmount()));
                table.addCell(
                        contractsGrantsBillingUtilityService.formatForCurrency(item.getClaimOnCashBalance()));
                table.addCell(contractsGrantsBillingUtilityService.formatForCurrency(item.getAmountToDraw()));
                table.addCell(contractsGrantsBillingUtilityService
                        .formatForCurrency(item.getAmountAvailableToDraw()));

                PdfPCell cell = new PdfPCell();
                cell.setPadding(ArConstants.LOCReviewPdf.RESULTS_TABLE_CELL_PADDING);
                cell.setColspan(ArConstants.LOCReviewPdf.RESULTS_TABLE_COLSPAN);
                PdfPTable newTable = new PdfPTable(ArConstants.LOCReviewPdf.INNER_TABLE_COLUMNS);
                newTable.setTotalWidth(ArConstants.LOCReviewPdf.INNER_TABLE_WIDTH);
                // fix the absolute width of the newTable
                newTable.setLockedWidth(true);

                // relative col widths in proportions - 1/8
                float[] newWidths = new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f };
                newTable.setWidths(newWidths);
                newTable.setHorizontalAlignment(0);
                addAccountsHeaders(newTable);
                for (ContractsGrantsLetterOfCreditReviewDetail newItem : locDocument
                        .getAccountReviewDetails()) {
                    if (item.getProposalNumber().equals(newItem.getProposalNumber())) {
                        newTable.addCell(newItem.getAccountDescription());
                        newTable.addCell(newItem.getChartOfAccountsCode());
                        newTable.addCell(newItem.getAccountNumber());
                        String accountExpirationDate = KFSConstants.EMPTY_STRING;
                        if (!ObjectUtils.isNull(newItem.getAccountExpirationDate())) {
                            accountExpirationDate = getDateTimeService()
                                    .toDateString(newItem.getAccountExpirationDate());
                        }
                        newTable.addCell(accountExpirationDate);
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getAwardBudgetAmount()));
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getClaimOnCashBalance()));
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getAmountToDraw()));
                        newTable.addCell(contractsGrantsBillingUtilityService
                                .formatForCurrency(newItem.getFundsNotDrawn()));
                    }
                }
                cell.addElement(newTable);
                table.addCell(cell);

            }
            document.add(table);
        }
        document.close();
    } catch (DocumentException e) {
        LOG.error("problem during ContractsGrantsInvoiceReportServiceImpl.generateInvoiceInPdf()", e);
    }
}

From source file:org.mapfish.print.PDFUtils.java

License:Open Source License

/**
 * When we have to do some custom drawing in a block that is layed out by
 * iText, we first give an empty table with the good dimensions to iText,
 * then iText will call a callback with the actual position. When that
 * happens, we use the given drawer to do the actual drawing.
 *//*from   ww  w.  j  av  a  2  s . co m*/
public static PdfPTable createPlaceholderTable(double width, double height, double spacingAfter,
        ChunkDrawer drawer, HorizontalAlign align, PDFCustomBlocks customBlocks) {
    PdfPTable placeHolderTable = new PdfPTable(1);
    placeHolderTable.setLockedWidth(true);
    placeHolderTable.setTotalWidth((float) width);
    final PdfPCell placeHolderCell = new PdfPCell();
    placeHolderCell.setMinimumHeight((float) height);
    placeHolderCell.setPadding(0f);
    placeHolderCell.setBorder(PdfPCell.NO_BORDER);
    placeHolderTable.addCell(placeHolderCell);
    customBlocks.addChunkDrawer(drawer);
    placeHolderTable.setTableEvent(drawer);
    placeHolderTable.setComplete(true);

    final PdfPCell surroundingCell = new PdfPCell(placeHolderTable);
    surroundingCell.setPadding(0f);
    surroundingCell.setBorder(PdfPCell.NO_BORDER);
    if (align != null) {
        placeHolderTable.setHorizontalAlignment(align.getCode());
        surroundingCell.setHorizontalAlignment(align.getCode());
    }

    PdfPTable surroundingTable = new PdfPTable(1);
    surroundingTable.setSpacingAfter((float) spacingAfter);
    surroundingTable.addCell(surroundingCell);
    surroundingTable.setComplete(true);

    return surroundingTable;
}

From source file:org.odftoolkit.odfdom.converter.internal.itext.stylable.StylableParagraph.java

License:Open Source License

private PdfPCell createCell() {
    PdfPCell cell = new PdfPCell();
    cell.setBorder(Table.NO_BORDER);//from  w  w  w  .j a v  a  2  s  . c o  m
    cell.setPadding(0.0f);
    cell.setUseBorderPadding(true);
    cell.getColumn().setAdjustFirstLine(false);
    cell.setUseDescender(true);
    return cell;
}

From source file:org.oscarehr.web.reports.ocan.IndividualNeedRatingOverTimeReportGenerator.java

License:Open Source License

private PdfPCell makeCell(Phrase phrase, int alignment) {
    PdfPCell c2 = new PdfPCell();
    c2.setPhrase(phrase);//  w w w. j  a v a  2  s .  c  om
    c2.setHorizontalAlignment(alignment);
    c2.setBorder(0);
    return c2;
}

From source file:org.oscarehr.web.reports.ocan.NeedRatingOverTimeReportGenerator.java

License:Open Source License

private void addSummaryOfNeedsHeader(PdfPTable summaryOfNeedsTable,
        List<OcanNeedRatingOverTimeSummaryOfNeedsBean> currentBeanList, int loopNo) {

    PdfPCell headerCell = new PdfPCell();
    headerCell.setPhrase(new Phrase("Summary of Needs" + (loopNo > 1 ? " (Contd.)" : ""),
            new Font(Font.HELVETICA, 20, Font.BOLD)));

    headerCell.setColspan(currentBeanList.size() * 3);
    headerCell.setVerticalAlignment(Element.ALIGN_TOP);
    headerCell.setBorder(0);/* w  w  w  .jav  a  2s  . co  m*/
    headerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    summaryOfNeedsTable.addCell(headerCell);

    Font f = new Font(Font.HELVETICA, 14, Font.BOLD, Color.WHITE);
    //row1
    PdfPCell c2 = null;

    c2 = new PdfPCell();
    c2.setBorder(0);
    summaryOfNeedsTable.addCell(c2);
    if (currentBeanList.size() > 0) {
        c2 = new PdfPCell();
        c2.setColspan(2);
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase(currentBeanList.get(0).getOcanName() + "\n"
                + dateFormatter.format(currentBeanList.get(0).getOcanDate()), f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }
    if (currentBeanList.size() > 1) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setColspan(2);
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase(currentBeanList.get(1).getOcanName() + "\n"
                + dateFormatter.format(currentBeanList.get(1).getOcanDate()), f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }
    if (currentBeanList.size() > 2) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setColspan(2);
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase(currentBeanList.get(2).getOcanName() + "\n"
                + dateFormatter.format(currentBeanList.get(2).getOcanDate()), f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }

    //row2
    c2 = new PdfPCell();
    c2.setBorder(0);
    summaryOfNeedsTable.addCell(c2);

    if (currentBeanList.size() > 0) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase("Consumer", f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase("Staff", f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }
    if (currentBeanList.size() > 1) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase("Consumer", f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase("Staff", f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }
    if (currentBeanList.size() > 2) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase("Consumer", f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase("Staff", f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }
}

From source file:org.oscarehr.web.reports.ocan.NeedRatingOverTimeReportGenerator.java

License:Open Source License

private void addSummaryOfNeedsDomainHeader(PdfPTable summaryOfNeedsTable,
        List<OcanNeedRatingOverTimeNeedBreakdownBean> currentBeanList, int loopNo) {

    Font f = new Font(Font.HELVETICA, 14, Font.BOLD, Color.WHITE);
    //row1//from w  w  w  .ja v  a 2  s  .  c  o m
    PdfPCell c2 = null;

    c2 = new PdfPCell();
    c2.setBorder(0);
    summaryOfNeedsTable.addCell(c2);

    if (loopNo > 1) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        summaryOfNeedsTable.addCell(c2);
    }

    if (currentBeanList.size() > 0) {
        c2 = new PdfPCell();
        c2.setColspan(2);
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase(currentBeanList.get(0).getOcanName() + "\n"
                + dateFormatter.format(currentBeanList.get(0).getOcanDate()), f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }
    if (currentBeanList.size() > 1) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setColspan(2);
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase(currentBeanList.get(1).getOcanName() + "\n"
                + dateFormatter.format(currentBeanList.get(1).getOcanDate()), f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }
    if (currentBeanList.size() > 2) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setColspan(2);
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase(currentBeanList.get(2).getOcanName() + "\n"
                + dateFormatter.format(currentBeanList.get(2).getOcanDate()), f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }

    //row2
    c2 = new PdfPCell();
    c2.setBackgroundColor(Color.BLUE);
    c2.setPhrase(new Phrase("Domains", f));
    c2.setHorizontalAlignment(Element.ALIGN_CENTER);
    summaryOfNeedsTable.addCell(c2);

    if (loopNo > 1) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        summaryOfNeedsTable.addCell(c2);
    }

    if (currentBeanList.size() > 0) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase("Consumer", f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase("Staff", f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }
    if (currentBeanList.size() > 1) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase("Consumer", f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase("Staff", f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }
    if (currentBeanList.size() > 2) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase("Consumer", f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLUE);
        c2.setPhrase(new Phrase("Staff", f));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }

}

From source file:org.oscarehr.web.reports.ocan.NeedRatingOverTimeReportGenerator.java

License:Open Source License

private void addSummaryOfNeedsRow(PdfPTable summaryOfNeedsTable, String needType, String needTypeKey,
        List<OcanNeedRatingOverTimeSummaryOfNeedsBean> currentBeanList) {
    //row3//  w  w  w  . jav a2  s.  c o m
    PdfPCell c2 = new PdfPCell();
    c2.setBackgroundColor(Color.BLUE);
    c2.setPhrase(new Phrase(needType, new Font(Font.HELVETICA, 14, Font.BOLD, Color.WHITE)));
    summaryOfNeedsTable.addCell(c2);

    if (currentBeanList.size() > 0) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.GREEN);
        c2.setPhrase(new Phrase(String.valueOf(currentBeanList.get(0).getConsumerNeedMap().get(needTypeKey)),
                new Font(Font.HELVETICA, 14, Font.BOLD)));
        c2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.LIGHT_GRAY);
        c2.setPhrase(new Phrase(String.valueOf(currentBeanList.get(0).getStaffNeedMap().get(needTypeKey)),
                new Font(Font.HELVETICA, 14, Font.BOLD)));
        c2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        summaryOfNeedsTable.addCell(c2);
    }
    if (currentBeanList.size() > 1) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.GREEN);
        c2.setPhrase(new Phrase(String.valueOf(currentBeanList.get(1).getConsumerNeedMap().get(needTypeKey)),
                new Font(Font.HELVETICA, 14, Font.BOLD)));
        c2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.LIGHT_GRAY);
        c2.setPhrase(new Phrase(String.valueOf(currentBeanList.get(1).getStaffNeedMap().get(needTypeKey)),
                new Font(Font.HELVETICA, 14, Font.BOLD)));
        c2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        summaryOfNeedsTable.addCell(c2);
    }
    if (currentBeanList.size() > 2) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.GREEN);
        c2.setPhrase(new Phrase(String.valueOf(currentBeanList.get(2).getConsumerNeedMap().get(needTypeKey)),
                new Font(Font.HELVETICA, 14, Font.BOLD)));
        c2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.LIGHT_GRAY);
        c2.setPhrase(new Phrase(String.valueOf(currentBeanList.get(2).getStaffNeedMap().get(needTypeKey)),
                new Font(Font.HELVETICA, 14, Font.BOLD)));
        c2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        summaryOfNeedsTable.addCell(c2);
    }

}

From source file:org.oscarehr.web.reports.ocan.NeedRatingOverTimeReportGenerator.java

License:Open Source License

private void addSummaryOfNeedsDomainRow(PdfPTable summaryOfNeedsTable, int rowNum, List<String> domains,
        List<OcanNeedRatingOverTimeNeedBreakdownBean> ocans,
        OcanNeedRatingOverTimeNeedBreakdownBean lastBreakDownBean) {

    PdfPCell c2 = new PdfPCell();
    c2.setBackgroundColor(Color.BLUE);
    c2.setPhrase(new Phrase(domains.get(rowNum), new Font(Font.HELVETICA, 14, Font.BOLD, Color.WHITE)));
    summaryOfNeedsTable.addCell(c2);//ww w .  j  a  va 2 s  .  co  m

    if (lastBreakDownBean != null) {
        boolean checkmark = false;
        if (!ocans.get(0).getNeeds().get(rowNum).getConsumerNeed()
                .equals(lastBreakDownBean.getNeeds().get(rowNum).getConsumerNeed())) {
            checkmark = true;
        }
        if (!ocans.get(0).getNeeds().get(rowNum).getStaffNeed()
                .equals(lastBreakDownBean.getNeeds().get(rowNum).getStaffNeed())) {
            checkmark = true;
        }
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        if (checkmark) {
            c2.setPhrase(new Phrase("X", new Font(Font.HELVETICA, 14, Font.BOLD, Color.WHITE)));
        }
        summaryOfNeedsTable.addCell(c2);
    }

    if (ocans.size() > 0) {
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.GREEN);
        c2.setPhrase(new Phrase(ocans.get(0).getNeeds().get(rowNum).getConsumerNeed(),
                new Font(Font.HELVETICA, 14,
                        (ocans.get(0).getNeeds().get(rowNum).getConsumerNeed().equals("Unmet Need") ? Font.BOLD
                                : Font.NORMAL),
                        (ocans.get(0).getNeeds().get(rowNum).getConsumerNeed().equals("Unmet Need") ? Color.RED
                                : Color.BLACK))));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.LIGHT_GRAY);
        c2.setPhrase(new Phrase(ocans.get(0).getNeeds().get(rowNum).getStaffNeed(),
                new Font(Font.HELVETICA, 14,
                        (ocans.get(0).getNeeds().get(rowNum).getStaffNeed().equals("Unmet Need") ? Font.BOLD
                                : Font.NORMAL),
                        (ocans.get(0).getNeeds().get(rowNum).getStaffNeed().equals("Unmet Need") ? Color.RED
                                : Color.BLACK))));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }
    if (ocans.size() > 1) {
        boolean checkmark = false;
        if (!ocans.get(1).getNeeds().get(rowNum).getConsumerNeed()
                .equals((ocans.get(0).getNeeds().get(rowNum).getConsumerNeed()))) {
            checkmark = true;
        }
        if (!ocans.get(1).getNeeds().get(rowNum).getStaffNeed()
                .equals((ocans.get(0).getNeeds().get(rowNum).getStaffNeed()))) {
            checkmark = true;
        }
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        if (checkmark) {
            c2.setPhrase(new Phrase("X", new Font(Font.HELVETICA, 14, Font.BOLD, Color.WHITE)));
        }
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.GREEN);
        c2.setPhrase(new Phrase(ocans.get(1).getNeeds().get(rowNum).getConsumerNeed(),
                new Font(Font.HELVETICA, 14,
                        (ocans.get(1).getNeeds().get(rowNum).getConsumerNeed().equals("Unmet Need") ? Font.BOLD
                                : Font.NORMAL),
                        (ocans.get(1).getNeeds().get(rowNum).getConsumerNeed().equals("Unmet Need") ? Color.RED
                                : Color.BLACK))));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.LIGHT_GRAY);
        c2.setPhrase(new Phrase(ocans.get(1).getNeeds().get(rowNum).getStaffNeed(),
                new Font(Font.HELVETICA, 14,
                        (ocans.get(1).getNeeds().get(rowNum).getStaffNeed().equals("Unmet Need") ? Font.BOLD
                                : Font.NORMAL),
                        (ocans.get(1).getNeeds().get(rowNum).getStaffNeed().equals("Unmet Need") ? Color.RED
                                : Color.BLACK))));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }
    if (ocans.size() > 2) {
        boolean checkmark = false;
        if (!ocans.get(2).getNeeds().get(rowNum).getConsumerNeed()
                .equals((ocans.get(1).getNeeds().get(rowNum).getConsumerNeed()))) {
            checkmark = true;
        }
        if (!ocans.get(2).getNeeds().get(rowNum).getStaffNeed()
                .equals((ocans.get(1).getNeeds().get(rowNum).getStaffNeed()))) {
            checkmark = true;
        }
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.BLACK);
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        if (checkmark) {
            c2.setPhrase(new Phrase("X", new Font(Font.HELVETICA, 14, Font.BOLD, Color.WHITE)));
        }
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.GREEN);
        c2.setPhrase(new Phrase(ocans.get(2).getNeeds().get(rowNum).getConsumerNeed(),
                new Font(Font.HELVETICA, 14,
                        (ocans.get(2).getNeeds().get(rowNum).getConsumerNeed().equals("Unmet Need") ? Font.BOLD
                                : Font.NORMAL),
                        (ocans.get(2).getNeeds().get(rowNum).getConsumerNeed().equals("Unmet Need") ? Color.RED
                                : Color.BLACK))));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
        c2 = new PdfPCell();
        c2.setBackgroundColor(Color.LIGHT_GRAY);
        c2.setPhrase(new Phrase(ocans.get(2).getNeeds().get(rowNum).getStaffNeed(),
                new Font(Font.HELVETICA, 14,
                        (ocans.get(2).getNeeds().get(rowNum).getStaffNeed().equals("Unmet Need") ? Font.BOLD
                                : Font.NORMAL),
                        (ocans.get(2).getNeeds().get(rowNum).getStaffNeed().equals("Unmet Need") ? Color.RED
                                : Color.BLACK))));
        c2.setHorizontalAlignment(Element.ALIGN_CENTER);
        summaryOfNeedsTable.addCell(c2);
    }

}

From source file:org.oscarehr.web.reports.ocan.SummaryOfActionsAndCommentsReportGenerator.java

License:Open Source License

private void createOcanEntry(PdfPTable table, SummaryOfActionsAndCommentsOCANBean ocanBean) {
    Font f = new Font(Font.HELVETICA, 12, Font.BOLD, Color.BLACK);
    //header//from  w  w  w. j a  v a  2s .co m
    PdfPCell c1 = new PdfPCell();
    c1.setBackgroundColor(Color.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setPhrase(new Phrase("Rating", f));
    table.addCell(c1);
    c1 = new PdfPCell();
    c1.setColspan(2);
    c1.setBackgroundColor(Color.LIGHT_GRAY);
    c1.setPhrase(new Phrase(ocanBean.getOcanName() + " - " + dateFormatter.format(ocanBean.getOcanDate()), f));
    table.addCell(c1);

    //actions
    c1 = new PdfPCell();
    c1.setBackgroundColor(Color.LIGHT_GRAY);
    c1.setBorderWidthBottom(0);
    table.addCell(c1);
    c1 = new PdfPCell();
    c1.setColspan(1);
    c1.setBackgroundColor(Color.LIGHT_GRAY);
    c1.setPhrase(new Phrase("Actions", f));
    table.addCell(c1);
    c1 = new PdfPCell();
    c1.setColspan(1);
    c1.setPhrase(new Phrase(ocanBean.getActions(), normalText));
    table.addCell(c1);

    //By Whom
    c1 = new PdfPCell();
    c1.setBackgroundColor(Color.LIGHT_GRAY);
    c1.setBorderWidthBottom(0);
    table.addCell(c1);
    c1 = new PdfPCell();
    c1.setColspan(1);
    c1.setBackgroundColor(Color.LIGHT_GRAY);
    c1.setPhrase(new Phrase("By Whom", f));
    table.addCell(c1);
    c1 = new PdfPCell();
    c1.setColspan(1);
    c1.setPhrase(new Phrase(ocanBean.getByWhom(), normalText));
    table.addCell(c1);

    //review date
    c1 = new PdfPCell();
    c1.setBackgroundColor(Color.LIGHT_GRAY);
    c1.setBorderWidthBottom(0);
    table.addCell(c1);
    c1 = new PdfPCell();
    c1.setColspan(1);
    c1.setBackgroundColor(Color.LIGHT_GRAY);
    c1.setPhrase(new Phrase("Review Date", f));
    table.addCell(c1);
    c1 = new PdfPCell();
    c1.setColspan(1);
    c1.setPhrase(new Phrase(ocanBean.getReviewDate(), normalText));
    table.addCell(c1);

    //consumer
    c1 = new PdfPCell();
    c1.setBackgroundColor(Color.LIGHT_GRAY);
    c1.setPhrase(new Phrase(convertNeedToWord(ocanBean.getConsumerNeedRating()), boldText));
    table.addCell(c1);
    c1 = new PdfPCell();
    c1.setColspan(1);
    c1.setBackgroundColor(Color.LIGHT_GRAY);
    c1.setPhrase(new Phrase("Consumer Comments", f));
    table.addCell(c1);
    c1 = new PdfPCell();
    c1.setColspan(1);
    c1.setPhrase(new Phrase(includeComments ? ocanBean.getConsumerComments() : "", normalText));
    table.addCell(c1);

    //staff
    c1 = new PdfPCell();
    c1.setBackgroundColor(Color.LIGHT_GRAY);
    c1.setPhrase(new Phrase(convertNeedToWord(ocanBean.getStaffNeedRating()), boldText));
    table.addCell(c1);
    c1 = new PdfPCell();
    c1.setColspan(1);
    c1.setBackgroundColor(Color.LIGHT_GRAY);
    c1.setPhrase(new Phrase("Staff Comments", f));
    table.addCell(c1);
    c1 = new PdfPCell();
    c1.setColspan(1);
    c1.setPhrase(new Phrase(includeComments ? ocanBean.getStaffComments() : "", normalText));
    table.addCell(c1);
}