Search in sources :

Example 6 with ConstantArraySpec

use of cbit.vcell.solver.ConstantArraySpec in project vcell by virtualcell.

the class XmlReader method getMathOverrides.

/**
 * This method returns a MathOverrides object from a XML Element.
 * Creation date: (5/21/2001 3:05:17 PM)
 * @return cbit.vcell.solver.MathOverrides
 * @param param org.jdom.Element
 */
private MathOverrides getMathOverrides(Element param, Simulation simulation) throws XmlParseException {
    MathOverrides mathOverrides = null;
    try {
        // Get the constants
        Object[] elements = param.getChildren().toArray();
        Vector<ConstantArraySpec> v1 = new Vector<ConstantArraySpec>();
        Vector<Constant> v2 = new Vector<Constant>();
        for (int i = 0; i < elements.length; i++) {
            Element e = (Element) elements[i];
            Attribute array = e.getAttribute(XMLTags.ConstantArraySpec);
            if (array != null) {
                // collect scan overrides
                String name = e.getAttributeValue(XMLTags.NameAttrTag);
                int type = array.getIntValue();
                v1.add(ConstantArraySpec.createFromString(name, e.getText(), type));
            } else {
                // collect regular overrides
                v2.add(getConstant(e));
            }
        }
        Constant[] constants = (Constant[]) BeanUtils.getArray(v2, Constant.class);
        ConstantArraySpec[] specs = (ConstantArraySpec[]) BeanUtils.getArray(v1, ConstantArraySpec.class);
        // create new MathOverrides object
        mathOverrides = new MathOverrides(simulation, constants, specs);
    } catch (ExpressionException e) {
        e.printStackTrace();
        throw new XmlParseException("A ExpressionException was fired when adding a Constant to the MathOverrides", e);
    } catch (DataConversionException e2) {
        e2.printStackTrace();
        throw new XmlParseException("A DataConversionException occured when reading a ConstantArraySpec type", e2);
    }
    return mathOverrides;
}
Also used : Attribute(org.jdom.Attribute) MacroscopicRateConstant(cbit.vcell.math.MacroscopicRateConstant) Constant(cbit.vcell.math.Constant) Element(org.jdom.Element) ConstantArraySpec(cbit.vcell.solver.ConstantArraySpec) ExpressionException(cbit.vcell.parser.ExpressionException) MathOverrides(cbit.vcell.solver.MathOverrides) VolumeRegionObject(cbit.vcell.mapping.spatial.VolumeRegionObject) PointObject(cbit.vcell.mapping.spatial.PointObject) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) SurfaceRegionObject(cbit.vcell.mapping.spatial.SurfaceRegionObject) CSGObject(cbit.vcell.geometry.CSGObject) DataConversionException(org.jdom.DataConversionException) Vector(java.util.Vector)

Aggregations

ConstantArraySpec (cbit.vcell.solver.ConstantArraySpec)6 Constant (cbit.vcell.math.Constant)3 Expression (cbit.vcell.parser.Expression)3 ExpressionException (cbit.vcell.parser.ExpressionException)2 MathOverrides (cbit.vcell.solver.MathOverrides)2 ScopedExpression (cbit.gui.ScopedExpression)1 BioModel (cbit.vcell.biomodel.BioModel)1 ParameterScanPanel (cbit.vcell.client.desktop.simulation.ParameterScanPanel)1 CSGObject (cbit.vcell.geometry.CSGObject)1 MathMapping (cbit.vcell.mapping.MathMapping)1 MathSymbolMapping (cbit.vcell.mapping.MathSymbolMapping)1 SimulationContext (cbit.vcell.mapping.SimulationContext)1 SpeciesContextSpecParameter (cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter)1 StructureMapping (cbit.vcell.mapping.StructureMapping)1 StructureMappingParameter (cbit.vcell.mapping.StructureMapping.StructureMappingParameter)1 PointObject (cbit.vcell.mapping.spatial.PointObject)1 SpatialObject (cbit.vcell.mapping.spatial.SpatialObject)1 SurfaceRegionObject (cbit.vcell.mapping.spatial.SurfaceRegionObject)1 VolumeRegionObject (cbit.vcell.mapping.spatial.VolumeRegionObject)1 Function (cbit.vcell.math.Function)1