Search in sources :

Example 16 with Section

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);
    }
}
Also used : Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Section(com.lowagie.text.Section) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Paragraph(com.lowagie.text.Paragraph)

Example 17 with Section

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);
}
Also used : AttributeVO(com.centurylink.mdw.model.value.attribute.AttributeVO) List(java.util.List) ArrayList(java.util.ArrayList) Phrase(com.lowagie.text.Phrase) ListItem(com.lowagie.text.ListItem) Chunk(com.lowagie.text.Chunk) Section(com.lowagie.text.Section) Paragraph(com.lowagie.text.Paragraph)

Example 18 with Section

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;
    }
}
Also used : Geometry(cbit.vcell.geometry.Geometry) Simulation(cbit.vcell.solver.Simulation) MathDescription(cbit.vcell.math.MathDescription) DocumentException(com.lowagie.text.DocumentException) Chapter(com.lowagie.text.Chapter) Section(com.lowagie.text.Section)

Example 19 with Section

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();
    }
}
Also used : Origin(org.vcell.util.Origin) Table(com.lowagie.text.Table) Extent(org.vcell.util.Extent) Phrase(com.lowagie.text.Phrase) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SimulationContext(cbit.vcell.mapping.SimulationContext) GeometryContext(cbit.vcell.mapping.GeometryContext) ReactionContext(cbit.vcell.mapping.ReactionContext) Section(com.lowagie.text.Section) DocumentException(com.lowagie.text.DocumentException) ExpressionException(cbit.vcell.parser.ExpressionException) Paragraph(com.lowagie.text.Paragraph)

Example 20 with Section

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);
    }
}
Also used : MembraneMapping(cbit.vcell.mapping.MembraneMapping) Table(com.lowagie.text.Table) Section(com.lowagie.text.Section) StructureMapping(cbit.vcell.mapping.StructureMapping) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) FeatureMapping(cbit.vcell.mapping.FeatureMapping) Expression(cbit.vcell.parser.Expression) SubVolume(cbit.vcell.geometry.SubVolume) GeometryContext(cbit.vcell.mapping.GeometryContext) ModelUnitSystem(cbit.vcell.model.ModelUnitSystem)

Aggregations

Section (com.lowagie.text.Section)20 Table (com.lowagie.text.Table)9 DocumentException (com.lowagie.text.DocumentException)7 Paragraph (com.lowagie.text.Paragraph)7 Expression (cbit.vcell.parser.Expression)6 GeometryContext (cbit.vcell.mapping.GeometryContext)5 ReactionContext (cbit.vcell.mapping.ReactionContext)4 SimulationContext (cbit.vcell.mapping.SimulationContext)4 ExpressionException (cbit.vcell.parser.ExpressionException)4 Chunk (com.lowagie.text.Chunk)4 ArrayList (java.util.ArrayList)4 Constant (cbit.vcell.math.Constant)3 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)3 Chapter (com.lowagie.text.Chapter)3 Geometry (cbit.vcell.geometry.Geometry)2 FeatureMapping (cbit.vcell.mapping.FeatureMapping)2 MembraneMapping (cbit.vcell.mapping.MembraneMapping)2 SpeciesContextSpecParameter (cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter)2 StructureMapping (cbit.vcell.mapping.StructureMapping)2 CompartmentSubDomain (cbit.vcell.math.CompartmentSubDomain)2