List of usage examples for java.text NumberFormat getCurrencyInstance
public static NumberFormat getCurrencyInstance(Locale inLocale)
From source file:richtercloud.document.scanner.gui.OCRPanel.java
/** * Creates new form OCRResultPanel/*from ww w . j a v a 2 s . c o m*/ * @param reflectionFormPanelMap A map with references to the * {@link ReflectionFormPanel} for each entity class which is manipulated by * the context menu items */ public OCRPanel(Set<Class<?>> entityClasses, Map<Class<?>, ReflectionFormPanel<?>> reflectionFormPanelMap, Map<Class<? extends JComponent>, ValueSetter<?, ?>> valueSetterMapping, EntityManager entityManager, MessageHandler messageHandler, ReflectionFormBuilder reflectionFormBuilder, DocumentScannerConf documentScannerConf) { this.initComponents(); if (messageHandler == null) { throw new IllegalArgumentException("messageHandler mustn't be null"); } this.messageHandler = messageHandler; if (documentScannerConf == null) { throw new IllegalArgumentException("documentScannerConf mustn't be " + "null"); } this.documentScannerConf = documentScannerConf; List<Class<?>> entityClassesSort = EntityPanel.sortEntityClasses(entityClasses); for (Class<?> entityClass : entityClassesSort) { ReflectionFormPanel<?> reflectionFormPanel = reflectionFormPanelMap.get(entityClass); if (reflectionFormPanel == null) { throw new IllegalArgumentException( String.format("entityClass %s has no %s mapped in reflectionFormPanelMap", entityClass, ReflectionFormPanel.class)); } String className; ClassInfo classInfo = entityClass.getAnnotation(ClassInfo.class); if (classInfo != null) { className = classInfo.name(); } else { className = entityClass.getSimpleName(); } JMenu entityClassMenu = new JMenu(className); List<Field> relevantFields = reflectionFormBuilder.getFieldRetriever() .retrieveRelevantFields(entityClass); for (Field relevantField : relevantFields) { String fieldName; FieldInfo fieldInfo = relevantField.getAnnotation(FieldInfo.class); if (fieldInfo != null) { fieldName = fieldInfo.name(); } else { fieldName = relevantField.getName(); } JMenuItem relevantFieldMenuItem = new JMenuItem(fieldName); relevantFieldMenuItem.addActionListener( new FieldActionListener(reflectionFormPanel, relevantField, valueSetterMapping)); entityClassMenu.add(relevantFieldMenuItem); } this.oCRResultPopupPasteIntoMenu.add(entityClassMenu); } Map<String, Pair<NumberFormat, Set<Locale>>> numberFormats = new HashMap<>(); Map<String, Pair<NumberFormat, Set<Locale>>> percentFormats = new HashMap<>(); Map<String, Pair<NumberFormat, Set<Locale>>> currencyFormats = new HashMap<>(); Iterator<Locale> localeIterator = new ArrayList<>(Arrays.asList(Locale.getAvailableLocales())).iterator(); Locale firstLocale = localeIterator.next(); String numberString = NumberFormat.getNumberInstance(firstLocale).format(FORMAT_VALUE); String percentString = NumberFormat.getPercentInstance(firstLocale).format(FORMAT_VALUE); String currencyString = NumberFormat.getCurrencyInstance(firstLocale).format(FORMAT_VALUE); numberFormats.put(numberString, new ImmutablePair<NumberFormat, Set<Locale>>( NumberFormat.getNumberInstance(firstLocale), new HashSet<>(Arrays.asList(firstLocale)))); percentFormats.put(percentString, new ImmutablePair<NumberFormat, Set<Locale>>( NumberFormat.getPercentInstance(firstLocale), new HashSet<>(Arrays.asList(firstLocale)))); currencyFormats.put(currencyString, new ImmutablePair<NumberFormat, Set<Locale>>( NumberFormat.getCurrencyInstance(firstLocale), new HashSet<>(Arrays.asList(firstLocale)))); while (localeIterator.hasNext()) { Locale locale = localeIterator.next(); numberString = NumberFormat.getNumberInstance(locale).format(FORMAT_VALUE); percentString = NumberFormat.getPercentInstance(locale).format(FORMAT_VALUE); currencyString = NumberFormat.getCurrencyInstance(locale).format(FORMAT_VALUE); Pair<NumberFormat, Set<Locale>> numberFormatsPair = numberFormats.get(numberString); if (numberFormatsPair == null) { numberFormatsPair = new ImmutablePair<NumberFormat, Set<Locale>>( NumberFormat.getNumberInstance(locale), new HashSet<Locale>()); numberFormats.put(numberString, numberFormatsPair); } Set<Locale> numberFormatsLocales = numberFormatsPair.getValue(); numberFormatsLocales.add(locale); Pair<NumberFormat, Set<Locale>> percentFormatsPair = percentFormats.get(percentString); if (percentFormatsPair == null) { percentFormatsPair = new ImmutablePair<NumberFormat, Set<Locale>>( NumberFormat.getPercentInstance(locale), new HashSet<Locale>()); percentFormats.put(percentString, percentFormatsPair); } Set<Locale> percentFormatsLocales = percentFormatsPair.getValue(); percentFormatsLocales.add(locale); Pair<NumberFormat, Set<Locale>> currencyFormatsPair = currencyFormats.get(currencyString); if (currencyFormatsPair == null) { currencyFormatsPair = new ImmutablePair<NumberFormat, Set<Locale>>( NumberFormat.getCurrencyInstance(locale), new HashSet<Locale>()); currencyFormats.put(currencyString, currencyFormatsPair); } Set<Locale> currencyFormatsLocales = currencyFormatsPair.getValue(); currencyFormatsLocales.add(locale); } for (Map.Entry<String, Pair<NumberFormat, Set<Locale>>> numberFormat : numberFormats.entrySet()) { JRadioButtonMenuItem menuItem = new NumberFormatMenuItem(numberFormat.getValue().getKey()); numberFormatPopup.add(menuItem); numberFormatPopupButtonGroup.add(menuItem); if (numberFormat.getValue().getValue().contains(this.documentScannerConf.getLocale())) { menuItem.setSelected(true); } } for (Map.Entry<String, Pair<NumberFormat, Set<Locale>>> percentFormat : percentFormats.entrySet()) { JRadioButtonMenuItem menuItem = new NumberFormatMenuItem(percentFormat.getValue().getKey()); percentFormatPopup.add(menuItem); percentFormatPopupButtonGroup.add(menuItem); if (percentFormat.getValue().getValue().contains(this.documentScannerConf.getLocale())) { menuItem.setSelected(true); } } for (Map.Entry<String, Pair<NumberFormat, Set<Locale>>> currencyFormat : currencyFormats.entrySet()) { JRadioButtonMenuItem menuItem = new NumberFormatMenuItem(currencyFormat.getValue().getKey()); currencyFormatPopup.add(menuItem); currencyFormatPopupButtonGroup.add(menuItem); if (currencyFormat.getValue().getValue().contains(this.documentScannerConf.getLocale())) { menuItem.setSelected(true); } } }
From source file:fr.hoteia.qalingo.core.web.util.impl.RequestUtilImpl.java
/** * *//* w w w . j a v a2s.c o m*/ public NumberFormat getNumberFormat(final RequestData requestData, final String currencyCode, final RoundingMode roundingMode, final int maximumFractionDigits, final int minimumFractionDigits, final int maximumIntegerDigits, final int minimumIntegerDigits) throws Exception { final Localization localization = requestData.getLocalization(); final Locale locale = localization.getLocale(); NumberFormat formatter = NumberFormat.getCurrencyInstance(locale); formatter.setGroupingUsed(true); formatter.setParseIntegerOnly(false); formatter.setRoundingMode(roundingMode); Currency currency = Currency.getInstance(currencyCode); formatter.setCurrency(currency); formatter.setMaximumFractionDigits(maximumFractionDigits); formatter.setMinimumFractionDigits(minimumFractionDigits); formatter.setMaximumIntegerDigits(maximumIntegerDigits); formatter.setMinimumIntegerDigits(minimumIntegerDigits); return formatter; }
From source file:org.apache.cocoon.template.instruction.FormatNumber.java
private NumberFormat createFormatter(Locale loc, String type) throws Exception { NumberFormat formatter = null; if ((type == null) || NUMBER.equalsIgnoreCase(type)) { formatter = NumberFormat.getNumberInstance(loc); } else if (CURRENCY.equalsIgnoreCase(type)) { formatter = NumberFormat.getCurrencyInstance(loc); } else if (PERCENT.equalsIgnoreCase(type)) { formatter = NumberFormat.getPercentInstance(loc); } else {// w w w . ja va 2 s. c o m throw new IllegalArgumentException( "Invalid type: \"" + type + "\": should be \"number\" or \"currency\" or \"percent\""); } return formatter; }
From source file:com.MainFiles.Functions.java
public String generateUniqueReferenceNumber() throws SQLException { String strReferenceNumber = ""; Connection dbConnection = connections.getDBConnection(ECSERVER, ECDB, ECUSER, ECPASSWORD); try {/*from ww w . j av a2 s .c o m*/ NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "tz")); String strStoredProcedure = "{call SP_GET_AGENCY_NEXT_SEQ(?)}"; CallableStatement callableStatement = dbConnection.prepareCall(strStoredProcedure); callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR); callableStatement.executeUpdate(); String response = callableStatement.getString(1); strReferenceNumber = "POS" + response; } catch (Exception ex) { this.log("INFO :: Error on generateUniqueReferenceNumber " + ex.getMessage() + "\n" + this.StackTraceWriter(ex), "ERROR"); } finally { dbConnection.close(); } return strReferenceNumber; }
From source file:com.emc.plants.utils.Util.java
/** * Get the shipping method strings, including prices and times, in an array. * @return The shipping method strings, including prices and times, in an array. *///from www . j a v a2 s . co m static public String[] getFullShippingMethodStrings() { String[] shippingMethods = new String[SHIPPING_METHOD_STRINGS.length]; for (int i = 0; i < shippingMethods.length; i++) { shippingMethods[i] = SHIPPING_METHOD_STRINGS[i] + " " + SHIPPING_METHOD_TIMES[i] + " " + NumberFormat .getCurrencyInstance(java.util.Locale.US).format(new Float(SHIPPING_METHOD_PRICES[i])); } return shippingMethods; }
From source file:semanticweb.hws14.movapp.activities.MovieDetail.java
private void setData(final MovieDet movie) { Thread picThread = new Thread(new Runnable() { public void run() { try { ImageView img = (ImageView) findViewById(R.id.imageViewMovie); URL url = new URL(movie.getPoster()); HttpGet httpRequest;/*from w w w .j a v a 2s .c o m*/ httpRequest = new HttpGet(url.toURI()); HttpClient httpclient = new DefaultHttpClient(); HttpResponse response = httpclient.execute(httpRequest); HttpEntity entity = response.getEntity(); BufferedHttpEntity b_entity = new BufferedHttpEntity(entity); InputStream input = b_entity.getContent(); Bitmap bitmap = BitmapFactory.decodeStream(input); img.setImageBitmap(bitmap); } catch (Exception ex) { Log.d("MovieDetail Picture Error ", ex.toString()); } } }); picThread.start(); if (!"".equals(movie.getTitle())) { TextView movieTitle = (TextView) findViewById(R.id.tvMovieTitle); movieTitle.setText(movie.getTitle()); movieTitle.setVisibility(View.VISIBLE); } if (!"".equals(movie.getPlot())) { TextView moviePlot = (TextView) findViewById(R.id.tvPlot); moviePlot.setText(movie.getPlot()); moviePlot.setVisibility(View.VISIBLE); } TextView ageRestriction = (TextView) findViewById(R.id.tvAgeRestriction); TextView arHc = (TextView) findViewById(R.id.tvAgeRestrictionHC); String aR = String.valueOf(movie.getRated()); //Decode the ageRestriction if (!aR.equals("")) { ageRestriction.setVisibility(View.VISIBLE); arHc.setVisibility(View.VISIBLE); if (aR.equals("X")) { ageRestriction.setText("18+"); } else if (aR.equals("R")) { ageRestriction.setText("16+"); } else if (aR.equals("M")) { ageRestriction.setText("12+"); } else if (aR.equals("G")) { ageRestriction.setText("6+"); } else { ageRestriction.setVisibility(View.GONE); arHc.setVisibility(View.GONE); } } TextView ratingCount = (TextView) findViewById(R.id.tvMovieRatingCount); TextView ratingCountHc = (TextView) findViewById(R.id.tvMovieRatingCountHC); String ratingCountText = movie.getVoteCount(); ratingCount.setText(ratingCountText); manageEmptyTextfields(ratingCountHc, ratingCount, ratingCountText, false); if (!"".equals(movie.getImdbRating())) { TextView movieRating = (TextView) findViewById(R.id.tvMovieRating); if (movie.getImdbRating().equals("0 No Rating")) { movieRating.setText("No Rating"); } else if (movie.getImdbRating().equals("0 No Data")) { movieRating.setText(""); } else { movieRating.setText(movie.getImdbRating() + "/10"); } movieRating.setVisibility(View.VISIBLE); findViewById(R.id.tvMovieRatingHC).setVisibility(View.VISIBLE); } TextView metaScore = (TextView) findViewById(R.id.tvMetaScore); TextView metaScoreHc = (TextView) findViewById(R.id.tvMetaScoreHC); String metaSoreText = String.valueOf(movie.getMetaScore()); metaScore.setText(metaSoreText + "/100"); manageEmptyTextfields(metaScoreHc, metaScore, metaSoreText, false); TextView tvGenreHc = (TextView) findViewById(R.id.tvGenreHC); TextView genre = (TextView) findViewById(R.id.tvGenre); String genreText = String.valueOf(movie.createTvOutOfList(movie.getGenres())); genre.setText(genreText); manageEmptyTextfields(tvGenreHc, genre, genreText, true); TextView releaseYear = (TextView) findViewById(R.id.tvReleaseYear); TextView releaseYearHc = (TextView) findViewById(R.id.tvReleaseYearHC); String releaseYearText = String.valueOf(movie.getReleaseYear()); releaseYear.setText(releaseYearText); manageEmptyTextfields(releaseYearHc, releaseYear, releaseYearText, true); TextView runtime = (TextView) findViewById(R.id.tvRuntime); TextView runTimeHc = (TextView) findViewById(R.id.tvRuntimeHC); String runtimeText = ""; try { runtimeText = runtimeComputation(Float.parseFloat(movie.getRuntime())); } catch (Exception e) { runtimeText = movie.getRuntime(); } runtime.setText(runtimeText); manageEmptyTextfields(runTimeHc, runtime, runtimeText, true); TextView budget = (TextView) findViewById(R.id.tvBudget); TextView budgetHc = (TextView) findViewById(R.id.tvBudgetHC); String budgetText = movie.getBudget(); //Decode the budget if (budgetText.contains("E")) { BigDecimal myNumber = new BigDecimal(budgetText); long budgetLong = myNumber.longValue(); NumberFormat formatter = NumberFormat.getCurrencyInstance(Locale.US); budgetText = formatter.format(budgetLong); budgetText = String.valueOf(budgetText); budgetText = budgetComputation(budgetText); budget.setText(budgetText); manageEmptyTextfields(budgetHc, budget, budgetText, true); } TextView awards = (TextView) findViewById(R.id.tvAwards); TextView awardsHc = (TextView) findViewById(R.id.tvAwardsHC); String awardsText = movie.getAwards(); awards.setText(awardsText); manageEmptyTextfields(awardsHc, awards, awardsText, true); TextView tvDirHc = (TextView) findViewById(R.id.tvDirectorsHC); TextView directors = (TextView) findViewById(R.id.tvDirectors); String directorText = String.valueOf(movie.createTvOutOfList(movie.getDirectors())); directors.setText(directorText); manageEmptyTextfields(tvDirHc, directors, directorText, true); TextView tvWriterHc = (TextView) findViewById(R.id.tvWritersHC); TextView writers = (TextView) findViewById(R.id.tvWriters); String writerText = String.valueOf(movie.createTvOutOfList(movie.getWriters())); writers.setText(writerText); manageEmptyTextfields(tvWriterHc, writers, writerText, true); TextView tvActorsHc = (TextView) findViewById(R.id.tvActorsHC); TextView actors = (TextView) findViewById(R.id.tvActors); String actorText = String.valueOf(movie.createTvOutOfList(movie.getActors())); actors.setText(actorText); manageEmptyTextfields(tvActorsHc, actors, actorText, true); colorIt(actors); if (movie.getActors().size() > 0) { btnActorList.setVisibility(View.VISIBLE); } btnRandomRelatedMovies.setVisibility(View.VISIBLE); btnRelatedMovies.setVisibility(View.VISIBLE); TextView tvRolesHc = (TextView) findViewById(R.id.tvRolesHC); TextView roles = (TextView) findViewById(R.id.tvRoles); ArrayList<String> roleList = movie.getRoles(); if (roleList.size() > 0) { roles.setVisibility(View.VISIBLE); tvRolesHc.setVisibility(View.VISIBLE); roles.setText(String.valueOf(movie.createTvOutOfList(roleList))); } TextView wikiAbstract = (TextView) findViewById(R.id.tvWikiAbstract); wikiAbstract.setText(movie.getWikiAbstract()); if (!"".equals(movie.getImdbId())) { btnImdbPage.setVisibility(View.VISIBLE); } if (!"".equals(movie.getWikiAbstract())) { btnSpoiler.setVisibility(View.VISIBLE); } try { picThread.join(); } catch (InterruptedException e) { e.printStackTrace(); } setProgressBarIndeterminateVisibility(false); }
From source file:org.kuali.ole.module.purap.pdf.PurchaseOrderQuotePdf.java
/** * Create a PDF using the given input parameters. * * @param po The PurchaseOrderDocument to be used to create the pdf. * @param poqv The PurchaseOrderVendorQuote to be used to generate the pdf. * @param campusName The campus name to be used to generate the pdf. * @param contractManagerCampusCode The contract manager campus code to be used to generate the pdf. * @param logoImage The logo image file name to be used to generate the pdf. * @param document The pdf document whose margins have already been set. * @param writer The PdfWriter to write the pdf document into. * @param environment The current environment used (e.g. DEV if it is a development environment). * @throws DocumentException/*w w w .j a v a 2s . com*/ */ private void createPOQuotePdf(PurchaseOrderDocument po, PurchaseOrderVendorQuote poqv, String campusName, String contractManagerCampusCode, String logoImage, Document document, PdfWriter writer, String environment) throws DocumentException { if (LOG.isDebugEnabled()) { LOG.debug("createQuotePdf() started for po number " + po.getPurapDocumentIdentifier()); } // 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; NumberFormat numberFormat = NumberFormat.getCurrencyInstance(Locale.US); // Date format pattern: MM-dd-yyyy SimpleDateFormat sdf = new SimpleDateFormat(RiceConstants.SIMPLE_DATE_FORMAT_FOR_DATE, Locale.getDefault()); CampusParameter campusParameter = getCampusParameter(contractManagerCampusCode); String purchasingAddressFull = getPurchasingAddressFull(campusParameter); // Turn on the page events that handle the header and page numbers. PurchaseOrderQuotePdf events = new PurchaseOrderQuotePdf().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 (address, vendor, other info) ***** LOG.debug("createQuotePdf() info table started."); float[] infoWidths = { 0.45f, 0.55f }; PdfPTable infoTable = new PdfPTable(infoWidths); infoTable.setWidthPercentage(100); infoTable.setHorizontalAlignment(Element.ALIGN_CENTER); infoTable.setSplitLate(false); p = new Paragraph(); ContractManager contractManager = po.getContractManager(); p.add(new Chunk("\n Return this form to:\n", ver_8_bold)); p.add(new Chunk(purchasingAddressFull + "\n", cour_10_normal)); p.add(new Chunk("\n", cour_10_normal)); p.add(new Chunk(" Fax #: ", ver_6_normal)); p.add(new Chunk(contractManager.getContractManagerFaxNumber() + "\n", cour_10_normal)); p.add(new Chunk(" Contract Manager: ", ver_6_normal)); p.add(new Chunk(contractManager.getContractManagerName() + " " + contractManager.getContractManagerPhoneNumber() + "\n", cour_10_normal)); p.add(new Chunk("\n", cour_10_normal)); p.add(new Chunk(" To:\n", ver_6_normal)); StringBuffer vendorInfo = new StringBuffer(); if (StringUtils.isNotBlank(poqv.getVendorAttentionName())) { vendorInfo.append(" ATTN: " + poqv.getVendorAttentionName().trim() + "\n"); } vendorInfo.append(" " + poqv.getVendorName() + "\n"); if (StringUtils.isNotBlank(poqv.getVendorLine1Address())) { vendorInfo.append(" " + poqv.getVendorLine1Address() + "\n"); } if (StringUtils.isNotBlank(poqv.getVendorLine2Address())) { vendorInfo.append(" " + poqv.getVendorLine2Address() + "\n"); } if (StringUtils.isNotBlank(poqv.getVendorCityName())) { vendorInfo.append(" " + poqv.getVendorCityName()); } if ((StringUtils.isNotBlank(poqv.getVendorStateCode())) && (!poqv.getVendorStateCode().equals("--"))) { vendorInfo.append(", " + poqv.getVendorStateCode()); } if (StringUtils.isNotBlank(poqv.getVendorAddressInternationalProvinceName())) { vendorInfo.append(", " + poqv.getVendorAddressInternationalProvinceName()); } if (StringUtils.isNotBlank(poqv.getVendorPostalCode())) { vendorInfo.append(" " + poqv.getVendorPostalCode() + "\n"); } else { vendorInfo.append("\n"); } if (!OLEConstants.COUNTRY_CODE_UNITED_STATES.equalsIgnoreCase(poqv.getVendorCountryCode()) && poqv.getVendorCountryCode() != null) { vendorInfo.append(" " + poqv.getVendorCountry().getName() + "\n\n"); } else { vendorInfo.append(" \n\n"); } p.add(new Chunk(vendorInfo.toString(), cour_10_normal)); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk("\n R.Q. Number: ", ver_8_bold)); p.add(new Chunk(po.getPurapDocumentIdentifier() + "\n", cour_10_normal)); java.sql.Date requestDate = getDateTimeService().getCurrentSqlDate(); if (poqv.getPurchaseOrderQuoteTransmitTimestamp() != null) { try { requestDate = getDateTimeService().convertToSqlDate(poqv.getPurchaseOrderQuoteTransmitTimestamp()); } catch (ParseException e) { throw new RuntimeException( "ParseException thrown when trying to convert from Timestamp to SqlDate.", e); } } p.add(new Chunk(" R.Q. Date: ", ver_8_bold)); p.add(new Chunk(sdf.format(requestDate) + "\n", cour_10_normal)); p.add(new Chunk(" RESPONSE MUST BE RECEIVED BY: ", ver_8_bold)); if (po.getPurchaseOrderQuoteDueDate() != null) { p.add(new Chunk(sdf.format(po.getPurchaseOrderQuoteDueDate()) + "\n\n", cour_10_normal)); } else { p.add(new Chunk("N/A\n\n", cour_10_normal)); } // retrieve the quote stipulations StringBuffer quoteStipulations = getPoQuoteLanguage(); p.add(new Chunk(quoteStipulations.toString(), ver_6_normal)); p.add(new Chunk("\n ALL QUOTES MUST BE TOTALED", ver_12_normal)); cell = new PdfPCell(p); infoTable.addCell(cell); document.add(infoTable); // ***** Notes and Stipulations table ***** // The notes and stipulations table is type Table instead of PdfPTable // because Table has the method setCellsFitPage and I can't find an equivalent // in PdfPTable. Long notes or stipulations would break to the next page, leaving // a large white space on the previous page. PdfPTable notesStipulationsTable = new PdfPTable(1); notesStipulationsTable.setWidthPercentage(100); notesStipulationsTable.setSplitLate(false); p = new Paragraph(); p.add(new Chunk(" Vendor Stipulations and Information\n\n", ver_6_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_10_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_10_normal)); } PdfPCell tableCell = new PdfPCell(p); tableCell.setHorizontalAlignment(Element.ALIGN_LEFT); tableCell.setVerticalAlignment(Element.ALIGN_TOP); notesStipulationsTable.addCell(tableCell); document.add(notesStipulationsTable); // ***** Items table ***** LOG.debug("createQuotePdf() items table started."); float[] itemsWidths = { 0.07f, 0.1f, 0.07f, 0.50f, 0.13f, 0.13f }; PdfPTable itemsTable = new PdfPTable(6); // 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 = createCell("Item\nNo.", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal); itemsTable.addCell(tableCell); tableCell = createCell("Quantity", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal); itemsTable.addCell(tableCell); tableCell = createCell("UOM", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal); itemsTable.addCell(tableCell); tableCell = createCell("Description", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal); itemsTable.addCell(tableCell); tableCell = createCell("Unit Cost\n(Required)", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal); itemsTable.addCell(tableCell); tableCell = createCell("Extended Cost\n(Required)", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal); itemsTable.addCell(tableCell); if (StringUtils.isNotBlank(po.getPurchaseOrderQuoteVendorNoteText())) { // Vendor notes line. itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); tableCell = createCell(po.getPurchaseOrderQuoteVendorNoteText(), false, false, false, false, Element.ALIGN_LEFT, cour_10_normal); itemsTable.addCell(tableCell); itemsTable.addCell(" "); itemsTable.addCell(" "); } for (PurchaseOrderItem poi : (List<PurchaseOrderItem>) po.getItems()) { if ((poi.getItemType() != null) && (StringUtils.isNotBlank(poi.getItemDescription())) && (poi .getItemType().isLineItemIndicator() || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_SHIP_AND_HAND_CODE) || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_FREIGHT_CODE) || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ORDER_DISCOUNT_CODE) || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_TRADE_IN_CODE))) { // "ITEM"s display the line number; other types don't. String description = ""; description = (StringUtils.isNotBlank(poi.getItemCatalogNumber())) ? poi.getItemCatalogNumber().trim() + " - " : ""; description = description + ((StringUtils.isNotBlank(poi.getItemDescription())) ? poi.getItemDescription().trim() : ""); // If this is a full order discount item or trade in item, we add the // itemType description and a dash to the purchase order item description. if (StringUtils.isNotBlank(poi.getItemDescription())) { if (poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ORDER_DISCOUNT_CODE) || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_TRADE_IN_CODE)) { description = poi.getItemType().getItemTypeDescription() + " - " + description; } } // We can do the normal table now because description is not too long. String itemLineNumber = new String(); if (poi.getItemType().isLineItemIndicator()) { itemLineNumber = poi.getItemLineNumber().toString(); } else { itemLineNumber = ""; } tableCell = createCell(itemLineNumber, false, false, false, false, Element.ALIGN_CENTER, cour_10_normal); itemsTable.addCell(tableCell); String quantity = (poi.getItemQuantity() != null) ? poi.getItemQuantity().toString() : " "; tableCell = createCell(quantity, false, false, false, false, Element.ALIGN_CENTER, cour_10_normal); itemsTable.addCell(tableCell); tableCell = createCell(poi.getItemUnitOfMeasureCode(), false, false, false, false, Element.ALIGN_CENTER, cour_10_normal); itemsTable.addCell(tableCell); tableCell = createCell(description, false, false, false, false, Element.ALIGN_LEFT, cour_10_normal); itemsTable.addCell(tableCell); itemsTable.addCell(" "); itemsTable.addCell(" "); } } // Blank line before totals createBlankRowInItemsTable(itemsTable); // Totals line. itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); tableCell = createCell("Total: ", false, false, false, false, Element.ALIGN_RIGHT, ver_10_normal); itemsTable.addCell(tableCell); itemsTable.addCell(" "); itemsTable.addCell(" "); // Blank line after totals createBlankRowInItemsTable(itemsTable); document.add(itemsTable); LOG.debug("createQuotePdf() vendorFillsIn table started."); float[] vendorFillsInWidths = { 0.50f, 0.50f }; PdfPTable vendorFillsInTable = new PdfPTable(vendorFillsInWidths); vendorFillsInTable.setWidthPercentage(100); vendorFillsInTable.setHorizontalAlignment(Element.ALIGN_CENTER); vendorFillsInTable.setSplitLate(false); vendorFillsInTable.getDefaultCell().setBorderWidth(0); vendorFillsInTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); vendorFillsInTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_CENTER); // New row String important = new String( "\nIMPORTANT: The information and signature below MUST BE COMPLETED or your offer may be rejected.\n"); cell = createCell(important, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); cell.setColspan(2); vendorFillsInTable.addCell(cell); // New row String cashDiscount = new String( "Terms of Payment: Cash discount_________%_________Days-Net________Days\n"); cell = createCell(cashDiscount, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); cell.setColspan(2); vendorFillsInTable.addCell(cell); // New row String fob = new String(" FOB: __ Destination (Title)\n"); cell = createCell(fob, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); vendorFillsInTable.addCell(cell); String freightVendor = new String(" __ Freight Vendor Paid (Allowed)\n"); cell = createCell(freightVendor, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); vendorFillsInTable.addCell(cell); // New row String shipping = new String(" __ Shipping Point (Title)\n"); cell = createCell(shipping, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); vendorFillsInTable.addCell(cell); String freightPrepaid = new String(" __ Freight Prepaid & Added Amount $_________\n"); cell = createCell(freightPrepaid, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); vendorFillsInTable.addCell(cell); // New row String commonCarrier = new String( " If material will ship common carrier, please provide the following:\n"); cell = createCell(commonCarrier, true, false, false, false, Element.ALIGN_LEFT, ver_8_bold); cell.setColspan(2); vendorFillsInTable.addCell(cell); // New row String origin = new String( " Point of origin and zip code: ______________________ Weight: _________ Class: _________\n"); cell = createCell(origin, true, false, false, false, Element.ALIGN_LEFT, ver_8_bold); cell.setColspan(2); vendorFillsInTable.addCell(cell); // New row p = new Paragraph(); p.add(new Chunk(" Unless otherwise stated, all material to be shipped to ", ver_8_normal)); String purchasingAddressPartial; if (po.getAddressToVendorIndicator()) // use receiving address purchasingAddressPartial = po.getReceivingCityName() + ", " + po.getReceivingStateCode() + " " + po.getReceivingPostalCode(); else // use final delivery address purchasingAddressPartial = po.getDeliveryCityName() + ", " + po.getDeliveryStateCode() + " " + po.getDeliveryPostalCode(); p.add(new Chunk(purchasingAddressPartial + "\n", cour_10_normal)); cell = new PdfPCell(p); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorderWidth(0); vendorFillsInTable.addCell(cell); // New row String offerEffective = new String(" Offer effective until (Date):_____________\n"); cell = createCell(offerEffective, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); vendorFillsInTable.addCell(cell); String deliverBy = new String(" Delivery can be made by (Date):_____________\n"); cell = createCell(deliverBy, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); vendorFillsInTable.addCell(cell); // New row String sign = new String(" SIGN HERE:____________________________\n"); cell = createCell(sign, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold); vendorFillsInTable.addCell(cell); String date = new String(" DATE:____________________________\n"); cell = createCell(date, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold); vendorFillsInTable.addCell(cell); // New row String name = new String(" PRINT NAME:____________________________\n"); cell = createCell(name, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold); vendorFillsInTable.addCell(cell); String phone = new String(" PHONE:____________________________\n"); cell = createCell(phone, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold); vendorFillsInTable.addCell(cell); // New row String company = new String(" COMPANY:____________________________\n"); cell = createCell(company, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold); vendorFillsInTable.addCell(cell); String fax = new String(" FAX:____________________________\n"); cell = createCell(fax, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold); vendorFillsInTable.addCell(cell); document.add(vendorFillsInTable); document.close(); LOG.debug("createQuotePdf()pdf document closed."); }
From source file:org.kuali.kfs.module.purap.pdf.PurchaseOrderQuotePdf.java
/** * Create a PDF using the given input parameters. * * @param po The PurchaseOrderDocument to be used to create the pdf. * @param poqv The PurchaseOrderVendorQuote to be used to generate the pdf. * @param campusName The campus name to be used to generate the pdf. * @param contractManagerCampusCode The contract manager campus code to be used to generate the pdf. * @param logoImage The logo image file name to be used to generate the pdf. * @param document The pdf document whose margins have already been set. * @param writer The PdfWriter to write the pdf document into. * @param environment The current environment used (e.g. DEV if it is a development environment). * @throws DocumentException// w ww . ja va 2s . c o m */ private void createPOQuotePdf(PurchaseOrderDocument po, PurchaseOrderVendorQuote poqv, String campusName, String contractManagerCampusCode, String logoImage, Document document, PdfWriter writer, String environment) throws DocumentException { if (LOG.isDebugEnabled()) { LOG.debug("createQuotePdf() started for po number " + po.getPurapDocumentIdentifier()); } // 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; NumberFormat numberFormat = NumberFormat.getCurrencyInstance(Locale.US); // Date format pattern: MM-dd-yyyy SimpleDateFormat sdf = PurApDateFormatUtils .getSimpleDateFormat(PurapConstants.NamedDateFormats.KUALI_SIMPLE_DATE_FORMAT_2); CampusParameter campusParameter = getCampusParameter(contractManagerCampusCode); String purchasingAddressFull = getPurchasingAddressFull(campusParameter); // Turn on the page events that handle the header and page numbers. PurchaseOrderQuotePdf events = new PurchaseOrderQuotePdf().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 (address, vendor, other info) ***** LOG.debug("createQuotePdf() info table started."); float[] infoWidths = { 0.45f, 0.55f }; PdfPTable infoTable = new PdfPTable(infoWidths); infoTable.setWidthPercentage(100); infoTable.setHorizontalAlignment(Element.ALIGN_CENTER); infoTable.setSplitLate(false); p = new Paragraph(); ContractManager contractManager = po.getContractManager(); p.add(new Chunk("\n Return this form to:\n", ver_8_bold)); p.add(new Chunk(purchasingAddressFull + "\n", cour_10_normal)); p.add(new Chunk("\n", cour_10_normal)); p.add(new Chunk(" Fax #: ", ver_6_normal)); p.add(new Chunk(contractManager.getContractManagerFaxNumber() + "\n", cour_10_normal)); p.add(new Chunk(" Contract Manager: ", ver_6_normal)); p.add(new Chunk(contractManager.getContractManagerName() + " " + contractManager.getContractManagerPhoneNumber() + "\n", cour_10_normal)); p.add(new Chunk("\n", cour_10_normal)); p.add(new Chunk(" To:\n", ver_6_normal)); StringBuffer vendorInfo = new StringBuffer(); if (StringUtils.isNotBlank(poqv.getVendorAttentionName())) { vendorInfo.append(" ATTN: " + poqv.getVendorAttentionName().trim() + "\n"); } vendorInfo.append(" " + poqv.getVendorName() + "\n"); if (StringUtils.isNotBlank(poqv.getVendorLine1Address())) { vendorInfo.append(" " + poqv.getVendorLine1Address() + "\n"); } if (StringUtils.isNotBlank(poqv.getVendorLine2Address())) { vendorInfo.append(" " + poqv.getVendorLine2Address() + "\n"); } if (StringUtils.isNotBlank(poqv.getVendorCityName())) { vendorInfo.append(" " + poqv.getVendorCityName()); } if ((StringUtils.isNotBlank(poqv.getVendorStateCode())) && (!poqv.getVendorStateCode().equals("--"))) { vendorInfo.append(", " + poqv.getVendorStateCode()); } if (StringUtils.isNotBlank(poqv.getVendorAddressInternationalProvinceName())) { vendorInfo.append(", " + poqv.getVendorAddressInternationalProvinceName()); } if (StringUtils.isNotBlank(poqv.getVendorPostalCode())) { vendorInfo.append(" " + poqv.getVendorPostalCode() + "\n"); } else { vendorInfo.append("\n"); } if (!KFSConstants.COUNTRY_CODE_UNITED_STATES.equalsIgnoreCase(poqv.getVendorCountryCode()) && poqv.getVendorCountryCode() != null) { vendorInfo.append(" " + poqv.getVendorCountry().getName() + "\n\n"); } else { vendorInfo.append(" \n\n"); } p.add(new Chunk(vendorInfo.toString(), cour_10_normal)); cell = new PdfPCell(p); cell.setHorizontalAlignment(Element.ALIGN_LEFT); infoTable.addCell(cell); p = new Paragraph(); p.add(new Chunk("\n R.Q. Number: ", ver_8_bold)); p.add(new Chunk(po.getPurapDocumentIdentifier() + "\n", cour_10_normal)); java.sql.Date requestDate = getDateTimeService().getCurrentSqlDate(); if (poqv.getPurchaseOrderQuoteTransmitTimestamp() != null) { try { requestDate = getDateTimeService().convertToSqlDate(poqv.getPurchaseOrderQuoteTransmitTimestamp()); } catch (ParseException e) { throw new RuntimeException( "ParseException thrown when trying to convert from Timestamp to SqlDate.", e); } } p.add(new Chunk(" R.Q. Date: ", ver_8_bold)); p.add(new Chunk(sdf.format(requestDate) + "\n", cour_10_normal)); p.add(new Chunk(" RESPONSE MUST BE RECEIVED BY: ", ver_8_bold)); if (po.getPurchaseOrderQuoteDueDate() != null) { p.add(new Chunk(sdf.format(po.getPurchaseOrderQuoteDueDate()) + "\n\n", cour_10_normal)); } else { p.add(new Chunk("N/A\n\n", cour_10_normal)); } // retrieve the quote stipulations StringBuffer quoteStipulations = getPoQuoteLanguage(); p.add(new Chunk(quoteStipulations.toString(), ver_6_normal)); p.add(new Chunk("\n ALL QUOTES MUST BE TOTALED", ver_12_normal)); cell = new PdfPCell(p); infoTable.addCell(cell); document.add(infoTable); // ***** Notes and Stipulations table ***** // The notes and stipulations table is type Table instead of PdfPTable // because Table has the method setCellsFitPage and I can't find an equivalent // in PdfPTable. Long notes or stipulations would break to the next page, leaving // a large white space on the previous page. PdfPTable notesStipulationsTable = new PdfPTable(1); notesStipulationsTable.setWidthPercentage(100); notesStipulationsTable.setSplitLate(false); p = new Paragraph(); p.add(new Chunk(" Vendor Stipulations and Information\n\n", ver_6_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_10_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_10_normal)); } PdfPCell tableCell = new PdfPCell(p); tableCell.setHorizontalAlignment(Element.ALIGN_LEFT); tableCell.setVerticalAlignment(Element.ALIGN_TOP); notesStipulationsTable.addCell(tableCell); document.add(notesStipulationsTable); // ***** Items table ***** LOG.debug("createQuotePdf() items table started."); float[] itemsWidths = { 0.07f, 0.1f, 0.07f, 0.50f, 0.13f, 0.13f }; PdfPTable itemsTable = new PdfPTable(6); // 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 = createCell("Item\nNo.", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal); itemsTable.addCell(tableCell); tableCell = createCell("Quantity", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal); itemsTable.addCell(tableCell); tableCell = createCell("UOM", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal); itemsTable.addCell(tableCell); tableCell = createCell("Description", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal); itemsTable.addCell(tableCell); tableCell = createCell("Unit Cost\n(Required)", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal); itemsTable.addCell(tableCell); tableCell = createCell("Extended Cost\n(Required)", false, false, false, false, Element.ALIGN_CENTER, ver_6_normal); itemsTable.addCell(tableCell); if (StringUtils.isNotBlank(po.getPurchaseOrderQuoteVendorNoteText())) { // Vendor notes line. itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); tableCell = createCell(po.getPurchaseOrderQuoteVendorNoteText(), false, false, false, false, Element.ALIGN_LEFT, cour_10_normal); itemsTable.addCell(tableCell); itemsTable.addCell(" "); itemsTable.addCell(" "); } for (PurchaseOrderItem poi : (List<PurchaseOrderItem>) po.getItems()) { if ((poi.getItemType() != null) && (StringUtils.isNotBlank(poi.getItemDescription())) && (poi .getItemType().isLineItemIndicator() || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_SHIP_AND_HAND_CODE) || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_FREIGHT_CODE) || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ORDER_DISCOUNT_CODE) || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_TRADE_IN_CODE))) { // "ITEM"s display the line number; other types don't. String description = ""; description = (StringUtils.isNotBlank(poi.getItemCatalogNumber())) ? poi.getItemCatalogNumber().trim() + " - " : ""; description = description + ((StringUtils.isNotBlank(poi.getItemDescription())) ? poi.getItemDescription().trim() : ""); // If this is a full order discount item or trade in item, we add the // itemType description and a dash to the purchase order item description. if (StringUtils.isNotBlank(poi.getItemDescription())) { if (poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_ORDER_DISCOUNT_CODE) || poi.getItemTypeCode().equals(PurapConstants.ItemTypeCodes.ITEM_TYPE_TRADE_IN_CODE)) { description = poi.getItemType().getItemTypeDescription() + " - " + description; } } // We can do the normal table now because description is not too long. String itemLineNumber = new String(); if (poi.getItemType().isLineItemIndicator()) { itemLineNumber = poi.getItemLineNumber().toString(); } else { itemLineNumber = ""; } tableCell = createCell(itemLineNumber, false, false, false, false, Element.ALIGN_CENTER, cour_10_normal); itemsTable.addCell(tableCell); String quantity = (poi.getItemQuantity() != null) ? poi.getItemQuantity().toString() : " "; tableCell = createCell(quantity, false, false, false, false, Element.ALIGN_CENTER, cour_10_normal); itemsTable.addCell(tableCell); tableCell = createCell(poi.getItemUnitOfMeasureCode(), false, false, false, false, Element.ALIGN_CENTER, cour_10_normal); itemsTable.addCell(tableCell); tableCell = createCell(description, false, false, false, false, Element.ALIGN_LEFT, cour_10_normal); itemsTable.addCell(tableCell); itemsTable.addCell(" "); itemsTable.addCell(" "); } } // Blank line before totals createBlankRowInItemsTable(itemsTable); // Totals line. itemsTable.addCell(" "); itemsTable.addCell(" "); itemsTable.addCell(" "); tableCell = createCell("Total: ", false, false, false, false, Element.ALIGN_RIGHT, ver_10_normal); itemsTable.addCell(tableCell); itemsTable.addCell(" "); itemsTable.addCell(" "); // Blank line after totals createBlankRowInItemsTable(itemsTable); document.add(itemsTable); LOG.debug("createQuotePdf() vendorFillsIn table started."); float[] vendorFillsInWidths = { 0.50f, 0.50f }; PdfPTable vendorFillsInTable = new PdfPTable(vendorFillsInWidths); vendorFillsInTable.setWidthPercentage(100); vendorFillsInTable.setHorizontalAlignment(Element.ALIGN_CENTER); vendorFillsInTable.setSplitLate(false); vendorFillsInTable.getDefaultCell().setBorderWidth(0); vendorFillsInTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER); vendorFillsInTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_CENTER); // New row String important = new String( "\nIMPORTANT: The information and signature below MUST BE COMPLETED or your offer may be rejected.\n"); cell = createCell(important, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); cell.setColspan(2); vendorFillsInTable.addCell(cell); // New row String cashDiscount = new String( "Terms of Payment: Cash discount_________%_________Days-Net________Days\n"); cell = createCell(cashDiscount, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); cell.setColspan(2); vendorFillsInTable.addCell(cell); // New row String fob = new String(" FOB: __ Destination (Title)\n"); cell = createCell(fob, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); vendorFillsInTable.addCell(cell); String freightVendor = new String(" __ Freight Vendor Paid (Allowed)\n"); cell = createCell(freightVendor, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); vendorFillsInTable.addCell(cell); // New row String shipping = new String(" __ Shipping Point (Title)\n"); cell = createCell(shipping, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); vendorFillsInTable.addCell(cell); String freightPrepaid = new String(" __ Freight Prepaid & Added Amount $_________\n"); cell = createCell(freightPrepaid, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); vendorFillsInTable.addCell(cell); // New row String commonCarrier = new String( " If material will ship common carrier, please provide the following:\n"); cell = createCell(commonCarrier, true, false, false, false, Element.ALIGN_LEFT, ver_8_bold); cell.setColspan(2); vendorFillsInTable.addCell(cell); // New row String origin = new String( " Point of origin and zip code: ______________________ Weight: _________ Class: _________\n"); cell = createCell(origin, true, false, false, false, Element.ALIGN_LEFT, ver_8_bold); cell.setColspan(2); vendorFillsInTable.addCell(cell); // New row p = new Paragraph(); p.add(new Chunk(" Unless otherwise stated, all material to be shipped to ", ver_8_normal)); String purchasingAddressPartial; if (po.getAddressToVendorIndicator()) { purchasingAddressPartial = po.getReceivingCityName() + ", " + po.getReceivingStateCode() + " " + po.getReceivingPostalCode(); } else { purchasingAddressPartial = po.getDeliveryCityName() + ", " + po.getDeliveryStateCode() + " " + po.getDeliveryPostalCode(); } p.add(new Chunk(purchasingAddressPartial + "\n", cour_10_normal)); cell = new PdfPCell(p); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorderWidth(0); vendorFillsInTable.addCell(cell); // New row String offerEffective = new String(" Offer effective until (Date):_____________\n"); cell = createCell(offerEffective, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); vendorFillsInTable.addCell(cell); String deliverBy = new String(" Delivery can be made by (Date):_____________\n"); cell = createCell(deliverBy, true, false, false, false, Element.ALIGN_LEFT, ver_8_normal); vendorFillsInTable.addCell(cell); // New row String sign = new String(" SIGN HERE:____________________________\n"); cell = createCell(sign, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold); vendorFillsInTable.addCell(cell); String date = new String(" DATE:____________________________\n"); cell = createCell(date, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold); vendorFillsInTable.addCell(cell); // New row String name = new String(" PRINT NAME:____________________________\n"); cell = createCell(name, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold); vendorFillsInTable.addCell(cell); String phone = new String(" PHONE:____________________________\n"); cell = createCell(phone, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold); vendorFillsInTable.addCell(cell); // New row String company = new String(" COMPANY:____________________________\n"); cell = createCell(company, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold); vendorFillsInTable.addCell(cell); String fax = new String(" FAX:____________________________\n"); cell = createCell(fax, true, false, false, false, Element.ALIGN_RIGHT, ver_10_bold); vendorFillsInTable.addCell(cell); document.add(vendorFillsInTable); document.close(); LOG.debug("createQuotePdf()pdf document closed."); }
From source file:net.cloudfree.apps.shop.internal.app.ListingServlet.java
private void writeListing(final SolrDocument listing, final PrintWriter writer, final HttpServletRequest req) { writer.println("<div style=\"float:left;\">"); final Object uripath = listing.getFirstValue("uripath"); if (null != uripath) { writer.print("<a href=\""); writer.print(getBaseUrl(req).append(uripath)); writer.print("\">"); }//from www .ja va 2 s. co m writer.print("<img border=\"0\" src=\""); Object thumb = listing.getFirstValue("img48"); if (null == thumb) { thumb = listing.getFirstValue("img480"); } writer.print(thumb); writer.print("\">"); if (null != uripath) { writer.print("</a>"); } writer.println("</div>"); writer.println("<br/>"); writer.print("<strong>"); writer.print(listing.getFirstValue("title")); writer.print("</strong>"); writer.println("<br/>"); writer.print("<small>"); writer.print(listing.getFirstValue("score")); writer.println("<br/>"); final Object size = listing.getFirstValue("size"); if (null != size) { writer.print("Size: "); writer.print(size); writer.println("<br/>"); } final Object color = listing.getFirstValue("color"); if (null != color) { writer.print("Color: "); writer.print(color); writer.println("<br/>"); } writer.print("</small>"); writer.print("<span style=\"font-size: 2em;\">"); NumberFormat.getCurrencyInstance(Locale.GERMAN).format((Double) listing.getFirstValue("price")); writer.print("</span><br/>"); final Object desc = listing.getFirstValue("description"); if (null != desc) { writer.println("<br/>"); writer.println("<blockquote>"); writer.print(desc); writer.println("</blockquote>"); } // writer.print("<pre>"); // writer.println(listing.toString()); // writer.print("</pre>"); writer.println("<div style=\"clear:both;\"> </div>"); }
From source file:com.formkiq.core.equifax.service.EquifaxResponseProcessor.java
/** * Process SCOR segment and update Response. * @param scorSegment {@link ScorSegment} * @param form {@link FormJSON}// w w w .ja v a 2 s . c o m * @return {@link String} error message */ private Map<String, List<FormJSONValidator>> processScorSegment(final ScorSegment scorSegment, final FormJSON form) { final int group = 3; Map<String, List<FormJSONValidator>> map = new HashMap<>(); String narrative = scorSegment.getDecisionNarrative(); Matcher matcher = UNDER_PATTERN.matcher(narrative); if (matcher.matches()) { try { String s = matcher.group(group).trim(); String[] strs = s.split("[ \\$]"); int max = Integer.parseInt(strs[1]); FormJSONValidator v1 = new FormJSONValidator(); v1.setRule(FormJSONValidatorRuleType.MAX); v1.setValue(strs[1]); v1.setMessage("Approved for a maximum of $" + this.formatter.format(max)); FormJSONValidator v2 = new FormJSONValidator(); v2.setRule(FormJSONValidatorRuleType.MESSAGE); v2.setMessage("Approved for a maximum of $" + this.formatter.format(max)); // SubTotal // TODO remove & change to something that can be references by // other forms map.put("$st", Arrays.asList(v1)); map.put("*", Arrays.asList(v2)); Locale locale = new Locale("en", "US"); NumberFormat currencyFormatter = NumberFormat.getCurrencyInstance(locale); String money = currencyFormatter.format(max); if (money.endsWith(".00")) { int centsIndex = money.lastIndexOf(".00"); if (centsIndex != -1) { money = money.substring(1, centsIndex); } } findValueByKey(form, "approvedamount").get().setValue(money); } catch (NumberFormatException e) { addValidation(map, FormJSONValidatorRuleType.STOP, "Unable to process Equifax Request. " + "Please try again later."); } } else { addValidation(map, FormJSONValidatorRuleType.STOP, "Application is not approved"); } return map; }