Example usage for com.lowagie.text Element ALIGN_CENTER

List of usage examples for com.lowagie.text Element ALIGN_CENTER

Introduction

In this page you can find the example usage for com.lowagie.text Element ALIGN_CENTER.

Prototype

int ALIGN_CENTER

To view the source code for com.lowagie.text Element ALIGN_CENTER.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

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

License:Educational Community License

/**
 * Prints report body for endowment detail
 * /*w w w . j  ava  2 s . co  m*/
 * @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 
 * //w w w .j ava  2s  .  c  o  m
 * @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  
 * /* w ww  .ja  v a2  s  . c om*/
 * @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    
 * /* w w  w. j  a v  a 2  s.c o  m*/
 * @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.EndowmentReportPrintBase.java

License:Educational Community License

/** 
 * Generates the report header sheet//  w w w  .  j  a v  a 2 s .  c  o  m
 * 
 * @param reportRequestHeaderDataHolder
 * @param document
 * @return
 */
public boolean printReportHeaderPage(EndowmentReportHeaderDataHolder reportRequestHeaderDataHolder,
        Document document, String listKemidsInHeader) {

    try {
        // report header
        Phrase header = new Paragraph(new Date().toString());
        Paragraph title = new Paragraph(reportRequestHeaderDataHolder.getInstitutionName());
        title.setAlignment(Element.ALIGN_CENTER);
        title.add("\nReport Request Header Sheet\n\n");
        document.add(title);

        PdfPTable requestTable = new PdfPTable(2);
        requestTable.setWidthPercentage(REQUEST_INFO_TABLE_WIDTH);
        int[] requestWidths = { 20, 80 };
        requestTable.setWidths(requestWidths);
        requestTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

        Paragraph reportRequested = new Paragraph(reportRequestHeaderDataHolder.getReportRequested(),
                headerSheetRegularFont);
        Paragraph dateRequested = new Paragraph(new Date().toString(), headerSheetRegularFont);
        Paragraph requestedBy = new Paragraph(reportRequestHeaderDataHolder.getRequestedBy(),
                headerSheetRegularFont);
        Paragraph endowmentOption = new Paragraph(reportRequestHeaderDataHolder.getEndowmentOption(),
                headerSheetRegularFont);
        Paragraph reportOption = new Paragraph(reportRequestHeaderDataHolder.getReportOption(),
                headerSheetRegularFont);

        requestTable.addCell(
                createCellWithDefaultFontAndWithoutBorderLine("Report Requested:", Element.ALIGN_RIGHT));
        requestTable.addCell(reportRequested);
        requestTable
                .addCell(createCellWithDefaultFontAndWithoutBorderLine("Date Requested:", Element.ALIGN_RIGHT));
        requestTable.addCell(dateRequested);
        requestTable
                .addCell(createCellWithDefaultFontAndWithoutBorderLine("Reqeusted by:", Element.ALIGN_RIGHT));
        requestTable.addCell(requestedBy);
        requestTable.addCell("");
        requestTable.addCell("");
        requestTable.addCell(
                createCellWithDefaultFontAndWithoutBorderLine("Endowment Option:", Element.ALIGN_RIGHT));
        requestTable.addCell(endowmentOption);
        requestTable
                .addCell(createCellWithDefaultFontAndWithoutBorderLine("Report Option:", Element.ALIGN_RIGHT));
        requestTable.addCell(reportOption);
        document.add(requestTable);

        // Criteria
        Paragraph criteria = new Paragraph("\nCriteria:\n\n");
        document.add(criteria);

        PdfPTable criteriaTable = new PdfPTable(2);
        criteriaTable.setWidthPercentage(CRITERIA_TABLE_WIDTH);
        int[] criteriaWidths = { 30, 50 };
        criteriaTable.setWidths(criteriaWidths);
        criteriaTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

        Paragraph benefittingCampus = new Paragraph(reportRequestHeaderDataHolder.getBenefittingCampus(),
                headerSheetRegularFont);
        Paragraph benefittingChart = new Paragraph(reportRequestHeaderDataHolder.getBenefittingChart(),
                headerSheetRegularFont);
        Paragraph benefittingOrganization = new Paragraph(
                reportRequestHeaderDataHolder.getBenefittingOrganization(), headerSheetRegularFont);
        Paragraph kemidTypeCode = new Paragraph(reportRequestHeaderDataHolder.getKemidTypeCode(),
                headerSheetRegularFont);
        Paragraph kemidPurposeCode = new Paragraph(reportRequestHeaderDataHolder.getKemidPurposeCode(),
                headerSheetRegularFont);
        Paragraph combinationGroupCode = new Paragraph(reportRequestHeaderDataHolder.getCombineGroupCode(),
                headerSheetRegularFont);

        criteriaTable.addCell(
                createCellWithDefaultFontAndWithoutBorderLine("Benefitting Campus:", Element.ALIGN_RIGHT));
        criteriaTable.addCell(benefittingCampus);
        criteriaTable.addCell(
                createCellWithDefaultFontAndWithoutBorderLine("Benefitting Chart:", Element.ALIGN_RIGHT));
        criteriaTable.addCell(benefittingChart);
        criteriaTable.addCell(createCellWithDefaultFontAndWithoutBorderLine("Benefitting Organization:",
                Element.ALIGN_RIGHT));
        criteriaTable.addCell(benefittingOrganization);
        criteriaTable.addCell(
                createCellWithDefaultFontAndWithoutBorderLine("KEMID Type Code:", Element.ALIGN_RIGHT));
        criteriaTable.addCell(kemidTypeCode);
        criteriaTable.addCell(
                createCellWithDefaultFontAndWithoutBorderLine("KEMID Purpose Code:", Element.ALIGN_RIGHT));
        criteriaTable.addCell(kemidPurposeCode);
        criteriaTable.addCell(
                createCellWithDefaultFontAndWithoutBorderLine("Combine Group Code:", Element.ALIGN_RIGHT));
        criteriaTable.addCell(combinationGroupCode);
        document.add(criteriaTable);

        // kemids with multiple benefitting organization
        Paragraph kemidWithMultipleBenefittingOrganization = new Paragraph(
                "\nKEMIDs with Multiple Benefitting Organizations:\n\n");
        document.add(kemidWithMultipleBenefittingOrganization);

        List<KemidsWithMultipleBenefittingOrganizationsDataHolder> kemidsWithMultipleBenefittingOrganizationsDataHolder = reportRequestHeaderDataHolder
                .getKemidsWithMultipleBenefittingOrganizationsDataHolders();
        if (kemidsWithMultipleBenefittingOrganizationsDataHolder != null
                && !kemidsWithMultipleBenefittingOrganizationsDataHolder.isEmpty()) {
            PdfPTable kemidWithMultipleBenefittingOrganizationTable = new PdfPTable(5);
            kemidWithMultipleBenefittingOrganizationTable.setWidthPercentage(MULTIPLE_KEMID_TABLE_WIDTH);
            kemidWithMultipleBenefittingOrganizationTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

            Paragraph kemid = new Paragraph("KEMID", titleFont);
            Paragraph campus = new Paragraph("Campus", titleFont);
            Paragraph chart = new Paragraph("Chart", titleFont);
            Paragraph organization = new Paragraph("Organziation", titleFont);
            Paragraph percent = new Paragraph("Percent", titleFont);
            kemidWithMultipleBenefittingOrganizationTable.addCell(kemid);
            kemidWithMultipleBenefittingOrganizationTable.addCell(campus);
            kemidWithMultipleBenefittingOrganizationTable.addCell(chart);
            kemidWithMultipleBenefittingOrganizationTable.addCell(organization);
            kemidWithMultipleBenefittingOrganizationTable.addCell(percent);

            for (KemidsWithMultipleBenefittingOrganizationsDataHolder kmbo : kemidsWithMultipleBenefittingOrganizationsDataHolder) {
                kemidWithMultipleBenefittingOrganizationTable
                        .addCell(new Paragraph(kmbo.getKemid(), headerSheetRegularFont));
                kemidWithMultipleBenefittingOrganizationTable
                        .addCell(new Paragraph(kmbo.getCampus(), headerSheetRegularFont));
                kemidWithMultipleBenefittingOrganizationTable
                        .addCell(new Paragraph(kmbo.getChart(), headerSheetRegularFont));
                kemidWithMultipleBenefittingOrganizationTable
                        .addCell(new Paragraph(kmbo.getOrganization(), headerSheetRegularFont));
                kemidWithMultipleBenefittingOrganizationTable
                        .addCell(new Paragraph(kmbo.getPercent().toString(), headerSheetRegularFont));
            }
            document.add(kemidWithMultipleBenefittingOrganizationTable);
        } else {
            Paragraph noneExistMessage = new Paragraph("NONE EXIST\n\n", headerSheetRegularFont);
            document.add(noneExistMessage);
        }

        // kemids selected
        if ("Y".equalsIgnoreCase(listKemidsInHeader)) {
            List<String> kemidsSelected = reportRequestHeaderDataHolder.getKemidsSelected();
            int totalKemidsSelected = reportRequestHeaderDataHolder.getKemidsSelected().size();
            Paragraph kemidsSelectedTitle = new Paragraph("\nKEMIDs Selected: " + totalKemidsSelected + "\n\n");
            document.add(kemidsSelectedTitle);

            PdfPTable kemidsTable = new PdfPTable(KEMIDS_SELECTED_COLUMN_NUM);
            kemidsTable.setWidthPercentage(KEMID_SELECTED_TABLE_WIDTH);
            kemidsTable.getDefaultCell().setBorder(Rectangle.NO_BORDER);

            for (int i = 0; i < totalKemidsSelected; i++) {
                kemidsTable.addCell(new Paragraph(kemidsSelected.get(i), headerSheetRegularFont));
            }
            // to fill out the rest of the empty cells. Otherwise, the row won't be displayed
            if (totalKemidsSelected % KEMIDS_SELECTED_COLUMN_NUM != 0) {
                for (int i = 0; i < (KEMIDS_SELECTED_COLUMN_NUM
                        - totalKemidsSelected % KEMIDS_SELECTED_COLUMN_NUM); i++) {
                    kemidsTable.addCell("");
                }
            }
            document.add(kemidsTable);
        }

    } catch (Exception e) {
        return false;
    }

    return true;
}

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

License:Educational Community License

/**
 * Generates the Transaction Statement report    
 * //from  w w w. ja v  a  2 s  .co  m
 * @param transactionStatementReports
 * @param document
 * @return
 */
public boolean printTransactionStatementReportBody(
        List<TransactionStatementReportDataHolder> transactionStatementReportDataHolders, Document document) {

    // for each kemid
    try {
        Font cellFont = regularFont;
        for (TransactionStatementReportDataHolder transactionStatementReport : transactionStatementReportDataHolders) {

            // new page
            document.newPage();

            // header
            StringBuffer title = new StringBuffer();
            title.append(transactionStatementReport.getInstitution()).append("\n");
            title.append("STATEMENT OF TRANSACTIONS FROM").append("\n");
            title.append(transactionStatementReport.getBeginningDate()).append(" to ")
                    .append(transactionStatementReport.getEndingDate()).append("\n");
            title.append(transactionStatementReport.getKemid()).append("     ")
                    .append(transactionStatementReport.getKemidLongTitle()).append("\n\n");
            Paragraph header = new Paragraph(title.toString());
            header.setAlignment(Element.ALIGN_CENTER);
            document.add(header);

            // report table
            PdfPTable table = new PdfPTable(4);
            table.setWidthPercentage(FULL_TABLE_WIDTH);
            int[] relativeWidths = { 10, 40, 25, 25 };
            table.setWidths(relativeWidths);
            table.getDefaultCell().setPadding(5);

            // table titles
            table.addCell(new Phrase("DATE", titleFont));
            table.addCell(new Phrase("DESCRIPTION", titleFont));
            table.addCell(
                    createCell("INCOME AMOUNT", titleFont, Element.ALIGN_RIGHT, Element.ALIGN_MIDDLE, true));
            table.addCell(
                    createCell("PRINCIPAL AMOUNT", titleFont, Element.ALIGN_RIGHT, Element.ALIGN_MIDDLE, true));

            // beginning cash balance
            table.addCell(new Phrase(transactionStatementReport.getBeginningDate(), cellFont));
            table.addCell(new Phrase("Beginning Cash Balance", cellFont));
            String amount = "";
            amount = formatAmount(transactionStatementReport.getBeginningIncomeCash());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            amount = formatAmount(transactionStatementReport.getBeginningPrincipalCash());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));

            // transactions
            List<TransactionArchiveInfo> TransactionArchiveInfoList = transactionStatementReport
                    .getTransactionArchiveInfoList();
            for (TransactionArchiveInfo transactionArchiveInfo : TransactionArchiveInfoList) {
                table.addCell(new Phrase(transactionArchiveInfo.getPostedDate(), cellFont));
                table.addCell(new Phrase(getDescription(transactionArchiveInfo), cellFont));
                amount = formatAmount(transactionArchiveInfo.getTransactionIncomeCash());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
                amount = formatAmount(transactionArchiveInfo.getTransactionPrincipalCash());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            }

            // ending cash balance
            table.addCell(new Phrase(transactionStatementReport.getEndingDate(), cellFont));
            table.addCell(new Phrase("Ending Cash Balance", cellFont));
            amount = formatAmount(transactionStatementReport.getEndingIncomeCash());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            amount = formatAmount(transactionStatementReport.getEndingPrincipalCash());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));

            document.add(table);

            // footer
            printFooter(transactionStatementReport.getFooter(), document);
        }

    } catch (Exception e) {
        return false;
    }

    return true;
}

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

License:Educational Community License

/**
 * Helper method to write the document header
 * //from  w  w  w . j  av a 2 s .  co  m
 * @param document
 * @param transactionSummaryReport
 */
protected void writeDocumentHeader(Document document,
        TransactionSummaryReportDataHolder transactionSummaryReport) {
    // header
    StringBuffer title = new StringBuffer();
    title.append(transactionSummaryReport.getInstitution()).append("\n");
    title.append("SUMMARY OF ACTIVITY FROM ");
    title.append(transactionSummaryReport.getBeginningDate()).append(" TO ")
            .append(transactionSummaryReport.getEndingDate()).append("\n");
    title.append(transactionSummaryReport.getKemid()).append("     ")
            .append(transactionSummaryReport.getKemidLongTitle()).append("\n\n");
    try {
        Paragraph header = new Paragraph(title.toString());
        header.setAlignment(Element.ALIGN_CENTER);
        document.add(header);
    } catch (DocumentException de) {
        LOG.info("writeDocumentHeader(): Unable to create the header for the report");
    }
}

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

License:Educational Community License

/**
 * Helper method to write a line containing the column headings for the report
 * /* ww w  .j a v a2  s.  c o m*/
 * @return table
 */
protected PdfPTable writeDocumentTitleHeadings(String reportOption) {
    // report table
    int pdfPTableColumns;
    int[] relativeWidthsForDetails = { 140, 25, 25, 25 };
    int[] relativeWidthsForSummary = { 140, 25 };

    if (EndowConstants.EndowmentReport.DETAIL.equalsIgnoreCase(reportOption)) {
        pdfPTableColumns = 4;
    } else {
        pdfPTableColumns = 2;
    }

    try {
        PdfPTable table = new PdfPTable(pdfPTableColumns);
        table.setWidthPercentage(FULL_TABLE_WIDTH);
        table.setWidths((EndowConstants.EndowmentReport.DETAIL.equalsIgnoreCase(reportOption))
                ? relativeWidthsForDetails
                : relativeWidthsForSummary);
        table.getDefaultCell().setPadding(5);

        // table titles
        table.addCell(new Phrase("", titleFont));

        if (EndowConstants.EndowmentReport.DETAIL.equalsIgnoreCase(reportOption)) {
            table.addCell(createCell("INCOME", titleFont, Element.ALIGN_CENTER, true));
            table.addCell(createCell("PRINCIPAL", titleFont, Element.ALIGN_CENTER, true));
        }

        table.addCell(createCell("TOTAL", titleFont, Element.ALIGN_CENTER, true));
        return table;
    } catch (DocumentException ex) {
        LOG.info("Unable to write column headers.");
        return null;
    }
}

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

License:Educational Community License

/**
 * Generates the Trial Balance report//from   ww w . j a v a2s .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;
}

From source file:org.kuali.kfs.module.purap.pdf.BulkReceivingPdf.java

License:Open Source License

private void loadHeaderTable() throws Exception {

    float[] headerWidths = { 0.20f, 0.80f };

    headerTable = new PdfPTable(headerWidths);
    headerTable.setWidthPercentage(100);
    headerTable.setHorizontalAlignment(Element.ALIGN_CENTER);
    headerTable.setSplitLate(false);//from  w  w  w .  java 2 s .c  om
    headerTable.getDefaultCell().setBorderWidth(0);
    headerTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    headerTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_CENTER);

    /**
     * Logo display
     */
    if (StringUtils.isNotBlank(logoImage)) {
        logo = Image.getInstance(logoImage);
        logo.scalePercent(3, 3);
        headerTable.addCell(new Phrase(new Chunk(logo, 0, 0)));
    } else {
        headerTable.addCell(new Phrase(new Chunk("")));
    }

    /**
     * Nested table in tableHeader to display title and doc number
     */
    float[] nestedHeaderWidths = { 0.70f, 0.30f };
    nestedHeaderTable = new PdfPTable(nestedHeaderWidths);
    nestedHeaderTable.setSplitLate(false);
    PdfPCell cell;

    /**
     * Title
     */
    cell = new PdfPCell(new Paragraph("RECEIVING TICKET", ver_15_normal));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorderWidth(0);
    nestedHeaderTable.addCell(cell);

    /**
     * Doc Number
     */
    Paragraph p = new Paragraph();
    p.add(new Chunk("Doc Number: ", ver_11_normal));
    p.add(new Chunk(blkRecDoc.getDocumentNumber().toString(), cour_10_normal));
    cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setBorderWidth(0);
    nestedHeaderTable.addCell(cell);

    // Add the nestedHeaderTable to the headerTable
    cell = new PdfPCell(nestedHeaderTable);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorderWidth(0);
    headerTable.addCell(cell);
}