List of usage examples for java.text NumberFormat getCurrencyInstance
public static final NumberFormat getCurrencyInstance()
From source file:stockit.allStocks.java
private void stockPerfmActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stockPerfmActionPerformed // TODO add your handling code here: DefaultCategoryDataset dataset = new DefaultCategoryDataset(); int row = table.getSelectedRow(); if (row != -1) { //dataset.setValue(, "", table.getValueAt(0,1).toString()); String selectedStock = table.getValueAt(row, 0).toString(); try {//from w w w.j a va 2 s . c o m DBConnection dbcon = new DBConnection(); dbcon.establishConnection(); Statement stmt = dbcon.con.createStatement(); ResultSet rs = stmt .executeQuery("Select stock_daily_performance.Closing_Price, stock_daily_performance.Date\n" + "FROM stock_daily_performance, stock\n" + "WHERE stock_daily_performance.StockID = stock.StockID AND stock.StockID = '" + selectedStock + "'" + "AND Date IN\n" + "( Select * from\n" + "(\n" + "SELECT Date \n" + "FROM stock_daily_performance \n" + "WHERE StockID = stockID \n" + "ORDER BY Date ASC\n" + ") temp_table)\n" + " "); while (rs.next()) { String formattedDate = rs.getString("Date"); int closing_price = rs.getInt("Closing_Price"); System.out.println("Closing Price: " + closing_price); System.out.println("Date: " + formattedDate); dataset.setValue(closing_price, "value", formattedDate); } dbcon.con.close(); } catch (Exception ex) { Logger.getLogger(clientLogin.class.getName()).log(Level.SEVERE, null, ex); } String stockName = table.getValueAt(row, 1).toString(); JFreeChart chart = ChartFactory.createLineChart(stockName + " Stock Performance", "Date", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); Color c = new Color(240, 240, 240, 0); chart.setBackgroundPaint(c); CategoryPlot catPlot = chart.getCategoryPlot(); catPlot.setRangeGridlinePaint(Color.BLACK); //set interval of Y-axis ticks (tick every 5 units) NumberAxis yAxis = (NumberAxis) catPlot.getRangeAxis(); yAxis.setTickUnit(new NumberTickUnit(5)); //set y-axis labels as currency types ($) NumberFormat currency = NumberFormat.getCurrencyInstance(); yAxis.setNumberFormatOverride(currency); //setting number of lines an x-axis label is displayed on CategoryAxis categoryAxis = catPlot.getDomainAxis(); categoryAxis.setMaximumCategoryLabelLines(4); graphPanel.setLayout(new java.awt.BorderLayout()); ChartPanel chartPanel = new ChartPanel(chart); graphPanel.removeAll(); graphPanel.add(chartPanel, BorderLayout.CENTER); graphPanel.validate(); graphPanel.repaint(); } }
From source file:biz.wolschon.fileformats.gnucash.baseclasses.SimpleAccount.java
/** * * @return The currency-format to use for formating. */// ww w . j a v a 2s. c o m public NumberFormat getCurrencyFormat() { if (currencyFormat == null) { currencyFormat = NumberFormat.getCurrencyInstance(); } // the currency may have changed if (this.getCurrencyNameSpace().equals(GnucashAccount.CURRENCYNAMESPACE_CURRENCY)) { Currency currency = getCurrency(); currencyFormat.setCurrency(currency); } else { currencyFormat = NumberFormat.getNumberInstance(); } return currencyFormat; }
From source file:org.pentaho.di.core.util.StringEvaluator.java
private void populateConversionMetaList() { int[] trimTypes; if (tryTrimming) { trimTypes = new int[] { ValueMetaInterface.TRIM_TYPE_NONE, ValueMetaInterface.TRIM_TYPE_BOTH, }; } else {/* ww w. j ava 2s . co m*/ trimTypes = new int[] { ValueMetaInterface.TRIM_TYPE_NONE, }; } for (int trimType : trimTypes) { for (String format : getDateFormats()) { ValueMetaInterface conversionMeta = new ValueMetaDate("date"); conversionMeta.setConversionMask(format); conversionMeta.setTrimType(trimType); conversionMeta.setDateFormatLenient(false); evaluationResults.add(new StringEvaluationResult(conversionMeta)); } EvalResultBuilder numberUsBuilder = new EvalResultBuilder("number-us", ValueMetaInterface.TYPE_NUMBER, 15, trimType, ".", ","); EvalResultBuilder numberEuBuilder = new EvalResultBuilder("number-eu", ValueMetaInterface.TYPE_NUMBER, 15, trimType, ",", "."); for (String format : getNumberFormats()) { if (format.equals("#") || format.equals("0")) { // skip the integer ones. we'll get those later continue; } int precision = determinePrecision(format); evaluationResults.add(numberUsBuilder.format(format, precision).build()); evaluationResults.add(numberEuBuilder.format(format, precision).build()); } // Try the locale's Currency DecimalFormat currencyFormat = ((DecimalFormat) NumberFormat.getCurrencyInstance()); ValueMetaInterface conversionMeta = new ValueMetaNumber("number-currency"); // replace the universal currency symbol with the locale's currency symbol for user recognition String currencyMask = currencyFormat.toLocalizedPattern().replace("\u00A4", currencyFormat.getCurrency().getSymbol()); conversionMeta.setConversionMask(currencyMask); conversionMeta.setTrimType(trimType); conversionMeta.setDecimalSymbol( String.valueOf(currencyFormat.getDecimalFormatSymbols().getDecimalSeparator())); conversionMeta.setGroupingSymbol( String.valueOf(currencyFormat.getDecimalFormatSymbols().getGroupingSeparator())); conversionMeta.setCurrencySymbol(currencyFormat.getCurrency().getSymbol()); conversionMeta.setLength(15); int currencyPrecision = currencyFormat.getCurrency().getDefaultFractionDigits(); conversionMeta.setPrecision(currencyPrecision); evaluationResults.add(new StringEvaluationResult(conversionMeta)); // add same mask w/o currency symbol String currencyMaskAsNumeric = currencyMask .replaceAll(Pattern.quote(currencyFormat.getCurrency().getSymbol()), ""); evaluationResults.add(numberUsBuilder.format(currencyMaskAsNumeric, currencyPrecision).build()); evaluationResults.add(numberEuBuilder.format(currencyMaskAsNumeric, currencyPrecision).build()); // Integer // conversionMeta = new ValueMetaInteger("integer"); conversionMeta.setConversionMask("#"); conversionMeta.setLength(15); evaluationResults.add(new StringEvaluationResult(conversionMeta)); conversionMeta = new ValueMetaInteger("integer"); conversionMeta.setConversionMask(" #"); conversionMeta.setLength(15); evaluationResults.add(new StringEvaluationResult(conversionMeta)); // Add support for left zero padded integers // for (int i = 1; i <= 15; i++) { String mask = " "; for (int x = 0; x < i; x++) { mask += "0"; } mask += ";-"; for (int x = 0; x < i; x++) { mask += "0"; } conversionMeta = new ValueMetaInteger("integer-zero-padded-" + i); conversionMeta.setConversionMask(mask); conversionMeta.setLength(i); evaluationResults.add(new StringEvaluationResult(conversionMeta)); } // Boolean // conversionMeta = new ValueMetaBoolean("boolean"); evaluationResults.add(new StringEvaluationResult(conversionMeta)); } }
From source file:org.ojbc.bundles.adapters.staticmock.samplegen.CriminalHistorySampleGenerator.java
private void addMainCycleElements(Document parentDocument, Element rapSheetElement, List<Arrest> arrests) { Element e;//from www.j a va2 s. c om for (Arrest arrest : arrests) { boolean courtAction = false; Element rapSheetCycle = appendElement(rapSheetElement, OjbcNamespaceContext.NS_CH_EXT, "RapSheetCycle"); e = appendElement(rapSheetCycle, OjbcNamespaceContext.NS_RAPSHEET_41, "CycleEarliestDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(arrest.date)); Element arrestElement = appendElement(rapSheetCycle, OjbcNamespaceContext.NS_RAPSHEET_41, "Arrest"); XmlUtils.addAttribute(arrestElement, OjbcNamespaceContext.NS_STRUCTURES, "id", arrest.id); e = appendElement(arrestElement, OjbcNamespaceContext.NS_NC, "ActivityDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(arrest.date)); e = appendElement(arrestElement, OjbcNamespaceContext.NS_JXDM_41, "ArrestAgencyRecordIdentification"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(arrest.recordId); for (ArrestCharge arrestCharge : arrest.charges) { Element arrestChargeElement = appendElement(arrestElement, OjbcNamespaceContext.NS_RAPSHEET_41, "ArrestCharge"); e = appendElement(arrestChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeDescriptionText"); e.setTextContent(arrestCharge.description); if (!arrestCharge.prosecuted) { e = appendElement(arrestChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeDisposition"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "DispositionDescriptionText"); e.setTextContent("LACK OF PROS"); } else { courtAction = true; } e = appendElement(arrestChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeIdentification"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(arrestCharge.id); e = appendElement(arrestChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeSeverityText"); e.setTextContent(arrestCharge.severity); e = appendElement(arrestChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeTrackingIdentification"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(arrestCharge.trackingId); } boolean sentenced = false; if (courtAction && arrest.dispoDate != null) { Element courtActionElement = appendElement(rapSheetCycle, OjbcNamespaceContext.NS_RAPSHEET_41, "CourtAction"); for (ArrestCharge arrestCharge : arrest.charges) { if (arrestCharge.prosecuted) { Element courtChargeElement = appendElement(courtActionElement, OjbcNamespaceContext.NS_RAPSHEET_41, "CourtCharge"); e = appendElement(courtChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeDescriptionText"); e.setTextContent(arrestCharge.description); e = appendElement(courtChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeDisposition"); Element dispoElement = e; e = appendElement(dispoElement, OjbcNamespaceContext.NS_NC, "DispositionDate"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "Date"); e.setTextContent(DATE_FORMATTER_YYYY_MM_DD.print(arrest.dispoDate)); e = appendElement(dispoElement, OjbcNamespaceContext.NS_NC, "DispositionDescriptionText"); if (arrestCharge.guilty) { e.setTextContent("GUILTY"); sentenced = true; } else { e.setTextContent("NOT GUILTY"); } e = appendElement(courtChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeIdentification"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(arrestCharge.id); e = appendElement(courtChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeSeverityText"); e.setTextContent(arrestCharge.severity); e = appendElement(courtChargeElement, OjbcNamespaceContext.NS_JXDM_41, "ChargeTrackingIdentification"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(arrestCharge.trackingId); } } } if (sentenced) { Element sentencingElement = appendElement(rapSheetCycle, OjbcNamespaceContext.NS_CH_EXT, "Sentencing"); for (ArrestCharge arrestCharge : arrest.charges) { if (arrestCharge.guilty) { Element sentenceElement = appendElement(sentencingElement, OjbcNamespaceContext.NS_CH_EXT, "Sentence"); e = appendElement(sentenceElement, OjbcNamespaceContext.NS_JXDM_41, "SentenceDescriptionText"); String termPeriod = " DAYS"; String sentenceType = " CONFINEMENT "; int termLength = arrestCharge.offense.daysInJail; if (termLength > 365 * 2) { termLength = (int) Math.round(termLength / 365.0); termPeriod = " YEARS"; } else if (termLength == 0) { termLength = (int) Math.round(arrestCharge.offense.daysOfProbation / 30.0); termPeriod = " MONTHS"; sentenceType = " PROBATION "; } e.setTextContent( "ON " + DATE_FORMATTER_MM_DD_YYYY.print(arrest.dispoDate) + " SUBJECT SENTENCED TO " + termLength + termPeriod + sentenceType + "AND " + "A FINE OF " + NumberFormat.getCurrencyInstance().format(arrestCharge.offense.fine)); e = appendElement(sentenceElement, OjbcNamespaceContext.NS_RAPSHEET_41, "SentenceCharge"); e = appendElement(e, OjbcNamespaceContext.NS_JXDM_41, "ChargeTrackingIdentification"); e = appendElement(e, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent(arrestCharge.trackingId); } } } } }
From source file:com.concursive.connect.web.modules.productcatalog.dao.Product.java
/** * Description of the Method/*from w ww. j a va 2 s . com*/ * * @return Description of the Return Value */ public String toString() { NumberFormat formatter = NumberFormat.getCurrencyInstance(); Currency currency = Currency.getInstance("USD"); formatter.setCurrency(currency); StringBuffer out = new StringBuffer(); out.append("Product: " + this.getName() + "\r\n"); out.append("Description: " + this.getPriceDescription() + "\r\n"); if (sku != null) { out.append("Sku: " + this.getSku() + "\r\n"); } out.append("Price: " + formatter.format(this.getTotalPrice()) + "\r\n"); out.append("Configuration: " + this.getConfiguredSummary() + "\r\n"); if (orderDescription != null) { out.append("Additional Information: " + this.getOrderDescription() + "\r\n"); } out.append("\r\n"); return out.toString(); }
From source file:com.pluscubed.velociraptor.SettingsActivity.java
private void showSupportDialog() { if (!billingProcessor.isInitialized()) { Snackbar.make(findViewById(android.R.id.content), R.string.in_app_unavailable, Snackbar.LENGTH_SHORT) .show();/*from w w w .ja v a 2 s . c o m*/ return; } final List<SkuDetails> purchaseListingDetails = billingProcessor .getPurchaseListingDetails(new ArrayList<>(Arrays.asList(PURCHASES))); final List<SkuDetails> subscriptionListingDetails = billingProcessor .getSubscriptionListingDetails(new ArrayList<>(Arrays.asList(SUBSCRIPTIONS))); if (purchaseListingDetails == null || purchaseListingDetails.isEmpty()) { Snackbar.make(findViewById(android.R.id.content), R.string.in_app_unavailable, Snackbar.LENGTH_SHORT) .show(); return; } purchaseListingDetails.addAll(0, subscriptionListingDetails); List<String> purchaseDisplay = new ArrayList<>(); for (SkuDetails details : purchaseListingDetails) { NumberFormat format = NumberFormat.getCurrencyInstance(); format.setCurrency(Currency.getInstance(details.currency)); String amount = format.format(details.priceValue); if (details.isSubscription) amount = String.format(getString(R.string.per_month), amount); else { amount = String.format(getString(R.string.one_time), amount); } purchaseDisplay.add(amount); } String content = getString(R.string.support_dev_dialog); if (PrefUtils.hasSupported(this) || !billingProcessor.listOwnedSubscriptions().isEmpty()) { content += "\n\n\uD83C\uDF89 " + getString(R.string.support_dev_dialog_badge) + " \uD83C\uDF89"; } new MaterialDialog.Builder(this) .icon(Utils.getVectorDrawableCompat(this, R.drawable.ic_favorite_black_24dp)) .title(R.string.support_development).content(content).items(purchaseDisplay) .itemsCallback(new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) { SkuDetails skuDetails = purchaseListingDetails.get(which); if (skuDetails.isSubscription) { billingProcessor.subscribe(SettingsActivity.this, skuDetails.productId); } else { billingProcessor.purchase(SettingsActivity.this, skuDetails.productId); } } }).show(); }
From source file:taximetrotema2.Main.java
private void jToggleButtonStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonStopActionPerformed jToggleButtonBanderaVerde.setEnabled(true); DecimalFormat formatoTicket = new DecimalFormat("00000"); contador++;/* w w w.j a va 2 s .c o m*/ String formatoContador = formatoTicket.format(contador); fechaHoraFin = Calendar.getInstance(); long milisegundosSalida = fechaHoraSalida.getTimeInMillis(); long milisegundosFin = fechaHoraFin.getTimeInMillis(); long duracionTrayectoMilis = milisegundosFin - milisegundosSalida; String formatoMilis = DurationFormatUtils.formatDuration(duracionTrayectoMilis, "HH:mm:ss"); NumberFormat formatoMoneda = NumberFormat.getCurrencyInstance(); double duracionTrayectoEnSeg = (duracionTrayectoMilis / 1000); double importe = (duracionTrayectoEnSeg / 60) * TARIFAXMINUTO; double importeIva = importe * IVA; double importeTotal = importe + importeIva; jTextArea1.setText("TICKET\n"); jTextArea1.append("======\n"); jTextArea1.append("Nticket: " + formatoContador); jTextArea1.append("\nFecha:" + formatoFecha.format(fechaHoraSalida.getTime())); jTextArea1.append("\n\n"); jTextArea1.append("Hora bajada de bandera: " + formatoHora.format(fechaHoraSalida.getTime())); jTextArea1.append("\nHora fin de trayecto: " + formatoHora.format(fechaHoraFin.getTime())); jTextArea1.append("\nDuracin de trayecto: " + formatoMilis); jTextArea1.append("\nTarifa por minuto: " + formatoMoneda.format(TARIFAXMINUTO)); jTextArea1.append("\n\n"); jTextArea1.append("Importe: " + formatoMoneda.format(importe)); jTextArea1.append("\nIVA: " + formatoMoneda.format(importeIva)); jTextArea1.append("\nImporte total: " + formatoMoneda.format(importeTotal)); jToggleButtonStop.setEnabled(false); }
From source file:org.kuali.ole.module.purap.pdf.PurchaseOrderPdf.java
/** * Create a PDF using the given input parameters. * * @param po The PurchaseOrderDocument to be used to create the pdf. * @param document The pdf document whose margins have already been set. * @param writer The PdfWriter to write the pdf document into. * @param statusInquiryUrl The status inquiry url to be displayed on the pdf document. * @param campusName The campus name to be displayed on the pdf document. * @param contractLanguage The contract language to be displayed on the pdf document. * @param logoImage The logo image file name to be displayed on the pdf document. * @param directorSignatureImage The director signature image to be displayed on the pdf document. * @param directorName The director name to be displayed on the pdf document. * @param directorTitle The director title to be displayed on the pdf document. * @param contractManagerSignatureImage The contract manager signature image to be displayed on the pdf document. * @param isRetransmit The boolean to indicate whether this is for a retransmit purchase order document. * @param environment The current environment used (e.g. DEV if it is a development environment). * @param retransmitItems The items selected by the user to be retransmitted. * @throws DocumentException//w ww .ja va 2s . com * @throws IOException */ private void createPdf(PurchaseOrderDocument po, Document document, PdfWriter writer, String statusInquiryUrl, String campusName, String contractLanguage, String logoImage, String directorSignatureImage, String directorName, String directorTitle, String contractManagerSignatureImage, boolean isRetransmit, String environment, List<PurchaseOrderItem> retransmitItems) throws DocumentException, IOException { if (LOG.isInfoEnabled()) { LOG.info("Inside createPdf statement" + "PO:" + po + "Document:" + document + "PdfWriter:" + writer + "StatusInquiryUrl:" + statusInquiryUrl + "Campus Name:" + campusName + "Contract Language" + contractLanguage + "Logo Image:" + logoImage + "Director Signature Image:" + directorSignatureImage + "Director Name" + directorName + "Director Title:" + directorTitle + "Contract Manager Signature Image :" + contractManagerSignatureImage + "isRetransmit" + isRetransmit + "Environment" + environment + "retransmitItems" + retransmitItems); } if (LOG.isDebugEnabled()) { LOG.debug("createPdf() started for po number " + po.getPurapDocumentIdentifier().toString()); } // These have to be set because they are used by the onOpenDocument() and onStartPage() methods. this.campusName = campusName; this.po = po; this.logoImage = logoImage; this.environment = environment; // Code has been changed to get the locale dynamically NumberFormat numberFormat = NumberFormat.getCurrencyInstance(); Collection errors = new ArrayList(); // Date format pattern: MM-dd-yyyy SimpleDateFormat sdf = new SimpleDateFormat(RiceConstants.SIMPLE_DATE_FORMAT_FOR_DATE, Locale.getDefault()); // This turns on the page events that handle the header and page numbers. PurchaseOrderPdf events = new PurchaseOrderPdf().getPageEvents(); writer.setPageEvent(this); // Passing in "this" lets it know about the po, campusName, etc. document.open(); PdfPCell cell; Paragraph p = new Paragraph(); // ***** Info table (vendor, address info) ***** LOG.debug("createPdf() info table started."); float[] infoWidths = { 0.50f, 0.50f }; PdfPTable infoTable = new PdfPTable(infoWidths); infoTable.setWidthPercentage(100); infoTable.setHorizontalAlignment(Element.ALIGN_CENTER); infoTable.setSplitLate(false); StringBuffer vendorInfo = new StringBuffer(); vendorInfo.append("\n"); if (StringUtils.isNotBlank(po.getVendorName())) { vendorInfo.append(" " + po.getVendorName() + "\n"); } vendorInfo.append(" ATTN: " + po.getVendorAttentionName() + "\n"); if (StringUtils.isNotBlank(po.getVendorLine1Address())) { vendorInfo.append(" " + po.getVendorLine1Address() + "\n"); } if (StringUtils.isNotBlank(po.getVendorLine2Address())) { vendorInfo.append(" " + po.getVendorLine2Address() + "\n"); } if (StringUtils.isNotBlank(po.getVendorCityName())) { vendorInfo.append(" " + po.getVendorCityName()); } if (StringUtils.isNotBlank(po.getVendorStateCode())) { vendorInfo.append(", " + po.getVendorStateCode()); } if (StringUtils.isNotBlank(po.getVendorAddressInternationalProvinceName())) { vendorInfo.append(", " + po.getVendorAddressInternationalProvinceName()); } if (StringUtils.isNotBlank(po.getVendorPostalCode())) { vendorInfo.append(" " + po.getVendorPostalCode() + "\n"); } else { vendorInfo.append("\n"); } if (!OLEConstants.COUNTRY_CODE_UNITED_STATES.equalsIgnoreCase(po.getVendorCountryCode()) && po.getVendorCountry() != null) { vendorInfo.append(" " + po.getVendorCountry().getName() + "\n\n"); } else { vendorInfo.append("\n\n"); } p = new Paragraph(); p.add(new Chunk(" Vendor", ver_5_normal)); p.add(new Chunk(vendorInfo.toString(), cour_7_normal)); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); StringBuffer shipToInfo = new StringBuffer(); shipToInfo.append("\n"); if (po.getAddressToVendorIndicator()) { // use receiving address shipToInfo.append(" " + po.getReceivingName() + "\n"); shipToInfo.append(" " + po.getReceivingLine1Address() + "\n"); if (StringUtils.isNotBlank(po.getReceivingLine2Address())) { shipToInfo.append(" " + po.getReceivingLine2Address() + "\n"); } shipToInfo.append(" " + po.getReceivingCityName() + ", " + po.getReceivingStateCode() + " " + po.getReceivingPostalCode() + "\n"); if (StringUtils.isNotBlank(po.getReceivingCountryCode()) && !OLEConstants.COUNTRY_CODE_UNITED_STATES.equalsIgnoreCase(po.getReceivingCountryCode())) { shipToInfo.append(" " + po.getReceivingCountryName() + "\n"); } } else { // use delivery address shipToInfo.append(" " + po.getDeliveryToName() + "\n"); // extra space needed below to separate other text going on same PDF line String deliveryBuildingName = po.getDeliveryBuildingName() + " "; if (po.isDeliveryBuildingOtherIndicator()) { deliveryBuildingName = ""; } shipToInfo .append(" " + deliveryBuildingName + "Room #" + po.getDeliveryBuildingRoomNumber() + "\n"); shipToInfo.append(" " + po.getDeliveryBuildingLine1Address() + "\n"); if (StringUtils.isNotBlank(po.getDeliveryBuildingLine2Address())) { shipToInfo.append(" " + po.getDeliveryBuildingLine2Address() + "\n"); } shipToInfo.append(" " + po.getDeliveryCityName() + ", " + po.getDeliveryStateCode() + " " + po.getDeliveryPostalCode() + "\n"); if (StringUtils.isNotBlank(po.getDeliveryCountryCode()) && !OLEConstants.COUNTRY_CODE_UNITED_STATES.equalsIgnoreCase(po.getDeliveryCountryCode())) { shipToInfo.append(" " + po.getDeliveryCountryName() + "\n"); } } // display deliveryToPhoneNumber disregard of whether receiving or delivery address is used shipToInfo.append(" " + po.getDeliveryToPhoneNumber()); /* // display deliveryToPhoneNumber based on the parameter indicator, disregard of whether receiving or delivery address is used boolean displayDeliveryPhoneNumber = SpringContext.getBean(ParameterService.class).getIndicatorParameter(PurchaseOrderDocument.class, PurapParameterConstants.DISPLAY_DELIVERY_PHONE_NUMBER_ON_PDF_IND); if (displayDeliveryPhoneNumber && StringUtils.isNotBlank(po.getDeliveryToPhoneNumber())) { shipToInfo.append(" " + po.getDeliveryToPhoneNumber()); } */ p = new Paragraph(); p.add(new Chunk(" Shipping Address", ver_5_normal)); p.add(new Chunk(shipToInfo.toString(), cour_7_normal)); cell = new PdfPCell(p); infoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk(" Shipping Terms\n", ver_5_normal)); if (po.getVendorShippingPaymentTerms() != null && po.getVendorShippingTitle() != null) { p.add(new Chunk(" " + po.getVendorShippingPaymentTerms().getVendorShippingPaymentTermsDescription(), cour_7_normal)); p.add(new Chunk(" - " + po.getVendorShippingTitle().getVendorShippingTitleDescription(), cour_7_normal)); } else if (po.getVendorShippingPaymentTerms() != null && po.getVendorShippingTitle() == null) { p.add(new Chunk(" " + po.getVendorShippingPaymentTerms().getVendorShippingPaymentTermsDescription(), cour_7_normal)); } else if (po.getVendorShippingTitle() != null && po.getVendorShippingPaymentTerms() == null) { p.add(new Chunk(" " + po.getVendorShippingTitle().getVendorShippingTitleDescription(), cour_7_normal)); } cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk(" Payment Terms\n", ver_5_normal)); if (po.getVendorPaymentTerms() != null) { p.add(new Chunk(" " + po.getVendorPaymentTerms().getVendorPaymentTermsDescription(), cour_7_normal)); } cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk(" Delivery Required By\n", ver_5_normal)); if (po.getDeliveryRequiredDate() != null && po.getDeliveryRequiredDateReason() != null) { p.add(new Chunk(" " + sdf.format(po.getDeliveryRequiredDate()), cour_7_normal)); p.add(new Chunk(" - " + po.getDeliveryRequiredDateReason().getDeliveryRequiredDateReasonDescription(), cour_7_normal)); } else if (po.getDeliveryRequiredDate() != null && po.getDeliveryRequiredDateReason() == null) { p.add(new Chunk(" " + sdf.format(po.getDeliveryRequiredDate()), cour_7_normal)); } else if (po.getDeliveryRequiredDate() == null && po.getDeliveryRequiredDateReason() != null) { p.add(new Chunk(" " + po.getDeliveryRequiredDateReason().getDeliveryRequiredDateReasonDescription(), cour_7_normal)); } cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk(" ", ver_5_normal)); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); // Nested table for Order Date, etc. float[] nestedInfoWidths = { 0.50f, 0.50f }; PdfPTable nestedInfoTable = new PdfPTable(nestedInfoWidths); nestedInfoTable.setSplitLate(false); p = new Paragraph(); p.add(new Chunk(" Order Date\n", ver_5_normal)); String orderDate = ""; if (po.getPurchaseOrderInitialOpenTimestamp() != null) { orderDate = sdf.format(po.getPurchaseOrderInitialOpenTimestamp()); } else { // This date isn't set until the first time this document is printed, so will be null the first time; use today's date. orderDate = sdf.format(getDateTimeService().getCurrentSqlDate()); } p.add(new Chunk(" " + orderDate, cour_7_normal)); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); nestedInfoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk(" Customer #\n", ver_5_normal)); if (po.getVendorCustomerNumber() != null) { p.add(new Chunk(" " + po.getVendorCustomerNumber(), cour_7_normal)); } cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); nestedInfoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk(" Delivery Instructions\n", ver_5_normal)); if (StringUtils.isNotBlank(po.getDeliveryInstructionText())) { p.add(new Chunk(" " + po.getDeliveryInstructionText(), cour_7_normal)); } cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); nestedInfoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk(" Contract ID\n", ver_5_normal)); if (po.getVendorContract() != null) { p.add(new Chunk(po.getVendorContract().getVendorContractName(), cour_7_normal)); } cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); nestedInfoTable.addCell(cell); // Add the nestedInfoTable to the infoTable cell = new PdfPCell(nestedInfoTable); cell.setHorizontalAlignment(Element.ALIGN_CENTER); infoTable.addCell(cell); StringBuffer billToInfo = new StringBuffer(); billToInfo.append("\n"); billToInfo.append(" " + po.getBillingName() + "\n"); billToInfo.append(" " + po.getBillingLine1Address() + "\n"); if (po.getBillingLine2Address() != null) { billToInfo.append(" " + po.getBillingLine2Address() + "\n"); } billToInfo.append(" " + po.getBillingCityName() + ", " + po.getBillingStateCode() + " " + po.getBillingPostalCode() + "\n"); if (po.getBillingPhoneNumber() != null) { billToInfo.append(" " + po.getBillingPhoneNumber()); } if (po.getBillingEmailAddress() != null) { billToInfo.append("\n " + po.getBillingEmailAddress()); } p = new Paragraph(); p.add(new Chunk(" Billing Address", ver_5_normal)); p.add(new Chunk(" " + billToInfo.toString(), cour_7_normal)); p.add(new Chunk("\n Invoice status inquiry: " + statusInquiryUrl, ver_6_normal)); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); document.add(infoTable); PdfPTable notesStipulationsTable = new PdfPTable(1); notesStipulationsTable.setWidthPercentage(100); notesStipulationsTable.setSplitLate(false); p = new Paragraph(); p.add(new Chunk(" Vendor Note(s)\n", ver_5_normal)); if (po.getVendorNoteText() != null) { p.add(new Chunk(" " + po.getVendorNoteText() + "\n", cour_7_normal)); } PdfPCell tableCell = new PdfPCell(p); tableCell.setHorizontalAlignment(Element.ALIGN_LEFT); tableCell.setVerticalAlignment(Element.ALIGN_TOP); notesStipulationsTable.addCell(tableCell); p = new Paragraph(); p.add(new Chunk(" Vendor Stipulations and Information\n", ver_5_normal)); if ((po.getPurchaseOrderBeginDate() != null) && (po.getPurchaseOrderEndDate() != null)) { p.add(new Chunk(" Order in effect from " + sdf.format(po.getPurchaseOrderBeginDate()) + " to " + sdf.format(po.getPurchaseOrderEndDate()) + ".\n", cour_7_normal)); } Collection<PurchaseOrderVendorStipulation> vendorStipulationsList = po.getPurchaseOrderVendorStipulations(); if (vendorStipulationsList.size() > 0) { StringBuffer vendorStipulations = new StringBuffer(); for (PurchaseOrderVendorStipulation povs : vendorStipulationsList) { vendorStipulations.append(" " + povs.getVendorStipulationDescription() + "\n"); } p.add(new Chunk(" " + vendorStipulations.toString(), cour_7_normal)); } tableCell = new PdfPCell(p); tableCell.setHorizontalAlignment(Element.ALIGN_LEFT); tableCell.setVerticalAlignment(Element.ALIGN_TOP); notesStipulationsTable.addCell(tableCell); document.add(notesStipulationsTable); // ***** Items table ***** LOG.debug("createPdf() items table started."); float[] itemsWidths = { 0.07f, 0.1f, 0.07f, 0.25f, 0.25f, 0.10f, 0.10f }; if (!po.isUseTaxIndicator()) { itemsWidths = ArrayUtils.add(itemsWidths, 0.14f); itemsWidths = ArrayUtils.add(itemsWidths, 0.15f); } PdfPTable itemsTable = new PdfPTable(itemsWidths.length); // itemsTable.setCellsFitPage(false); With this set to true a large cell will // skip to the next page. The default Table behaviour seems to be what we want: // start the large cell on the same page and continue it to the next. itemsTable.setWidthPercentage(100); itemsTable.setWidths(itemsWidths); itemsTable.setSplitLate(false); tableCell = new PdfPCell(new Paragraph("Item\nNo.", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph("Quantity", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph("UOM", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph("Description", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph("Special Instructions", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph("Unit Cost", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph("Extended Cost", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); if (!po.isUseTaxIndicator()) { tableCell = new PdfPCell(new Paragraph("Tax Amount", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph("Total Amount", ver_5_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); } Collection<PurchaseOrderItem> itemsList = new ArrayList(); if (isRetransmit) { itemsList = retransmitItems; } else { itemsList = po.getItems(); } for (PurchaseOrderItem poi : itemsList) { if ((poi.getItemType() != null) && (poi.getItemType().isLineItemIndicator() || poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_SHIP_AND_HAND_CODE) || poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_FREIGHT_CODE) || poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ORDER_DISCOUNT_CODE) || poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_TRADE_IN_CODE)) && lineItemDisplaysOnPdf(poi)) { boolean noteFlag = true; String description = (poi.getItemCatalogNumber() != null) ? poi.getItemCatalogNumber().trim() + " - " : ""; String vendorNotes = ""; if (poi.getNotes().size() > 0) { for (OleNotes oleNotes : poi.getNotes()) { String note = getNoteType(oleNotes.getNoteTypeId()); if ((note != null && note.equals(OLEConstants.VENDOR_TYPE)) && noteFlag) { vendorNotes = oleNotes.getNote(); noteFlag = false; } } } description = description + ((poi.getItemDescription() != null) ? poi.getItemDescription().trim() : ""); if (StringUtils.isNotBlank(description)) { if (poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ORDER_DISCOUNT_CODE) || poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_TRADE_IN_CODE) || poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_FREIGHT_CODE) || poi.getItemType().getItemTypeCode() .equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_SHIP_AND_HAND_CODE)) { // If this is a full order discount or trade-in item, we add the item type description to the description. description = poi.getItemType().getItemTypeDescription() + " - " + description; } } // Above the line item types items display the line number; other types don't. if (poi.getItemType().isLineItemIndicator()) { tableCell = new PdfPCell(new Paragraph(poi.getItemLineNumber().toString(), cour_7_normal)); } else { tableCell = new PdfPCell(new Paragraph(" ", cour_7_normal)); } tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); String quantity = (poi.getItemQuantity() != null) ? poi.getItemQuantity().toString() : " "; tableCell = new PdfPCell(new Paragraph(quantity, cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph(poi.getItemUnitOfMeasureCode(), cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_CENTER); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph(" " + description, cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_LEFT); itemsTable.addCell(tableCell); tableCell = new PdfPCell(new Paragraph(" " + vendorNotes, cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_LEFT); itemsTable.addCell(tableCell); String unitPrice = poi.getItemUnitPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString(); tableCell = new PdfPCell(new Paragraph(unitPrice + " ", cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); tableCell = new PdfPCell( new Paragraph(numberFormat.format(poi.getExtendedPrice()) + " ", cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); if (!po.isUseTaxIndicator()) { KualiDecimal taxAmount = poi.getItemTaxAmount(); taxAmount = taxAmount == null ? KualiDecimal.ZERO : taxAmount; tableCell = new PdfPCell(new Paragraph(numberFormat.format(taxAmount) + " ", cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); tableCell = new PdfPCell( new Paragraph(numberFormat.format(poi.getTotalAmount()) + " ", cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); } } } // Blank line before totals itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); if (!po.isUseTaxIndicator()) { itemsTable.addCell(" "); itemsTable.addCell(" "); } //Next Line if (!po.isUseTaxIndicator()) { //Print Total Prior to Tax itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); tableCell = new PdfPCell(new Paragraph("Total Prior to Tax: ", ver_10_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); itemsTable.addCell(tableCell); itemsTable.addCell(" "); KualiDecimal totalDollarAmount = new KualiDecimal(BigDecimal.ZERO); if (po instanceof PurchaseOrderRetransmitDocument) { totalDollarAmount = ((PurchaseOrderRetransmitDocument) po) .getTotalPreTaxDollarAmountForRetransmit(); } else { totalDollarAmount = po.getTotalPreTaxDollarAmount(); } tableCell = new PdfPCell(new Paragraph(numberFormat.format(totalDollarAmount) + " ", cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); //Print Total Tax itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); tableCell = new PdfPCell(new Paragraph("Total Tax: ", ver_10_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); itemsTable.addCell(tableCell); itemsTable.addCell(" "); totalDollarAmount = new KualiDecimal(BigDecimal.ZERO); if (po instanceof PurchaseOrderRetransmitDocument) { totalDollarAmount = ((PurchaseOrderRetransmitDocument) po).getTotalTaxDollarAmountForRetransmit(); } else { totalDollarAmount = po.getTotalTaxAmount(); } tableCell = new PdfPCell(new Paragraph(numberFormat.format(totalDollarAmount) + " ", cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); } // Totals line; first 5 cols empty itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); if (!po.isUseTaxIndicator()) { itemsTable.addCell(" "); itemsTable.addCell(" "); } tableCell = new PdfPCell(new Paragraph("Total order amount: ", ver_10_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); itemsTable.addCell(tableCell); itemsTable.addCell(" "); KualiDecimal totalDollarAmount = new KualiDecimal(BigDecimal.ZERO); if (po instanceof PurchaseOrderRetransmitDocument) { totalDollarAmount = ((PurchaseOrderRetransmitDocument) po).getTotalDollarAmountForRetransmit(); } else { totalDollarAmount = po.getTotalDollarAmount(); } tableCell = new PdfPCell(new Paragraph(numberFormat.format(totalDollarAmount) + " ", cour_7_normal)); tableCell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableCell.setNoWrap(true); itemsTable.addCell(tableCell); // Blank line after totals itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); if (!po.isUseTaxIndicator()) { itemsTable.addCell(" "); itemsTable.addCell(" "); } document.add(itemsTable); // Contract language. LOG.debug("createPdf() contract language started."); document.add(new Paragraph(contractLanguage, ver_6_normal)); document.add(new Paragraph("\n", ver_6_normal)); // ***** Signatures table ***** LOG.debug("createPdf() signatures table started."); float[] signaturesWidths = { 0.30f, 0.70f }; PdfPTable signaturesTable = new PdfPTable(signaturesWidths); signaturesTable.setWidthPercentage(100); signaturesTable.setHorizontalAlignment(Element.ALIGN_CENTER); signaturesTable.setSplitLate(false); // Director signature and "for more info" line; only on APOs if (po.getPurchaseOrderAutomaticIndicator()) { // Empty cell. cell = new PdfPCell(new Paragraph(" ", cour_7_normal)); cell.setBorderWidth(0); signaturesTable.addCell(cell); //boolean displayRequestorEmail = true; //SpringContext.getBean(ParameterService.class).getIndicatorParameter(PurchaseOrderDocument.class, PurapParameterConstants.DISPLAY_REQUESTOR_EMAIL_ADDRESS_ON_PDF_IND); if (StringUtils.isBlank(po.getInstitutionContactName()) || StringUtils.isBlank(po.getInstitutionContactPhoneNumber()) || StringUtils.isBlank(po.getInstitutionContactEmailAddress())) { //String emailAddress = displayRequestorEmail ? " " + po.getRequestorPersonEmailAddress() : ""; //p = new Paragraph("For more information contact: " + po.getRequestorPersonName() + " " + po.getRequestorPersonPhoneNumber() + emailAddress, cour_7_normal); p = new Paragraph( "For more information contact: " + po.getRequestorPersonName() + " " + po.getRequestorPersonPhoneNumber() + " " + po.getRequestorPersonEmailAddress(), cour_7_normal); } else { //String emailAddress = displayRequestorEmail ? " " + po.getInstitutionContactEmailAddress() : ""; //p = new Paragraph("For more information contact: " + po.getInstitutionContactName() + " " + po.getInstitutionContactPhoneNumber() + emailAddress, cour_7_normal); p = new Paragraph("For more information contact: " + po.getInstitutionContactName() + " " + po.getInstitutionContactPhoneNumber() + " " + po.getInstitutionContactEmailAddress(), cour_7_normal); } cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setBorderWidth(0); signaturesTable.addCell(cell); Image directorSignature = null; if (StringUtils.isNotBlank(directorSignatureImage)) { try { directorSignature = Image.getInstance(directorSignatureImage); } catch (FileNotFoundException e) { LOG.info("The director signature image [" + directorSignatureImage + "] is not available. Defaulting to the default image."); } } if (directorSignature == null) { // an empty cell if the contract manager signature image is not available. cell = new PdfPCell(); } else { directorSignature.scalePercent(30, 30); cell = new PdfPCell(directorSignature, false); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); cell.setBorderWidth(0); signaturesTable.addCell(cell); // Empty cell. cell = new PdfPCell(new Paragraph(" ", cour_7_normal)); cell.setBorderWidth(0); signaturesTable.addCell(cell); } // Director name and title; on every pdf. p = new Paragraph(); if (LOG.isDebugEnabled()) { LOG.debug("createPdf() directorName parameter: " + directorName); } if (po.getPurchaseOrderAutomaticIndicator()) { // The signature is on the pdf; use small font. p.add(new Chunk(directorName, ver_6_normal)); } else { // The signature isn't on the pdf; use larger font. p.add(new Chunk(directorName, ver_10_normal)); } p.add(new Chunk("\n" + directorTitle, ver_4_normal)); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setBorderWidth(0); signaturesTable.addCell(cell); // Contract manager signature, name and phone; only on non-APOs if (!po.getPurchaseOrderAutomaticIndicator()) { Image contractManagerSignature = null; if (StringUtils.isNotBlank(contractManagerSignatureImage)) { try { contractManagerSignature = Image.getInstance(contractManagerSignatureImage); } catch (FileNotFoundException e) { LOG.info("The contract manager image [" + contractManagerSignatureImage + "] is not available. Defaulting to the default image."); } } if (contractManagerSignature == null) { // an empty cell if the contract manager signature image is not available. cell = new PdfPCell(); } else { contractManagerSignature.scalePercent(15, 15); cell = new PdfPCell(contractManagerSignature, false); } cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); cell.setBorderWidth(0); signaturesTable.addCell(cell); // Empty cell. cell = new PdfPCell(new Paragraph(" ", ver_10_normal)); cell.setBorderWidth(0); signaturesTable.addCell(cell); cell = new PdfPCell(new Paragraph(po.getContractManager().getContractManagerName() + " " + po.getContractManager().getContractManagerPhoneNumber(), cour_7_normal)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_TOP); cell.setBorderWidth(0); signaturesTable.addCell(cell); } else { // Empty cell. cell = new PdfPCell(new Paragraph(" ", ver_10_normal)); cell.setBorderWidth(0); signaturesTable.addCell(cell); } document.add(signaturesTable); document.close(); LOG.debug("createPdf()pdf document closed."); }
From source file:com.pluscubed.velociraptor.settings.SettingsActivity.java
private void showSupportDialog() { String content = getString(BuildConfig.FLAVOR.equals("play") ? R.string.support_dev_dialog : R.string.support_dev_dialog_notplay); if (PrefUtils.hasSupported(this) || !billingProcessor.listOwnedSubscriptions().isEmpty()) { content += "\n\n\uD83C\uDF89 " + getString(R.string.support_dev_dialog_badge) + " \uD83C\uDF89"; }/*from w ww .j av a 2 s. c om*/ MaterialDialog.Builder builder = new MaterialDialog.Builder(this) .icon(Utils.getVectorDrawableCompat(this, R.drawable.ic_favorite_black_24dp)) .title(R.string.support_development).content(Html.fromHtml(content)); if (BuildConfig.FLAVOR.equals("play")) { if (!billingProcessor.isInitialized()) { Snackbar.make(findViewById(android.R.id.content), R.string.in_app_unavailable, Snackbar.LENGTH_SHORT).show(); return; } final List<SkuDetails> purchaseListingDetails = billingProcessor .getPurchaseListingDetails(new ArrayList<>(Arrays.asList(PURCHASES))); final List<SkuDetails> subscriptionListingDetails = billingProcessor .getSubscriptionListingDetails(new ArrayList<>(Arrays.asList(SUBSCRIPTIONS))); if (purchaseListingDetails == null || purchaseListingDetails.isEmpty()) { Snackbar.make(findViewById(android.R.id.content), R.string.in_app_unavailable, Snackbar.LENGTH_SHORT).show(); return; } purchaseListingDetails.addAll(0, subscriptionListingDetails); List<String> purchaseDisplay = new ArrayList<>(); for (SkuDetails details : purchaseListingDetails) { NumberFormat format = NumberFormat.getCurrencyInstance(); format.setCurrency(Currency.getInstance(details.currency)); String amount = format.format(details.priceValue); if (details.isSubscription) amount = String.format(getString(R.string.per_month), amount); else { amount = String.format(getString(R.string.one_time), amount); } purchaseDisplay.add(amount); } builder.items(purchaseDisplay).itemsCallback(new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) { SkuDetails skuDetails = purchaseListingDetails.get(which); if (skuDetails.isSubscription) { billingProcessor.subscribe(SettingsActivity.this, skuDetails.productId); } else { billingProcessor.purchase(SettingsActivity.this, skuDetails.productId); } } }); } if (BuildConfig.FLAVOR.equals("full")) { builder.positiveText(R.string.dismiss); } builder.show(); }
From source file:stockit.ClientFrame.java
private void createChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); int row = StockInfoTable.getSelectedRow(); if (row != -1) { //dataset.setValue(, "", table.getValueAt(0,1).toString()); String selectedStock = StockInfoTable.getValueAt(row, 0).toString(); try {// w w w . j ava2s . com DBConnection dbcon = new DBConnection(); dbcon.establishConnection(); Statement stmt = dbcon.con.createStatement(); ResultSet rs = stmt .executeQuery("Select stock_daily_performance.Closing_Price, stock_daily_performance.Date\n" + "FROM stock_daily_performance, stock\n" + "WHERE stock_daily_performance.StockID = stock.StockID AND stock.StockID = '" + selectedStock + "'" + "AND Date IN\n" + "( Select * from\n" + "(\n" + "SELECT Date \n" + "FROM stock_daily_performance \n" + "WHERE StockID = stockID \n" + "ORDER BY Date ASC\n" + ") temp_table)\n" + " "); while (rs.next()) { String formattedDate = rs.getString("Date"); int closing_price = rs.getInt("Closing_Price"); dataset.setValue(closing_price, "value", formattedDate); } dbcon.con.close(); } catch (Exception ex) { System.out.println(ex.toString()); } String stockName = StockInfoTable.getValueAt(row, 1).toString(); JFreeChart chart = ChartFactory.createBarChart3D(stockName + " Stock Performance", "Date", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); Color c = new Color(240, 240, 240, 0); chart.setBackgroundPaint(c); CategoryPlot catPlot = chart.getCategoryPlot(); catPlot.setRangeGridlinePaint(Color.BLACK); //set interval of Y-axis ticks (tick every 5 units) NumberAxis yAxis = (NumberAxis) catPlot.getRangeAxis(); yAxis.setTickUnit(new NumberTickUnit(5)); //set y-axis labels as currency types ($) NumberFormat currency = NumberFormat.getCurrencyInstance(); yAxis.setNumberFormatOverride(currency); //setting number of lines an x-axis label is displayed on CategoryAxis categoryAxis = catPlot.getDomainAxis(); categoryAxis.setMaximumCategoryLabelLines(4); ChartContainer.setLayout(new java.awt.BorderLayout()); ChartPanel chartPanel = new ChartPanel(chart); ChartContainer.removeAll(); ChartContainer.add(chartPanel, BorderLayout.CENTER); ChartContainer.validate(); ChartContainer.repaint(); } }