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

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

Introduction

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

Prototype


public void setBackgroundColor(Color backgroundColor) 

Source Link

Document

Sets the backgroundcolor of the rectangle.

Usage

From source file:org.goodoldai.jeff.report.pdf.PDFDataChunkBuilder.java

License:Open Source License

/**
 * This is a private method that is used to insert single data content into
 * the PDF document./* w  w w.j  a v  a  2 s .co m*/
 *
 * @param data single data which needs to be transformed
 * @param document PDF document in which the transformed data will be
 * written
 */
private void inputSingleDataContent(SingleData data, Document document) {
    String value = String.valueOf(data.getValue());

    //Create table with only one column and set some formatting options
    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(30);
    table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
    table.setSpacingBefore(15.0F);
    table.setSpacingAfter(15.0F);

    //Create the header cell
    PdfPCell cell1 = new PdfPCell(new Paragraph(turnDimensionIntoHeader(data.getDimension())));
    cell1.setBackgroundColor(Color.lightGray);

    //Create a single data cell
    PdfPCell cell2 = new PdfPCell(new Paragraph(value));

    //Insert cells into table
    table.addCell(cell1);
    table.addCell(cell2);

    try {
        document.add(table);
    } catch (DocumentException ex) {
        throw new ExplanationException(ex.getMessage());
    }

}

From source file:org.goodoldai.jeff.report.pdf.PDFDataChunkBuilder.java

License:Open Source License

/**
 * This is a private method that is used to insert one dimensional data 
 * content into the PDF document./*from  w  ww.jav a  2s.co m*/
 *
 * @param data one dimensional data which needs to be transformed
 * @param document PDF document in which the transformed data will be
 * written
 */
private void inputOneDimDataContent(OneDimData data, Document document) {

    //Create table with only one column and set some formatting options
    PdfPTable table = new PdfPTable(1);
    table.setWidthPercentage(30);
    table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
    table.setSpacingBefore(15.0F);
    table.setSpacingAfter(15.0F);

    //Create the header cell
    PdfPCell cell1 = new PdfPCell(new Paragraph(turnDimensionIntoHeader(data.getDimension())));
    cell1.setBackgroundColor(Color.lightGray);
    table.addCell(cell1);

    //Create and insert data cells
    ArrayList<Object> values = data.getValues();

    for (int i = 0; i < values.size(); i++) {
        table.addCell(new Paragraph(transformValue(values.get(i))));
    }

    try {
        document.add(table);
    } catch (DocumentException ex) {
        throw new ExplanationException(ex.getMessage());
    }

}

From source file:org.goodoldai.jeff.report.pdf.PDFDataChunkBuilder.java

License:Open Source License

/**
 * This is a private method that is used to insert two dimensional data
 * content into the PDF document./*w ww.  java  2s.  c  o  m*/
 *
 * @param data two dimensional data which needs to be transformed
 * @param document PDF document in which the transformed data will be
 * written
 */
private void inputTwoDimDataContent(TwoDimData data, Document document) {

    //Create table with two columns and set some formatting options
    PdfPTable table = new PdfPTable(2);
    table.setWidthPercentage(50);
    table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
    table.setSpacingBefore(15.0F);
    table.setSpacingAfter(15.0F);

    //Create the header cells
    PdfPCell cell1 = new PdfPCell(new Paragraph(turnDimensionIntoHeader(data.getDimension1())));
    cell1.setBackgroundColor(Color.lightGray);
    table.addCell(cell1);

    PdfPCell cell2 = new PdfPCell(new Paragraph(turnDimensionIntoHeader(data.getDimension2())));
    cell2.setBackgroundColor(Color.lightGray);
    table.addCell(cell2);

    //Create and insert data cells
    ArrayList<Tuple> values = data.getValues();

    for (int i = 0; i < values.size(); i++) {
        Tuple tuple = (Tuple) (values.get(i));
        table.addCell(new Paragraph(transformValue(tuple.getValue1())));
        table.addCell(new Paragraph(transformValue(tuple.getValue2())));
    }

    try {
        document.add(table);
    } catch (DocumentException ex) {
        throw new ExplanationException(ex.getMessage());
    }

}

From source file:org.goodoldai.jeff.report.pdf.PDFDataChunkBuilder.java

License:Open Source License

/**
 * This is a private method that is used to insert three dimensional data
 * content into the PDF document.// w w w.j av  a  2s .c  om
 *
 * @param data three dimensional data which needs to be transformed
 * @param document PDF document in which the transformed data will be
 * written
 */
private void inputThreeDimDataContent(ThreeDimData data, Document document) {

    //Create table with three columns and set some formatting options
    PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(80);
    table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
    table.setSpacingBefore(15.0F);
    table.setSpacingAfter(15.0F);

    //Create the header cells
    PdfPCell cell1 = new PdfPCell(new Paragraph(turnDimensionIntoHeader(data.getDimension1())));
    cell1.setBackgroundColor(Color.lightGray);
    table.addCell(cell1);

    PdfPCell cell2 = new PdfPCell(new Paragraph(turnDimensionIntoHeader(data.getDimension2())));
    cell2.setBackgroundColor(Color.lightGray);
    table.addCell(cell2);

    PdfPCell cell3 = new PdfPCell(new Paragraph(turnDimensionIntoHeader(data.getDimension3())));
    cell3.setBackgroundColor(Color.lightGray);
    table.addCell(cell3);

    //Create and insert data cells
    ArrayList<Triple> values = data.getValues();

    for (int i = 0; i < values.size(); i++) {
        Triple triple = (Triple) (values.get(i));
        table.addCell(new Paragraph(transformValue(triple.getValue1())));
        table.addCell(new Paragraph(transformValue(triple.getValue2())));
        table.addCell(new Paragraph(transformValue(triple.getValue3())));
    }

    try {
        document.add(table);
    } catch (DocumentException ex) {
        throw new ExplanationException(ex.getMessage());
    }

}

From source file:org.jmesa.view.pdfp.PdfPView.java

License:Apache License

@Override
public PdfPTable render() {

    PdfPTable pdfpTable = new PdfPTable(getTable().getRow().getColumns().size());
    pdfpTable.setSpacingBefore(3);// ww  w .  j av  a2s  .  c o  m

    Row row = getTable().getRow();

    List<Column> columns = row.getColumns();

    // build table headers
    for (Iterator<Column> iter = columns.iterator(); iter.hasNext();) {
        Column column = iter.next();
        PdfPCell cell = new PdfPCell(new Paragraph(column.getTitle(), getHeaderCellFont()));
        cell.setPadding(3.0f);
        cell.setBackgroundColor(getHeaderBackgroundColor());
        pdfpTable.addCell(cell);
    }

    // build table body
    Collection<?> items = getCoreContext().getPageItems();
    int rowcount = 0;
    for (Object item : items) {
        rowcount++;

        columns = row.getColumns();

        for (Iterator<Column> iter = columns.iterator(); iter.hasNext();) {
            Column column = iter.next();

            String property = column.getProperty();
            Object value = column.getCellEditor().getValue(item, property, rowcount);
            PdfPCell cell = new PdfPCell(
                    new Paragraph(value == null ? "" : String.valueOf(value), getCellFont()));
            cell.setPadding(3.0f);

            if (isRowEven(rowcount)) {
                cell.setBackgroundColor(getEvenCellBackgroundColor());
            } else {
                cell.setBackgroundColor(getOddCellBackgroundColor());
            }

            pdfpTable.addCell(cell);
        }
    }

    return pdfpTable;
}

From source file:org.kuali.kfs.module.endow.report.util.AssetStatementReportPrint.java

License:Educational Community License

/**
 * Prints report body for endowment detail
 * /*from  www . ja  v a 2s  .c  om*/
 * @param endowmentAssetStatementReportDataHolders
 * @param document
 * @return
 */
public boolean printAssetStatementReportBodyForEndowmentTotal(
        List<AssetStatementReportDataHolder> endowmentAssetStatementReportDataHolders, Document document) {

    BigDecimal totalHistoryIncomeCash = BigDecimal.ZERO;
    BigDecimal totalHistoryPrincipalCash = BigDecimal.ZERO;
    TreeMap<Integer, TreeMap<String, List<ReportGroupData>>> reportGroupsForIncomeTotal = null;
    TreeMap<Integer, TreeMap<String, List<ReportGroupData>>> reportGroupsForPrincipalTotal = null;

    // get the cash totals
    for (AssetStatementReportDataHolder data : endowmentAssetStatementReportDataHolders) {
        totalHistoryIncomeCash = totalHistoryIncomeCash.add(data.getHistoryIncomeCash());
        totalHistoryPrincipalCash = totalHistoryPrincipalCash.add(data.getHistoryPrincipalCash());
    }

    // for income
    reportGroupsForIncomeTotal = createReportGroupsForTotal(endowmentAssetStatementReportDataHolders,
            IncomePrincipalIndicator.INCOME);

    // for principal
    reportGroupsForPrincipalTotal = createReportGroupsForTotal(endowmentAssetStatementReportDataHolders,
            IncomePrincipalIndicator.PRINCIPAL);

    // for each kemid
    try {
        Font cellFont = regularFont;

        // for the common info
        AssetStatementReportDataHolder reportData = endowmentAssetStatementReportDataHolders.get(0);

        document.newPage();

        // header
        StringBuffer title = new StringBuffer();
        title.append(reportData.getInstitution()).append("\n");
        title.append("STATEMENT OF ASSETS FOR PERIOD ENDING").append("\n");
        title.append(reportData.getMonthEndDate()).append("\n\n");
        Paragraph header = new Paragraph(title.toString());
        header.setAlignment(Element.ALIGN_CENTER);
        document.add(header);

        // report table
        float[] colsWidth = { 15f, 17f, 17f, 17f, 17f, 17f };
        PdfPTable table = new PdfPTable(colsWidth);
        table.setWidthPercentage(FULL_TABLE_WIDTH);
        table.getDefaultCell().setPadding(5);

        // column titles
        table.addCell("");
        table.addCell(createCell("UNITS HELD", titleFont, Element.ALIGN_RIGHT, true));
        table.addCell(createCell("MARKET VALUE", titleFont, Element.ALIGN_RIGHT, true));
        table.addCell(createCell("ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true));
        table.addCell(
                createCell("FY REMAINDER ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true));
        table.addCell(createCell("NEXT FY ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true));

        // 1. Expendable funds 

        PdfPCell cellExpendableFunds = new PdfPCell(new Paragraph("EXPENDABLE FUNDS", titleFont));
        cellExpendableFunds.setColspan(6);
        table.addCell(cellExpendableFunds);

        PdfPCell cellCashEquivalnets = new PdfPCell(new Paragraph("CASH AND EQUIVALENTS", titleFont));
        cellCashEquivalnets.setColspan(6);
        table.addCell(cellCashEquivalnets);

        // report groups for income
        printReportGroupForIncomeEndowmentTotal(reportGroupsForIncomeTotal, totalHistoryIncomeCash, document,
                table, cellFont);

        // 2. Endowed funds 

        PdfPCell cellEndowedFunds = new PdfPCell(new Paragraph("ENDOWED FUNDS", titleFont));
        cellEndowedFunds.setColspan(6);
        table.addCell(cellEndowedFunds);

        table.addCell(cellCashEquivalnets);

        // report groups for principal
        printReportGroupForPrincipalEndowmentTotal(reportGroupsForPrincipalTotal, totalHistoryPrincipalCash,
                document, table, cellFont);

        // 3. total (endowment + non-endowed)
        PdfPCell blank = new PdfPCell(new Paragraph("", cellFont));
        blank.setColspan(6);
        blank.setBackgroundColor(Color.LIGHT_GRAY);
        table.addCell(blank);

        BigDecimal totalKemidMarketValue = BigDecimal.ZERO;
        BigDecimal totalKemidEstimatedAnnualIncome = BigDecimal.ZERO;
        BigDecimal totalKemidFYRemainderEstimatedAnnualIncome = BigDecimal.ZERO;
        BigDecimal totalKemidNextFYEstimayedAnnualIncome = BigDecimal.ZERO;
        for (AssetStatementReportDataHolder data : endowmentAssetStatementReportDataHolders) {
            totalKemidMarketValue = totalKemidMarketValue
                    .add(data.getTotalSumOfMarketValue(IncomePrincipalIndicator.INCOME)
                            .add(data.getTotalSumOfMarketValue(IncomePrincipalIndicator.PRINCIPAL)));
            totalKemidEstimatedAnnualIncome = totalKemidEstimatedAnnualIncome
                    .add(data.getTotalSumOfEstimatedIncome(IncomePrincipalIndicator.INCOME)
                            .add(data.getTotalSumOfEstimatedIncome(IncomePrincipalIndicator.PRINCIPAL)));
            totalKemidFYRemainderEstimatedAnnualIncome = totalKemidFYRemainderEstimatedAnnualIncome
                    .add(data.getTotalSumOfRemainderOfFYEstimated(IncomePrincipalIndicator.INCOME)
                            .add(data.getTotalSumOfRemainderOfFYEstimated(IncomePrincipalIndicator.PRINCIPAL)));
            totalKemidNextFYEstimayedAnnualIncome = totalKemidNextFYEstimayedAnnualIncome
                    .add(data.getTotalSumOfNextFYEstimatedIncome(IncomePrincipalIndicator.INCOME)
                            .add(data.getTotalSumOfNextFYEstimatedIncome(IncomePrincipalIndicator.PRINCIPAL)));
        }

        table.addCell(new Paragraph("TOTAL KEMID VALUE", titleFont));
        table.addCell("");
        table.addCell(getAmountCell(
                totalKemidMarketValue.add(totalHistoryIncomeCash).add(totalHistoryPrincipalCash), titleFont));
        table.addCell(getAmountCell(totalKemidEstimatedAnnualIncome, titleFont));
        table.addCell(getAmountCell(totalKemidFYRemainderEstimatedAnnualIncome, titleFont));
        table.addCell(getAmountCell(totalKemidNextFYEstimayedAnnualIncome, titleFont));

        document.add(table);

    } catch (Exception e) {
        LOG.error(e.getMessage());
        return false;
    }

    return true;

}

From source file:org.kuali.kfs.module.endow.report.util.AssetStatementReportPrint.java

License:Educational Community License

/**
 * Generates the Asset Statement report for Non-Endowed total 
 * /*ww  w .  ja va 2  s  . com*/
 * @param transactionStatementReports
 * @param document
 * @return
 */
public boolean printAssetStatementReportBodyForNonEndowedTotal(
        List<AssetStatementReportDataHolder> nonEndowedAssetStatementReportDataHolders, Document document) {

    BigDecimal totalHistoryIncomeCash = BigDecimal.ZERO;
    BigDecimal totalHistoryPrincipalCash = BigDecimal.ZERO;
    TreeMap<Integer, TreeMap<String, List<ReportGroupData>>> reportGroupsForTotal = null;

    // get the cash totals
    for (AssetStatementReportDataHolder data : nonEndowedAssetStatementReportDataHolders) {
        totalHistoryIncomeCash = totalHistoryIncomeCash.add(data.getHistoryIncomeCash());
        totalHistoryPrincipalCash = totalHistoryPrincipalCash.add(data.getHistoryPrincipalCash());
    }

    reportGroupsForTotal = createReportGroupsForTotal(nonEndowedAssetStatementReportDataHolders,
            IncomePrincipalIndicator.INCOME);

    // for each kemid
    try {
        Font cellFont = regularFont;

        // for the common info
        AssetStatementReportDataHolder reportData = nonEndowedAssetStatementReportDataHolders.get(0);

        document.newPage();

        // header
        StringBuffer title = new StringBuffer();
        title.append(reportData.getInstitution()).append("\n");
        title.append("STATEMENT OF ASSETS FOR PERIOD ENDING").append("\n");
        title.append(reportData.getMonthEndDate()).append("\n\n");
        Paragraph header = new Paragraph(title.toString());
        header.setAlignment(Element.ALIGN_CENTER);
        document.add(header);

        // report table
        float[] colsWidth = { 15f, 17f, 17f, 17f, 17f, 17f };
        PdfPTable table = new PdfPTable(colsWidth);
        table.setWidthPercentage(FULL_TABLE_WIDTH);
        table.getDefaultCell().setPadding(5);

        // column titles
        table.addCell("");
        table.addCell(createCell("UNITS HELD", titleFont, Element.ALIGN_RIGHT, true));
        table.addCell(createCell("MARKET VALUE", titleFont, Element.ALIGN_RIGHT, true));
        table.addCell(createCell("ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true));
        table.addCell(
                createCell("FY REMAINDER ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true));
        table.addCell(createCell("NEXT FY ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true));

        PdfPCell cellCashEquivalnets = new PdfPCell(new Paragraph("CASH AND EQUIVALENTS", titleFont));
        cellCashEquivalnets.setColspan(6);
        table.addCell(cellCashEquivalnets);

        // report groups
        printReportGroupForNonEndowedTotal(reportGroupsForTotal, totalHistoryIncomeCash,
                totalHistoryPrincipalCash, document, table, cellFont);

        // total
        PdfPCell blank = new PdfPCell(new Paragraph("", cellFont));
        blank.setColspan(6);
        blank.setBackgroundColor(Color.LIGHT_GRAY);
        table.addCell(blank);

        BigDecimal totalKemidMarketValue = BigDecimal.ZERO;
        BigDecimal totalKemidEstimatedAnnualIncome = BigDecimal.ZERO;
        BigDecimal totalKemidFYRemainderEstimatedAnnualIncome = BigDecimal.ZERO;
        BigDecimal totalKemidNextFYEstimayedAnnualIncome = BigDecimal.ZERO;
        for (AssetStatementReportDataHolder data : nonEndowedAssetStatementReportDataHolders) {
            totalKemidMarketValue = totalKemidMarketValue
                    .add(data.getTotalSumOfMarketValue(IncomePrincipalIndicator.INCOME));
            totalKemidEstimatedAnnualIncome = totalKemidEstimatedAnnualIncome
                    .add(data.getTotalSumOfEstimatedIncome(IncomePrincipalIndicator.INCOME));
            totalKemidFYRemainderEstimatedAnnualIncome = totalKemidFYRemainderEstimatedAnnualIncome
                    .add(totalKemidFYRemainderEstimatedAnnualIncome
                            .add(data.getTotalSumOfRemainderOfFYEstimated(IncomePrincipalIndicator.INCOME)));
            totalKemidNextFYEstimayedAnnualIncome = totalKemidNextFYEstimayedAnnualIncome
                    .add(data.getTotalSumOfNextFYEstimatedIncome(IncomePrincipalIndicator.INCOME));
        }

        table.addCell(new Paragraph("TOTAL KEMID VALUE", titleFont));
        table.addCell("");
        table.addCell(getAmountCell(
                totalKemidMarketValue.add(totalHistoryIncomeCash).add(totalHistoryPrincipalCash), titleFont));
        table.addCell(getAmountCell(totalKemidEstimatedAnnualIncome, titleFont));
        table.addCell(getAmountCell(totalKemidFYRemainderEstimatedAnnualIncome, titleFont));
        table.addCell(getAmountCell(totalKemidNextFYEstimayedAnnualIncome, titleFont));

        document.add(table);

    } catch (Exception e) {
        LOG.error(e.getMessage());
        return false;
    }

    return true;
}

From source file:org.kuali.kfs.module.endow.report.util.AssetStatementReportPrint.java

License:Educational Community License

/**
 * Generates the Asset Statement report for Endowment detail  
 * /*from ww  w . j a  va  2  s .c  o m*/
 * @param transactionStatementReports
 * @param document
 * @return
 */
public boolean printAssetStatementReportBodyForEndowmentDetail(
        List<AssetStatementReportDataHolder> endowmentAssetStatementReportDataHolders, Document document) {

    // for each kemid
    try {
        Font cellFont = regularFont;
        for (AssetStatementReportDataHolder reportData : endowmentAssetStatementReportDataHolders) {

            document.newPage();

            // header
            StringBuffer title = new StringBuffer();
            title.append(reportData.getInstitution()).append("\n");
            title.append("STATEMENT OF ASSETS FOR PERIOD ENDING").append("\n");
            title.append(reportData.getMonthEndDate()).append("\n");
            title.append(reportData.getKemid()).append("     ").append(reportData.getKemidLongTitle())
                    .append("\n\n");
            Paragraph header = new Paragraph(title.toString());
            header.setAlignment(Element.ALIGN_CENTER);
            document.add(header);

            // report table
            float[] colsWidth = { 15f, 17f, 17f, 17f, 17f, 17f };
            PdfPTable table = new PdfPTable(colsWidth);
            table.setWidthPercentage(FULL_TABLE_WIDTH);
            table.getDefaultCell().setPadding(5);

            // column titles
            table.addCell("");
            table.addCell(createCell("UNITS HELD", titleFont, Element.ALIGN_RIGHT, true));
            table.addCell(createCell("MARKET VALUE", titleFont, Element.ALIGN_RIGHT, true));
            table.addCell(createCell("ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true));
            table.addCell(
                    createCell("FY REMAINDER ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true));
            table.addCell(createCell("NEXT FY ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true));

            // 1. Expendable funds 

            PdfPCell cellExpendableFunds = new PdfPCell(new Paragraph("EXPENDABLE FUNDS", titleFont));
            cellExpendableFunds.setColspan(6);
            //cellExpendableFunds.setBackgroundColor(Color.LIGHT_GRAY);
            table.addCell(cellExpendableFunds);

            PdfPCell cellCashEquivalnets = new PdfPCell(new Paragraph("CASH AND EQUIVALENTS", cellFont));
            cellCashEquivalnets.setColspan(6);
            table.addCell(cellCashEquivalnets);

            // report groups 
            printReportGroupForIncomeEndowmentDetail(reportData, document, table, cellFont);

            // 2. Endowed funds 

            PdfPCell cellEndowedFunds = new PdfPCell(new Paragraph("ENDOWED FUNDS", titleFont));
            cellEndowedFunds.setColspan(6);
            //cellEndowedFunds.setBackgroundColor(Color.LIGHT_GRAY);
            table.addCell(cellEndowedFunds);

            table.addCell(cellCashEquivalnets);

            printReportGroupForPrincipalEndowmentDetail(reportData, document, table, cellFont);

            // 3. total (endowment + non-endowed)
            PdfPCell blank = new PdfPCell(new Paragraph("", cellFont));
            blank.setColspan(6);
            blank.setBackgroundColor(Color.LIGHT_GRAY);
            table.addCell(blank);

            BigDecimal totalKemidMarketValue = reportData
                    .getTotalSumOfMarketValue(IncomePrincipalIndicator.INCOME)
                    .add(reportData.getHistoryIncomeCash())
                    .add(reportData.getTotalSumOfMarketValue(IncomePrincipalIndicator.PRINCIPAL)
                            .add(reportData.getHistoryPrincipalCash()));
            BigDecimal totalKemidEstimatedAnnualIncome = reportData
                    .getTotalSumOfEstimatedIncome(IncomePrincipalIndicator.INCOME)
                    .add(reportData.getTotalSumOfEstimatedIncome(IncomePrincipalIndicator.PRINCIPAL));
            BigDecimal totalKemidFYRemainderEstimatedAnnualIncome = reportData
                    .getTotalSumOfRemainderOfFYEstimated(IncomePrincipalIndicator.INCOME)
                    .add(reportData.getTotalSumOfRemainderOfFYEstimated(IncomePrincipalIndicator.PRINCIPAL));
            BigDecimal totalKemidNextFYEstimayedAnnualIncome = reportData
                    .getTotalSumOfNextFYEstimatedIncome(IncomePrincipalIndicator.INCOME)
                    .add(reportData.getTotalSumOfNextFYEstimatedIncome(IncomePrincipalIndicator.PRINCIPAL));

            table.addCell(new Paragraph("TOTAL KEMID VALUE", titleFont));
            table.addCell("");
            table.addCell(getAmountCell(totalKemidMarketValue, titleFont));
            table.addCell(getAmountCell(totalKemidEstimatedAnnualIncome, titleFont));
            table.addCell(getAmountCell(totalKemidFYRemainderEstimatedAnnualIncome, titleFont));
            table.addCell(getAmountCell(totalKemidNextFYEstimayedAnnualIncome, titleFont));

            document.add(table);

            // footer
            printFooter(reportData.getFooter(), document);
        }
    } catch (Exception e) {
        LOG.error(e.getMessage());
        return false;
    }

    return true;
}

From source file:org.kuali.kfs.module.endow.report.util.AssetStatementReportPrint.java

License:Educational Community License

/**
 * Generates the Asset Statement report for Non-Endowed    
 * //  ww w .j  a  v  a 2 s  .c  om
 * @param transactionStatementReports
 * @param document
 * @return
 */
public boolean printAssetStatementReportBodyForNonEndowedDetail(
        List<AssetStatementReportDataHolder> nonEndowedAssetStatementReportDataHolders, Document document) {

    // for each kemid
    try {
        Font cellFont = regularFont;
        for (AssetStatementReportDataHolder reportData : nonEndowedAssetStatementReportDataHolders) {

            document.newPage();

            // header
            StringBuffer title = new StringBuffer();
            title.append(reportData.getInstitution()).append("\n");
            title.append("STATEMENT OF ASSETS FOR PERIOD ENDING").append("\n");
            title.append(reportData.getMonthEndDate()).append("\n");
            title.append(reportData.getKemid()).append("     ").append(reportData.getKemidLongTitle())
                    .append("\n\n");
            Paragraph header = new Paragraph(title.toString());
            header.setAlignment(Element.ALIGN_CENTER);
            document.add(header);

            // report table
            float[] colsWidth = { 15f, 17f, 17f, 17f, 17f, 17f };
            PdfPTable table = new PdfPTable(colsWidth);
            table.setWidthPercentage(FULL_TABLE_WIDTH);
            table.getDefaultCell().setPadding(5);

            // column titles
            table.addCell("");
            table.addCell(createCell("UNITS HELD", titleFont, Element.ALIGN_RIGHT, true));
            table.addCell(createCell("MARKET VALUE", titleFont, Element.ALIGN_RIGHT, true));
            table.addCell(createCell("ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true));
            table.addCell(
                    createCell("FY REMAINDER ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true));
            table.addCell(createCell("NEXT FY ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true));

            PdfPCell cellCashEquivalnets = new PdfPCell(new Paragraph("CASH AND EQUIVALENTS", cellFont));
            cellCashEquivalnets.setColspan(6);
            table.addCell(cellCashEquivalnets);

            // report groups 
            printReportGroupForNonEndowedDetail(reportData, document, table, cellFont);

            // total
            PdfPCell blank = new PdfPCell(new Paragraph("", cellFont));
            blank.setColspan(6);
            blank.setBackgroundColor(Color.LIGHT_GRAY);
            table.addCell(blank);

            BigDecimal totalKemidMarketValue = reportData
                    .getTotalSumOfMarketValue(IncomePrincipalIndicator.INCOME)
                    .add(reportData.getHistoryIncomeCash()).add(reportData.getHistoryPrincipalCash());
            BigDecimal totalKemidEstimatedAnnualIncome = reportData
                    .getTotalSumOfEstimatedIncome(IncomePrincipalIndicator.INCOME)
                    .add(reportData.getTotalSumOfEstimatedIncome(IncomePrincipalIndicator.PRINCIPAL));
            BigDecimal totalKemidFYRemainderEstimatedAnnualIncome = reportData
                    .getTotalSumOfRemainderOfFYEstimated(IncomePrincipalIndicator.INCOME)
                    .add(reportData.getTotalSumOfRemainderOfFYEstimated(IncomePrincipalIndicator.PRINCIPAL));
            BigDecimal totalKemidNextFYEstimayedAnnualIncome = reportData
                    .getTotalSumOfNextFYEstimatedIncome(IncomePrincipalIndicator.INCOME)
                    .add(reportData.getTotalSumOfNextFYEstimatedIncome(IncomePrincipalIndicator.PRINCIPAL));

            table.addCell(new Paragraph("TOTAL KEMID VALUE", titleFont));
            table.addCell("");
            table.addCell(getAmountCell(totalKemidMarketValue, titleFont));
            table.addCell(getAmountCell(totalKemidEstimatedAnnualIncome, titleFont));
            table.addCell(getAmountCell(totalKemidFYRemainderEstimatedAnnualIncome, titleFont));
            table.addCell(getAmountCell(totalKemidNextFYEstimayedAnnualIncome, titleFont));

            document.add(table);

            // footer
            printFooter(reportData.getFooter(), document);
        }
    } catch (Exception e) {
        LOG.error(e.getMessage());
        return false;
    }

    return true;
}

From source file:org.kuali.kfs.module.endow.report.util.TrialBalanceReportPrint.java

License:Educational Community License

/**
 * Generates the Trial Balance report//from   w  w  w .ja  va  2  s .  c o  m
 * 
 * @param trialBalanceReports
 * @param document
 * @return
 */
public boolean printTrialBalanceReportBody(List<TrialBalanceReportDataHolder> trialBalanceReports,
        Document document) {

    try {
        // title
        Paragraph title = new Paragraph("KEMID Trial Balance");
        title.setAlignment(Element.ALIGN_CENTER);
        Date currentDate = SpringContext.getBean(KEMService.class).getCurrentDate();
        DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class);
        String asOfDate = dateTimeService.toDateString(currentDate);
        title.add("\nAs of " + asOfDate + "\n\n");
        document.add(title);

        // report table
        PdfPTable table = new PdfPTable(7);
        table.setWidthPercentage(FULL_TABLE_WIDTH);
        int[] relativeWidths = { 10, 15, 15, 15, 15, 15, 15 };
        table.setWidths(relativeWidths);
        table.getDefaultCell().setPadding(2);

        // table titles
        table.addCell(new Phrase("KEMID", titleFont));
        table.addCell(new Phrase("KEMID Name", titleFont));
        table.addCell(new Phrase("Income Cash Balance", titleFont));
        table.addCell(new Phrase("Principal Cash Balance", titleFont));
        table.addCell(new Phrase("KEMID Total Market Value", titleFont));
        table.addCell(new Phrase("Available Expendable Funds", titleFont));
        table.addCell(new Phrase("FY Remainder Estimated Income", titleFont));

        // table body
        Font cellFont = regularFont;
        BigDecimal totalIncomeCashBalance = BigDecimal.ZERO;
        BigDecimal totalPrincipalCashBalance = BigDecimal.ZERO;
        BigDecimal totalMarketValueBalance = BigDecimal.ZERO;
        BigDecimal totalAvailableExpendableFundsBalance = BigDecimal.ZERO;
        BigDecimal totalFyRemainderEstimatedIncome = BigDecimal.ZERO;

        for (TrialBalanceReportDataHolder trialBalanceReport : trialBalanceReports) {

            // totals, which is the last row
            if (trialBalanceReport.getKemid().equalsIgnoreCase("TOTALS")) {
                cellFont = titleFont;
            }

            table.addCell(new Phrase(trialBalanceReport.getKemid(), cellFont));
            table.addCell(new Phrase(trialBalanceReport.getKemidName(), cellFont));
            if (trialBalanceReport.getInocmeCashBalance() != null) {
                String amount = formatAmount(trialBalanceReport.getInocmeCashBalance().bigDecimalValue());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
                totalIncomeCashBalance = totalIncomeCashBalance
                        .add(trialBalanceReport.getInocmeCashBalance().bigDecimalValue());
            } else {
                table.addCell(createCell(ZERO_FOR_REPORT, cellFont, Element.ALIGN_RIGHT, true));
            }
            if (trialBalanceReport.getPrincipalcashBalance() != null) {
                String amount = formatAmount(trialBalanceReport.getPrincipalcashBalance().bigDecimalValue());
                totalPrincipalCashBalance = totalPrincipalCashBalance
                        .add(trialBalanceReport.getPrincipalcashBalance().bigDecimalValue());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            } else {
                table.addCell(createCell(ZERO_FOR_REPORT, cellFont, Element.ALIGN_RIGHT, true));
            }
            if (trialBalanceReport.getKemidTotalMarketValue() != null) {
                String amount = formatAmount(trialBalanceReport.getKemidTotalMarketValue());
                totalMarketValueBalance = totalMarketValueBalance
                        .add(trialBalanceReport.getKemidTotalMarketValue());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            } else {
                table.addCell(createCell(ZERO_FOR_REPORT, cellFont, Element.ALIGN_RIGHT, true));
            }
            if (trialBalanceReport.getAvailableExpendableFunds() != null) {
                String amount = formatAmount(trialBalanceReport.getAvailableExpendableFunds());
                totalAvailableExpendableFundsBalance = totalAvailableExpendableFundsBalance
                        .add(trialBalanceReport.getAvailableExpendableFunds());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            } else {
                table.addCell(createCell(ZERO_FOR_REPORT, cellFont, Element.ALIGN_RIGHT, true));
            }
            if (trialBalanceReport.getFyRemainderEstimatedIncome() != null) {
                String amount = formatAmount(trialBalanceReport.getFyRemainderEstimatedIncome());
                totalFyRemainderEstimatedIncome = totalFyRemainderEstimatedIncome
                        .add(trialBalanceReport.getFyRemainderEstimatedIncome());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            } else {
                table.addCell(createCell(ZERO_FOR_REPORT, cellFont, Element.ALIGN_RIGHT, true));
            }
        }

        // totals
        PdfPCell blank = new PdfPCell(new Paragraph("", cellFont));
        blank.setColspan(7);
        blank.setBackgroundColor(Color.LIGHT_GRAY);
        table.addCell(blank);

        table.addCell(createCell("TOTALS", titleFont, Element.ALIGN_LEFT, true));
        table.addCell(createCell("", cellFont, Element.ALIGN_RIGHT, true));
        table.addCell(createCell(formatAmount(totalIncomeCashBalance), cellFont, Element.ALIGN_RIGHT, true));
        table.addCell(createCell(formatAmount(totalPrincipalCashBalance), cellFont, Element.ALIGN_RIGHT, true));
        table.addCell(createCell(formatAmount(totalMarketValueBalance), cellFont, Element.ALIGN_RIGHT, true));
        table.addCell(createCell(formatAmount(totalAvailableExpendableFundsBalance), cellFont,
                Element.ALIGN_RIGHT, true));
        table.addCell(
                createCell(formatAmount(totalFyRemainderEstimatedIncome), cellFont, Element.ALIGN_RIGHT, true));

        document.add(table);

    } catch (Exception e) {
        return false;
    }

    return true;
}