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);
}
}
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);
}
}
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);
}
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();
}
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);
}
Aggregations