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

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

Introduction

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

Prototype

public void setHorizontalAlignment(int horizontalAlignment) 

Source Link

Document

Sets the horizontal alignment for the cell.

Usage

From source file:org.opentestsystem.delivery.testreg.rest.view.PDFReportView.java

License:Open Source License

private PdfPTable createMessageHeaders(final String[] headerColumns, final HierarchyLevel level,
        final String message) throws BadElementException {
    PdfPTable table = null;/*www  . java 2  s . com*/
    if (level != null && level == HierarchyLevel.CLIENT) {
        table = new PdfPTable(headerColumns.length - 3);
    } else {
        table = new PdfPTable(headerColumns.length);
    }
    table.setWidthPercentage(100);
    PdfPCell cell;
    cell = new PdfPCell(new Paragraph(message, HEADER_MESSAGE_FONT));
    cell.setColspan(headerColumns.length);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(Rectangle.NO_BORDER);
    table.addCell(cell);
    return table;
}

From source file:org.oscarehr.casemgmt.print.OscarChartPrinter.java

License:Open Source License

public void printDocHeaderFooter() throws DocumentException {
    String headerTitle = demographic.getFormattedName() + " " + demographic.getAge() + " "
            + demographic.getSex() + " DOB:" + demographic.getFormattedDob();

    //set up document title and header
    ResourceBundle propResource = ResourceBundle.getBundle("oscarResources");
    String title = propResource.getString("oscarEncounter.pdfPrint.title") + " "
            + (String) request.getAttribute("demoName") + "\n";
    String gender = propResource.getString("oscarEncounter.pdfPrint.gender") + " "
            + (String) request.getAttribute("demoSex") + "\n";
    String dob = propResource.getString("oscarEncounter.pdfPrint.dob") + " "
            + (String) request.getAttribute("demoDOB") + "\n";
    String age = propResource.getString("oscarEncounter.pdfPrint.age") + " "
            + (String) request.getAttribute("demoAge") + "\n";
    String mrp = propResource.getString("oscarEncounter.pdfPrint.mrp") + " "
            + (String) request.getAttribute("mrp") + "\n";
    String[] info = new String[] { title, gender, dob, age, mrp };

    ClinicData clinicData = new ClinicData();
    clinicData.refreshClinicData();//from   ww w  . j a  v  a  2 s . com
    String[] clinic = new String[] { clinicData.getClinicName(), clinicData.getClinicAddress(),
            clinicData.getClinicCity() + ", " + clinicData.getClinicProvince(), clinicData.getClinicPostal(),
            clinicData.getClinicPhone() };

    if (newPage) {
        document.newPage();
        newPage = false;
    }

    //Header will be printed at top of every page beginning with p2
    Phrase headerPhrase = new Phrase(LEADING, headerTitle, boldFont);
    HeaderFooter header = new HeaderFooter(headerPhrase, false);
    header.setAlignment(HeaderFooter.ALIGN_CENTER);
    document.setHeader(header);

    getDocument().add(headerPhrase);
    getDocument().add(new Phrase("\n"));

    Paragraph p = new Paragraph("Tel:" + demographic.getPhone(), getFont());
    p.setAlignment(Paragraph.ALIGN_LEFT);
    // getDocument().add(p);

    Paragraph p2 = new Paragraph("Date of Visit: ", getFont());
    p2.setAlignment(Paragraph.ALIGN_RIGHT);
    // getDocument().add(p);

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100f);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    PdfPCell cell1 = new PdfPCell(p);
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    PdfPCell cell2 = new PdfPCell(p2);
    cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell2.setBorder(PdfPCell.NO_BORDER);
    table.addCell(cell1);
    table.addCell(cell2);

    getDocument().add(table);

    table = new PdfPTable(3);
    table.setWidthPercentage(100f);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    cell1 = new PdfPCell(getParagraph("Signed Provider:" + ((signingProvider != null) ? signingProvider : "")));
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2 = new PdfPCell(getParagraph("RFR:"));
    cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell2.setBorder(PdfPCell.NO_BORDER);
    PdfPCell cell3 = new PdfPCell(getParagraph("Ref:"));
    cell3.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell3.setBorder(PdfPCell.NO_BORDER);
    table.addCell(cell1);
    table.addCell(cell2);
    table.addCell(cell3);

    getDocument().add(table);

    //Write title with top and bottom borders on p1
    cb = writer.getDirectContent();
    cb.setColorStroke(new Color(0, 0, 0));
    cb.setLineWidth(0.5f);

    cb.moveTo(document.left(), document.top() - (font.getCalculatedLeading(LINESPACING) * 5f));
    cb.lineTo(document.right(), document.top() - (font.getCalculatedLeading(LINESPACING) * 5f));
    cb.stroke();
}

From source file:org.oscarehr.casemgmt.print.OscarChartPrinter.java

License:Open Source License

private PdfPCell generalCellForApptHistory(String text) {
    Paragraph p = new Paragraph(text, getFont());
    p.setAlignment(Paragraph.ALIGN_LEFT);
    PdfPCell cell1 = new PdfPCell(p);
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    return cell1;

}

From source file:org.oscarehr.common.service.PdfRecordPrinter.java

License:Open Source License

public void printDocHeaderFooter() throws DocumentException {
    document.resetHeader();/*ww  w  .ja v  a2  s. co m*/
    document.resetFooter();
    //document.resetPageCount();
    String headerTitle = demographic.getFormattedName() + " " + demographic.getAge() + " "
            + demographic.getSex() + " DOB:" + demographic.getFormattedDob();

    //set up document title and header
    ResourceBundle propResource = ResourceBundle.getBundle("oscarResources");
    String title = propResource.getString("oscarEncounter.pdfPrint.title") + " "
            + (String) request.getAttribute("demoName") + "\n";
    String gender = propResource.getString("oscarEncounter.pdfPrint.gender") + " "
            + (String) request.getAttribute("demoSex") + "\n";
    String dob = propResource.getString("oscarEncounter.pdfPrint.dob") + " "
            + (String) request.getAttribute("demoDOB") + "\n";
    String age = propResource.getString("oscarEncounter.pdfPrint.age") + " "
            + (String) request.getAttribute("demoAge") + "\n";
    String mrp = propResource.getString("oscarEncounter.pdfPrint.mrp") + " "
            + (String) request.getAttribute("mrp") + "\n";
    String[] info = new String[] { title, gender, dob, age, mrp };

    ClinicData clinicData = new ClinicData();
    clinicData.refreshClinicData();
    String[] clinic = new String[] { clinicData.getClinicName(), clinicData.getClinicAddress(),
            clinicData.getClinicCity() + ", " + clinicData.getClinicProvince(), clinicData.getClinicPostal(),
            clinicData.getClinicPhone() };

    if (newPage) {
        document.newPage();
        newPage = false;
    }

    //Header will be printed at top of every page beginning with p2

    Phrase headerPhrase = new Phrase(LEADING, headerTitle, boldFont);
    /*
            HeaderFooter header = new HeaderFooter(headerPhrase,false);
            header.setAlignment(HeaderFooter.ALIGN_CENTER);
            document.setHeader(header);
    */
    getDocument().add(headerPhrase);
    getDocument().add(new Phrase("\n"));

    Paragraph p = new Paragraph("Tel:" + demographic.getPhone(), getFont());
    p.setAlignment(Paragraph.ALIGN_LEFT);
    // getDocument().add(p);

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Paragraph p2 = new Paragraph("Date of Visit: " + sdf.format(appointment.getAppointmentDate()), getFont());
    p2.setAlignment(Paragraph.ALIGN_RIGHT);
    // getDocument().add(p);

    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(100f);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    PdfPCell cell1 = new PdfPCell(p);
    cell1.setBorder(PdfPCell.NO_BORDER);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    PdfPCell cell2 = new PdfPCell(p2);
    cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell2.setBorder(PdfPCell.NO_BORDER);
    table.addCell(cell1);
    table.addCell(cell2);

    getDocument().add(table);

    table = new PdfPTable(3);
    table.setWidthPercentage(100f);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    cell1 = new PdfPCell(getParagraph("Signed Provider:" + ((signingProvider != null) ? signingProvider : "")));
    cell1.setBorder(PdfPCell.BOTTOM);
    cell1.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell2 = new PdfPCell(getParagraph("RFR:" + this.appointment.getReason()));
    cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell2.setBorder(PdfPCell.BOTTOM);
    PdfPCell cell3 = new PdfPCell(getParagraph("Ref:" + this.getRefName(this.demographic)));
    cell3.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell3.setBorder(PdfPCell.BOTTOM);
    table.addCell(cell1);
    table.addCell(cell2);
    table.addCell(cell3);
    getDocument().add(table);

    /*
    HeaderFooter footer = new HeaderFooter(new Phrase("-",font),new Phrase("-",font));
    footer.setAlignment(HeaderFooter.ALIGN_CENTER);
    footer.setBorder(0);
            
    document.setFooter(footer);
    */

    //Write title with top and bottom borders on p1

    // cb = writer.getDirectContent();
    /*
    cb.setColorStroke(new Color(0,0,0));
    cb.setLineWidth(0.5f);
    * 
    cb.moveTo(document.left(), document.top() - (font.getCalculatedLeading(LINESPACING)*5f));
    cb.lineTo(document.right(), document.top() - (font.getCalculatedLeading(LINESPACING)*5f));
    cb.stroke();     
    */
}

From source file:org.oscarehr.common.service.PdfRecordPrinter.java

License:Open Source License

public void printSpecsHistory(List<EyeformSpecsHistory> specsHistory) throws DocumentException {
    ProviderDao providerDao = (ProviderDao) SpringUtils.getBean("providerDao");

    /*// w  w w  .j  av a  2 s.co  m
         if( getNewPage() )
    getDocument().newPage();
           else
    setNewPage(true);
    */

    Font obsfont = new Font(getBaseFont(), FONTSIZE, Font.UNDERLINE);

    Paragraph p = new Paragraph();
    p.setAlignment(Paragraph.ALIGN_LEFT);
    Phrase phrase = new Phrase(LEADING, "\n", getFont());
    p.add(phrase);
    phrase = new Phrase(LEADING, "Specs History", obsfont);
    p.add(phrase);
    getDocument().add(p);

    PdfPTable table = new PdfPTable(2);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    table.setSpacingBefore(10f);
    table.setSpacingAfter(10f);
    table.setTotalWidth(new float[] { 10f, 60f });
    table.setTotalWidth(5f);
    table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);

    for (EyeformSpecsHistory specs : specsHistory) {
        PdfPCell cell1 = new PdfPCell(new Phrase(getFormatter().format(specs.getDate()), getFont()));
        cell1.setBorder(PdfPCell.NO_BORDER);
        cell1.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        table.addCell(cell1);

        PdfPCell cell2 = new PdfPCell(new Phrase(specs.toString2(), getFont()));
        cell2.setBorder(PdfPCell.NO_BORDER);
        cell2.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        table.addCell(cell2);
    }

    getDocument().add(table);
}

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);// ww w  .j av a  2s  .  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  ww.  j a  v  a2  s.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   ww w.  j a v a 2s .  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//from  w w w  .  j a va 2 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);/* w ww . j  av a2  s  .  com*/

    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);
    }

}