List of usage examples for com.itextpdf.text.pdf PdfPCell setPaddingRight
public void setPaddingRight(float paddingRight)
From source file:com.dandymadeproductions.ajqvue.io.PDFDataTableDumpThread.java
License:Open Source License
public void run() { // Class Method Instances String title;//from w ww . ja v a 2s. c o m Font titleFont; Font rowHeaderFont; Font tableDataFont; BaseFont rowHeaderBaseFont; PdfPTable pdfTable; PdfPCell titleCell; PdfPCell rowHeaderCell; PdfPCell bodyCell; Document pdfDocument; PdfWriter pdfWriter; ByteArrayOutputStream byteArrayOutputStream; int columnCount, rowNumber; int[] columnWidths; int totalWidth; Rectangle pageSize; ProgressBar dumpProgressBar; HashMap<String, String> summaryListTableNameTypes; DataExportProperties pdfDataExportOptions; String currentTableFieldName; String currentType, currentString; // Setup columnCount = summaryListTable.getColumnCount(); rowNumber = summaryListTable.getRowCount(); columnWidths = new int[columnCount]; pdfTable = new PdfPTable(columnCount); pdfTable.setWidthPercentage(100); pdfTable.getDefaultCell().setPaddingBottom(4); pdfTable.getDefaultCell().setBorderWidth(1); summaryListTableNameTypes = new HashMap<String, String>(); pdfDataExportOptions = DBTablesPanel.getDataExportProperties(); titleFont = new Font(pdfDataExportOptions.getFont()); titleFont.setStyle(Font.BOLD); titleFont.setSize((float) pdfDataExportOptions.getTitleFontSize()); titleFont.setColor(new BaseColor(pdfDataExportOptions.getTitleColor().getRGB())); rowHeaderFont = new Font(pdfDataExportOptions.getFont()); rowHeaderFont.setStyle(Font.BOLD); rowHeaderFont.setSize((float) pdfDataExportOptions.getHeaderFontSize()); rowHeaderFont.setColor(new BaseColor(pdfDataExportOptions.getHeaderColor().getRGB())); rowHeaderBaseFont = rowHeaderFont.getCalculatedBaseFont(false); tableDataFont = pdfDataExportOptions.getFont(); // Constructing progress bar. dumpProgressBar = new ProgressBar(exportedTable + " Dump"); dumpProgressBar.setTaskLength(rowNumber); dumpProgressBar.pack(); dumpProgressBar.center(); dumpProgressBar.setVisible(true); // Create a Title if Optioned. title = pdfDataExportOptions.getTitle(); if (!title.equals("")) { if (title.equals("EXPORTED TABLE")) title = exportedTable; titleCell = new PdfPCell(new Phrase(title, titleFont)); titleCell.setBorder(0); titleCell.setPadding(10); titleCell.setColspan(summaryListTable.getColumnCount()); titleCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pdfTable.addCell(titleCell); pdfTable.setHeaderRows(2); } else pdfTable.setHeaderRows(1); // Create Row Header. for (int i = 0; i < columnCount; i++) { currentTableFieldName = summaryListTable.getColumnName(i); rowHeaderCell = new PdfPCell(new Phrase(currentTableFieldName, rowHeaderFont)); rowHeaderCell.setBorderWidth(pdfDataExportOptions.getHeaderBorderSize()); rowHeaderCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); rowHeaderCell.setBorderColor(new BaseColor(pdfDataExportOptions.getHeaderBorderColor().getRGB())); pdfTable.addCell(rowHeaderCell); columnWidths[i] = Math.min(50000, Math.max(columnWidths[i], rowHeaderBaseFont.getWidth(currentTableFieldName + " "))); if (tableColumnTypeNameHashMap != null) summaryListTableNameTypes.put(Integer.toString(i), tableColumnTypeNameHashMap.get(currentTableFieldName)); else summaryListTableNameTypes.put(Integer.toString(i), "String"); } // Create the Body of Data. int i = 0; while ((i < rowNumber) && !dumpProgressBar.isCanceled()) { dumpProgressBar.setCurrentValue(i); // Collecting rows of data & formatting date & timestamps // as needed according to the Export Properties. if (summaryListTable.getValueAt(i, 0) != null) { for (int j = 0; j < summaryListTable.getColumnCount(); j++) { currentString = summaryListTable.getValueAt(i, j) + ""; currentString = currentString.replaceAll("\n", ""); currentString = currentString.replaceAll("\r", ""); currentType = summaryListTableNameTypes.get(Integer.toString(j)); // Format Date & Timestamp Fields as Needed. if ((currentType != null) && (currentType.equals("DATE") || currentType.equals("DATETIME") || currentType.indexOf("TIMESTAMP") != -1)) { if (!currentString.toLowerCase(Locale.ENGLISH).equals("null")) { int firstSpace; String time; // Dates fall through DateTime and Timestamps try // to get the time separated before formatting // the date. if (currentString.indexOf(" ") != -1) { firstSpace = currentString.indexOf(" "); time = currentString.substring(firstSpace); currentString = currentString.substring(0, firstSpace); } else time = ""; currentString = Utils.convertViewDateString_To_DBDateString(currentString, DBTablesPanel.getGeneralDBProperties().getViewDateFormat()); currentString = Utils.convertDBDateString_To_ViewDateString(currentString, pdfDataExportOptions.getPDFDateFormat()) + time; } } bodyCell = new PdfPCell(new Phrase(currentString, tableDataFont)); bodyCell.setPaddingBottom(4); if (currentType != null) { // Set Numeric Fields Alignment. if (currentType.indexOf("BIT") != -1 || currentType.indexOf("BOOL") != -1 || currentType.indexOf("NUM") != -1 || currentType.indexOf("INT") != -1 || currentType.indexOf("FLOAT") != -1 || currentType.indexOf("DOUBLE") != -1 || currentType.equals("REAL") || currentType.equals("DECIMAL") || currentType.indexOf("COUNTER") != -1 || currentType.equals("BYTE") || currentType.equals("CURRENCY")) { bodyCell.setHorizontalAlignment(pdfDataExportOptions.getNumberAlignment()); bodyCell.setPaddingRight(4); } // Set Date/Time Field Alignment. if (currentType.indexOf("DATE") != -1 || currentType.indexOf("TIME") != -1 || currentType.indexOf("YEAR") != -1) bodyCell.setHorizontalAlignment(pdfDataExportOptions.getDateAlignment()); } pdfTable.addCell(bodyCell); columnWidths[j] = Math.min(50000, Math.max(columnWidths[j], BASE_FONT.getWidth(currentString + " "))); } } i++; } dumpProgressBar.dispose(); // Check to see if any data was in the summary // table to even be saved. if (pdfTable.size() <= pdfTable.getHeaderRows()) return; // Create a document of the PDF formatted data // to be saved to the given output file. try { // Sizing & Layout totalWidth = 0; for (int width : columnWidths) totalWidth += width; if (pdfDataExportOptions.getPageLayout() == PDFExportPreferencesPanel.LAYOUT_PORTRAIT) pageSize = PageSize.A4; else { pageSize = PageSize.A4.rotate(); pageSize.setRight(pageSize.getRight() * Math.max(1f, totalWidth / 53000f)); pageSize.setTop(pageSize.getTop() * Math.max(1f, totalWidth / 53000f)); } pdfTable.setWidths(columnWidths); // Document pdfDocument = new Document(pageSize); byteArrayOutputStream = new ByteArrayOutputStream(); pdfWriter = PdfWriter.getInstance(pdfDocument, byteArrayOutputStream); pdfDocument.open(); pdfTemplate = pdfWriter.getDirectContent().createTemplate(100, 100); pdfTemplate.setBoundingBox(new com.itextpdf.text.Rectangle(-20, -20, 100, 100)); pdfWriter.setPageEvent(this); pdfDocument.add(pdfTable); pdfDocument.close(); // Outputting WriteDataFile.mainWriteDataString(fileName, byteArrayOutputStream.toByteArray(), false); } catch (DocumentException de) { if (Ajqvue.getDebug()) { System.out.println("Failed to Create Document Needed to Output Data. \n" + de.toString()); } } }
From source file:com.etest.pdfgenerator.ItemAnalysisReportPDF.java
public ItemAnalysisReportPDF(int tqCoverageId) { this.tqCoverageId = tqCoverageId; Document document = null;//from www. ja v a2s . c o m Date date = new Date(); try { document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter.getInstance(document, outputStream); document.open(); Font header = FontFactory.getFont("Times-Roman", 12, Font.BOLD); Font content = FontFactory.getFont("Times-Roman", 10); Font dateFont = FontFactory.getFont("Times-Roman", 8); Image img = null; try { img = Image.getInstance("C:\\eTest-images\\SUCN_seal.png"); img.scaleToFit(60, 60); img.setAbsolutePosition(450, 730); } catch (BadElementException | IOException ex) { Logger.getLogger(TQCoveragePDF.class.getName()).log(Level.SEVERE, null, ex); } document.add(img); Paragraph reportTitle = new Paragraph(); reportTitle.setAlignment(Element.ALIGN_CENTER); reportTitle.add(new Phrase("Item Analysis Report", header)); document.add(reportTitle); Paragraph datePrinted = new Paragraph(); datePrinted.setSpacingAfter(20f); datePrinted.setAlignment(Element.ALIGN_CENTER); datePrinted.add( new Phrase("Date printed: " + new SimpleDateFormat("dd MMMM yyyy").format(date), dateFont)); document.add(datePrinted); Paragraph subject = new Paragraph(); subject.setAlignment(Element.ALIGN_LEFT); subject.add(new Phrase( "Subject: " + cs.getCurriculumById(tq.getTQCoverageById(getTqCoverageId()).getCurriculumId()) .getSubject().toUpperCase(), content)); document.add(subject); Paragraph term = new Paragraph(); term.setAlignment(Element.ALIGN_LEFT); term.add(new Phrase("SY and Semester Administered: 2015-16 2nd Semester", content)); document.add(term); Paragraph type = new Paragraph(); type.setSpacingAfter(20f); type.setAlignment(Element.ALIGN_LEFT); type.add( new Phrase("Type of Test: " + tq.getTQCoverageById(getTqCoverageId()).getExamTitle(), content)); document.add(type); PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100); table.setWidths(new int[] { 130, 300, 300, 300, 300 }); // table.setSpacingAfter(5f); PdfPCell cellOne = new PdfPCell(new Phrase("Item No.")); cellOne.setBorderWidthTop(1); cellOne.setBorderWidthLeft(1); cellOne.setBorderWidthRight(1); cellOne.setBorderWidthBottom(1); cellOne.setPaddingLeft(10); cellOne.setPaddingRight(10); cellOne.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cellOne.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellTwo = new PdfPCell(new Phrase("Difficulty")); cellTwo.setBorderWidthTop(1); cellTwo.setBorderWidthLeft(1); cellTwo.setBorderWidthRight(1); cellTwo.setBorderWidthBottom(1); cellTwo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTwo.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellThree = new PdfPCell(new Phrase("Interpretation")); cellThree.setBorderWidthTop(1); cellThree.setBorderWidthLeft(1); cellThree.setBorderWidthRight(1); cellThree.setBorderWidthBottom(1); cellThree.setHorizontalAlignment(Element.ALIGN_CENTER); cellThree.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellFour = new PdfPCell(new Phrase("Discrimination")); cellFour.setBorderWidthTop(1); cellFour.setBorderWidthLeft(1); cellFour.setBorderWidthRight(1); cellFour.setBorderWidthBottom(1); cellFour.setHorizontalAlignment(Element.ALIGN_CENTER); cellFour.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cellFive = new PdfPCell(new Phrase("Interpretation")); cellFive.setBorderWidthTop(1); cellFive.setBorderWidthLeft(1); cellFive.setBorderWidthRight(1); cellFive.setBorderWidthBottom(1); cellFive.setHorizontalAlignment(Element.ALIGN_CENTER); cellFive.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cellOne); table.addCell(cellTwo); table.addCell(cellThree); table.addCell(cellFour); table.addCell(cellFive); table.getDefaultCell().setBorderWidth(0f); document.add(table); PdfPTable table2 = new PdfPTable(5); table2.setWidthPercentage(100); table2.setWidths(new int[] { 130, 300, 300, 300, 300 }); int itemNo = 1; for (CellItem ci : cis.getItemAnalysisResult(tqCoverageId)) { PdfPCell cell1 = new PdfPCell(new Paragraph(String.valueOf(itemNo), content)); cell1.setBorderWidthTop(1); cell1.setBorderWidthLeft(1); cell1.setBorderWidthRight(1); cell1.setBorderWidthBottom(1); cell1.setPaddingLeft(10); cell1.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); cell1.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell2 = new PdfPCell(new Paragraph(String.valueOf(ci.getDifficultIndex()), content)); cell2.setBorderWidthTop(1); cell2.setBorderWidthLeft(1); cell2.setBorderWidthRight(1); cell2.setBorderWidthBottom(1); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell3 = new PdfPCell(new Paragraph( ItemAnalysisInterpretation.getDifficultyInterpretation(ci.getDifficultIndex()), content)); cell3.setBorderWidthTop(1); cell3.setBorderWidthLeft(1); cell3.setBorderWidthRight(1); cell3.setBorderWidthBottom(1); cell3.setHorizontalAlignment(Element.ALIGN_CENTER); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell4 = new PdfPCell(new Paragraph(String.valueOf(ci.getDiscriminationIndex()), content)); cell4.setBorderWidthTop(1); cell4.setBorderWidthLeft(1); cell4.setBorderWidthRight(1); cell4.setBorderWidthBottom(1); cell4.setHorizontalAlignment(Element.ALIGN_CENTER); cell4.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell5 = new PdfPCell(new Paragraph( ItemAnalysisInterpretation.getDiscriminationInterpretation(ci.getDiscriminationIndex()), content)); cell5.setBorderWidthTop(1); cell5.setBorderWidthLeft(1); cell5.setBorderWidthRight(1); cell5.setBorderWidthBottom(1); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); cell5.setVerticalAlignment(Element.ALIGN_MIDDLE); table2.addCell(cell1); table2.addCell(cell2); table2.addCell(cell3); table2.addCell(cell4); table2.addCell(cell5); itemNo++; } table.getDefaultCell().setBorderWidth(0f); document.add(table2); } catch (DocumentException ex) { Logger.getLogger(ItemAnalysisReportPDF.class.getName()).log(Level.SEVERE, null, ex); } finally { document.close(); } }
From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public LinkedHashMap<String, PdfPCell> getTotalCharges(List<LclBlAc> chargeList, List<LclBlPiece> lclBlPiecesList) throws Exception { List formattedChargesList = null; String chargeCode = ""; LinkedHashMap<String, PdfPCell> chargeMap = new LinkedHashMap<String, PdfPCell>(); if (chargeList != null && chargeList.size() > 0 && lclBlPiecesList != null) { if (!"".equalsIgnoreCase(engmet)) { if (lclBlPiecesList.size() == 1) { formattedChargesList = blUtils.getFormattedLabelChargesForBl(lclBlPiecesList, chargeList, engmet, null, true); } else { formattedChargesList = blUtils.getRolledUpChargesForBl(lclBlPiecesList, chargeList, engmet, null, true);/* ww w . j a v a 2 s . co m*/ } } Double bundleMinchg = 0.0; Double flatRateMinimum = 0.0; Double barrelBundlechg = 0.0; Double barrelAmount = 0.0; boolean is_OFBARR_Bundle = false; if (formattedChargesList != null && !formattedChargesList.isEmpty()) { PdfPCell chargeCell = null; Paragraph p = null; for (int i = 0; i < formattedChargesList.size(); i++) { LclBlAc lclBlAc = (LclBlAc) formattedChargesList.get(i); if (lclBlAc.getBundleIntoOf()) { if ("TTBARR".equalsIgnoreCase(lclBlAc.getArglMapping().getChargeCode())) { if (null != lclBlAc.getRolledupCharges()) { barrelBundlechg += lclBlAc.getRolledupCharges().doubleValue(); } else if (!CommonUtils.isEmpty(lclBlAc.getArAmount())) { barrelBundlechg += lclBlAc.getArAmount().doubleValue(); } } else { if ("OFBARR".equalsIgnoreCase(lclBlAc.getArglMapping().getChargeCode())) { is_OFBARR_Bundle = true; } if (null != lclBlAc.getRolledupCharges()) { bundleMinchg += lclBlAc.getRolledupCharges().doubleValue(); } else if (!CommonUtils.isEmpty(lclBlAc.getArAmount())) { bundleMinchg += lclBlAc.getArAmount().doubleValue(); } } } } for (int k = 0; k < formattedChargesList.size(); k++) { LclBlAc lclBlAc = (LclBlAc) formattedChargesList.get(k); if (lclBlAc.getArglMapping().getChargeCode().equals(CommonConstants.OFR_CHARGECODE)) { if (null != lclBlAc.getRolledupCharges()) { flatRateMinimum = lclBlAc.getRolledupCharges().doubleValue() + bundleMinchg; } else if (lclBlAc != null && lclBlAc.getArAmount() != null) { flatRateMinimum = lclBlAc.getArAmount().doubleValue() + bundleMinchg; } } else if (!is_OFBARR_Bundle && lclBlAc.getArglMapping().getChargeCode().equalsIgnoreCase("OFBARR")) { if (null != lclBlAc.getRolledupCharges()) { barrelAmount = lclBlAc.getRolledupCharges().doubleValue() + barrelBundlechg; } else if (lclBlAc.getArAmount() != null) { barrelAmount = lclBlAc.getArAmount().doubleValue() + barrelBundlechg; } } } Iterator sList = formattedChargesList.iterator(); while (sList.hasNext()) { LclBlAc lclBl = (LclBlAc) sList.next(); if (lclBl.getBundleIntoOf()) { sList.remove(); } else if (!lclBl.getPrintOnBl()) { sList.remove(); } } for (int i = 0; i < formattedChargesList.size(); i++) { LclBlAc lclBlAc = (LclBlAc) formattedChargesList.get(i); String chargeDesc = null; String lbl = ""; if (lclBlAc.getArglMapping() != null && CommonUtils.isNotEmpty(lclBlAc.getArglMapping().getChargeCode())) { chargeCode = lclBlAc.getArglMapping().getChargeCode(); chargeDesc = CommonUtils.isNotEmpty(lclBlAc.getArglMapping().getChargeDescriptions()) ? lclBlAc.getArglMapping().getChargeDescriptions() : lclBlAc.getArglMapping().getChargeCode(); } String ar_amountLabel = ""; if (lclBlAc.getArAmount() != null) { if (lclBlAc.getArglMapping().getChargeCode().equals(CommonConstants.OFR_CHARGECODE)) { flatRateMinimum += is_OFBARR_Bundle ? barrelBundlechg : 0; this.total_ar_amount += flatRateMinimum; ar_amountLabel = NumberUtils.convertToTwoDecimal(flatRateMinimum); OCNFRT_Total = NumberUtils.convertToTwoDecimal(flatRateMinimum); } else if (!is_OFBARR_Bundle && lclBlAc.getArglMapping().getChargeCode().equalsIgnoreCase("OFBARR")) { this.total_ar_amount += barrelAmount; ar_amountLabel = NumberUtils.convertToTwoDecimal(barrelAmount); } else if (null != lclBlAc.getRolledupCharges()) { this.total_ar_amount += lclBlAc.getRolledupCharges().doubleValue(); ar_amountLabel = lclBlAc.getRolledupCharges().toString(); } else if (!CommonUtils.isEmpty(lclBlAc.getArAmount())) { this.total_ar_amount += lclBlAc.getArAmount().doubleValue(); ar_amountLabel = lclBlAc.getArAmount().toString(); } } chargeCell = new PdfPCell(); chargeCell.setBorder(0); if (lclBlAc.getRatePerUnitUom().equalsIgnoreCase("W") || lclBlAc.getRatePerUnitUom().equalsIgnoreCase("FRW")) { lbl = "WT"; chargeCell.setPaddingRight(-14); } else if (lclBlAc.getRatePerUnitUom().equalsIgnoreCase("V") || lclBlAc.getRatePerUnitUom().equalsIgnoreCase("FRV")) { lbl = "MEA"; chargeCell.setPaddingRight(-14); } else if (lclBlAc.getRatePerUnitUom().equalsIgnoreCase("M") || lclBlAc.getRatePerUnitUom().equalsIgnoreCase("FRM")) { lbl = "MIN"; chargeCell.setPaddingRight(-14); } else { chargeCell.setPaddingRight(7); } chargeCell.setPaddingLeft(-5); p = new Paragraph(7f, ar_amountLabel + " " + lbl, totalFontQuote); p.setAlignment(Element.ALIGN_RIGHT); chargeCell.addElement(p); int blAcId = lclBlAc.getId().intValue(); chargeMap.put(chargeCode + "#" + chargeDesc + "$" + blAcId, chargeCell); } } } return chargeMap; }
From source file:com.gp.cong.logisoft.lcl.report.LclAllBLPdfCreator.java
public List<LinkedHashMap<String, PdfPCell>> getTotalChargesList(List<LclBlAc> chargeList, List<LclBlPiece> lclBlPiecesList) throws Exception { List<LinkedHashMap<String, PdfPCell>> l = new ArrayList<LinkedHashMap<String, PdfPCell>>(); List formattedChargesList = null; String chargeCode = ""; LinkedHashMap<String, PdfPCell> ppdChargeMap = new LinkedHashMap<String, PdfPCell>(); LinkedHashMap<String, PdfPCell> colChargeMap = new LinkedHashMap<String, PdfPCell>(); Double bundleMinchg = 0.0;/*from www. j av a 2s . c o m*/ Double flatRateMinimum = 0.0; Double barrelBundlechg = 0.0; Double barrelAmount = 0.0; boolean is_OFBARR_Bundle = false; PdfPCell chargeCell = null; Paragraph p = null; if (chargeList != null && chargeList.size() > 0 && lclBlPiecesList != null) { String engmet = new PortsDAO() .getEngmet(lclbl.getFinalDestination() != null ? lclbl.getFinalDestination().getUnLocationCode() : lclbl.getPortOfDestination().getUnLocationCode()); if (!"".equalsIgnoreCase(engmet)) { if (lclBlPiecesList.size() == 1) { formattedChargesList = blUtils.getFormattedLabelChargesForBl(lclBlPiecesList, chargeList, engmet, null, true); } else { formattedChargesList = blUtils.getRolledUpChargesForBl(lclBlPiecesList, chargeList, engmet, null, true); } } if (formattedChargesList != null && !formattedChargesList.isEmpty()) { for (int i = 0; i < formattedChargesList.size(); i++) { LclBlAc lclBlAc = (LclBlAc) formattedChargesList.get(i); if (lclBlAc.getBundleIntoOf()) { if ("TTBARR".equalsIgnoreCase(lclBlAc.getArglMapping().getChargeCode())) { if (null != lclBlAc.getRolledupCharges()) { barrelBundlechg += lclBlAc.getRolledupCharges().doubleValue(); } else if (!CommonUtils.isEmpty(lclBlAc.getArAmount())) { barrelBundlechg += lclBlAc.getArAmount().doubleValue(); } } else { if ("OFBARR".equalsIgnoreCase(lclBlAc.getArglMapping().getChargeCode())) { is_OFBARR_Bundle = true; } if (null != lclBlAc.getRolledupCharges()) { bundleMinchg += lclBlAc.getRolledupCharges().doubleValue(); } else if (!CommonUtils.isEmpty(lclBlAc.getArAmount())) { bundleMinchg += lclBlAc.getArAmount().doubleValue(); } } } } for (int k = 0; k < formattedChargesList.size(); k++) { LclBlAc lclBlAc = (LclBlAc) formattedChargesList.get(k); if (lclBlAc.getArglMapping().getChargeCode().equals(CommonConstants.OFR_CHARGECODE)) { if (null != lclBlAc.getRolledupCharges()) { flatRateMinimum = lclBlAc.getRolledupCharges().doubleValue() + bundleMinchg; } else if (lclBlAc != null && lclBlAc.getArAmount() != null) { flatRateMinimum = lclBlAc.getArAmount().doubleValue() + bundleMinchg; } } else if (!is_OFBARR_Bundle && lclBlAc.getArglMapping().getChargeCode().equalsIgnoreCase("OFBARR")) { if (null != lclBlAc.getRolledupCharges()) { barrelAmount = lclBlAc.getRolledupCharges().doubleValue() + barrelBundlechg; } else if (lclBlAc != null && lclBlAc.getArAmount() != null) { barrelAmount = lclBlAc.getArAmount().doubleValue() + barrelBundlechg; } } } Iterator sList = formattedChargesList.iterator(); while (sList.hasNext()) { LclBlAc lclBl = (LclBlAc) sList.next(); if (lclBl.getBundleIntoOf()) { sList.remove(); } else if (!lclBl.getPrintOnBl()) { sList.remove(); } } for (int i = 0; i < formattedChargesList.size(); i++) { LclBlAc lclBlAc = (LclBlAc) formattedChargesList.get(i); String chargeDesc = null; String lbl = ""; if (lclBlAc.getArglMapping() != null && CommonUtils.isNotEmpty(lclBlAc.getArglMapping().getChargeCode())) { chargeCode = lclBlAc.getArglMapping().getChargeCode(); chargeDesc = CommonUtils.isNotEmpty(lclBlAc.getArglMapping().getChargeDescriptions()) ? lclBlAc.getArglMapping().getChargeDescriptions() : lclBlAc.getArglMapping().getChargeCode(); } String ar_amountLabel = ""; if (lclBlAc.getArAmount() != null) { if (lclBlAc.getArglMapping().getChargeCode().equals(CommonConstants.OFR_CHARGECODE)) { flatRateMinimum += is_OFBARR_Bundle ? barrelBundlechg : 0; if ("A".equalsIgnoreCase(lclBlAc.getArBillToParty())) { this.total_ar_col_amount += flatRateMinimum; } else { this.total_ar_ppd_amount += flatRateMinimum; } ar_amountLabel = NumberUtils.convertToTwoDecimal(flatRateMinimum); OCNFRT_Total = NumberUtils.convertToTwoDecimal(flatRateMinimum); } else if (!is_OFBARR_Bundle && lclBlAc.getArglMapping().getChargeCode().equalsIgnoreCase("OFBARR")) { if ("A".equalsIgnoreCase(lclBlAc.getArBillToParty())) { this.total_ar_col_amount += barrelAmount; } else { this.total_ar_ppd_amount += barrelAmount; } ar_amountLabel = NumberUtils.convertToTwoDecimal(barrelAmount); } else if (null != lclBlAc.getRolledupCharges()) { if ("A".equalsIgnoreCase(lclBlAc.getArBillToParty())) { this.total_ar_col_amount += lclBlAc.getRolledupCharges().doubleValue(); } else { this.total_ar_ppd_amount += lclBlAc.getRolledupCharges().doubleValue(); } ar_amountLabel = lclBlAc.getRolledupCharges().toString(); } else if (!CommonUtils.isEmpty(lclBlAc.getArAmount())) { if ("A".equalsIgnoreCase(lclBlAc.getArBillToParty())) { this.total_ar_col_amount += lclBlAc.getArAmount().doubleValue(); } else { this.total_ar_ppd_amount += lclBlAc.getArAmount().doubleValue(); } ar_amountLabel = lclBlAc.getArAmount().toString(); } } chargeCell = new PdfPCell(); chargeCell.setBorder(0); if ("A".equalsIgnoreCase(lclBlAc.getArBillToParty())) { lbl = "COL"; } else { lbl = "PPD"; } chargeCell.setPaddingRight(-14); chargeCell.setPaddingLeft(-5); p = new Paragraph(7f, ar_amountLabel + " " + lbl, totalFontQuote); p.setAlignment(Element.ALIGN_RIGHT); chargeCell.addElement(p); int blAcId = lclBlAc.getId().intValue(); if ("A".equalsIgnoreCase(lclBlAc.getArBillToParty())) { colChargeMap.put(chargeCode + "#" + chargeDesc + "$" + blAcId, chargeCell); } else { ppdBillToSet.add(lclBlAc.getArBillToParty()); ppdChargeMap.put(chargeCode + "#" + chargeDesc + "$" + blAcId, chargeCell); } } if (!ppdChargeMap.isEmpty() && !colChargeMap.isEmpty()) { l.add(0, ppdChargeMap); l.add(1, colChargeMap); } else if (!ppdChargeMap.isEmpty()) { l.add(0, ppdChargeMap); } else if (!colChargeMap.isEmpty()) { l.add(0, colChargeMap); } } } return l; }
From source file:com.softwaremagico.tm.pdf.complete.skills.MainSkillsTableFactory.java
License:Open Source License
public static PdfPTable getSkillsTable(CharacterPlayer characterPlayer, String language) throws InvalidXmlElementException { float[] widths = { 1f, 12f, 1f }; PdfPTable table = new PdfPTable(widths); setTablePropierties(table);/*from ww w .j ava 2 s . c o m*/ PdfPCell separator = createSeparator(); separator.setPadding(PADDING); table.addCell(separator); table.addCell(separator); table.addCell(separator); PdfPCell vitalityCell = new PdfPCell(new VitalityTable(characterPlayer)); vitalityCell.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP | Rectangle.LEFT); vitalityCell.setPadding(0); table.addCell(vitalityCell); PdfPCell skillsCell = new PdfPCell(CompleteSkillsTable.getSkillsTable(characterPlayer, language)); skillsCell.setBorder(0); skillsCell.setPadding(0); skillsCell.setPaddingRight(FadingSunsTheme.DEFAULT_MARGIN); skillsCell.setPaddingLeft(FadingSunsTheme.DEFAULT_MARGIN); table.addCell(skillsCell); PdfPCell wyrdCell = new PdfPCell(new WyrdTable(characterPlayer)); wyrdCell.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP | Rectangle.LEFT); wyrdCell.setPadding(0); table.addCell(wyrdCell); return table; }
From source file:com.softwaremagico.tm.pdf.small.counters.VitalityTable.java
License:Open Source License
public VitalityTable(CharacterPlayer characterPlayer) { super(characterPlayer); getDefaultCell().setBorder(0);/*from www .j a v a 2 s . c o m*/ Font font = new Font(FadingSunsTheme.getTitleFont(), FadingSunsTheme.CHARACTER_VITALITY_TITLE_FONT_SIZE); Phrase content = new Phrase(getTranslator().getTranslatedText("vitality"), font); PdfPCell titleCell = new PdfPCell(content); titleCell.setBorder(0); titleCell.setPaddingRight(0); titleCell.setPaddingTop(paddingTop); titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE); addCell(titleCell); addedCircle = 0; for (int i = 0; i < getNumberOfCircles(); i++) { addCell(getCircle()); addedCircle++; } }
From source file:com.softwaremagico.tm.pdf.small.counters.VitalityTable.java
License:Open Source License
@Override protected PdfPCell createCircle() { if (addedCircle >= 5) { return super.createCircle(); }/*from w w w . ja va 2s . co m*/ PdfPCell cell = createValue("-" + (10 - addedCircle * 2), new Font(FadingSunsTheme.getLineFontBold(), FadingSunsTheme.CHARACTER_VITALITY_PENALTIES_TITLE_FONT_SIZE), Element.ALIGN_MIDDLE); cell.setPaddingTop(0f); cell.setPaddingRight(-2f); return cell; }
From source file:com.solidmaps.webapp.report.EnableCompanyRequerimentFederalPDF.java
private void insertCellAlteracaoOption(PdfPTable table, String number, String text, Boolean selected) { String fullText = ""; if (selected) { fullText += number + " |X|" + " " + text; } else {/*from w ww .j av a 2 s.c o m*/ fullText += number + " | |" + " " + text; } if (StringUtils.isBlank(number) && StringUtils.isBlank(text)) { fullText = ""; } // create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(fullText.trim(), FONT_PARAGRAPH)); // set the cell alignment // in case there is no text and you wan to create an empty row if (fullText.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(Rectangle.RIGHT); cell.setPaddingTop(10f); cell.setPaddingBottom(10f); cell.setPaddingLeft(10f); cell.setPaddingRight(10f); // add the call to the table table.addCell(cell); }
From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java
private void insertCellAlteracaoOption(PdfPTable table, String number, String text, Boolean selected) { String fullText = ""; if (selected) { fullText += number + " |X|" + " " + text; } else {//w w w. j a v a 2 s.co m fullText += number + " | |" + " " + text; } if (StringUtils.isBlank(number) && StringUtils.isBlank(text)) { fullText = ""; } // create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(fullText.trim(), FONT_PARAGRAPH)); // set the cell alignment // in case there is no text and you wan to create an empty row if (fullText.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(2); cell.setBorder(Rectangle.RIGHT); cell.setPaddingTop(10f); cell.setPaddingBottom(10f); cell.setPaddingLeft(25f); cell.setPaddingRight(25f); // add the call to the table table.addCell(cell); }
From source file:com.vectorprint.report.itext.style.stylers.Padding.java
License:Open Source License
public PdfPCell style(PdfPCell cell, Object data) { switch (getWhichPadding()) { case LEFT://from w w w . j av a 2 s . c o m case LB: case LBT: case LR: case LRB: case LRT: case LT: case TRBL: cell.setPaddingLeft(getPadding()); } switch (getWhichPadding()) { case LBT: case LRT: case LT: case TRBL: case RBT: case RT: case TOP: case BT: cell.setPaddingTop(getPadding()); } switch (getWhichPadding()) { case LB: case LBT: case LRB: case TRBL: case RB: case RBT: case BOTTOM: case BT: cell.setPaddingBottom(getPadding()); } switch (getWhichPadding()) { case LR: case LRB: case LRT: case TRBL: case RIGHT: case RB: case RBT: case RT: cell.setPaddingRight(getPadding()); } return cell; }