use of cbit.vcell.geometry.GeometryClass in project vcell by virtualcell.
the class Xmlproducer method getXML.
/**
* This method returns a XML representation of a MembraneMapping.
* Creation date: (3/1/2001 8:48:14 PM)
* @return Element
* @param param cbit.vcell.mapping.MembraneMapping
*/
private Element getXML(MembraneMapping param) {
// Allow 'null' subvolumes
// if (param.getSubVolume() == null) {
// return null;
// }
Element membrane = new Element(XMLTags.MembraneMappingTag);
// Add atributes
membrane.setAttribute(XMLTags.MembraneAttrTag, mangle(param.getMembrane().getName()));
// SurfaceToVolumeRatio if it exsits, amended Sept. 27th, 2007
if (param.getSurfaceToVolumeParameter().getExpression() != null) {
membrane.setAttribute(XMLTags.SurfaceToVolumeRatioTag, mangleExpression(param.getSurfaceToVolumeParameter().getExpression()));
}
// VolumeFraction if it exsits, amended Sept. 27th, 2007
if (param.getVolumeFractionParameter().getExpression() != null) {
membrane.setAttribute(XMLTags.VolumeFractionTag, mangleExpression(param.getVolumeFractionParameter().getExpression()));
}
// Add size
if (param.getSizeParameter().getExpression() != null) {
membrane.setAttribute(XMLTags.SizeTag, mangleExpression(param.getSizeParameter().getExpression()));
}
// Add area/unit_area and area/unit_vol if they exist
if (param.getAreaPerUnitAreaParameter().getExpression() != null) {
membrane.setAttribute(XMLTags.AreaPerUnitAreaTag, mangleExpression(param.getAreaPerUnitAreaParameter().getExpression()));
}
if (param.getAreaPerUnitVolumeParameter().getExpression() != null) {
membrane.setAttribute(XMLTags.AreaPerUnitVolumeTag, mangleExpression(param.getAreaPerUnitVolumeParameter().getExpression()));
}
// Add the electrical properties
membrane.setAttribute(XMLTags.CalculateVoltageTag, String.valueOf(param.getCalculateVoltage()));
membrane.setAttribute(XMLTags.SpecificCapacitanceTag, mangleExpression(param.getSpecificCapacitanceParameter().getExpression()));
membrane.setAttribute(XMLTags.InitialVoltageTag, mangleExpression(param.getInitialVoltageParameter().getExpression()));
GeometryClass geometryClass = param.getGeometryClass();
if (geometryClass != null) {
membrane.setAttribute(XMLTags.GeometryClassAttrTag, mangle(geometryClass.getName()));
}
return membrane;
}
use of cbit.vcell.geometry.GeometryClass in project vcell by virtualcell.
the class XmlReader method getMembraneMapping.
/**
* This method retuns a MembraneMapping object from a XML representation.
* Creation date: (5/7/2001 4:12:03 PM)
* @return cbit.vcell.mapping.MembraneMapping
* @param param org.jdom.Element
*/
private MembraneMapping getMembraneMapping(Element param, SimulationContext simulationContext) throws XmlParseException {
// Retrieve attributes
String membranename = unMangle(param.getAttributeValue(XMLTags.MembraneAttrTag));
Membrane membraneref = (Membrane) simulationContext.getModel().getStructure(membranename);
if (membraneref == null) {
throw new XmlParseException("The Membrane " + membranename + " could not be resolved!");
}
// *** Create new Membrane Mapping ****
MembraneMapping memmap = new MembraneMapping(membraneref, simulationContext, simulationContext.getModel().getUnitSystem());
// Set SurfacetoVolumeRatio when it exists, amended Sept. 27th, 2007
if (param.getAttributeValue(XMLTags.SurfaceToVolumeRatioTag) != null) {
String ratio = unMangle(param.getAttributeValue(XMLTags.SurfaceToVolumeRatioTag));
try {
memmap.getSurfaceToVolumeParameter().setExpression(unMangleExpression(ratio));
} catch (ExpressionException e) {
e.printStackTrace(System.out);
throw new XmlParseException("An expressionException was fired when setting the SurfacetoVolumeRatio Expression " + ratio + " to a membraneMapping!", e);
}
}
// Set VolumeFraction when it exists, amended Sept. 27th, 2007
if (param.getAttributeValue(XMLTags.VolumeFractionTag) != null) {
String fraction = unMangle(param.getAttributeValue(XMLTags.VolumeFractionTag));
try {
memmap.getVolumeFractionParameter().setExpression(unMangleExpression(fraction));
} catch (ExpressionException e) {
e.printStackTrace(System.out);
throw new XmlParseException("An expressionException was fired when setting the VolumeFraction Expression " + fraction + " to a membraneMapping!", e);
}
}
// Set Area/unit_area if it exists, amended Sept. 27th, 2007
if (param.getAttributeValue(XMLTags.AreaPerUnitAreaTag) != null) {
String ratio = unMangle(param.getAttributeValue(XMLTags.AreaPerUnitAreaTag));
try {
memmap.getAreaPerUnitAreaParameter().setExpression(unMangleExpression(ratio));
} catch (ExpressionException e) {
e.printStackTrace(System.out);
throw new XmlParseException("An expressionException was fired when setting the AreaPerUnitArea Expression " + ratio + " to a membraneMapping!", e);
}
}
// Set SurfacetoVolumeRatio when it exists, amended Sept. 27th, 2007
if (param.getAttributeValue(XMLTags.AreaPerUnitVolumeTag) != null) {
String ratio = unMangle(param.getAttributeValue(XMLTags.AreaPerUnitVolumeTag));
try {
memmap.getAreaPerUnitVolumeParameter().setExpression(unMangleExpression(ratio));
} catch (ExpressionException e) {
e.printStackTrace(System.out);
throw new XmlParseException("An expressionException was fired when setting the AreaPerUnitVolume Expression " + ratio + " to a membraneMapping!", e);
}
}
// Set Size
if (param.getAttributeValue(XMLTags.SizeTag) != null) {
String size = unMangle(param.getAttributeValue(XMLTags.SizeTag));
try {
memmap.getSizeParameter().setExpression(unMangleExpression(size));
} catch (ExpressionException e) {
e.printStackTrace(System.out);
throw new XmlParseException("An expressionException was fired when setting the size Expression " + size + " to a membraneMapping!", e);
}
} else {
try {
memmap.getSizeParameter().setExpression(null);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("unexpected exception while setting structure size", e);
}
}
// ** Set electrical properties **
// set specific capacitance
double specificCap = Double.parseDouble(param.getAttributeValue(XMLTags.SpecificCapacitanceTag));
try {
memmap.getSpecificCapacitanceParameter().setExpression(new Expression(specificCap));
} catch (ExpressionException e) {
e.printStackTrace(System.out);
throw new XmlParseException(e);
}
// set flag calculate voltage
boolean calculateVolt = (Boolean.valueOf(param.getAttributeValue(XMLTags.CalculateVoltageTag))).booleanValue();
memmap.setCalculateVoltage(calculateVolt);
// set initial Voltage
String initialVoltString = param.getAttributeValue(XMLTags.InitialVoltageTag);
try {
Expression initialExpr = unMangleExpression(initialVoltString);
memmap.getInitialVoltageParameter().setExpression(initialExpr);
} catch (ExpressionException e) {
e.printStackTrace(System.out);
throw new XmlParseException(e);
}
String geometryClassName = param.getAttributeValue(XMLTags.GeometryClassAttrTag);
if (geometryClassName != null) {
geometryClassName = unMangle(geometryClassName);
}
// Retrieve subvolumeref, allow subvolumes to be 'null'
if (geometryClassName != null) {
GeometryClass[] geometryClasses = simulationContext.getGeometry().getGeometryClasses();
for (int i = 0; i < geometryClasses.length; i++) {
if (geometryClasses[i].getName().equals(geometryClassName)) {
try {
memmap.setGeometryClass(geometryClasses[i]);
} catch (PropertyVetoException e) {
e.printStackTrace();
throw new XmlParseException("A propertyVetoException was fired when trying to set the subvolume or surface " + geometryClassName + " to a MembraneMapping!", e);
}
}
}
}
return memmap;
}
use of cbit.vcell.geometry.GeometryClass in project vcell by virtualcell.
the class Xmlproducer method getXML.
/**
* This method returns a XML representation of a featureMapping object.
* Creation date: (3/1/2001 8:16:57 PM)
* @return Element
* @param param cbit.vcell.mapping.FeatureMapping
*/
private Element getXML(FeatureMapping param) {
// Allow null subvolumes
// if (param.getSubVolume()==null) { //5/92001
// return null;
// }
Element feature = new Element(XMLTags.FeatureMappingTag);
// Add atributes
feature.setAttribute(XMLTags.FeatureAttrTag, mangle(param.getFeature().getName()));
GeometryClass geometryClass = param.getGeometryClass();
if (geometryClass != null) {
feature.setAttribute(XMLTags.GeometryClassAttrTag, Xmlproducer.mangle(geometryClass.getName()));
if (geometryClass instanceof SubVolume) {
feature.setAttribute(XMLTags.SubVolumeAttrTag, Xmlproducer.mangle(geometryClass.getName()));
}
}
// Add size
if (param.getSizeParameter().getExpression() != null)
feature.setAttribute(XMLTags.SizeTag, mangleExpression(param.getSizeParameter().getExpression()));
// Add volume/unit_Area and volume/unit_vol if they exist
if (param.getVolumePerUnitAreaParameter().getExpression() != null) {
feature.setAttribute(XMLTags.VolumePerUnitAreaTag, mangleExpression(param.getVolumePerUnitAreaParameter().getExpression()));
}
if (param.getVolumePerUnitVolumeParameter().getExpression() != null) {
feature.setAttribute(XMLTags.VolumePerUnitVolumeTag, mangleExpression(param.getVolumePerUnitVolumeParameter().getExpression()));
}
// write BoundariesyConditions
Element boundariestypes = new Element(XMLTags.BoundariesTypesTag);
// Xm
boundariestypes.setAttribute(XMLTags.BoundaryAttrValueXm, param.getBoundaryConditionTypeXm().boundaryTypeStringValue());
// Xp
boundariestypes.setAttribute(XMLTags.BoundaryAttrValueXp, param.getBoundaryConditionTypeXp().boundaryTypeStringValue());
// Ym
boundariestypes.setAttribute(XMLTags.BoundaryAttrValueYm, param.getBoundaryConditionTypeYm().boundaryTypeStringValue());
// Yp
boundariestypes.setAttribute(XMLTags.BoundaryAttrValueYp, param.getBoundaryConditionTypeYp().boundaryTypeStringValue());
// Zm
boundariestypes.setAttribute(XMLTags.BoundaryAttrValueZm, param.getBoundaryConditionTypeZm().boundaryTypeStringValue());
// Zp
boundariestypes.setAttribute(XMLTags.BoundaryAttrValueZp, param.getBoundaryConditionTypeZp().boundaryTypeStringValue());
// add boundaries to the feature
feature.addContent(boundariestypes);
return feature;
}
use of cbit.vcell.geometry.GeometryClass in project vcell by virtualcell.
the class OutputFunctionsPanel method addFunction.
private void addFunction() throws Exception {
String funcName = getFunctionNameTextField().getText();
Expression funcExp = null;
funcExp = new Expression(getFunctionExpressionTextField().getText());
Domain domain = null;
VariableType newFunctionVariableType = null;
boolean bSpatial = simulationWorkspace.getSimulationOwner().getGeometry().getDimension() > 0;
if (bSpatial) {
Object selectedItem = getSubdomainComboBox().getSelectedItem();
if (selectedItem instanceof GeometryClass) {
GeometryClass geoClass = (GeometryClass) selectedItem;
domain = new Domain(geoClass);
if (selectedItem instanceof SubVolume) {
newFunctionVariableType = VariableType.VOLUME;
} else if (selectedItem instanceof SurfaceClass) {
newFunctionVariableType = VariableType.MEMBRANE;
}
} else if (selectedItem instanceof VariableType) {
newFunctionVariableType = (VariableType) selectedItem;
} else {
newFunctionVariableType = VariableType.UNKNOWN;
}
} else {
newFunctionVariableType = VariableType.NONSPATIAL;
}
AnnotatedFunction tempFunction = new AnnotatedFunction(funcName, funcExp, domain, null, newFunctionVariableType, FunctionCategory.OUTPUTFUNCTION);
VariableType vt = outputFunctionContext.computeFunctionTypeWRTExpression(tempFunction, funcExp);
FunctionCategory category = FunctionCategory.OUTPUTFUNCTION;
if (vt.equals(VariableType.POSTPROCESSING)) {
category = FunctionCategory.POSTPROCESSFUNCTION;
}
AnnotatedFunction newFunction = new AnnotatedFunction(funcName, funcExp, domain, null, vt, category);
outputFunctionContext.addOutputFunction(newFunction);
setSelectedObjects(new Object[] { newFunction });
enableDeleteFnButton();
}
use of cbit.vcell.geometry.GeometryClass in project vcell by virtualcell.
the class OutputFunctionsPanel method getSubdomainComboBox.
private JComboBox getSubdomainComboBox() {
if (subdomainComboBox == null) {
try {
subdomainComboBox = new JComboBox();
subdomainComboBox.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof GeometryClass) {
setText(((GeometryClass) value).getName());
} else if (value instanceof VariableType) {
setText(((VariableType) value).getTypeName());
}
return this;
}
});
} catch (java.lang.Throwable e) {
e.printStackTrace(System.out);
}
}
return subdomainComboBox;
}
Aggregations