Search in sources :

Example 6 with SurfaceKinematics

use of cbit.vcell.mapping.spatial.processes.SurfaceKinematics in project vcell by virtualcell.

the class XmlReader method getSpatialProcesses.

public SpatialProcess[] getSpatialProcesses(SimulationContext simContext, Element spatialProcessesElement) throws XmlParseException {
    Iterator<Element> spatialProcessElementIterator = spatialProcessesElement.getChildren(XMLTags.SpatialProcessTag, vcNamespace).iterator();
    ArrayList<SpatialProcess> spatialProcessList = new ArrayList<SpatialProcess>();
    while (spatialProcessElementIterator.hasNext()) {
        Element spatialProcessElement = (Element) spatialProcessElementIterator.next();
        SpatialProcess spatialProcess = null;
        String name = unMangle(spatialProcessElement.getAttributeValue(XMLTags.NameAttrTag));
        String type = unMangle(spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessTypeAttrTag));
        if (type.equals(XMLTags.SpatialProcessTypeAttrValue_PointKinematics)) {
            PointKinematics pointKinematics = new PointKinematics(name, simContext);
            String pointObjectName = spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessPointObjectAttrTag);
            PointObject pointObject = (PointObject) simContext.getSpatialObject(pointObjectName);
            pointKinematics.setPointObject(pointObject);
            spatialProcess = pointKinematics;
        } else if (type.equals(XMLTags.SpatialProcessTypeAttrValue_PointLocation)) {
            PointLocation pointLocation = new PointLocation(name, simContext);
            String pointObjectName = spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessPointObjectAttrTag);
            PointObject pointObject = (PointObject) simContext.getSpatialObject(pointObjectName);
            pointLocation.setPointObject(pointObject);
            spatialProcess = pointLocation;
        } else if (type.equals(XMLTags.SpatialProcessTypeAttrValue_SurfaceKinematics)) {
            SurfaceKinematics surfaceKinematics = new SurfaceKinematics(name, simContext);
            String surfaceRegionObjectName = spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessSurfaceObjectAttrTag);
            SurfaceRegionObject surfaceRegionObject = (SurfaceRegionObject) simContext.getSpatialObject(surfaceRegionObjectName);
            surfaceKinematics.setSurfaceRegionObject(surfaceRegionObject);
            spatialProcess = surfaceKinematics;
        } else if (type.equals(XMLTags.SpatialProcessTypeAttrValue_VolumeKinematics)) {
            VolumeKinematics volumeKinematics = new VolumeKinematics(name, simContext);
            String volumeRegionObjectName = spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessVolumeObjectAttrTag);
            VolumeRegionObject volumeRegionObject = (VolumeRegionObject) simContext.getSpatialObject(volumeRegionObjectName);
            volumeKinematics.setVolumeRegionObject(volumeRegionObject);
            spatialProcess = volumeKinematics;
        }
        // set parameters
        Iterator<Element> paramElementIter = spatialProcessElement.getChildren(XMLTags.ParameterTag, vcNamespace).iterator();
        ArrayList<LocalParameter> parameters = new ArrayList<LocalParameter>();
        while (paramElementIter.hasNext()) {
            Element paramElement = paramElementIter.next();
            // Get parameter attributes
            String paramName = paramElement.getAttributeValue(XMLTags.NameAttrTag);
            Expression exp = unMangleExpression(paramElement.getText());
            String roleStr = paramElement.getAttributeValue(XMLTags.ParamRoleAttrTag);
            SpatialProcessParameterType parameterType = SpatialProcessParameterType.fromRoleXmlName(roleStr);
            VCUnitDefinition unit = simContext.getModel().getUnitSystem().getInstance_TBD();
            String unitSymbol = paramElement.getAttributeValue(XMLTags.VCUnitDefinitionAttrTag);
            if (unitSymbol != null) {
                unit = simContext.getModel().getUnitSystem().getInstance(unitSymbol);
            }
            parameters.add(spatialProcess.createNewParameter(paramName, parameterType, exp, unit));
        }
        try {
            spatialProcess.setParameters(parameters.toArray(new LocalParameter[0]));
        } catch (PropertyVetoException | ExpressionBindingException e) {
            e.printStackTrace();
            throw new XmlParseException("failed to read parameters in bioEvent " + name + ": " + e.getMessage(), e);
        }
        spatialProcessList.add(spatialProcess);
    }
    return spatialProcessList.toArray(new SpatialProcess[0]);
}
Also used : VolumeRegionObject(cbit.vcell.mapping.spatial.VolumeRegionObject) PointLocation(cbit.vcell.mapping.spatial.processes.PointLocation) SurfaceKinematics(cbit.vcell.mapping.spatial.processes.SurfaceKinematics) VolumeKinematics(cbit.vcell.mapping.spatial.processes.VolumeKinematics) Element(org.jdom.Element) ArrayList(java.util.ArrayList) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) PropertyVetoException(java.beans.PropertyVetoException) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) PointObject(cbit.vcell.mapping.spatial.PointObject) Expression(cbit.vcell.parser.Expression) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) PointKinematics(cbit.vcell.mapping.spatial.processes.PointKinematics) SpatialProcessParameterType(cbit.vcell.mapping.spatial.processes.SpatialProcess.SpatialProcessParameterType) SurfaceRegionObject(cbit.vcell.mapping.spatial.SurfaceRegionObject)

Aggregations

SurfaceKinematics (cbit.vcell.mapping.spatial.processes.SurfaceKinematics)6 PointKinematics (cbit.vcell.mapping.spatial.processes.PointKinematics)5 PointLocation (cbit.vcell.mapping.spatial.processes.PointLocation)5 SpatialProcess (cbit.vcell.mapping.spatial.processes.SpatialProcess)5 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)3 PointObject (cbit.vcell.mapping.spatial.PointObject)3 SurfaceRegionObject (cbit.vcell.mapping.spatial.SurfaceRegionObject)3 VolumeRegionObject (cbit.vcell.mapping.spatial.VolumeRegionObject)3 VolumeKinematics (cbit.vcell.mapping.spatial.processes.VolumeKinematics)3 SpatialObjectTableModel (cbit.vcell.client.desktop.biomodel.SpatialObjectTableModel)2 SpatialProcessTableModel (cbit.vcell.client.desktop.biomodel.SpatialProcessTableModel)2 SpatialObject (cbit.vcell.mapping.spatial.SpatialObject)2 Expression (cbit.vcell.parser.Expression)2 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)2 PropertyVetoException (java.beans.PropertyVetoException)2 ArrayList (java.util.ArrayList)2 Icon (javax.swing.Icon)2 Element (org.jdom.Element)2 ModelProcessEquation (cbit.gui.ModelProcessEquation)1 BioModelEditorApplicationsTableModel (cbit.vcell.client.desktop.biomodel.BioModelEditorApplicationsTableModel)1