Search in sources :

Example 6 with GeometryContext

use of cbit.vcell.mapping.GeometryContext 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 7 with GeometryContext

use of cbit.vcell.mapping.GeometryContext in project vcell by virtualcell.

the class StructureMappingTableModel method propertyChange.

/**
 * This method gets called when a bound property is changed.
 * @param evt A PropertyChangeEvent object describing the event source
 *   and the property that has changed.
 */
public void propertyChange(java.beans.PropertyChangeEvent evt) {
    if (evt.getSource() == this && evt.getPropertyName().equals(PROPERTY_GEOMETRY_CONTEXT)) {
        GeometryContext oldValue = (GeometryContext) evt.getOldValue();
        if (oldValue != null) {
            oldValue.removePropertyChangeListener(this);
            StructureMapping[] oldStructureMappings = oldValue.getStructureMappings();
            for (int i = 0; i < oldStructureMappings.length; i++) {
                oldStructureMappings[i].removePropertyChangeListener(this);
            }
            SubVolume[] subvols = oldValue.getGeometry().getGeometrySpec().getSubVolumes();
            for (int i = 0; i < subvols.length; i++) {
                subvols[i].removePropertyChangeListener(this);
            }
        }
        GeometryContext newValue = (GeometryContext) evt.getNewValue();
        if (newValue != null) {
            newValue.addPropertyChangeListener(this);
            StructureMapping[] newStructureMappings = newValue.getStructureMappings();
            for (int i = 0; i < newStructureMappings.length; i++) {
                newStructureMappings[i].addPropertyChangeListener(this);
            }
            SubVolume[] subvols = newValue.getGeometry().getGeometrySpec().getSubVolumes();
            for (int i = 0; i < subvols.length; i++) {
                subvols[i].addPropertyChangeListener(this);
            }
        }
        update();
    }
    if (evt.getSource() == getGeometryContext() && evt.getPropertyName().equals(GeometryOwner.PROPERTY_NAME_GEOMETRY)) {
        SubVolume[] subvols = ((Geometry) evt.getOldValue()).getGeometrySpec().getSubVolumes();
        for (int i = 0; i < subvols.length; i++) {
            subvols[i].removePropertyChangeListener(this);
        }
        subvols = ((Geometry) evt.getNewValue()).getGeometrySpec().getSubVolumes();
        for (int i = 0; i < subvols.length; i++) {
            subvols[i].addPropertyChangeListener(this);
        }
        update();
    }
    // subvolume name change
    if (evt.getSource() instanceof SubVolume) {
        update();
    }
    if (evt.getSource() instanceof GeometryContext && evt.getPropertyName().equals(GeometryContext.PROPERTY_STRUCTURE_MAPPINGS)) {
        StructureMapping[] oldStructureMappings = (StructureMapping[]) evt.getOldValue();
        StructureMapping[] newStructureMappings = (StructureMapping[]) evt.getNewValue();
        for (int i = 0; oldStructureMappings != null && i < oldStructureMappings.length; i++) {
            oldStructureMappings[i].removePropertyChangeListener(this);
        }
        for (int i = 0; newStructureMappings != null && i < newStructureMappings.length; i++) {
            newStructureMappings[i].addPropertyChangeListener(this);
        }
        update();
    }
    if (evt.getSource() instanceof StructureMapping) {
        fireTableRowsUpdated(0, getRowCount() - 1);
    }
}
Also used : Geometry(cbit.vcell.geometry.Geometry) SubVolume(cbit.vcell.geometry.SubVolume) GeometryContext(cbit.vcell.mapping.GeometryContext) StructureMapping(cbit.vcell.mapping.StructureMapping)

Example 8 with GeometryContext

use of cbit.vcell.mapping.GeometryContext in project vcell by virtualcell.

the class StructureMappingTableModel method setGeometryContext.

/**
 * Sets the geometryContext property (cbit.vcell.mapping.GeometryContext) value.
 * @param geometryContext The new value for the property.
 * @see #getGeometryContext
 */
public void setGeometryContext(GeometryContext geometryContext) {
    GeometryContext oldValue = fieldGeometryContext;
    fieldGeometryContext = geometryContext;
    firePropertyChange(PROPERTY_GEOMETRY_CONTEXT, oldValue, geometryContext);
}
Also used : GeometryContext(cbit.vcell.mapping.GeometryContext)

Example 9 with GeometryContext

use of cbit.vcell.mapping.GeometryContext in project vcell by virtualcell.

the class ElectricalMembraneMappingTableModel method setGeometryContext.

/**
 * Sets the geometryContext property (cbit.vcell.mapping.GeometryContext) value.
 * @param geometryContext The new value for the property.
 * @see #getGeometryContext
 */
public void setGeometryContext(GeometryContext geometryContext) {
    GeometryContext oldValue = fieldGeometryContext;
    if (oldValue != null) {
        oldValue.removePropertyChangeListener(this);
        StructureMapping[] oldStructureMappings = oldValue.getStructureMappings();
        for (int i = 0; i < oldStructureMappings.length; i++) {
            if (oldStructureMappings[i] instanceof MembraneMapping) {
                oldStructureMappings[i].removePropertyChangeListener(this);
            }
        }
    }
    fieldGeometryContext = geometryContext;
    if (geometryContext != null) {
        geometryContext.addPropertyChangeListener(this);
        StructureMapping[] newStructureMappings = geometryContext.getStructureMappings();
        for (int i = 0; i < newStructureMappings.length; i++) {
            if (newStructureMappings[i] instanceof MembraneMapping) {
                newStructureMappings[i].addPropertyChangeListener(this);
            }
        }
    }
    refreshData();
}
Also used : MembraneMapping(cbit.vcell.mapping.MembraneMapping) GeometryContext(cbit.vcell.mapping.GeometryContext) StructureMapping(cbit.vcell.mapping.StructureMapping)

Example 10 with GeometryContext

use of cbit.vcell.mapping.GeometryContext in project vcell by virtualcell.

the class StructureMappingPanel method setGeometryContext.

/**
 * Sets the geometryContext property (cbit.vcell.mapping.GeometryContext) value.
 * @param geometryContext The new value for the property.
 * @see #getGeometryContext
 */
public void setGeometryContext(GeometryContext geometryContext) {
    GeometryContext oldValue = fieldGeometryContext;
    fieldGeometryContext = geometryContext;
    firePropertyChange(PROPERTY_GEOMETRY_CONTEXT, oldValue, geometryContext);
}
Also used : GeometryContext(cbit.vcell.mapping.GeometryContext)

Aggregations

GeometryContext (cbit.vcell.mapping.GeometryContext)17 StructureMapping (cbit.vcell.mapping.StructureMapping)10 SimulationContext (cbit.vcell.mapping.SimulationContext)8 Geometry (cbit.vcell.geometry.Geometry)6 Structure (cbit.vcell.model.Structure)6 Simulation (cbit.vcell.solver.Simulation)6 BioModel (cbit.vcell.biomodel.BioModel)5 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)5 ReactionStep (cbit.vcell.model.ReactionStep)5 SpeciesContext (cbit.vcell.model.SpeciesContext)5 SubVolume (cbit.vcell.geometry.SubVolume)4 Model (cbit.vcell.model.Model)4 Expression (cbit.vcell.parser.Expression)4 BioEvent (cbit.vcell.mapping.BioEvent)3 FeatureMapping (cbit.vcell.mapping.FeatureMapping)3 UnmappedGeometryClass (cbit.vcell.mapping.GeometryContext.UnmappedGeometryClass)3 MembraneMapping (cbit.vcell.mapping.MembraneMapping)3 MicroscopeMeasurement (cbit.vcell.mapping.MicroscopeMeasurement)3 SpatialObject (cbit.vcell.mapping.spatial.SpatialObject)3 SpatialProcess (cbit.vcell.mapping.spatial.processes.SpatialProcess)3