Search in sources :

Example 1 with Section

use of com.lowagie.text.Section in project mdw-designer by CenturyLinkCloud.

the class ExportHelper method printNodePdf.

private void printNodePdf(Node node, Chapter chapter) throws Exception {
    Section section;
    String id = node.getDisplayId(nodeIdType);
    if (id == null || id.length() == 0)
        id = node.getId().toString();
    String tmp = ACTIVITY + id + ": \"" + node.getName().replace('\n', ' ') + "\n";
    Paragraph sTitle = new Paragraph(tmp, sectionFont);
    section = chapter.addSection(sTitle, options.contains(SECTION_NUMBER) ? 2 : 0);
    String summary = node.getAttribute(WorkAttributeConstant.DESCRIPTION);
    if (summary != null && summary.length() > 0) {
        printBoldParagraphsPdf(section, summary);
    }
    if (options.contains(DOCUMENTATION)) {
        String detail = node.getAttribute(WorkAttributeConstant.DOCUMENTATION);
        if (detail != null && detail.length() > 0) {
            printHtmlParagraphsPdf(section, detail, options.contains(SECTION_NUMBER) ? 2 : 0);
            section.add(new Paragraph("\n", FontFactory.getFont(FontFactory.TIMES, 4, Font.NORMAL, new Color(0, 0, 0))));
        }
    }
    if (options.contains(ATTRIBUTES) && !node.getAttributes().isEmpty()) {
        printAttributesPdf(section, node.getAttributes(), options.contains(SECTION_NUMBER) ? 2 : 0);
    }
    section.add(new Paragraph("\n", normalFont));
}
Also used : Color(java.awt.Color) Section(com.lowagie.text.Section) Paragraph(com.lowagie.text.Paragraph)

Example 2 with Section

use of com.lowagie.text.Section in project mdw-designer by CenturyLinkCloud.

the class ExportHelper method printVariablesPdf.

private void printVariablesPdf(Chapter chapter, List<VariableVO> variables, int parentLevel) {
    Paragraph sTitle = new Paragraph("Process Variables", sectionFont);
    Section section = chapter.addSection(sTitle, parentLevel == 0 ? 0 : (parentLevel + 1));
    com.lowagie.text.List list = new com.lowagie.text.List(false, false, 10.0f);
    for (VariableVO var : variables) {
        Phrase phrase = new Phrase();
        phrase.add(new Chunk(var.getVariableName(), fixedWidthFont));
        String v = var.getVariableType();
        if (var.getDescription() != null)
            v += " (" + var.getDescription() + ")";
        phrase.add(new Chunk(": " + v + "\n", normalFont));
        list.add(new ListItem(phrase));
    }
    section.add(list);
}
Also used : VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) 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 3 with Section

use of com.lowagie.text.Section in project vcell by virtualcell.

the class ITextWriter method writeModel.

// model description ignored.
protected void writeModel(Chapter physioChapter, Model model) throws DocumentException {
    Section structSection = null;
    // add structures image
    // if (model.getNumStructures() > 0) {
    // try {
    // ByteArrayOutputStream bos = generateDocStructureImage(model, ITextWriter.LOW_RESOLUTION);
    // structSection = physioChapter.addSection("Structures For: " + model.getName(), physioChapter.numberDepth() + 1);
    // addImage(structSection, bos);
    // } catch(Exception e) {
    // System.err.println("Unable to add structures image for model: " + model.getName());
    // e.printStackTrace();
    // }
    // }
    // write structures
    Table structTable = null;
    for (int i = 0; i < model.getNumStructures(); i++) {
        if (structTable == null) {
            structTable = getTable(4, 100, 1, 3, 3);
            structTable.addCell(createCell("Structures", getBold(DEF_HEADER_FONT_SIZE), 4, 1, Element.ALIGN_CENTER, true));
            structTable.addCell(createHeaderCell("Name", getFont(), 1));
            structTable.addCell(createHeaderCell("Type", getFont(), 1));
            structTable.addCell(createHeaderCell("Inside", getFont(), 1));
            structTable.addCell(createHeaderCell("Outside", getFont(), 1));
            structTable.endHeaders();
        }
        writeStructure(model, model.getStructure(i), structTable);
    }
    // if (structTable != null) {
    // structSection.add(structTable);
    // }
    // write reactions
    writeReactions(physioChapter, model);
}
Also used : Table(com.lowagie.text.Table) Section(com.lowagie.text.Section)

Example 4 with Section

use of com.lowagie.text.Section in project vcell by virtualcell.

the class ITextWriter method writeMembraneMapping.

protected void writeMembraneMapping(Section simContextSection, SimulationContext simContext) throws DocumentException {
    GeometryContext geoContext = simContext.getGeometryContext();
    if (geoContext == null) {
        return;
    }
    Section memMapSection = null;
    Table memMapTable = null;
    StructureMapping[] structMappings = geoContext.getStructureMappings();
    for (int i = 0; i < structMappings.length; i++) {
        MembraneMapping memMapping = null;
        if (structMappings[i] instanceof FeatureMapping) {
            continue;
        } else {
            memMapping = (MembraneMapping) structMappings[i];
        }
        String structName = memMapping.getStructure().getName();
        String initVoltage = "";
        Expression tempExp = memMapping.getInitialVoltageParameter().getExpression();
        VCUnitDefinition tempUnit = memMapping.getInitialVoltageParameter().getUnitDefinition();
        if (tempExp != null) {
            initVoltage = tempExp.infix();
            if (tempUnit != null) {
                initVoltage += "   " + tempUnit.getSymbolUnicode();
            }
        }
        String spCap = "";
        tempExp = memMapping.getSpecificCapacitanceParameter().getExpression();
        tempUnit = memMapping.getSpecificCapacitanceParameter().getUnitDefinition();
        if (tempExp != null) {
            spCap = tempExp.infix();
            if (tempUnit != null) {
                spCap += "   " + tempUnit.getSymbolUnicode();
            }
        }
        if (memMapTable == null) {
            memMapTable = getTable(4, 100, 1, 3, 3);
            memMapTable.addCell(createCell("Electrical Mapping - Membrane Potential", getBold(DEF_HEADER_FONT_SIZE), 4, 1, Element.ALIGN_CENTER, true));
            memMapTable.addCell(createHeaderCell("Membrane", getBold(), 1));
            memMapTable.addCell(createHeaderCell("Calculate V (T/F)", getBold(), 1));
            memMapTable.addCell(createHeaderCell("V initial", getBold(), 1));
            memMapTable.addCell(createHeaderCell("Specific Capacitance", getBold(), 1));
            memMapTable.endHeaders();
        }
        memMapTable.addCell(createCell(structName, getFont()));
        memMapTable.addCell(createCell((memMapping.getCalculateVoltage() ? " T " : " F "), getFont()));
        memMapTable.addCell(createCell(initVoltage, getFont()));
        memMapTable.addCell(createCell(spCap, getFont()));
    }
    if (memMapTable != null) {
        memMapSection = simContextSection.addSection("Membrane Mapping For " + simContext.getName(), simContextSection.numberDepth() + 1);
        memMapSection.add(memMapTable);
    }
    int[] widths = { 1, 1, 1, 5, 8 };
    Table electTable = null;
    ElectricalStimulus[] electricalStimuli = simContext.getElectricalStimuli();
    for (int j = 0; j < electricalStimuli.length; j++) {
        if (j == 0) {
            electTable = getTable(5, 100, 1, 3, 3);
            electTable.addCell(createCell("Electrical Mapping - Electrical Stimulus", getBold(DEF_HEADER_FONT_SIZE), 5, 1, Element.ALIGN_CENTER, true));
            electTable.addCell(createHeaderCell("Stimulus Name", getBold(), 1));
            electTable.addCell(createHeaderCell("Current Name", getBold(), 1));
            electTable.addCell(createHeaderCell("Clamp Type", getBold(), 1));
            electTable.addCell(createHeaderCell("Voltage/Current Density", getBold(), 1));
            electTable.addCell(createHeaderCell("Clamp Device", getBold(), 1));
            electTable.endHeaders();
        }
        String stimName = electricalStimuli[j].getName();
        String currName = "";
        String clampType = "", expStr = "";
        Expression tempExp = null;
        VCUnitDefinition tempUnit = null;
        if (electricalStimuli[j] instanceof CurrentDensityClampStimulus) {
            CurrentDensityClampStimulus stimulus = (CurrentDensityClampStimulus) electricalStimuli[j];
            LocalParameter currentDensityParameter = stimulus.getCurrentDensityParameter();
            tempExp = currentDensityParameter.getExpression();
            tempUnit = currentDensityParameter.getUnitDefinition();
            clampType = "Current Density (deprecated)";
        } else if (electricalStimuli[j] instanceof TotalCurrentClampStimulus) {
            TotalCurrentClampStimulus stimulus = (TotalCurrentClampStimulus) electricalStimuli[j];
            LocalParameter totalCurrentParameter = stimulus.getCurrentParameter();
            tempExp = totalCurrentParameter.getExpression();
            tempUnit = totalCurrentParameter.getUnitDefinition();
            clampType = "Current";
        } else if (electricalStimuli[j] instanceof VoltageClampStimulus) {
            VoltageClampStimulus stimulus = (VoltageClampStimulus) electricalStimuli[j];
            Parameter voltageParameter = stimulus.getVoltageParameter();
            tempExp = voltageParameter.getExpression();
            tempUnit = voltageParameter.getUnitDefinition();
            clampType = "Voltage";
        }
        if (tempExp != null) {
            expStr = tempExp.infix();
            if (tempUnit != null) {
                expStr += "   " + tempUnit.getSymbolUnicode();
            }
        }
        electTable.addCell(createCell(stimName, getFont()));
        electTable.addCell(createCell(currName, getFont()));
        electTable.addCell(createCell(clampType, getFont()));
        electTable.addCell(createCell(expStr, getFont()));
        // add electrode info
        Electrode electrode = electricalStimuli[j].getElectrode();
        if (electrode == null) {
            electTable.addCell(createCell("N/A", getFont()));
        } else {
            Coordinate c = electrode.getPosition();
            String location = c.getX() + ", " + c.getY() + ", " + c.getZ();
            String featureName = electrode.getFeature().getName();
            electTable.addCell(createCell("(" + location + ") in " + featureName, getFont()));
        }
    }
    if (electTable != null) {
        if (memMapSection == null) {
            memMapSection = simContextSection.addSection("Membrane Mapping For " + simContext.getName(), 1);
        }
        electTable.setWidths(widths);
        memMapSection.add(electTable);
    }
    // add temperature
    Table tempTable = getTable(1, 75, 1, 3, 3);
    tempTable.setAlignment(Table.ALIGN_LEFT);
    tempTable.addCell(createCell("Temperature: " + simContext.getTemperatureKelvin() + " K", getFont()));
    if (memMapSection != null) {
        memMapSection.add(tempTable);
    }
}
Also used : MembraneMapping(cbit.vcell.mapping.MembraneMapping) Table(com.lowagie.text.Table) Electrode(cbit.vcell.mapping.Electrode) CurrentDensityClampStimulus(cbit.vcell.mapping.CurrentDensityClampStimulus) Section(com.lowagie.text.Section) StructureMapping(cbit.vcell.mapping.StructureMapping) TotalCurrentClampStimulus(cbit.vcell.mapping.TotalCurrentClampStimulus) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) ElectricalStimulus(cbit.vcell.mapping.ElectricalStimulus) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) FeatureMapping(cbit.vcell.mapping.FeatureMapping) Expression(cbit.vcell.parser.Expression) Coordinate(org.vcell.util.Coordinate) VoltageClampStimulus(cbit.vcell.mapping.VoltageClampStimulus) Parameter(cbit.vcell.model.Parameter) SpeciesContextSpecParameter(cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) GeometryContext(cbit.vcell.mapping.GeometryContext)

Example 5 with Section

use of com.lowagie.text.Section in project vcell by virtualcell.

the class ITextWriter method writeSimulation.

// container can be a chapter or a section of a chapter.
protected void writeSimulation(Section container, Simulation sim) throws DocumentException {
    if (sim == null) {
        return;
    }
    Section simSection = container.addSection(sim.getName(), container.numberDepth() + 1);
    writeMetadata(simSection, sim.getName(), sim.getDescription(), null, "Simulation ");
    // add overriden params
    Table overParamTable = null;
    MathOverrides mo = sim.getMathOverrides();
    if (mo != null) {
        String[] constants = mo.getOverridenConstantNames();
        for (int i = 0; i < constants.length; i++) {
            String actualStr = "", defStr = "";
            Expression tempExp = mo.getDefaultExpression(constants[i]);
            if (tempExp != null) {
                defStr = tempExp.infix();
            }
            if (mo.isScan(constants[i])) {
                actualStr = mo.getConstantArraySpec(constants[i]).toString();
            } else {
                tempExp = mo.getActualExpression(constants[i], 0);
                if (tempExp != null) {
                    actualStr = tempExp.infix();
                }
            }
            if (overParamTable == null) {
                overParamTable = getTable(3, 75, 1, 3, 3);
                overParamTable.setAlignment(Table.ALIGN_LEFT);
                overParamTable.addCell(createCell("Overriden Parameters", getBold(DEF_HEADER_FONT_SIZE), 3, 1, Element.ALIGN_CENTER, true));
                overParamTable.addCell(createHeaderCell("Name", getBold(), 1));
                overParamTable.addCell(createHeaderCell("Actual Value", getBold(), 1));
                overParamTable.addCell(createHeaderCell("Default Value", getBold(), 1));
            }
            overParamTable.addCell(createCell(constants[i], getFont()));
            overParamTable.addCell(createCell(actualStr, getFont()));
            overParamTable.addCell(createCell(defStr, getFont()));
        }
    }
    if (overParamTable != null) {
        simSection.add(overParamTable);
    }
    // add spatial details
    // sim.isSpatial();
    Table meshTable = null;
    MeshSpecification mesh = sim.getMeshSpecification();
    if (mesh != null) {
        Geometry geom = mesh.getGeometry();
        Extent extent = geom.getExtent();
        String extentStr = "(" + extent.getX() + ", " + extent.getY() + ", " + extent.getZ() + ")";
        ISize meshSize = mesh.getSamplingSize();
        String meshSizeStr = "(" + meshSize.getX() + ", " + meshSize.getY() + ", " + meshSize.getZ() + ")";
        meshTable = getTable(2, 75, 1, 3, 3);
        meshTable.setAlignment(Table.ALIGN_LEFT);
        meshTable.addCell(createCell("Geometry Setting", getBold(DEF_HEADER_FONT_SIZE), 2, 1, Element.ALIGN_CENTER, true));
        meshTable.addCell(createCell("Geometry Size (um)", getFont()));
        meshTable.addCell(createCell(extentStr, getFont()));
        meshTable.addCell(createCell("Mesh Size (elements)", getFont()));
        meshTable.addCell(createCell(meshSizeStr, getFont()));
    }
    if (meshTable != null) {
        simSection.add(meshTable);
    }
    // write advanced sim settings
    Table simAdvTable = null;
    SolverTaskDescription solverDesc = sim.getSolverTaskDescription();
    if (solverDesc != null) {
        String solverName = solverDesc.getSolverDescription().getDisplayLabel();
        simAdvTable = getTable(2, 75, 1, 3, 3);
        simAdvTable.setAlignment(Table.ALIGN_LEFT);
        simAdvTable.addCell(createCell("Advanced Settings", getBold(DEF_HEADER_FONT_SIZE), 2, 1, Element.ALIGN_CENTER, true));
        simAdvTable.addCell(createCell("Solver Name", getFont()));
        simAdvTable.addCell(createCell(solverName, getFont()));
        simAdvTable.addCell(createCell("Time Bounds - Starting", getFont()));
        simAdvTable.addCell(createCell("" + solverDesc.getTimeBounds().getStartingTime(), getFont()));
        simAdvTable.addCell(createCell("Time Bounds - Ending", getFont()));
        simAdvTable.addCell(createCell("" + solverDesc.getTimeBounds().getEndingTime(), getFont()));
        simAdvTable.addCell(createCell("Time Step - Min", getFont()));
        simAdvTable.addCell(createCell("" + solverDesc.getTimeStep().getMinimumTimeStep(), getFont()));
        simAdvTable.addCell(createCell("Time Step - Default", getFont()));
        simAdvTable.addCell(createCell("" + solverDesc.getTimeStep().getDefaultTimeStep(), getFont()));
        simAdvTable.addCell(createCell("Time Step - Max", getFont()));
        simAdvTable.addCell(createCell("" + solverDesc.getTimeStep().getMaximumTimeStep(), getFont()));
        ErrorTolerance et = solverDesc.getErrorTolerance();
        if (et != null) {
            simAdvTable.addCell(createCell("Error Tolerance - Absolute", getFont()));
            simAdvTable.addCell(createCell("" + et.getAbsoluteErrorTolerance(), getFont()));
            simAdvTable.addCell(createCell("Error Tolerance - Relative", getFont()));
            simAdvTable.addCell(createCell("" + et.getRelativeErrorTolerance(), getFont()));
        }
        OutputTimeSpec ots = solverDesc.getOutputTimeSpec();
        if (ots.isDefault()) {
            simAdvTable.addCell(createCell("Keep Every", getFont()));
            simAdvTable.addCell(createCell("" + ((DefaultOutputTimeSpec) ots).getKeepEvery(), getFont()));
            simAdvTable.addCell(createCell("Keep At Most", getFont()));
            simAdvTable.addCell(createCell("" + ((DefaultOutputTimeSpec) ots).getKeepAtMost(), getFont()));
        } else if (ots.isUniform()) {
            simAdvTable.addCell(createCell("Output Time Step", getFont()));
            simAdvTable.addCell(createCell("" + ((UniformOutputTimeSpec) ots).getOutputTimeStep(), getFont()));
        } else if (ots.isExplicit()) {
            simAdvTable.addCell(createCell("Output Time Points", getFont()));
            simAdvTable.addCell(createCell("" + ((ExplicitOutputTimeSpec) ots).toCommaSeperatedOneLineOfString(), getFont()));
        }
        simAdvTable.addCell(createCell("Use Symbolic Jacobian (T/F)", getFont()));
        simAdvTable.addCell(createCell((solverDesc.getUseSymbolicJacobian() ? " T " : " F "), getFont()));
        Constant sp = solverDesc.getSensitivityParameter();
        if (sp != null) {
            simAdvTable.addCell(createCell("Sensitivity Analysis Param", getFont()));
            simAdvTable.addCell(createCell(sp.getName(), getFont()));
        }
    }
    if (simAdvTable != null) {
        simSection.add(simAdvTable);
    }
}
Also used : Table(com.lowagie.text.Table) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) Extent(org.vcell.util.Extent) ISize(org.vcell.util.ISize) Constant(cbit.vcell.math.Constant) Section(com.lowagie.text.Section) MeshSpecification(cbit.vcell.solver.MeshSpecification) Geometry(cbit.vcell.geometry.Geometry) MathOverrides(cbit.vcell.solver.MathOverrides) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec) ExplicitOutputTimeSpec(cbit.vcell.solver.ExplicitOutputTimeSpec) OutputTimeSpec(cbit.vcell.solver.OutputTimeSpec) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) Expression(cbit.vcell.parser.Expression) ErrorTolerance(cbit.vcell.solver.ErrorTolerance) SolverTaskDescription(cbit.vcell.solver.SolverTaskDescription)

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