use of com.lowagie.text.Section in project mdw-designer by CenturyLinkCloud.
the class ExportHelper method printGraphPdf.
private void printGraphPdf(GraphCommon graph, Chapter chapter) throws Exception {
Section section;
String tmp;
if (graph instanceof SubGraph) {
SubGraph subgraph = (SubGraph) graph;
String id = subgraph.getDisplayId(nodeIdType);
if (id == null || id.length() == 0)
id = subgraph.getId().toString();
tmp = "Subprocess " + id + ": \"" + subgraph.getName().replace('\n', ' ') + "\"";
} else {
tmp = "Process Description";
}
Paragraph sTitle = new Paragraph(tmp, sectionFont);
sTitle.setSpacingBefore(10);
section = chapter.addSection(sTitle, options.contains(SECTION_NUMBER) ? 2 : 0);
String summary = (graph instanceof SubGraph) ? ((SubGraph) graph).getProcessVO().getProcessDescription() : ((Graph) graph).getProcessVO().getProcessDescription();
if (summary != null && summary.length() > 0)
printBoldParagraphsPdf(section, summary);
if (options.contains(DOCUMENTATION)) {
String detail = graph.getProcessVO().getAttribute(WorkAttributeConstant.DOCUMENTATION);
if (detail != null && detail.length() > 0) {
printHtmlParagraphsPdf(section, detail, options.contains(SECTION_NUMBER) ? 2 : 0);
}
}
if (options.contains(ATTRIBUTES) && !graph.getProcessVO().getAttributes().isEmpty() && graph instanceof SubGraph) {
printAttributesPdf(section, graph.getProcessVO().getAttributes(), options.contains(SECTION_NUMBER) ? 2 : 0);
}
}
use of com.lowagie.text.Section in project mdw-designer by CenturyLinkCloud.
the class ExportHelper method printAttributesPdf.
private void printAttributesPdf(Section section, List<AttributeVO> attrs, int parentLevel) {
Paragraph sTitle = new Paragraph("Activity Attributes", subSectionFont);
Section subsection = section.addSection(sTitle, parentLevel == 0 ? 0 : (parentLevel + 1));
com.lowagie.text.List list = new com.lowagie.text.List(false, false, 20.0f);
for (AttributeVO attr : attrs) {
if (excludeAttribute(attr.getAttributeName(), attr.getAttributeValue()))
continue;
Phrase phrase = new Phrase();
phrase.add(new Chunk(attr.getAttributeName(), fixedWidthFont));
String v = attr.getAttributeValue();
if (v == null)
v = "";
phrase.add(new Chunk(": " + v, normalFont));
list.add(new ListItem(phrase));
}
subsection.add(list);
}
use of com.lowagie.text.Section in project vcell by virtualcell.
the class ITextWriter method writeMathModel.
public void writeMathModel(MathModel mathModel, FileOutputStream fos, PageFormat pageFormat, PublishPreferences preferences) throws Exception {
if (mathModel == null || fos == null || pageFormat == null || preferences == null) {
throw new IllegalArgumentException("One or more null params while publishing MathModel.");
}
try {
createDocument(pageFormat);
createDocWriter(fos);
// Add metadata before you open the document...
String name = mathModel.getName().trim();
String userName = "Unknown";
if (mathModel.getVersion() != null) {
userName = mathModel.getVersion().getOwner().getName();
}
document.addTitle(name + "[owned by " + userName + "]");
document.addCreator("Virtual Cell");
document.addCreationDate();
// writeWatermark(document, pageFormat);
writeHeaderFooter("MathModel: " + name);
document.open();
//
int chapterNum = 1;
Section introSection = null;
if (preferences.includeMathDesc()) {
MathDescription mathDesc = mathModel.getMathDescription();
Chapter mathDescChapter = new Chapter("Math Description", chapterNum++);
introSection = mathDescChapter.addSection("General Info", mathDescChapter.numberDepth() + 1);
writeMetadata(introSection, name, mathModel.getDescription(), userName, "MathModel");
writeMathDescAsText(mathDescChapter, mathDesc);
document.add(mathDescChapter);
}
if (preferences.includeSim()) {
// unlike biomodels, simulations are chapters, not chapter sections.
Simulation[] sims = mathModel.getSimulations();
if (sims != null) {
Chapter simChapter = new Chapter("Simulations", chapterNum++);
if (introSection == null) {
introSection = simChapter.addSection("General Info", simChapter.numberDepth() + 1);
writeMetadata(introSection, name, mathModel.getDescription(), userName, "MathModel");
}
for (int i = 0; i < sims.length; i++) {
writeSimulation(simChapter, sims[i]);
}
document.add(simChapter);
} else {
System.err.println("Bad Request: No simulations to publish for Mathmodel: " + name);
}
}
if (preferences.includeGeom()) {
// unlike biomodels, geometry is a chapter, not a chapter section.
Geometry geom = mathModel.getMathDescription().getGeometry();
if (geom != null) {
Chapter geomChapter = new Chapter("Geometry", chapterNum++);
if (introSection == null) {
introSection = geomChapter.addSection("General Info", geomChapter.numberDepth() + 1);
writeMetadata(introSection, name, mathModel.getDescription(), userName, "MathModel");
}
writeGeom(geomChapter, geom, null);
document.add(geomChapter);
} else {
System.err.println("Bad Request: No geometry to publish for Mathmodel: " + name);
}
}
document.close();
} catch (DocumentException e) {
System.err.println("Unable to publish MathModel.");
e.printStackTrace();
throw e;
}
}
use of com.lowagie.text.Section in project vcell by virtualcell.
the class ITextWriter method writeGeom.
// Section used can be a chapter or a section of one, based on the document type.
protected void writeGeom(Section container, Geometry geom, GeometryContext geomCont) throws Exception {
try {
Section geomSection = container.addSection("Geometry: " + geom.getName(), container.numberDepth() + 1);
if (geom.getDimension() == 0) {
Paragraph p = new Paragraph(new Phrase("Non spatial geometry."));
p.setAlignment(Paragraph.ALIGN_CENTER);
geomSection.add(p);
return;
}
ByteArrayOutputStream bos = generateGeometryImage(geom);
com.lowagie.text.Image geomImage = com.lowagie.text.Image.getInstance(java.awt.Toolkit.getDefaultToolkit().createImage(bos.toByteArray()), null);
geomImage.setAlignment(Table.ALIGN_LEFT);
geomSection.add(geomImage);
// addImage(geomSection, bos);
Table geomTable = getTable(2, 50, 1, 2, 2);
geomTable.setAlignment(Table.ALIGN_LEFT);
Extent extent = geom.getExtent();
String extentStr = "(" + extent.getX() + ", " + extent.getY() + ", " + extent.getZ() + ")";
Origin origin = geom.getOrigin();
String originStr = "(" + origin.getX() + ", " + origin.getY() + ", " + origin.getZ() + ")";
geomTable.addCell(createCell("Size", getFont()));
geomTable.addCell(createCell(extentStr, getFont()));
geomTable.addCell(createCell("Origin", getFont()));
geomTable.addCell(createCell(originStr, getFont()));
geomSection.add(geomTable);
} catch (Exception e) {
System.err.println("Unable to add geometry image to report.");
e.printStackTrace();
}
}
use of com.lowagie.text.Section in project vcell by virtualcell.
the class ITextWriter method writeStructureMapping.
// boundary types ignored.
protected void writeStructureMapping(Section simContextSection, SimulationContext sc) throws DocumentException {
GeometryContext gc = sc.getGeometryContext();
if (gc == null) {
return;
}
Section structMappSection = null;
/*try {
ByteArrayOutputStream bos = generateStructureMappingImage(sc);
com.lowagie.text.Image structMapImage = com.lowagie.text.Image.getInstance(Toolkit.getDefaultToolkit().createImage(bos.toByteArray()), null);
structMappSection = simContextSection.addSection("Structure Mapping For " + sc.getName(), simContextSection.numberDepth() + 1);
structMappSection.add(structMapImage);
} catch (Exception e) {
System.err.println("Unable to add structure mapping image to report.");
e.printStackTrace();
}*/
StructureMapping[] structMap = gc.getStructureMappings();
Table structMapTable = null;
ModelUnitSystem modelUnitSystem = sc.getModel().getUnitSystem();
for (int i = 0; i < structMap.length; i++) {
if (!(structMap[i] instanceof FeatureMapping)) {
continue;
}
if (i == 0) {
structMapTable = getTable(5, 100, 1, 3, 3);
structMapTable.addCell(createCell("Structure Mapping", getBold(DEF_HEADER_FONT_SIZE), 5, 1, Element.ALIGN_CENTER, true));
structMapTable.addCell(createHeaderCell("Structure", getBold(), 1));
structMapTable.addCell(createHeaderCell("Subdomain", getBold(), 1));
structMapTable.addCell(createHeaderCell("Resolved (T/F)", getBold(), 1));
structMapTable.addCell(createHeaderCell("Surf/Vol", getBold(), 1));
structMapTable.addCell(createHeaderCell("VolFract", getBold(), 1));
structMapTable.endHeaders();
}
String structName = structMap[i].getStructure().getName();
SubVolume subVol = (SubVolume) ((FeatureMapping) structMap[i]).getGeometryClass();
String subDomain = "";
if (subVol != null) {
subDomain = subVol.getName();
}
// ((FeatureMapping)structMap[i]).getResolved();
boolean isResolved = false;
String surfVolStr = "", volFractStr = "";
MembraneMapping mm = (MembraneMapping) gc.getStructureMapping(sc.getModel().getStructureTopology().getParentStructure(structMap[i].getStructure()));
if (mm != null) {
StructureMapping.StructureMappingParameter smp = mm.getSurfaceToVolumeParameter();
if (smp != null) {
Expression tempExp = smp.getExpression();
VCUnitDefinition tempUnit = smp.getUnitDefinition();
if (tempExp != null) {
surfVolStr = tempExp.infix();
if (tempUnit != null && !modelUnitSystem.getInstance_DIMENSIONLESS().compareEqual(tempUnit)) {
// no need to add '1' for dimensionless unit
surfVolStr += " " + tempUnit.getSymbolUnicode();
}
}
}
smp = mm.getVolumeFractionParameter();
if (smp != null) {
Expression tempExp = smp.getExpression();
VCUnitDefinition tempUnit = smp.getUnitDefinition();
if (tempExp != null) {
volFractStr = tempExp.infix();
if (tempUnit != null && !modelUnitSystem.getInstance_DIMENSIONLESS().compareEqual(tempUnit)) {
volFractStr += " " + tempUnit.getSymbolUnicode();
}
}
}
}
structMapTable.addCell(createCell(structName, getFont()));
structMapTable.addCell(createCell(subDomain, getFont()));
structMapTable.addCell(createCell((isResolved ? " T " : " F "), getFont()));
structMapTable.addCell(createCell(surfVolStr, getFont()));
structMapTable.addCell(createCell(volFractStr, getFont()));
}
if (structMapTable != null) {
if (structMappSection == null) {
structMappSection = simContextSection.addSection("Structure Mapping For " + sc.getName(), simContextSection.numberDepth() + 1);
}
structMappSection.add(structMapTable);
}
}
Aggregations