in server/src/main/java/com/epam/indigoeln/core/service/print/itext2/sections/experiment/BatchInformationSection.java [57:129]
protected PdfPTable generateContentTable(float width) {
PdfPTable table = TableFactory.createDefaultTable(HEADERS, COLUMN_WIDTH, width);
float imagePart = (float) (COLUMN_WIDTH[1] / DoubleStreamEx.of(COLUMN_WIDTH).sum());
float structureTableWidth = imagePart * width;
float yieldPart = (float) (COLUMN_WIDTH[3] / DoubleStreamEx.of(COLUMN_WIDTH).sum());
float yieldWidth = yieldPart * width;
for (BatchInformationRow row : model.getRows()) {
Structure structure = row.getStructure();
PdfPTable structureTable = TableFactory.createDefaultTable(1, structureTableWidth);
if (structure.getImage().getPngBytes(structureTableWidth).isPresent()) {
PdfPCell imageCell = CellFactory.getImageCell(structure.getImage(), structureTableWidth);
structureTable.addCell(getStructureCell(imageCell));
}
String content = structure.getName() + " " + structure.getDescription();
if (!StringUtils.isBlank(content)) {
PdfPCell textCell = CellFactory.getCommonCell(content);
structureTable.addCell(getStructureCell(textCell));
}
PdfPTable yieldTable = TableFactory.createDefaultTable(1, yieldWidth);
if (!StringUtils.isBlank(row.getTheoWeight())) {
yieldTable.addCell(getYieldCell(FormatUtils
.formatDecimal(row.getTheoWeight(), row.getTheoWeightUnit())));
}
if (!StringUtils.isBlank(row.getYield())) {
yieldTable.addCell(getYieldCell(FormatUtils.formatDecimal(row.getYield(), "%")));
}
PdfPTable batchInformation = new PdfPTable(INFO_COLUMN_WIDTH);
BatchInformation batchInfo = row.getBatchInformation();
PdfPCell molWeightLabel = getBatchCell("Mol Wgt:");
PdfPCell molWeight = getBatchCell(FormatUtils.formatDecimal(batchInfo.getMolWeight()));
PdfPCell exactMassLabel = getBatchCell("Exact Mass:");
PdfPCell exactMass = getBatchCell(FormatUtils.formatDecimal(batchInfo.getExactMass()));
PdfPCell saltCodeLabel = getBatchCell("Salt Code:");
PdfPCell saltCode = getBatchCell(batchInfo.getSaltCode());
PdfPCell saltEqLabel = getBatchCell("Salt EQ:");
PdfPCell saltEq = getBatchCell(FormatUtils.formatDecimal(batchInfo.getSaltEq()));
PdfPCell batchOwnerLabel = getBatchCell("Batch Owner:");
PdfPCell batchOwner = getBatchCell(StringUtils.join(batchInfo.getBatchOwner(), COMMA));
PdfPCell commentsLabel = getBatchCell("Comments:");
PdfPCell comments = getBatchCell(batchInfo.getComments());
batchInformation.addCell(molWeightLabel);
batchInformation.addCell(molWeight);
batchInformation.addCell(exactMassLabel);
batchInformation.addCell(exactMass);
batchInformation.addCell(saltCodeLabel);
batchInformation.addCell(saltCode);
batchInformation.addCell(saltEqLabel);
batchInformation.addCell(saltEq);
batchInformation.addCell(batchOwnerLabel);
batchInformation.addCell(batchOwner);
batchInformation.addCell(commentsLabel);
batchInformation.addCell(comments);
table.addCell(CellFactory.getCommonCell(row.getNbkBatch()));
table.addCell(CellFactory.getCommonCell(structureTable));
table.addCell(CellFactory.getCommonCell(FormatUtils
.formatDecimal(row.getAmountMade(), row.getAmountMadeUnit())));
table.addCell(CellFactory.getCommonCell(yieldTable));
table.addCell(CellFactory.getCommonCell(row.getPurity()));
table.addCell(CellFactory.getCommonCell(batchInformation, CELL_VERTICAL_PADDING));
}
return table;
}