List of usage examples for com.lowagie.text Phrase Phrase
public Phrase(float leading, String string)
Phrase
with a certain leading and a certain String
. From source file:com.qcadoo.mes.qualityControls.print.QualityControlForOrderPdfView.java
License:Open Source License
private void addProductSeries(final Document document, final Entry<Entity, List<Entity>> entry, final Locale locale) throws DocumentException { document.add(qualityControlsReportService.prepareTitle(entry.getKey(), locale, "order")); List<String> productHeader = new ArrayList<String>(); productHeader/*from w w w. j a v a 2 s . com*/ .add(translationService.translate("qualityControls.qualityControl.report.control.number", locale)); productHeader.add(translationService.translate( "qualityControls.qualityControlForOrderDetails.window.qualityControlForOrder.controlResult.label", locale)); PdfPTable table = pdfHelper.createTableWithHeader(2, productHeader, false); List<Entity> sortedOrders = entry.getValue(); Collections.sort(sortedOrders, new EntityNumberComparator()); for (Entity entity : sortedOrders) { table.addCell(new Phrase(entity.getStringField("number"), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase( translationService.translate("qualityControls.qualityForOrder.controlResult.value." + entity.getField("controlResult").toString(), locale), FontUtils.getDejavuRegular7Dark())); } document.add(table); }
From source file:com.qcadoo.mes.qualityControls.print.QualityControlForUnitPdfView.java
License:Open Source License
private void addOrderSeries(final Document document, final Map<Entity, List<BigDecimal>> quantities, final Locale locale) throws DocumentException { List<String> qualityHeader = new ArrayList<String>(); qualityHeader/*www . j av a 2s . c om*/ .add(translationService.translate("qualityControls.qualityControl.report.product.number", locale)); qualityHeader.add(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.controlledQuantity.label", locale)); qualityHeader.add(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.rejectedQuantity.label", locale)); qualityHeader.add(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.acceptedDefectsQuantity.label", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put(translationService.translate("qualityControls.qualityControl.report.product.number", locale), HeaderAlignment.LEFT); alignments.put(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.controlledQuantity.label", locale), HeaderAlignment.RIGHT); alignments.put(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.rejectedQuantity.label", locale), HeaderAlignment.RIGHT); alignments.put(translationService.translate( "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.acceptedDefectsQuantity.label", locale), HeaderAlignment.RIGHT); PdfPTable table = pdfHelper.createTableWithHeader(4, qualityHeader, false, alignments); for (Entry<Entity, List<BigDecimal>> entry : quantities.entrySet()) { table.addCell(new Phrase(entry.getKey() == null ? "" : entry.getKey().getStringField("number"), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell( new Phrase(numberService.format(entry.getValue().get(0)), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(numberService.format(entry.getValue().get(1)), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(numberService.format(entry.getValue().get(2)), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); } document.add(table); }
From source file:com.qcadoo.mes.qualityControls.print.QualityControlForUnitPdfView.java
License:Open Source License
private void addProductSeries(final Document document, final Entry<Entity, List<Entity>> entry, final Locale locale) throws DocumentException { document.add(qualityControlsReportService.prepareTitle(entry.getKey(), locale, "unit")); List<String> productHeader = new ArrayList<String>(); productHeader// w w w.ja va2s . c o m .add(translationService.translate("qualityControls.qualityControl.report.control.number", locale)); productHeader.add( translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale)); productHeader.add( translationService.translate("qualityControls.qualityControl.report.rejected.quantity", locale)); productHeader.add(translationService .translate("qualityControls.qualityControl.report.accepted.defects.quantity", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put(translationService.translate("qualityControls.qualityControl.report.control.number", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate("qualityControls.qualityControl.report.controlled.quantity", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate("qualityControls.qualityControl.report.rejected.quantity", locale), HeaderAlignment.RIGHT); alignments.put(translationService.translate( "qualityControls.qualityControl.report.accepted.defects.quantity", locale), HeaderAlignment.RIGHT); PdfPTable table = pdfHelper.createTableWithHeader(4, productHeader, false, alignments); List<Entity> sortedOrders = entry.getValue(); Collections.sort(sortedOrders, new EntityNumberComparator()); for (Entity entity : sortedOrders) { table.addCell(new Phrase(entity.getStringField("number"), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(new Phrase(numberService.format(entity.getField("controlledQuantity")), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(numberService.format(entity.getField("rejectedQuantity")), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(numberService.format(entity.getField("acceptedDefectsQuantity")), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); } document.add(table); }
From source file:com.qcadoo.mes.qualityControls.print.QualityControlsReportService.java
License:Open Source License
public final void addQualityControlReportHeader(final Document document, final Map<String, Object> model, final Locale locale) throws DocumentException { if (!model.containsKey(ENTITIES)) { Paragraph firstParagraphTitle = new Paragraph(new Phrase( translationService.translate("qualityControls.qualityControl.report.paragrah", locale), FontUtils.getDejavuBold11Light())); firstParagraphTitle.add(new Phrase(" " + model.get("dateFrom") + " - " + model.get("dateTo"), FontUtils.getDejavuBold11Light())); firstParagraphTitle.setSpacingBefore(20); document.add(firstParagraphTitle); }//from ww w . j ava 2 s.c o m Paragraph secondParagraphTitle = new Paragraph( new Phrase(translationService.translate("qualityControls.qualityControl.report.paragrah2", locale), FontUtils.getDejavuBold11Light())); secondParagraphTitle.setSpacingBefore(20); document.add(secondParagraphTitle); }
From source file:com.qcadoo.mes.qualityControls.print.QualityControlsReportService.java
License:Open Source License
public final Element prepareTitle(final Entity product, final Locale locale, final String type) { Paragraph title = new Paragraph(); if ("batch".equals(type)) { title.add(new Phrase( translationService.translate("qualityControls.qualityControl.report.paragrah3", locale), FontUtils.getDejavuBold11Light())); } else if (MODEL_ORDER.equals(type)) { title.add(new Phrase( translationService.translate("qualityControls.qualityControl.report.paragrah4", locale), FontUtils.getDejavuBold11Light())); } else if ("unit".equals(type)) { title.add(new Phrase( translationService.translate("qualityControls.qualityControl.report.paragrah5", locale), FontUtils.getDejavuBold11Light())); } else if (MODEL_OPERATION.equals(type)) { title.add(new Phrase( translationService.translate("qualityControls.qualityControl.report.paragrah6", locale), FontUtils.getDejavuBold11Light())); }/*from w w w .j a va 2s. c om*/ String name = ""; if (product != null) { if (MODEL_OPERATION.equals(type)) { name = product.getBelongsToField(MODEL_OPERATION).getStringField("name"); } else { name = product.getStringField("name"); } } title.add(new Phrase(" " + name, FontUtils.getDejavuBold11Dark())); return title; }
From source file:com.qcadoo.mes.simpleMaterialBalance.internal.print.SimpleMaterialBalancePdfService.java
License:Open Source License
private void addBalance(final Document document, final Entity simpleMaterialBalance, final Locale locale) throws DocumentException { document.add(new Paragraph( translationService.translate("simpleMaterialBalance.simpleMaterialBalance.report.paragrah", locale), FontUtils.getDejavuBold11Dark())); List<String> simpleMaterialBalanceTableHeader = new ArrayList<String>(); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.number", locale)); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.name", locale)); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.needed", locale)); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.inLocation", locale)); simpleMaterialBalanceTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.balance", locale)); simpleMaterialBalanceTableHeader.add(translationService.translate("basic.product.unit.label", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put(/*from w w w . j a v a 2 s. co m*/ translationService.translate( "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.number", locale), HeaderAlignment.LEFT); alignments.put(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.name", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.needed", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate( "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.inLocation", locale), HeaderAlignment.RIGHT); alignments.put( translationService.translate( "simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.balance", locale), HeaderAlignment.RIGHT); alignments.put(translationService.translate("basic.product.unit.label", locale), HeaderAlignment.LEFT); PdfPTable table = pdfHelper.createTableWithHeader(6, simpleMaterialBalanceTableHeader, false, alignments); List<Entity> simpleMaterialBalanceOrdersComponents = simpleMaterialBalance .getHasManyField(L_SIMPLE_MATERIAL_BALANCE_ORDERS_COMPONENTS); MrpAlgorithm mrpAlgorithm = MrpAlgorithm.parseString(simpleMaterialBalance.getStringField("mrpAlgorithm")); Map<Long, BigDecimal> neededProductQuantities = productQuantitiesService .getNeededProductQuantitiesForComponents(simpleMaterialBalanceOrdersComponents, mrpAlgorithm); List<Entity> simpleMaterialBalanceLocationComponents = simpleMaterialBalance .getHasManyField(L_SIMPLE_MATERIAL_BALANCE_LOCATIONS_COMPONENTS); // TODO LUPO fix comparator // products = SortUtil.sortMapUsingComparator(products, new EntityNumberComparator()); for (Entry<Long, BigDecimal> neededProductQuantity : neededProductQuantities.entrySet()) { Entity product = productQuantitiesService.getProduct(neededProductQuantity.getKey()); table.addCell(new Phrase(product.getField(L_NUMBER).toString(), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(product.getField(L_NAME).toString(), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(new Phrase(numberService.format(neededProductQuantity.getValue()), FontUtils.getDejavuRegular7Dark())); BigDecimal available = BigDecimal.ZERO; for (Entity simpleMaterialBalanceLocationComponent : simpleMaterialBalanceLocationComponents) { available = available.add(materialFlowService.calculateShouldBeInLocation( simpleMaterialBalanceLocationComponent.getBelongsToField(L_LOCATION).getId(), product.getId(), (Date) simpleMaterialBalance.getField(L_DATE))); } table.addCell(new Phrase(numberService.format(available), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase( numberService.format( available.subtract(neededProductQuantity.getValue(), numberService.getMathContext())), FontUtils.getDejavuBold7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(new Phrase(product.getField(L_UNIT).toString(), FontUtils.getDejavuRegular7Dark())); } document.add(table); }
From source file:com.qcadoo.mes.simpleMaterialBalance.internal.print.SimpleMaterialBalancePdfService.java
License:Open Source License
private void addOrders(final Document document, final Entity simpleMaterialBalance, final Locale locale) throws DocumentException { document.add(Chunk.NEWLINE);/*from w ww .ja va 2s . c o m*/ document.add(new Paragraph(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.paragrah2", locale), FontUtils.getDejavuBold11Dark())); List<String> simpleMaterialBalanceOrdersTableHeader = new ArrayList<String>(); simpleMaterialBalanceOrdersTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.number", locale)); simpleMaterialBalanceOrdersTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.name", locale)); PdfPTable table = pdfHelper.createTableWithHeader(2, simpleMaterialBalanceOrdersTableHeader, false); List<Entity> orders = new ArrayList<Entity>( simpleMaterialBalance.getHasManyField(L_SIMPLE_MATERIAL_BALANCE_ORDERS_COMPONENTS)); Collections.sort(orders, new EntityOrderNumberComparator()); for (Entity e : orders) { table.addCell(new Phrase(e.getBelongsToField(L_ORDER).getStringField(L_NUMBER), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(e.getBelongsToField(L_ORDER).getStringField(L_NAME), FontUtils.getDejavuRegular7Dark())); } document.add(table); }
From source file:com.qcadoo.mes.simpleMaterialBalance.internal.print.SimpleMaterialBalancePdfService.java
License:Open Source License
private void addLocations(final Document document, final Entity simpleMaterialBalance, final Locale locale) throws DocumentException { document.add(Chunk.NEWLINE);// w ww . j a v a 2 s.c o m document.add(new Paragraph(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.paragrah3", locale), FontUtils.getDejavuBold11Dark())); List<String> simpleMaterialBalanceLocationTableHeader = new ArrayList<String>(); simpleMaterialBalanceLocationTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.number", locale)); simpleMaterialBalanceLocationTableHeader.add(translationService .translate("simpleMaterialBalance.simpleMaterialBalance.report.columnHeader.name", locale)); PdfPTable table = pdfHelper.createTableWithHeader(2, simpleMaterialBalanceLocationTableHeader, false); List<Entity> simpleMaterialBalanceLocationComponents = new ArrayList<Entity>( simpleMaterialBalance.getHasManyField(L_SIMPLE_MATERIAL_BALANCE_LOCATIONS_COMPONENTS)); Collections.sort(simpleMaterialBalanceLocationComponents, new EntityLocationNumberComparator()); for (Entity simpleMaterialBalanceLocationComponent : simpleMaterialBalanceLocationComponents) { table.addCell(new Phrase( simpleMaterialBalanceLocationComponent.getBelongsToField(L_LOCATION).getStringField(L_NUMBER), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase( simpleMaterialBalanceLocationComponent.getBelongsToField(L_LOCATION).getStringField(L_NAME), FontUtils.getDejavuRegular7Dark())); } document.add(table); }
From source file:com.qcadoo.mes.technologies.print.TechnologiesTechnologyDetailsPdfView.java
License:Open Source License
@Override protected final String addContent(final Document document, final Map<String, Object> model, final Locale locale, final PdfWriter writer) throws DocumentException, IOException { checkState(model.get("id") != null, "Unable to generate report for unsaved technology! (missing id)"); String documentTitle = translationService .translate("technologies.technologiesTechnologyDetails.report.title", locale); String documentAuthor = translationService.translate("qcadooReport.commons.generatedBy.label", locale); pdfHelper.addDocumentHeader(document, "", documentTitle, documentAuthor, new Date()); DataDefinition technologyDD = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY); Entity technology = technologyDD.get(valueOf(model.get("id").toString())); Map<String, String> panelTableValues = newLinkedHashMap(); panelTableValues.put(TechnologyFields.NAME, technology.getStringField(TechnologyFields.NAME)); panelTableValues.put(TechnologyFields.NUMBER, technology.getStringField(TechnologyFields.NUMBER)); panelTableValues.put(TechnologyFields.PRODUCT, technology.getBelongsToField(TechnologyFields.PRODUCT).getStringField(ProductFields.NAME)); panelTableValues.put("default", technology.getBooleanField(TechnologyFields.MASTER) ? translationService.translate("qcadooView.true", locale) : translationService.translate("qcadooView.false", locale)); panelTableValues.put(TechnologyFields.DESCRIPTION, technology.getStringField(TechnologyFields.DESCRIPTION)); PdfPTable panelTable = pdfHelper.createPanelTable(2); for (Map.Entry<String, String> panelEntry : panelTableValues.entrySet()) { pdfHelper.addTableCellAsOneColumnTable(panelTable, translationService.translate( "technologies.technologiesTechnologyDetails.report.panel.technology." + panelEntry.getKey(), locale), panelEntry.getValue()); }/*from www . j av a 2 s . c o m*/ panelTable.setSpacingAfter(20); panelTable.setSpacingBefore(20); document.add(panelTable); List<String> technologyDetailsTableHeader = new ArrayList<String>(); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.level", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.name", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.direction", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.productNumber", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.productName", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.quantity", locale)); technologyDetailsTableHeader.add(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.unit", locale)); Map<String, HeaderAlignment> alignments = Maps.newHashMap(); alignments.put(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.level", locale), HeaderAlignment.LEFT); alignments.put(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.name", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "technologies.technologiesTechnologyDetails.report.columnHeader.direction", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "technologies.technologiesTechnologyDetails.report.columnHeader.productNumber", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "technologies.technologiesTechnologyDetails.report.columnHeader.productName", locale), HeaderAlignment.LEFT); alignments.put( translationService.translate( "technologies.technologiesTechnologyDetails.report.columnHeader.quantity", locale), HeaderAlignment.RIGHT); alignments.put(translationService .translate("technologies.technologiesTechnologyDetails.report.columnHeader.unit", locale), HeaderAlignment.LEFT); PdfPTable table = pdfHelper.createTableWithHeader(7, technologyDetailsTableHeader, false, alignments); EntityTree technologyTree = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); treeNumberingService.generateTreeNumbers(technologyTree); List<Entity> technologyOperationComponents = entityTreeUtilsService.getSortedEntities(technologyTree); for (Entity technologyOperationComponent : technologyOperationComponents) { String nodeNumber = technologyOperationComponent .getStringField(TechnologyOperationComponentFields.NODE_NUMBER); String operationName = technologyOperationComponent .getBelongsToField(TechnologyOperationComponentFields.OPERATION) .getStringField(OperationFields.NAME); List<Entity> operationProductComponents = newArrayList(); operationProductComponents.addAll(technologyOperationComponent .getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS)); operationProductComponents.addAll(technologyOperationComponent .getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS)); for (Entity operationProductComponent : operationProductComponents) { Entity product = operationProductComponent.getBelongsToField(L_PRODUCT); String productType = "technologies.technologiesTechnologyDetails.report.direction.out"; if (operationProductComponent.getDataDefinition().getName().equals("operationProductInComponent")) { productType = "technologies.technologiesTechnologyDetails.report.direction.in"; } table.addCell(new Phrase(nodeNumber, FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(operationName, FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(translationService.translate(productType, locale), FontUtils.getDejavuRegular7Dark())); table.addCell(new Phrase(product.getStringField(ProductFields.NUMBER), FontUtils.getDejavuRegular7Dark())); table.addCell( new Phrase(product.getStringField(ProductFields.NAME), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(new Phrase(numberService.format(operationProductComponent.getField(L_QUANTITY)), FontUtils.getDejavuRegular7Dark())); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell( new Phrase(product.getStringField(ProductFields.UNIT), FontUtils.getDejavuRegular7Dark())); } } document.add(table); return translationService.translate("technologies.technologiesTechnologyDetails.report.fileName", locale); }
From source file:com.qcadoo.mes.warehouseMinimalState.print.DocumentPdf.java
License:Open Source License
public void addSmallCell(PdfPTable table, String content) { table.addCell(new Phrase(content, FontUtils.getDejavuRegular7Dark())); }