in server/src/main/java/com/epam/indigoeln/core/service/print/itext2/sections/experiment/StoichiometrySection.java [55:123]
protected PdfPTable generateContentTable(float width) {
PdfPTable table = TableFactory.createDefaultTable(HEADERS, COLUMN_WIDTH, width);
float imagePart = (float) (COLUMN_WIDTH[0] / DoubleStreamEx.of(COLUMN_WIDTH).sum());
float reagentCellWidth = imagePart * width;
for (StoichiometryRow row : model.getRows()) {
PdfPTable reagentTable = TableFactory.createDefaultTable(1, reagentCellWidth);
Structure structure = row.getStructure();
if (structure.getImage().getPngBytes(reagentCellWidth).isPresent()) {
PdfPCell imageCell = CellFactory.getImageCell(structure.getImage(), reagentCellWidth);
reagentTable.addCell(getStructureCell(imageCell));
}
if (!StringUtils.isBlank(row.getFullNbkBatch())) {
PdfPCell fullNbkBatch = CellFactory.getCommonCell(row.getFullNbkBatch());
reagentTable.addCell(getStructureCell(fullNbkBatch));
}
if (!StringUtils.isBlank(row.getFullNbkBatch())) {
PdfPCell compoundId = CellFactory.getCommonCell(row.getCompoundId());
reagentTable.addCell(getStructureCell(compoundId));
}
PdfPTable otherInformation = new PdfPTable(INFO_COLUMN_WIDTH);
PdfPCell chemNameLabel = getInfoCell("Name:");
PdfPCell chemicalName = getInfoCell(row.getChemicalName());
PdfPCell rxnRoleLabel = getInfoCell("Rxn Role:");
PdfPCell rxnRole = getInfoCell(row.getRxnRole());
PdfPCell purityLabel = getInfoCell("Purity:");
PdfPCell stoicPurity = getInfoCell(FormatUtils.formatDecimal(row.getStoicPurity()));
PdfPCell molarityLabel = getInfoCell("Molarity:");
PdfPCell molarity = getInfoCell(FormatUtils.formatDecimal(row.getMolarity(), row.getMolarityUnit()));
PdfPCell hazardLabel = getInfoCell("Hazard:");
PdfPCell hazard = getInfoCell(row.getHazardComments());
PdfPCell commentsLabel = getInfoCell("Comments:");
PdfPCell comments = getInfoCell(row.getComments());
PdfPCell saltCodeLabel = getInfoCell("Salt Code:");
PdfPCell saltCode = getInfoCell(row.getSaltCode());
PdfPCell saltEqLabel = getInfoCell("Salt EQ:");
PdfPCell saltEq = getInfoCell(FormatUtils.formatDecimal(row.getSaltEq()));
otherInformation.addCell(chemNameLabel);
otherInformation.addCell(chemicalName);
otherInformation.addCell(rxnRoleLabel);
otherInformation.addCell(rxnRole);
otherInformation.addCell(purityLabel);
otherInformation.addCell(stoicPurity);
otherInformation.addCell(molarityLabel);
otherInformation.addCell(molarity);
otherInformation.addCell(hazardLabel);
otherInformation.addCell(hazard);
otherInformation.addCell(commentsLabel);
otherInformation.addCell(comments);
otherInformation.addCell(saltCodeLabel);
otherInformation.addCell(saltCode);
otherInformation.addCell(saltEqLabel);
otherInformation.addCell(saltEq);
table.addCell(CellFactory.getCommonCell(reagentTable, CELL_VERTICAL_PADDING));
table.addCell(CellFactory.getCommonCell(FormatUtils.formatDecimal(row.getMolecularWeight())));
table.addCell(CellFactory.getCommonCell(FormatUtils.formatDecimal(row.getWeight(), row.getWeightUnit())));
table.addCell(CellFactory.getCommonCell(FormatUtils.formatDecimal(row.getMoles(), row.getMolesUnit())));
table.addCell(CellFactory.getCommonCell(FormatUtils.formatDecimal(row.getVolume(), row.getVolumeUnit())));
table.addCell(CellFactory.getCommonCell(FormatUtils.formatDecimal(row.getEq())));
table.addCell(CellFactory.getCommonCell(otherInformation, CELL_VERTICAL_PADDING, CELL_HORIZONTAL_PADDING));
}
return table;
}