List of usage examples for com.lowagie.text Element ALIGN_RIGHT
int ALIGN_RIGHT
To view the source code for com.lowagie.text Element ALIGN_RIGHT.
Click Source Link
From source file:org.kuali.coeus.common.impl.print.watermark.WatermarkServiceImpl.java
License:Open Source License
/** * This method is for setting the properties of watermark Text. */// w w w. j av a2 s. c o m private void decoratePdfWatermarkText(PdfContentByte pdfContentByte, Rectangle rectangle, WatermarkBean watermarkBean) { float x, y, x1, y1, angle; final float OPACITY = 0.3f; PdfGState pdfGState = new PdfGState(); pdfGState.setFillOpacity(OPACITY); int pageWidth = (int) rectangle.getWidth(); int pageHeight = (int) rectangle.getHeight(); try { if (watermarkBean.getType().equalsIgnoreCase(WatermarkConstants.WATERMARK_TYPE_TEXT)) { pdfContentByte.beginText(); pdfContentByte.setGState(pdfGState); Color fillColor = watermarkBean.getFont().getColor() == null ? WatermarkConstants.DEFAULT_WATERMARK_COLOR : watermarkBean.getFont().getColor(); pdfContentByte.setColorFill(fillColor); if (watermarkBean.getPosition().equals(WatermarkConstants.WATERMARK_POSITION_FOOTER)) { pdfContentByte.setFontAndSize(watermarkBean.getFont().getBaseFont(), watermarkBean.getPositionFont().getSize()); if (watermarkBean.getAlignment().equals(WatermarkConstants.ALIGN_CENTER)) { pdfContentByte.showTextAligned(Element.ALIGN_CENTER, watermarkBean.getText(), (rectangle.getLeft(rectangle.getBorderWidthLeft()) + rectangle.getRight(rectangle.getBorderWidthRight())) / 2, rectangle.getBottom(rectangle.getBorderWidthBottom() + watermarkBean.getPositionFont().getSize()), 0); } else if (watermarkBean.getAlignment().equals(WatermarkConstants.ALIGN_RIGHT)) { pdfContentByte.showTextAligned(Element.ALIGN_RIGHT, watermarkBean.getText(), rectangle.getRight(rectangle.getBorderWidthRight()), rectangle.getBottom(rectangle.getBorderWidthBottom() + watermarkBean.getPositionFont().getSize()), 0); } else if (watermarkBean.getAlignment().equals(WatermarkConstants.ALIGN_LEFT)) { pdfContentByte.showTextAligned(Element.ALIGN_LEFT, watermarkBean.getText(), rectangle.getLeft(rectangle.getBorderWidthLeft()), rectangle.getBottom(rectangle.getBorderWidthBottom() + watermarkBean.getPositionFont().getSize()), 0); } } else if (watermarkBean.getPosition().equals(WatermarkConstants.WATERMARK_POSITION_HEADER)) { pdfContentByte.setFontAndSize(watermarkBean.getFont().getBaseFont(), watermarkBean.getPositionFont().getSize()); if (watermarkBean.getAlignment().equals(WatermarkConstants.ALIGN_CENTER)) { pdfContentByte.showTextAligned(Element.ALIGN_CENTER, watermarkBean.getText(), (rectangle.getLeft(rectangle.getBorderWidthLeft()) + rectangle.getRight(rectangle.getBorderWidthRight())) / 2, rectangle.getTop( rectangle.getBorderWidthTop() + watermarkBean.getPositionFont().getSize()), 0); } else if (watermarkBean.getAlignment().equals(WatermarkConstants.ALIGN_RIGHT)) { pdfContentByte.showTextAligned(Element.ALIGN_RIGHT, watermarkBean.getText(), rectangle.getRight(rectangle.getBorderWidthRight()), rectangle.getTop( rectangle.getBorderWidthTop() + watermarkBean.getPositionFont().getSize()), 0); } else if (watermarkBean.getAlignment().equals(WatermarkConstants.ALIGN_LEFT)) { pdfContentByte.showTextAligned(Element.ALIGN_LEFT, watermarkBean.getText(), rectangle.getLeft(rectangle.getBorderWidthLeft()), rectangle.getTop( rectangle.getBorderWidthTop() + watermarkBean.getPositionFont().getSize()), 0); } } else { pdfContentByte.setFontAndSize(watermarkBean.getFont().getBaseFont(), watermarkBean.getFont().getSize()); int textWidth = (int) pdfContentByte.getEffectiveStringWidth(watermarkBean.getText(), false); int diagonal = (int) Math.sqrt((pageWidth * pageWidth) + (pageHeight * pageHeight)); int pivotPoint = (diagonal - textWidth) / 2; angle = (float) Math.atan((float) pageHeight / pageWidth); x = (float) (pivotPoint * pageWidth) / diagonal; y = (float) (pivotPoint * pageHeight) / diagonal; x1 = (float) (((float) watermarkBean.getFont().getSize() / 2) * Math.sin(angle)); y1 = (float) (((float) watermarkBean.getFont().getSize() / 2) * Math.cos(angle)); pdfContentByte.showTextAligned(Element.ALIGN_LEFT, watermarkBean.getText(), x + x1, y - y1, (float) Math.toDegrees(angle)); } pdfContentByte.endText(); } } catch (Exception exception) { LOG.error("Exception occured in WatermarkServiceImpl. Water mark Exception: " + exception.getMessage()); } }
From source file:org.kuali.kfs.module.ar.report.service.impl.ContractsGrantsInvoiceReportServiceImpl.java
License:Open Source License
/** * this method generated the actual pdf for the Contracts & Grants LOC Review Document. * * @param os// ww w . ja v a 2 s.c o m * @param LOCDocument */ protected void generateLOCReviewInPdf(OutputStream os, ContractsGrantsLetterOfCreditReviewDocument locDocument) { try { Document document = new Document( new Rectangle(ArConstants.LOCReviewPdf.LENGTH, ArConstants.LOCReviewPdf.WIDTH)); PdfWriter.getInstance(document, os); document.open(); Paragraph header = new Paragraph(); Paragraph text = new Paragraph(); Paragraph title = new Paragraph(); // Lets write the header header.add(new Paragraph(configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_TITLE), ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT)); if (StringUtils.isNotEmpty(locDocument.getLetterOfCreditFundGroupCode())) { header.add(new Paragraph( configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_FUND_GROUP_CODE) + locDocument.getLetterOfCreditFundGroupCode(), ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT)); } if (StringUtils.isNotEmpty(locDocument.getLetterOfCreditFundCode())) { header.add(new Paragraph( configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_FUND_CODE) + locDocument.getLetterOfCreditFundCode(), ArConstants.PdfReportFonts.LOC_REVIEW_TITLE_FONT)); } header.add(new Paragraph(KFSConstants.BLANK_SPACE)); header.setAlignment(Element.ALIGN_CENTER); title.add(new Paragraph( configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_NUMBER) + locDocument.getDocumentNumber(), ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT)); Person person = getPersonService() .getPerson(locDocument.getFinancialSystemDocumentHeader().getInitiatorPrincipalId()); // writing the Document details title.add(new Paragraph( configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_APP_DOC_STATUS) + locDocument.getFinancialSystemDocumentHeader().getApplicationDocumentStatus(), ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT)); title.add( new Paragraph( configService.getPropertyValueAsString( ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_INITIATOR) + person.getName(), ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT)); title.add(new Paragraph( configService .getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_HEADER_DOCUMENT_CREATE_DATE) + getDateTimeService().toDateString( locDocument.getFinancialSystemDocumentHeader().getWorkflowCreateDate()), ArConstants.PdfReportFonts.LOC_REVIEW_HEADER_FONT)); title.add(new Paragraph(KFSConstants.BLANK_SPACE)); title.setAlignment(Element.ALIGN_RIGHT); text.add(new Paragraph( configService.getPropertyValueAsString(ArKeyConstants.LOC_REVIEW_PDF_SUBHEADER_AWARDS), ArConstants.PdfReportFonts.LOC_REVIEW_SMALL_BOLD)); text.add(new Paragraph(KFSConstants.BLANK_SPACE)); document.add(header); document.add(title); document.add(text); PdfPTable table = new PdfPTable(11); table.setTotalWidth(ArConstants.LOCReviewPdf.RESULTS_TABLE_WIDTH); // fix the absolute width of the table table.setLockedWidth(true); // relative col widths in proportions - 1/11 float[] widths = new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f }; table.setWidths(widths); table.setHorizontalAlignment(0); addAwardHeaders(table); if (CollectionUtils.isNotEmpty(locDocument.getHeaderReviewDetails()) && CollectionUtils.isNotEmpty(locDocument.getAccountReviewDetails())) { for (ContractsGrantsLetterOfCreditReviewDetail item : locDocument.getHeaderReviewDetails()) { table.addCell(Long.toString(item.getProposalNumber())); table.addCell(item.getAwardDocumentNumber()); table.addCell(item.getAgencyNumber()); table.addCell(item.getCustomerNumber()); table.addCell(getDateTimeService().toDateString(item.getAwardBeginningDate())); table.addCell(getDateTimeService().toDateString(item.getAwardEndingDate())); table.addCell( contractsGrantsBillingUtilityService.formatForCurrency(item.getAwardBudgetAmount())); table.addCell( contractsGrantsBillingUtilityService.formatForCurrency(item.getLetterOfCreditAmount())); table.addCell( contractsGrantsBillingUtilityService.formatForCurrency(item.getClaimOnCashBalance())); table.addCell(contractsGrantsBillingUtilityService.formatForCurrency(item.getAmountToDraw())); table.addCell(contractsGrantsBillingUtilityService .formatForCurrency(item.getAmountAvailableToDraw())); PdfPCell cell = new PdfPCell(); cell.setPadding(ArConstants.LOCReviewPdf.RESULTS_TABLE_CELL_PADDING); cell.setColspan(ArConstants.LOCReviewPdf.RESULTS_TABLE_COLSPAN); PdfPTable newTable = new PdfPTable(ArConstants.LOCReviewPdf.INNER_TABLE_COLUMNS); newTable.setTotalWidth(ArConstants.LOCReviewPdf.INNER_TABLE_WIDTH); // fix the absolute width of the newTable newTable.setLockedWidth(true); // relative col widths in proportions - 1/8 float[] newWidths = new float[] { 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f }; newTable.setWidths(newWidths); newTable.setHorizontalAlignment(0); addAccountsHeaders(newTable); for (ContractsGrantsLetterOfCreditReviewDetail newItem : locDocument .getAccountReviewDetails()) { if (item.getProposalNumber().equals(newItem.getProposalNumber())) { newTable.addCell(newItem.getAccountDescription()); newTable.addCell(newItem.getChartOfAccountsCode()); newTable.addCell(newItem.getAccountNumber()); String accountExpirationDate = KFSConstants.EMPTY_STRING; if (!ObjectUtils.isNull(newItem.getAccountExpirationDate())) { accountExpirationDate = getDateTimeService() .toDateString(newItem.getAccountExpirationDate()); } newTable.addCell(accountExpirationDate); newTable.addCell(contractsGrantsBillingUtilityService .formatForCurrency(newItem.getAwardBudgetAmount())); newTable.addCell(contractsGrantsBillingUtilityService .formatForCurrency(newItem.getClaimOnCashBalance())); newTable.addCell(contractsGrantsBillingUtilityService .formatForCurrency(newItem.getAmountToDraw())); newTable.addCell(contractsGrantsBillingUtilityService .formatForCurrency(newItem.getFundsNotDrawn())); } } cell.addElement(newTable); table.addCell(cell); } document.add(table); } document.close(); } catch (DocumentException e) { LOG.error("problem during ContractsGrantsInvoiceReportServiceImpl.generateInvoiceInPdf()", e); } }
From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java
License:Open Source License
/** * This method adds the log lines into the report * // www .j ava 2s .co m * @param reportLog */ private void generateReportLogBody(List<String[]> reportLog) { try { Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL); int columnwidths[]; columnwidths = new int[] { 40, 15 }; Table aTable = new Table(2, linesPerPage); int rowsWritten = 0; for (String[] columns : reportLog) { if (pageNumber == 0 || line >= linesPerPage) { if (pageNumber > 0) { this.document.add(aTable); } int elementsLeft = reportLog.size() - rowsWritten; int rowsNeeded = (elementsLeft >= linesPerPage ? linesPerPage : elementsLeft); this.document.newPage(); this.generateColumnHeaders(); aTable = new Table(2, rowsNeeded); // 12 columns, 11 rows. aTable.setAutoFillEmptyCells(true); aTable.setPadding(3); aTable.setWidths(columnwidths); aTable.setWidth(100); aTable.setBorder(Rectangle.NO_BORDER); line = 0; pageNumber++; } rowsWritten++; Cell cell; cell = new Cell(new Phrase(columns[0], font)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable.addCell(cell); cell = new Cell(new Phrase(columns[1], font)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable.addCell(cell); line++; } this.document.add(aTable); } catch (DocumentException de) { throw new RuntimeException( "DepreciationReport.generateReportLogBody(List<String[]> reportLog) - error: " + de.getMessage()); } }
From source file:org.kuali.kfs.module.endow.report.util.AssetStatementReportPrint.java
License:Educational Community License
/** * Prints report body for endowment detail * //from w ww . ja v a2s. c o 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 * //from w ww . ja v a 2s .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 w w w.j a v a 2s .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 * /*from w w w . j av a 2 s .co 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/*from www. 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.EndowmentReportPrintBase.java
License:Educational Community License
/** * Created a cell with a specific font//from w ww . j ava 2 s. c o m * * @param value * @param font * @return */ protected PdfPCell getAmountCell(BigDecimal value, Font font) { String amount = (value == null) ? ZERO_FOR_REPORT : formatAmount(value); return createCell(amount, font, Element.ALIGN_RIGHT, true); }
From source file:org.kuali.kfs.module.endow.report.util.EndowmentReportPrintBase.java
License:Educational Community License
/** * Created a cell with a specific font and format * /*from w ww . j a va2 s . c o m*/ * @param value * @param font * @param format * @return */ protected PdfPCell getAmountCell(BigDecimal value, Font font, String format) { String amount = (value == null) ? ZERO_FOR_REPORT : formatAmount(value, format); return createCell(amount, font, Element.ALIGN_RIGHT, true); }