Example usage for com.lowagie.text Chunk NEWLINE

List of usage examples for com.lowagie.text Chunk NEWLINE

Introduction

In this page you can find the example usage for com.lowagie.text Chunk NEWLINE.

Prototype

Chunk NEWLINE

To view the source code for com.lowagie.text Chunk NEWLINE.

Click Source Link

Document

This is a Chunk containing a newline.

Usage

From source file:com.qcadoo.mes.deliveries.print.OrderReportPdf.java

License:Open Source License

private void createHeaderTable(final Document document, final Entity delivery, final Locale locale)
        throws DocumentException {
    PdfPTable dynaminHeaderTable = pdfHelper.createPanelTable(3);
    dynaminHeaderTable.getDefaultCell().setVerticalAlignment(Element.ALIGN_TOP);

    PdfPTable firstColumnHeaderTable = new PdfPTable(1);
    PdfPTable secondColumnHeaderTable = new PdfPTable(1);
    PdfPTable thirdColumnHeaderTable = new PdfPTable(1);

    setSimpleFormat(firstColumnHeaderTable);
    setSimpleFormat(secondColumnHeaderTable);
    setSimpleFormat(thirdColumnHeaderTable);

    dynaminHeaderTable.setSpacingBefore(7);

    Map<String, Object> firstColumn = createFirstColumn(delivery);
    Map<String, Object> secondColumn = createSecondColumn(delivery);
    Map<String, Object> thirdColumn = createThirdColumn(delivery);

    int maxSize = pdfHelper.getMaxSizeOfColumnsRows(Lists.newArrayList(
            Integer.valueOf(firstColumn.values().size()), Integer.valueOf(secondColumn.values().size()),
            Integer.valueOf(thirdColumn.values().size())));

    for (int i = 0; i < maxSize; i++) {
        firstColumnHeaderTable = pdfHelper.addDynamicHeaderTableCell(firstColumnHeaderTable, firstColumn,
                locale);/*from w  ww. j a v  a 2 s . com*/
        secondColumnHeaderTable = pdfHelper.addDynamicHeaderTableCell(secondColumnHeaderTable, secondColumn,
                locale);
        thirdColumnHeaderTable = pdfHelper.addDynamicHeaderTableCell(thirdColumnHeaderTable, thirdColumn,
                locale);
    }

    dynaminHeaderTable.addCell(firstColumnHeaderTable);
    dynaminHeaderTable.addCell(secondColumnHeaderTable);
    dynaminHeaderTable.addCell(thirdColumnHeaderTable);

    document.add(dynaminHeaderTable);
    document.add(Chunk.NEWLINE);
}

From source file:com.qcadoo.mes.genealogies.print.GenealogyForProductView.java

License:Open Source License

private void addComponentSeries(final Document document, final List<Entity> orders, final Locale locale)
        throws DocumentException {
    for (Entity order : orders) {
        document.add(Chunk.NEWLINE);
        Paragraph title = new Paragraph(new Phrase(
                translationService.translate("genealogies.genealogyForProduct.report.paragrah", locale),
                FontUtils.getDejavuBold11Light()));
        title.add(new Phrase(" " + order.getField(NUMBER_FIELD).toString(), FontUtils.getDejavuBold19Dark()));
        document.add(title);/*from  w  w  w.  java 2  s .c o  m*/
        List<String> componentHeader = new ArrayList<String>();
        componentHeader.add(translationService.translate("basic.product.number.label", locale));
        componentHeader.add(translationService.translate("basic.product.name.label", locale));
        componentHeader.add(
                translationService.translate("genealogiesForComponents.productInBatch.batch.label", locale));
        PdfPTable table = pdfHelper.createTableWithHeader(3, componentHeader, false);

        List<Pair<String, Entity>> batchList = getBatchList(order);

        Collections.sort(batchList, new BatchOrderNrComparator());

        for (Pair<String, Entity> pair : batchList) {
            String batch = pair.getKey();
            Entity product = pair.getValue();
            table.addCell(
                    new Phrase(product.getField(NUMBER_FIELD).toString(), FontUtils.getDejavuRegular9Dark()));
            table.addCell(
                    new Phrase(product.getField(NAME_FIELD).toString(), FontUtils.getDejavuRegular9Dark()));
            table.addCell(new Phrase(batch, FontUtils.getDejavuRegular9Dark()));
        }
        document.add(table);

    }
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionBalancePdfService.java

License:Open Source License

public void addOutputProductsBalance(final Document document, final Entity productionBalance,
        final Locale locale) throws DocumentException {

    List<String> outputProductsTableHeader = Lists.newArrayList();

    outputProductsTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.number", locale));
    outputProductsTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.productionName", locale));
    outputProductsTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.plannedQuantity", locale));
    outputProductsTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.producedQuantity", locale));
    outputProductsTableHeader//from  w  w w  .j  ava2s .c  o  m
            .add(translationService.translate(L_PRODUCTION_BALANCE_REPORT_COLUMN_HEADER_BALANCE, locale));
    outputProductsTableHeader.add(translationService.translate("basic.product.unit.label", locale));

    Map<String, HeaderAlignment> alignments = Maps.newHashMap();
    alignments.put(translationService.translate(
            "productionCounting.productionBalance.report.columnHeader.number", locale), HeaderAlignment.LEFT);

    alignments.put(
            translationService.translate(
                    "productionCounting.productionBalance.report.columnHeader.productionName", locale),
            HeaderAlignment.LEFT);

    alignments.put(
            translationService.translate(
                    "productionCounting.productionBalance.report.columnHeader.plannedQuantity", locale),
            HeaderAlignment.RIGHT);

    alignments.put(
            translationService.translate(
                    "productionCounting.productionBalance.report.columnHeader.producedQuantity", locale),
            HeaderAlignment.RIGHT);

    alignments.put(translationService.translate(PCPBRCHB_LITERAL, locale), HeaderAlignment.RIGHT);

    alignments.put(translationService.translate("basic.product.unit.label", locale), HeaderAlignment.LEFT);

    List<Entity> outputProductsList = productionBalance
            .getHasManyField(ProductionBalanceFields.BALANCE_OPERATION_PRODUCT_OUT_COMPONENTS);

    if (!outputProductsList.isEmpty()) {
        document.add(Chunk.NEWLINE);
        document.add(new Paragraph(
                translationService.translate("productionCounting.productionBalance.report.paragraph2", locale),
                FontUtils.getDejavuBold11Dark()));

        outputProductsList = Lists.newLinkedList(outputProductsList);

        PdfPTable outputProductsTable = pdfHelper.createTableWithHeader(6, outputProductsTableHeader, false,
                alignments);

        for (Entity outputProduct : outputProductsList) {
            outputProductsTable
                    .addCell(
                            new Phrase(
                                    outputProduct
                                            .getBelongsToField(
                                                    BalanceOperationProductOutComponentFields.PRODUCT)
                                            .getStringField(ProductFields.NUMBER),
                                    FontUtils.getDejavuRegular9Dark()));
            outputProductsTable
                    .addCell(
                            new Phrase(
                                    outputProduct
                                            .getBelongsToField(
                                                    BalanceOperationProductOutComponentFields.PRODUCT)
                                            .getStringField(ProductFields.NAME),
                                    FontUtils.getDejavuRegular9Dark()));

            outputProductsTable.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            outputProductsTable.addCell(new Phrase(
                    numberService.format(
                            outputProduct.getField(BalanceOperationProductOutComponentFields.PLANNED_QUANTITY)),
                    FontUtils.getDejavuRegular9Dark()));
            if (outputProduct.getField(BalanceOperationProductOutComponentFields.USED_QUANTITY) == null) {
                outputProductsTable.addCell(new Phrase(L_N_A, FontUtils.getDejavuRegular9Dark()));
                outputProductsTable.addCell(new Phrase(L_N_A, FontUtils.getDejavuRegular9Dark()));
            } else {
                outputProductsTable.addCell(new Phrase(
                        numberService.format(outputProduct
                                .getField(BalanceOperationProductOutComponentFields.USED_QUANTITY)),
                        FontUtils.getDejavuRegular9Dark()));
                outputProductsTable.addCell(new Phrase(
                        numberService.format(
                                outputProduct.getField(BalanceOperationProductOutComponentFields.BALANCE)),
                        FontUtils.getDejavuRegular9Dark()));
            }
            outputProductsTable.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            outputProductsTable
                    .addCell(
                            new Phrase(
                                    outputProduct
                                            .getBelongsToField(
                                                    BalanceOperationProductOutComponentFields.PRODUCT)
                                            .getStringField(ProductFields.UNIT),
                                    FontUtils.getDejavuRegular9Dark()));
        }

        document.add(outputProductsTable);
    }
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionBalancePdfService.java

License:Open Source License

public void addMachineTimeBalance(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);
    document.add(new Paragraph(
            translationService.translate("productionCounting.productionBalance.report.paragraph3", locale),
            FontUtils.getDejavuBold11Dark()));

    List<String> operationsTimeTableHeader = Lists.newArrayList();

    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationLevel", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationNumber", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.plannedDuration", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.registeredTime", locale));
    operationsTimeTableHeader/*from   ww w. j  av a 2  s  .c o  m*/
            .add(translationService.translate(L_PRODUCTION_BALANCE_REPORT_COLUMN_HEADER_BALANCE, locale));

    PdfPTable machineTimeTable = pdfHelper.createTableWithHeader(5, operationsTimeTableHeader, false);

    List<Entity> operationTimeComponents = productionBalance
            .getHasManyField(ProductionBalanceFields.OPERATION_TIME_COMPONENTS);

    if (!operationTimeComponents.isEmpty()) {
        for (Entity operationTimeComponent : operationTimeComponents) {
            machineTimeTable
                    .addCell(new Phrase(
                            operationTimeComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getStringField(TechnologyOperationComponentFields.NODE_NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            machineTimeTable
                    .addCell(new Phrase(
                            operationTimeComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getBelongsToField(TechnologyOperationComponentFields.OPERATION)
                                    .getStringField(OperationFields.NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            machineTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(operationTimeComponent
                            .getIntegerField(OperationTimeComponentFields.PLANNED_MACHINE_TIME)),
                    FontUtils.getDejavuRegular9Dark()));
            machineTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(
                            operationTimeComponent.getIntegerField(OperationTimeComponentFields.MACHINE_TIME)),
                    FontUtils.getDejavuRegular9Dark()));
            machineTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(operationTimeComponent
                            .getIntegerField(OperationTimeComponentFields.MACHINE_TIME_BALANCE)),
                    FontUtils.getDejavuRegular9Dark()));
        }
    }

    machineTimeTable.addCell(new Phrase(
            translationService.translate("productionCounting.productionBalance.report.total", locale),
            FontUtils.getDejavuRegular9Dark()));
    machineTimeTable.addCell(new Phrase("", FontUtils.getDejavuRegular9Dark()));
    machineTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.PLANNED_MACHINE_TIME)),
            FontUtils.getDejavuRegular9Dark()));
    machineTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.MACHINE_TIME)),
            FontUtils.getDejavuRegular9Dark()));
    machineTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.MACHINE_TIME_BALANCE)),
            FontUtils.getDejavuRegular9Dark()));

    document.add(machineTimeTable);
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionBalancePdfService.java

License:Open Source License

public void addLaborTimeBalance(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);
    document.add(new Paragraph(
            translationService.translate("productionCounting.productionBalance.report.paragraph4", locale),
            FontUtils.getDejavuBold11Dark()));

    List<String> operationsTimeTableHeader = Lists.newArrayList();

    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationLevel", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationNumber", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.plannedDuration", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.registeredTime", locale));
    operationsTimeTableHeader/*  w w  w  .  j a  va  2  s. c om*/
            .add(translationService.translate(L_PRODUCTION_BALANCE_REPORT_COLUMN_HEADER_BALANCE, locale));

    PdfPTable laborTimeTable = pdfHelper.createTableWithHeader(5, operationsTimeTableHeader, false);

    List<Entity> operationTimeComponents = productionBalance
            .getHasManyField(ProductionBalanceFields.OPERATION_TIME_COMPONENTS);

    if (!operationTimeComponents.isEmpty()) {
        for (Entity operationTimeComponent : operationTimeComponents) {
            laborTimeTable
                    .addCell(new Phrase(
                            operationTimeComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getStringField(TechnologyOperationComponentFields.NODE_NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            laborTimeTable
                    .addCell(new Phrase(
                            operationTimeComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getBelongsToField(TechnologyOperationComponentFields.OPERATION)
                                    .getStringField(OperationFields.NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            laborTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(operationTimeComponent
                            .getIntegerField(OperationTimeComponentFields.PLANNED_LABOR_TIME)),
                    FontUtils.getDejavuRegular9Dark()));
            laborTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(
                            operationTimeComponent.getIntegerField(OperationTimeComponentFields.LABOR_TIME)),
                    FontUtils.getDejavuRegular9Dark()));
            laborTimeTable.addCell(new Phrase(
                    timeConverterService.convertTimeToString(operationTimeComponent
                            .getIntegerField(OperationTimeComponentFields.LABOR_TIME_BALANCE)),
                    FontUtils.getDejavuRegular9Dark()));
        }
    }

    laborTimeTable.addCell(new Phrase(
            translationService.translate("productionCounting.productionBalance.report.total", locale),
            FontUtils.getDejavuRegular9Dark()));
    laborTimeTable.addCell(new Phrase("", FontUtils.getDejavuRegular9Dark()));
    laborTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.PLANNED_LABOR_TIME)),
            FontUtils.getDejavuRegular9Dark()));
    laborTimeTable.addCell(new Phrase(
            timeConverterService
                    .convertTimeToString(productionBalance.getIntegerField(ProductionBalanceFields.LABOR_TIME)),
            FontUtils.getDejavuRegular9Dark()));
    laborTimeTable.addCell(new Phrase(
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.LABOR_TIME_BALANCE)),
            FontUtils.getDejavuRegular9Dark()));

    document.add(laborTimeTable);
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionBalancePdfService.java

License:Open Source License

public void addPieceworkBalance(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);
    document.add(new Paragraph(
            translationService.translate("productionCounting.productionBalance.report.paragraph5", locale),
            FontUtils.getDejavuBold11Dark()));

    List<String> operationsTimeTableHeader = Lists.newArrayList();

    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationLevel", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.operationNumber", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.plannedCycles", locale));
    operationsTimeTableHeader.add(translationService
            .translate("productionCounting.productionBalance.report.columnHeader.registeredCycles", locale));
    operationsTimeTableHeader//from w w  w  .j  av  a2  s. c  o m
            .add(translationService.translate(L_PRODUCTION_BALANCE_REPORT_COLUMN_HEADER_BALANCE, locale));

    PdfPTable pieceworkTable = pdfHelper.createTableWithHeader(5, operationsTimeTableHeader, false);

    List<Entity> operationPieceworkComponents = productionBalance
            .getHasManyField(ProductionBalanceFields.OPERATION_PIECEWORK_COMPONENTS);

    BigDecimal totalPlannedCycles = BigDecimal.ZERO;
    BigDecimal totalCycles = BigDecimal.ZERO;
    BigDecimal totalCyclesBalance = BigDecimal.ZERO;

    if (!operationPieceworkComponents.isEmpty()) {
        for (Entity operationPieceworkComponent : operationPieceworkComponents) {
            BigDecimal plannedCycles = operationPieceworkComponent
                    .getDecimalField(OperationPieceworkComponentFields.PLANNED_CYCLES);
            BigDecimal cycles = operationPieceworkComponent
                    .getDecimalField(OperationPieceworkComponentFields.CYCLES);
            BigDecimal cyclesBalance = operationPieceworkComponent
                    .getDecimalField(OperationPieceworkComponentFields.CYCLES_BALANCE);

            pieceworkTable
                    .addCell(new Phrase(
                            operationPieceworkComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getStringField(TechnologyOperationComponentFields.NODE_NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            pieceworkTable
                    .addCell(new Phrase(
                            operationPieceworkComponent
                                    .getBelongsToField(
                                            OperationTimeComponentFields.TECHNOLOGY_OPERATION_COMPONENT)
                                    .getBelongsToField(TechnologyOperationComponentFields.OPERATION)
                                    .getStringField(OperationFields.NUMBER),
                            FontUtils.getDejavuRegular9Dark()));
            pieceworkTable.addCell(
                    new Phrase(numberService.format(plannedCycles), FontUtils.getDejavuRegular9Dark()));
            pieceworkTable.addCell(new Phrase(numberService.format(cycles), FontUtils.getDejavuRegular9Dark()));
            pieceworkTable.addCell(
                    new Phrase(numberService.format(cyclesBalance), FontUtils.getDejavuRegular9Dark()));

            totalPlannedCycles = totalPlannedCycles.add(plannedCycles, numberService.getMathContext());
            totalCycles = totalPlannedCycles.add(cycles, numberService.getMathContext());
            totalCyclesBalance = totalPlannedCycles.add(cyclesBalance, numberService.getMathContext());
        }
    }

    pieceworkTable.addCell(new Phrase(
            translationService.translate("productionCounting.productionBalance.report.total", locale),
            FontUtils.getDejavuRegular9Dark()));
    pieceworkTable.addCell(new Phrase("", FontUtils.getDejavuRegular9Dark()));
    pieceworkTable
            .addCell(new Phrase(numberService.format(totalPlannedCycles), FontUtils.getDejavuRegular9Dark()));
    pieceworkTable.addCell(new Phrase(numberService.format(totalCycles), FontUtils.getDejavuRegular9Dark()));
    pieceworkTable
            .addCell(new Phrase(numberService.format(totalCyclesBalance), FontUtils.getDejavuRegular9Dark()));

    document.add(pieceworkTable);
}

From source file:com.qcadoo.mes.productionCounting.print.ProductionBalancePdfService.java

License:Open Source License

public void addTimeBalanceAsPanel(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);
    document.add(/*from ww  w .j  ava  2 s .  c o  m*/
            new Paragraph(
                    translationService.translate(
                            "productionCounting.productionBalanceDetails.window.productionTime", locale),
                    FontUtils.getDejavuBold11Dark()));

    PdfPTable timePanel = pdfHelper.createPanelTable(3);

    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.plannedMachineTime",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.PLANNED_MACHINE_TIME)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.machineTime",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.MACHINE_TIME)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.machineTimeBalance",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.MACHINE_TIME_BALANCE)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.plannedLaborTime",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.PLANNED_LABOR_TIME)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.laborTime",
            locale) + ":",
            timeConverterService
                    .convertTimeToString(productionBalance.getIntegerField(ProductionBalanceFields.LABOR_TIME)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);
    addTableCellAsTable(timePanel, translationService.translate(
            "productionCounting.productionBalanceDetails.window.workTab.operationsTime.column.laborTimeBalance",
            locale) + ":",
            timeConverterService.convertTimeToString(
                    productionBalance.getIntegerField(ProductionBalanceFields.LABOR_TIME_BALANCE)),
            null, FontUtils.getDejavuRegular9Dark(), FontUtils.getDejavuRegular9Dark(), null);

    timePanel.setSpacingBefore(10);
    document.add(timePanel);
}

From source file:com.qcadoo.mes.productionCountingWithCosts.pdf.ProductionBalanceWithCostsPdfService.java

License:Open Source License

private void addProductionCosts(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    document.add(Chunk.NEWLINE);
    document.add(/* ww w.  ja va  2 s.c  o m*/
            new Paragraph(
                    translationService.translate(
                            "productionCounting.productionBalance.report.panel.productionCosts", locale),
                    FontUtils.getDejavuBold11Dark()));

    PdfPTable costsPanel = pdfHelper.createPanelTable(3);

    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.machinePlanned",
            productionBalance.getField(ProductionBalanceFieldsPCWC.PLANNED_MACHINE_COSTS), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.machineRegistered",
            productionBalance.getField(ProductionBalanceFieldsPCWC.MACHINE_COSTS), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.machineBalance",
            productionBalance.getField(ProductionBalanceFieldsPCWC.MACHINE_COSTS_BALANCE), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.laborPlanned",
            productionBalance.getField(ProductionBalanceFieldsPCWC.PLANNED_LABOR_COSTS), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.laborRegistered",
            productionBalance.getField(ProductionBalanceFieldsPCWC.LABOR_COSTS), locale);
    addCurrencyNumericWithLabel(costsPanel,
            "productionCounting.productionBalance.report.panel.productionCosts.laborBalance",
            productionBalance.getField(ProductionBalanceFieldsPCWC.LABOR_COSTS_BALANCE), locale);

    costsPanel.setSpacingBefore(10);
    document.add(costsPanel);
}

From source file:com.qcadoo.mes.productionCountingWithCosts.pdf.ProductionBalanceWithCostsPdfService.java

License:Open Source License

private void addMaterialCost(final Document document, final Entity productionBalance, final Locale locale)
        throws DocumentException {
    List<String> materialCostTableHeader = Lists.newArrayList();

    materialCostTableHeader.add(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyOperationProductInComponents.column.productNumber",
            locale));//from w w  w.j  a  va  2s .  c  o m
    materialCostTableHeader.add(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyOperationProductInComponents.column.plannedCost",
            locale));
    materialCostTableHeader.add(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyOperationProductInComponents.column.registeredCost",
            locale));
    materialCostTableHeader.add(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyOperationProductInComponents.column.balance",
            locale));
    Map<String, HeaderAlignment> alignments = Maps.newHashMap();

    alignments.put(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyInstOperProductInComps.column.productNumber",
            locale), HeaderAlignment.LEFT);
    alignments.put(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyInstOperProductInComps.column.plannedCost",
            locale), HeaderAlignment.RIGHT);

    alignments.put(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyInstOperProductInComps.column.registeredCost",
            locale), HeaderAlignment.RIGHT);

    alignments.put(translationService.translate(
            "productionCounting.productionBalanceDetails.window.materialCostsTab.technologyInstOperProductInComps.column.balance",
            locale), HeaderAlignment.RIGHT);

    List<Entity> technologyOperationProductInComponents = productionBalance
            .getHasManyField(ProductionBalanceFieldsPCWC.TECHNOLOGY_OPERATION_PRODUCT_IN_COMPONENTS);

    if (!technologyOperationProductInComponents.isEmpty()) {
        document.add(Chunk.NEWLINE);

        document.add(
                new Paragraph(
                        translationService.translate(
                                "productionCounting.productionBalance.report.table.materialCost", locale),
                        FontUtils.getDejavuBold11Dark()));

        technologyOperationProductInComponents = Lists.newLinkedList(technologyOperationProductInComponents);
        Collections.sort(technologyOperationProductInComponents, new EntityProductInOutComparator());

        PdfPTable productsTable = pdfHelper.createTableWithHeader(4, materialCostTableHeader, false,
                alignments);

        String currency = " " + currencyService.getCurrencyAlphabeticCode();

        for (Entity technologyOperationProductInComponent : technologyOperationProductInComponents) {
            productsTable.addCell(new Phrase(technologyOperationProductInComponent
                    .getBelongsToField(TechnologyOperationProductInCompFields.PRODUCT)
                    .getStringField(ProductFields.NUMBER), FontUtils.getDejavuRegular7Dark()));
            productsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);

            String plannedCost = numberService.format(technologyOperationProductInComponent
                    .getField(TechnologyOperationProductInCompFields.PLANNED_COST));
            productsTable.addCell(new Phrase((plannedCost == null) ? L_NULL_OBJECT : (plannedCost + currency),
                    FontUtils.getDejavuRegular7Dark()));
            String registeredCost = numberService.format(technologyOperationProductInComponent
                    .getField(TechnologyOperationProductInCompFields.REGISTERED_COST));
            productsTable
                    .addCell(new Phrase((registeredCost == null) ? L_NULL_OBJECT : (registeredCost + currency),
                            FontUtils.getDejavuRegular7Dark()));
            String balance = numberService.format(technologyOperationProductInComponent
                    .getField(TechnologyOperationProductInCompFields.BALANCE));
            productsTable.addCell(new Phrase((balance == null) ? L_NULL_OBJECT : (balance + currency),
                    FontUtils.getDejavuRegular7Dark()));
            productsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);

        }

        productsTable.addCell(new Phrase(
                translationService.translate("productionCounting.productionBalance.report.total", locale),
                FontUtils.getDejavuRegular7Dark()));
        String plannedComponentsCosts = numberService.format(
                productionBalance.getDecimalField(ProductionBalanceFieldsPCWC.PLANNED_COMPONENTS_COSTS));
        productsTable.addCell(new Phrase(
                (plannedComponentsCosts == null) ? L_NULL_OBJECT : (plannedComponentsCosts + currency),
                FontUtils.getDejavuRegular7Dark()));
        String componentsCosts = numberService
                .format(productionBalance.getDecimalField(ProductionBalanceFieldsPCWC.COMPONENTS_COSTS));
        productsTable
                .addCell(new Phrase((componentsCosts == null) ? L_NULL_OBJECT : (componentsCosts + currency),
                        FontUtils.getDejavuRegular7Dark()));
        String componentsCostsBalance = numberService.format(
                productionBalance.getDecimalField(ProductionBalanceFieldsPCWC.COMPONENTS_COSTS_BALANCE));
        productsTable.addCell(new Phrase(
                (componentsCostsBalance == null) ? L_NULL_OBJECT : (componentsCostsBalance + currency),
                FontUtils.getDejavuRegular7Dark()));
        productsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);

        document.add(productsTable);
    }
}

From source file:com.qcadoo.mes.productionCountingWithCosts.pdf.ProductionBalanceWithCostsPdfService.java

License:Open Source License

private void addCostsBalance(final String type, final Document document, final Entity productionBalance,
        final Locale locale) throws DocumentException {

    List<String> tableHeader = Lists.newArrayList();

    tableHeader.add(translationService.translate(
            "productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column.operationLevel",
            locale));/*from   w ww.j  ava 2s.c om*/
    tableHeader.add(translationService.translate(
            "productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column.operationName",
            locale));
    tableHeader.add(translationService.translate(
            "productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column.planned"
                    + upperCaseFirstLetter(type, locale) + L_COSTS,
            locale));
    tableHeader.add(translationService
            .translate("productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column."
                    + type + L_COSTS, locale));
    tableHeader.add(translationService
            .translate("productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column."
                    + type + "CostsBalance", locale));
    Map<String, HeaderAlignment> alignments = Maps.newHashMap();
    alignments.put(translationService.translate(
            "productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column.operationLevel",
            locale), HeaderAlignment.LEFT);
    alignments.put(translationService.translate(
            "productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column.operationName",
            locale), HeaderAlignment.LEFT);
    alignments.put(translationService.translate(
            "productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column.planned"
                    + upperCaseFirstLetter(type, locale) + L_COSTS,
            locale), HeaderAlignment.RIGHT);
    alignments.put(translationService
            .translate("productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column."
                    + type + L_COSTS, locale),
            HeaderAlignment.RIGHT);
    alignments.put(translationService
            .translate("productionCounting.productionBalanceDetails.window.workCostsTab.operationsCost.column."
                    + type + "CostsBalance", locale),
            HeaderAlignment.RIGHT);

    boolean isPiecework = "cycles".equals(type);

    List<Entity> operationComponents = productionBalance
            .getHasManyField(isPiecework ? ProductionBalanceFieldsPCWC.OPERATION_PIECEWORK_COST_COMPONENTS
                    : ProductionBalanceFieldsPCWC.OPERATION_COST_COMPONENTS);

    if (!operationComponents.isEmpty()) {
        document.add(Chunk.NEWLINE);

        document.add(new Paragraph(translationService.translate(
                "productionCounting.productionBalanceDetails.window.workCostsTab." + type + L_COSTS, locale),
                FontUtils.getDejavuBold11Dark()));

        operationComponents = Lists.newLinkedList(operationComponents);
        Collections.sort(operationComponents, new EntityProductionTrackingOperationComparator());

        PdfPTable costsTable = pdfHelper.createTableWithHeader(5, tableHeader, false, alignments);

        String currency = " " + currencyService.getCurrencyAlphabeticCode();

        for (Entity operationComponent : operationComponents) {
            costsTable.addCell(new Phrase(
                    operationComponent.getBelongsToField(L_TECHNOLOGY_OPERATION_COMPONENT)
                            .getStringField(TechnologyOperationComponentFields.NODE_NUMBER),
                    FontUtils.getDejavuRegular7Dark()));
            costsTable.addCell(new Phrase(operationComponent.getBelongsToField(L_TECHNOLOGY_OPERATION_COMPONENT)
                    .getBelongsToField(TechnologyOperationComponentFields.OPERATION)
                    .getStringField(OperationFields.NAME), FontUtils.getDejavuRegular7Dark()));

            costsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);

            String plannedCost = numberService.format(
                    operationComponent.getField("planned" + upperCaseFirstLetter(type, locale) + L_COSTS));
            costsTable.addCell(new Phrase((plannedCost == null) ? L_NULL_OBJECT : (plannedCost + currency),
                    FontUtils.getDejavuRegular7Dark()));
            String registeredCost = numberService.format(operationComponent.getField(type + L_COSTS));
            costsTable
                    .addCell(new Phrase((registeredCost == null) ? L_NULL_OBJECT : (registeredCost + currency),
                            FontUtils.getDejavuRegular7Dark()));
            String balance = numberService.format(operationComponent.getField(type + L_COSTS_BALANCE));
            costsTable.addCell(new Phrase((balance == null) ? L_NULL_OBJECT : (balance + currency),
                    FontUtils.getDejavuRegular7Dark()));
            costsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);

        }

        costsTable.addCell(new Phrase(
                translationService.translate("productionCounting.productionBalance.report.total", locale),
                FontUtils.getDejavuRegular7Dark()));
        costsTable.addCell(new Phrase("", FontUtils.getDejavuRegular7Dark()));
        costsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);

        String plannedCosts = numberService.format(
                productionBalance.getDecimalField(L_PLANNED + upperCaseFirstLetter(type, locale) + L_COSTS));
        costsTable.addCell(new Phrase((plannedCosts == null) ? L_NULL_OBJECT : (plannedCosts + currency),
                FontUtils.getDejavuRegular7Dark()));
        String registeredCosts = numberService.format(productionBalance.getDecimalField(type + L_COSTS));
        costsTable.addCell(new Phrase((registeredCosts == null) ? L_NULL_OBJECT : (registeredCosts + currency),
                FontUtils.getDejavuRegular7Dark()));
        String costsBalance = numberService.format(productionBalance.getDecimalField(type + L_COSTS_BALANCE));
        costsTable.addCell(new Phrase((costsBalance == null) ? L_NULL_OBJECT : (costsBalance + currency),
                FontUtils.getDejavuRegular7Dark()));
        costsTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);

        document.add(costsTable);
    }
}