Search in sources :

Example 36 with GeometryClass

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;
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) Element(org.jdom.Element)

Example 37 with GeometryClass

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;
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) MembraneMapping(cbit.vcell.mapping.MembraneMapping) ExpressionException(cbit.vcell.parser.ExpressionException) GeometryException(cbit.vcell.geometry.GeometryException) MathFormatException(cbit.vcell.math.MathFormatException) MappingException(cbit.vcell.mapping.MappingException) PropertyVetoException(java.beans.PropertyVetoException) ImageException(cbit.image.ImageException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) ModelException(cbit.vcell.model.ModelException) DataConversionException(org.jdom.DataConversionException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) PropertyVetoException(java.beans.PropertyVetoException) Expression(cbit.vcell.parser.Expression) Membrane(cbit.vcell.model.Membrane)

Example 38 with GeometryClass

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;
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) SubVolume(cbit.vcell.geometry.SubVolume) CompartmentSubVolume(cbit.vcell.geometry.CompartmentSubVolume) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume) Element(org.jdom.Element)

Example 39 with GeometryClass

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();
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) VariableType(cbit.vcell.math.VariableType) Expression(cbit.vcell.parser.Expression) SurfaceClass(cbit.vcell.geometry.SurfaceClass) SubVolume(cbit.vcell.geometry.SubVolume) Domain(cbit.vcell.math.Variable.Domain) FunctionCategory(cbit.vcell.solver.AnnotatedFunction.FunctionCategory) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Example 40 with GeometryClass

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;
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) JComboBox(javax.swing.JComboBox) VariableType(cbit.vcell.math.VariableType) DefaultListCellRenderer(javax.swing.DefaultListCellRenderer) Component(java.awt.Component) JList(javax.swing.JList)

Aggregations

GeometryClass (cbit.vcell.geometry.GeometryClass)43 SubVolume (cbit.vcell.geometry.SubVolume)21 SurfaceClass (cbit.vcell.geometry.SurfaceClass)19 Expression (cbit.vcell.parser.Expression)18 ExpressionException (cbit.vcell.parser.ExpressionException)14 PropertyVetoException (java.beans.PropertyVetoException)13 Structure (cbit.vcell.model.Structure)12 StructureMapping (cbit.vcell.mapping.StructureMapping)8 MathDescription (cbit.vcell.math.MathDescription)7 MathException (cbit.vcell.math.MathException)7 Variable (cbit.vcell.math.Variable)7 SpeciesContext (cbit.vcell.model.SpeciesContext)7 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)7 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)7 MappingException (cbit.vcell.mapping.MappingException)6 Domain (cbit.vcell.math.Variable.Domain)6 ModelException (cbit.vcell.model.ModelException)6 Parameter (cbit.vcell.model.Parameter)6 ArrayList (java.util.ArrayList)6 Geometry (cbit.vcell.geometry.Geometry)5