Search in sources :

Example 1 with AssignmentRule

use of cbit.vcell.mapping.AssignmentRule in project vcell by virtualcell.

the class XmlReader method getSimulationContext.

/**
 * This method returns a SimulationContext from a XML representation.
 * Creation date: (4/2/2001 3:19:01 PM)
 * @return cbit.vcell.mapping.SimulationContext
 * @param param org.jdom.Element
 */
private SimulationContext getSimulationContext(Element param, BioModel biomodel) throws XmlParseException {
    // get the attributes
    // name
    String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    boolean bStoch = false;
    boolean bRuleBased = false;
    boolean bUseConcentration = true;
    boolean bRandomizeInitCondition = false;
    boolean bInsufficientIterations = false;
    boolean bInsufficientMaxMolecules = false;
    // default is true for now
    boolean bMassConservationModelReduction = true;
    NetworkConstraints nc = null;
    Element ncElement = param.getChild(XMLTags.RbmNetworkConstraintsTag, vcNamespace);
    if (ncElement != null) {
        // one network constraint element
        nc = getAppNetworkConstraints(ncElement, biomodel.getModel());
    } else {
        if (legacyNetworkConstraints != null) {
            nc = legacyNetworkConstraints;
        }
    }
    if ((param.getAttributeValue(XMLTags.StochAttrTag) != null) && (param.getAttributeValue(XMLTags.StochAttrTag).equals("true"))) {
        bStoch = true;
    }
    if (bStoch) {
        // stochastic and using concentration vs amount
        if ((param.getAttributeValue(XMLTags.ConcentrationAttrTag) != null) && (param.getAttributeValue(XMLTags.ConcentrationAttrTag).equals("false"))) {
            bUseConcentration = false;
        }
        // stochastic and randomizing initial conditions or not (for non-spatial)
        if ((param.getAttributeValue(XMLTags.RandomizeInitConditionTag) != null) && (param.getAttributeValue(XMLTags.RandomizeInitConditionTag).equals("true"))) {
            bRandomizeInitCondition = true;
        }
    }
    if ((param.getAttributeValue(XMLTags.MassConservationModelReductionTag) != null) && (param.getAttributeValue(XMLTags.MassConservationModelReductionTag).equals("false"))) {
        bMassConservationModelReduction = false;
    }
    if ((param.getAttributeValue(XMLTags.InsufficientIterationsTag) != null) && (param.getAttributeValue(XMLTags.InsufficientIterationsTag).equals("true"))) {
        bInsufficientIterations = true;
    }
    if ((param.getAttributeValue(XMLTags.InsufficientMaxMoleculesTag) != null) && (param.getAttributeValue(XMLTags.InsufficientMaxMoleculesTag).equals("true"))) {
        bInsufficientMaxMolecules = true;
    }
    if ((param.getAttributeValue(XMLTags.RuleBasedAttrTag) != null) && (param.getAttributeValue(XMLTags.RuleBasedAttrTag).equals("true"))) {
        bRuleBased = true;
        if ((param.getAttributeValue(XMLTags.ConcentrationAttrTag) != null) && (param.getAttributeValue(XMLTags.ConcentrationAttrTag).equals("false"))) {
            bUseConcentration = false;
        }
        if ((param.getAttributeValue(XMLTags.RandomizeInitConditionTag) != null) && (param.getAttributeValue(XMLTags.RandomizeInitConditionTag).equals("true"))) {
            // we propagate the flag but we don't use it for now
            bRandomizeInitCondition = true;
        }
    }
    // Retrieve Geometry
    Geometry newgeometry = null;
    try {
        newgeometry = getGeometry(param.getChild(XMLTags.GeometryTag, vcNamespace));
    } catch (Throwable e) {
        e.printStackTrace();
        String stackTrace = null;
        try {
            java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
            java.io.PrintStream ps = new java.io.PrintStream(bos);
            e.printStackTrace(ps);
            ps.flush();
            bos.flush();
            stackTrace = new String(bos.toByteArray());
            ps.close();
            bos.close();
        } catch (Exception e2) {
        // do Nothing
        }
        throw new XmlParseException("A Problem occurred while retrieving the geometry for the simulationContext " + name, e);
    }
    // Retrieve MathDescription(if there is no MathDescription skip it)
    MathDescription newmathdesc = null;
    Element xmlMathDescription = param.getChild(XMLTags.MathDescriptionTag, vcNamespace);
    if (xmlMathDescription != null) {
        newmathdesc = getMathDescription(xmlMathDescription, newgeometry);
        if (biomodel.getVersion() != null && biomodel.getVersion().getVersionKey() != null) {
            Long lpcBMKey = Long.valueOf(biomodel.getVersion().getVersionKey().toString());
            // MathDescription.originalHasLowPrecisionConstants.remove(lpcBMKey);
            try {
                Enumeration<Constant> myenum = newmathdesc.getConstants();
                while (myenum.hasMoreElements()) {
                    Constant nextElement = myenum.nextElement();
                    String name2 = nextElement.getName();
                    ReservedSymbol reservedSymbolByName = biomodel.getModel().getReservedSymbolByName(name2);
                    if (reservedSymbolByName != null && nextElement.getExpression() != null && reservedSymbolByName.getExpression() != null) {
                        // System.out.println(name2);
                        boolean equals = nextElement.getExpression().infix().equals(reservedSymbolByName.getExpression().infix());
                        // System.out.println("--"+" "+nextElement.getExpression().infix() +" "+reservedSymbolByName.getExpression().infix()+" "+equals);
                        if (!equals) {
                            TreeSet<String> treeSet = MathDescription.originalHasLowPrecisionConstants.get(lpcBMKey);
                            if (treeSet == null) {
                                treeSet = new TreeSet<>();
                                MathDescription.originalHasLowPrecisionConstants.put(lpcBMKey, treeSet);
                            }
                            treeSet.add(newmathdesc.getVersion().getVersionKey().toString());
                            break;
                        }
                    }
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    // Retrieve Version (Metada)
    Version version = getVersion(param.getChild(XMLTags.VersionTag, vcNamespace));
    // ------ Create SimContext ------
    SimulationContext newsimcontext = null;
    try {
        newsimcontext = new SimulationContext(biomodel.getModel(), newgeometry, newmathdesc, version, bStoch, bRuleBased);
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace(System.out);
        throw new XmlParseException("A propertyveto exception was generated when creating the new SimulationContext " + name, e);
    }
    // set attributes
    try {
        newsimcontext.setName(name);
        // Add annotation
        String annotation = param.getChildText(XMLTags.AnnotationTag, vcNamespace);
        if (annotation != null) /* && annotation.length()>0*/
        {
            newsimcontext.setDescription(unMangle(annotation));
        }
        // set if using concentration
        newsimcontext.setUsingConcentration(bUseConcentration);
        // set mass conservation model reduction flag
        newsimcontext.setUsingMassConservationModelReduction(bMassConservationModelReduction);
        // set if randomizing init condition or not (for stochastic applications
        if (bStoch) {
            newsimcontext.setRandomizeInitConditions(bRandomizeInitCondition);
        }
        if (bInsufficientIterations) {
            newsimcontext.setInsufficientIterations(bInsufficientIterations);
        }
        if (bInsufficientMaxMolecules) {
            newsimcontext.setInsufficientMaxMolecules(bInsufficientMaxMolecules);
        }
        if (nc != null) {
            newsimcontext.setNetworkConstraints(nc);
        }
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace(System.out);
        throw new XmlParseException("Exception", e);
    }
    String tempchar = param.getAttributeValue(XMLTags.CharacteristicSizeTag);
    if (tempchar != null) {
        try {
            newsimcontext.setCharacteristicSize(Double.valueOf(tempchar));
        } catch (java.beans.PropertyVetoException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException("A PropertyVetoException was fired when setting the CharacteristicSize " + tempchar, e);
        }
    }
    // Retrieve DataContext
    Element dataContextElement = param.getChild(XMLTags.DataContextTag, vcNamespace);
    if (dataContextElement != null) {
        DataContext dataContext = newsimcontext.getDataContext();
        ArrayList<DataSymbol> dataSymbols = getDataSymbols(dataContextElement, dataContext, newsimcontext.getModel().getUnitSystem());
        for (int i = 0; i < dataSymbols.size(); i++) {
            dataContext.addDataSymbol(dataSymbols.get(i));
        }
    }
    // Retrieve spatialObjects and add to simContext
    Element spatialObjectsElement = param.getChild(XMLTags.SpatialObjectsTag, vcNamespace);
    if (spatialObjectsElement != null) {
        SpatialObject[] spatialObjects = getSpatialObjects(newsimcontext, spatialObjectsElement);
        try {
            newsimcontext.setSpatialObjects(spatialObjects);
        } catch (PropertyVetoException e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("Error adding spatialObjects to simulationContext", e);
        }
    }
    // Retrieve application parameters and add to simContext
    Element appParamsElement = param.getChild(XMLTags.ApplicationParametersTag, vcNamespace);
    if (appParamsElement != null) {
        SimulationContextParameter[] appParameters = getSimulationContextParams(appParamsElement, newsimcontext);
        try {
            newsimcontext.setSimulationContextParameters(appParameters);
        } catch (PropertyVetoException e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("Error adding application parameters to simulationContext", e);
        }
    }
    // 
    // -Process the GeometryContext-
    // 
    Element tempelement = param.getChild(XMLTags.GeometryContextTag, vcNamespace);
    LinkedList<StructureMapping> maplist = new LinkedList<StructureMapping>();
    // Retrieve FeatureMappings
    Iterator<Element> iterator = tempelement.getChildren(XMLTags.FeatureMappingTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        maplist.add(getFeatureMapping((Element) (iterator.next()), newsimcontext));
    }
    // Retrieve MembraneMappings
    iterator = tempelement.getChildren(XMLTags.MembraneMappingTag, vcNamespace).iterator();
    while (iterator.hasNext()) {
        maplist.add(getMembraneMapping((Element) (iterator.next()), newsimcontext));
    }
    // Add these mappings to the internal geometryContext of this simcontext
    StructureMapping[] structarray = new StructureMapping[maplist.size()];
    maplist.toArray(structarray);
    try {
        newsimcontext.getGeometryContext().setStructureMappings(structarray);
        newsimcontext.getGeometryContext().refreshStructureMappings();
        newsimcontext.refreshSpatialObjects();
    } catch (MappingException e) {
        e.printStackTrace();
        throw new XmlParseException("A MappingException was fired when trying to set the StructureMappings array to the Geometrycontext of the SimContext " + name, e);
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace(System.out);
        throw new XmlParseException("A PopertyVetoException was fired when trying to set the StructureMappings array to the Geometrycontext of the SimContext " + name, e);
    }
    // 
    // -Process the ReactionContext-
    // 
    tempelement = param.getChild(XMLTags.ReactionContextTag, vcNamespace);
    // Retrieve ReactionSpecs
    List<Element> children = tempelement.getChildren(XMLTags.ReactionSpecTag, vcNamespace);
    if (children.size() != 0) {
        if (children.size() != biomodel.getModel().getReactionSteps().length) {
            throw new XmlParseException("The number of reactions is not consistent.\n" + "Model reactions=" + biomodel.getModel().getReactionSteps().length + ", Reaction specs=" + children.size());
        }
        // *NOTE: Importing a model from other languages does not generates reaction specs.
        // A more robust code will read the reactions in the source file and replace the ones created by the default by the VirtualCell framework.
        ReactionSpec[] reactionSpecs = new ReactionSpec[children.size()];
        int rSpecCounter = 0;
        for (Element rsElement : children) {
            reactionSpecs[rSpecCounter] = getReactionSpec(rsElement, newsimcontext);
            rSpecCounter++;
        }
        try {
            newsimcontext.getReactionContext().setReactionSpecs(reactionSpecs);
        } catch (java.beans.PropertyVetoException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException("A PropertyVetoException occurred while setting the ReactionSpecs to the SimContext " + name, e);
        }
    }
    // Retrieve ReactionRuleSpecs
    Element reactionRuleSpecsElement = tempelement.getChild(XMLTags.ReactionRuleSpecsTag, vcNamespace);
    if (reactionRuleSpecsElement != null) {
        ReactionRuleSpec[] reactionRuleSpecs = getReactionRuleSpecs(newsimcontext, reactionRuleSpecsElement);
        try {
            newsimcontext.getReactionContext().setReactionRuleSpecs(reactionRuleSpecs);
        } catch (PropertyVetoException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException("A PropertyVetoException occurred while setting the ReactionRuleSpecs to the SimContext " + name, e);
        }
    }
    children = tempelement.getChildren(XMLTags.SpeciesContextSpecTag, vcNamespace);
    getSpeciesContextSpecs(children, newsimcontext.getReactionContext(), biomodel.getModel());
    // Retrieve output functions
    Element outputFunctionsElement = param.getChild(XMLTags.OutputFunctionsTag, vcNamespace);
    if (outputFunctionsElement != null) {
        ArrayList<AnnotatedFunction> outputFunctions = getOutputFunctions(outputFunctionsElement);
        try {
            // construct OutputFnContext from mathDesc in newSimContext and add output functions that were read in from XML.
            OutputFunctionContext outputFnContext = newsimcontext.getOutputFunctionContext();
            for (AnnotatedFunction outputFunction : outputFunctions) {
                outputFnContext.addOutputFunction(outputFunction);
            }
        } catch (PropertyVetoException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException(e);
        }
    }
    // Retrieve Electrical context
    org.jdom.Element electElem = param.getChild(XMLTags.ElectricalContextTag, vcNamespace);
    // this information is optional!
    if (electElem != null) {
        if (electElem.getChild(XMLTags.ClampTag, vcNamespace) != null) {
            // read clamp
            ElectricalStimulus[] electArray = new ElectricalStimulus[1];
            electArray[0] = getElectricalStimulus(electElem.getChild(XMLTags.ClampTag, vcNamespace), newsimcontext);
            try {
                newsimcontext.setElectricalStimuli(electArray);
            } catch (java.beans.PropertyVetoException e) {
                e.printStackTrace(System.out);
                throw new XmlParseException(e);
            }
        }
        // read ground electrode
        if (electElem.getChild(XMLTags.ElectrodeTag, vcNamespace) != null) {
            Electrode groundElectrode = getElectrode(electElem.getChild(XMLTags.ElectrodeTag, vcNamespace), newsimcontext);
            try {
                newsimcontext.setGroundElectrode(groundElectrode);
            } catch (java.beans.PropertyVetoException e) {
                e.printStackTrace(System.out);
                throw new XmlParseException(e);
            }
        }
    }
    // Retrieve (bio)events and add to simContext
    tempelement = param.getChild(XMLTags.BioEventsTag, vcNamespace);
    if (tempelement != null) {
        BioEvent[] bioEvents = getBioEvents(newsimcontext, tempelement);
        try {
            newsimcontext.setBioEvents(bioEvents);
        } catch (PropertyVetoException e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("Error adding events to simulationContext", e);
        }
    }
    // Retrieve spatialProcesses and add to simContext
    tempelement = param.getChild(XMLTags.SpatialProcessesTag, vcNamespace);
    if (tempelement != null) {
        SpatialProcess[] spatialProcesses = getSpatialProcesses(newsimcontext, tempelement);
        try {
            newsimcontext.setSpatialProcesses(spatialProcesses);
        } catch (PropertyVetoException e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("Error adding spatialProcesses to simulationContext", e);
        }
    }
    // Retrieve rate rules and add to simContext
    tempelement = param.getChild(XMLTags.RateRulesTag, vcNamespace);
    if (tempelement != null) {
        RateRule[] rateRules = getRateRules(newsimcontext, tempelement);
        try {
            newsimcontext.setRateRules(rateRules);
        } catch (PropertyVetoException e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("Error adding rate rules to simulationContext", e);
        }
    }
    tempelement = param.getChild(XMLTags.AssignmentRulesTag, vcNamespace);
    if (tempelement != null) {
        AssignmentRule[] assignmentRules = getAssignmentRules(newsimcontext, tempelement);
        try {
            newsimcontext.setAssignmentRules(assignmentRules);
        } catch (PropertyVetoException e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("Error adding assignment rules to simulationContext", e);
        }
    }
    org.jdom.Element analysisTaskListElement = param.getChild(XMLTags.AnalysisTaskListTag, vcNamespace);
    if (analysisTaskListElement != null) {
        children = analysisTaskListElement.getChildren(XMLTags.ParameterEstimationTaskTag, vcNamespace);
        if (children.size() != 0) {
            Vector<ParameterEstimationTask> analysisTaskList = new Vector<ParameterEstimationTask>();
            for (Element parameterEstimationTaskElement : children) {
                try {
                    ParameterEstimationTask parameterEstimationTask = ParameterEstimationTaskXMLPersistence.getParameterEstimationTask(parameterEstimationTaskElement, newsimcontext);
                    analysisTaskList.add(parameterEstimationTask);
                } catch (Exception e) {
                    e.printStackTrace(System.out);
                    throw new XmlParseException("An Exception occurred when parsing AnalysisTasks of SimContext " + name, e);
                }
            }
            try {
                AnalysisTask[] analysisTasks = (AnalysisTask[]) BeanUtils.getArray(analysisTaskList, AnalysisTask.class);
                newsimcontext.setAnalysisTasks(analysisTasks);
            } catch (java.beans.PropertyVetoException e) {
                e.printStackTrace(System.out);
                throw new XmlParseException("A PropertyVetoException occurred when setting the AnalysisTasks of the SimContext " + name, e);
            }
        }
    }
    // Microscope Measurement
    org.jdom.Element element = param.getChild(XMLTags.MicroscopeMeasurement, vcNamespace);
    if (element != null) {
        getMicroscopeMeasurement(element, newsimcontext);
    }
    for (GeometryClass gc : newsimcontext.getGeometry().getGeometryClasses()) {
        try {
            StructureSizeSolver.updateUnitStructureSizes(newsimcontext, gc);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    newsimcontext.getGeometryContext().enforceHierarchicalBoundaryConditions(newsimcontext.getModel().getStructureTopology());
    return newsimcontext;
}
Also used : MathDescription(cbit.vcell.math.MathDescription) MappingException(cbit.vcell.mapping.MappingException) PropertyVetoException(java.beans.PropertyVetoException) Version(org.vcell.util.document.Version) RedistributionVersion(cbit.vcell.solvers.mb.MovingBoundarySolverOptions.RedistributionVersion) SimulationVersion(org.vcell.util.document.SimulationVersion) VCellSoftwareVersion(org.vcell.util.document.VCellSoftwareVersion) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) RateRule(cbit.vcell.mapping.RateRule) Vector(java.util.Vector) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) Electrode(cbit.vcell.mapping.Electrode) ReactionSpec(cbit.vcell.mapping.ReactionSpec) ReactionRuleSpec(cbit.vcell.mapping.ReactionRuleSpec) AssignmentRule(cbit.vcell.mapping.AssignmentRule) LinkedList(java.util.LinkedList) PropertyVetoException(java.beans.PropertyVetoException) OutputFunctionContext(cbit.vcell.solver.OutputFunctionContext) FieldDataSymbol(cbit.vcell.data.FieldDataSymbol) DataSymbol(cbit.vcell.data.DataSymbol) ParameterEstimationTask(cbit.vcell.modelopt.ParameterEstimationTask) AnalysisTask(cbit.vcell.modelopt.AnalysisTask) NetworkConstraints(org.vcell.model.rbm.NetworkConstraints) GeometryClass(cbit.vcell.geometry.GeometryClass) MacroscopicRateConstant(cbit.vcell.math.MacroscopicRateConstant) Constant(cbit.vcell.math.Constant) Element(org.jdom.Element) ReservedSymbol(cbit.vcell.model.Model.ReservedSymbol) StructureMapping(cbit.vcell.mapping.StructureMapping) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) DataContext(cbit.vcell.data.DataContext) SimulationContext(cbit.vcell.mapping.SimulationContext) SimulationContextParameter(cbit.vcell.mapping.SimulationContext.SimulationContextParameter) 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) Geometry(cbit.vcell.geometry.Geometry) ElectricalStimulus(cbit.vcell.mapping.ElectricalStimulus) BioEvent(cbit.vcell.mapping.BioEvent) Element(org.jdom.Element)

Example 2 with AssignmentRule

use of cbit.vcell.mapping.AssignmentRule in project vcell by virtualcell.

the class Xmlproducer method getXML.

/**
 * This method returns a XML representation of a SimulationContext object.
 * Creation date: (2/22/2001 2:15:14 PM)
 * @return Element
 * @param param cbit.vcell.mapping.SimulationContext
 */
public Element getXML(SimulationContext param, BioModel bioModel) throws XmlParseException {
    SimulationContext.Application applicationType = param.getApplicationType();
    Element simulationcontext = new Element(XMLTags.SimulationSpecTag);
    // add attributes
    String name = mangle(param.getName());
    simulationcontext.setAttribute(XMLTags.NameAttrTag, name);
    // set isStoch, isUsingConcentration attributes
    if (applicationType == Application.NETWORK_STOCHASTIC) {
        simulationcontext.setAttribute(XMLTags.StochAttrTag, "true");
        setBooleanAttribute(simulationcontext, XMLTags.ConcentrationAttrTag, param.isUsingConcentration());
        // write out 'randomizeInitConditin' flag only if non-spatial stochastic simContext
        if (param.getGeometry().getDimension() == 0) {
            setBooleanAttribute(simulationcontext, XMLTags.RandomizeInitConditionTag, param.isRandomizeInitCondition());
        }
    } else {
        simulationcontext.setAttribute(XMLTags.StochAttrTag, "false");
        simulationcontext.setAttribute(XMLTags.ConcentrationAttrTag, "true");
    }
    final boolean ruleBased = param.getApplicationType() == SimulationContext.Application.RULE_BASED_STOCHASTIC;
    setBooleanAttribute(simulationcontext, XMLTags.RuleBasedAttrTag, ruleBased);
    if (ruleBased) {
        setBooleanAttribute(simulationcontext, XMLTags.ConcentrationAttrTag, param.isUsingConcentration());
        if (param.getGeometry().getDimension() == 0) {
            // we don't use it yet but we do propagate it
            setBooleanAttribute(simulationcontext, XMLTags.RandomizeInitConditionTag, param.isRandomizeInitCondition());
        }
    }
    setBooleanAttribute(simulationcontext, XMLTags.MassConservationModelReductionTag, param.isUsingMassConservationModelReduction());
    setBooleanAttribute(simulationcontext, XMLTags.InsufficientIterationsTag, param.isInsufficientIterations());
    setBooleanAttribute(simulationcontext, XMLTags.InsufficientMaxMoleculesTag, param.isInsufficientMaxMolecules());
    NetworkConstraints constraints = param.getNetworkConstraints();
    if (constraints != null) {
        simulationcontext.addContent(getXML(constraints, param));
    }
    // add annotation
    if (param.getDescription() != null) /*&& param.getDescription().length()>0*/
    {
        Element annotationElem = new Element(XMLTags.AnnotationTag);
        annotationElem.setText(mangle(param.getDescription()));
        simulationcontext.addContent(annotationElem);
    }
    if (param.getCharacteristicSize() != null) {
        simulationcontext.setAttribute(XMLTags.CharacteristicSizeTag, param.getCharacteristicSize().toString());
    }
    // write Geometry (or GeometryRef???)
    try {
        simulationcontext.addContent(getXML(param.getGeometryContext().getGeometry()));
    } catch (XmlParseException e) {
        e.printStackTrace();
        throw new XmlParseException("A problem occurred when trying to process the geometry for the simulationContext " + name, e);
    }
    // write GeometryContext (geometric mapping)
    simulationcontext.addContent(getXML(param.getGeometryContext()));
    // write ReactionContext (parameter/variable mapping)
    simulationcontext.addContent(getXML(param.getReactionContext()));
    // check if there is anything to write first for the electrical context
    if (param.getElectricalStimuli().length == 1 || param.getGroundElectrode() != null) {
        // create ElectricalContext
        Element electricalElement = new Element(XMLTags.ElectricalContextTag);
        // Write the electrical stimuli
        if (param.getElectricalStimuli().length == 1) {
            // write clamp
            electricalElement.addContent(getXML(param.getElectricalStimuli(0)));
        // Element clampElem = new Element(XMLTags.ClampTag);
        // clampElem.addContent(getXML(param.getElectricalStimuli(0)));
        // if (param.getElectricalStimuli()[0] instanceof VoltageClampStimulus) {
        // //this is a VOLTAGE clamp
        // clampElem.setAttribute(XMLTags.TypeAttrTag, XMLTags.VoltageClampTag);
        // clampElem.setAttribute( XMLTags.NameAttrTag, this.mangle((param.getElectricalStimuli()[0]).getName()) );
        // String tempExp = this.mangleExpression( ((VoltageClampStimulus)param.getElectricalStimuli()[0]).getVoltageParameter().getExpression() );
        // clampElem.setAttribute(XMLTags.ExpressionAttrTag, tempExp);
        // //add probe-electrode
        // clampElem.addContent(getXML(param.getElectricalStimuli()[0].getElectrode()));
        // } else {
        // //this is a CURRENT clamp
        // clampElem.setAttribute(XMLTags.TypeAttrTag, XMLTags.CurrentClampTag);
        // clampElem.setAttribute( XMLTags.NameAttrTag, this.mangle((param.getElectricalStimuli()[0]).getName()) );
        // String tempExp = this.mangleExpression( ((CurrentClampStimulus)param.getElectricalStimuli()[0]).getCurrentParameter().getExpression() );
        // clampElem.setAttribute(XMLTags.ExpressionAttrTag, tempExp);
        // //add probe-electrode
        // clampElem.addContent(getXML(param.getElectricalStimuli()[0].getElectrode()));
        // }
        // electricalElement.addContent(clampElem);
        // 
        } else if (param.getElectricalStimuli().length > 1) {
            // **ONLY ONE ELECTRODE IS SUPPORTED RIGHT NOW!
            throw new IllegalArgumentException("More than one electrode is not supported!");
        }
        // Process the Ground electrode
        if (param.getGroundElectrode() != null) {
            // write the ground electrode
            electricalElement.addContent(getXML(param.getGroundElectrode()));
        }
        simulationcontext.addContent(electricalElement);
    }
    // Add Mathdescription (if present)
    if (param.getMathDescription() != null) {
        simulationcontext.addContent(getXML(param.getMathDescription()));
    }
    if (param.getOutputFunctionContext() != null) {
        ArrayList<AnnotatedFunction> outputFunctions = param.getOutputFunctionContext().getOutputFunctionsList();
        if (outputFunctions != null && outputFunctions.size() > 0) {
            // get output functions
            simulationcontext.addContent(getXML(outputFunctions));
        }
    }
    // Add Simulations to the simulationSpec
    if (bioModel != null) {
        cbit.vcell.solver.Simulation[] simulations = bioModel.getSimulations(param);
        for (int i = 0; simulations != null && i < simulations.length; i++) {
            simulationcontext.addContent(getXML(simulations[i]));
        }
    }
    // Add AnalysisTasks
    if (param.getAnalysisTasks() != null && param.getAnalysisTasks().length > 0) {
        // if the task is empty (no parameters set up, no reference data), we shall not save it
        if (param.getAnalysisTasks().length == 1) {
            AnalysisTask task = param.getAnalysisTasks()[0];
            if (task instanceof ParameterEstimationTask) {
                if (!((ParameterEstimationTask) task).isEmpty()) {
                    simulationcontext.addContent(getXML(param.getAnalysisTasks()));
                }
            }
        } else // have more than one analysis task
        {
            simulationcontext.addContent(getXML(param.getAnalysisTasks()));
        }
    }
    // Add (Bio)events
    BioEvent[] bioEvents = param.getBioEvents();
    if (bioEvents != null && bioEvents.length > 0) {
        simulationcontext.addContent(getXML(bioEvents));
    }
    SimulationContextParameter[] appParams = param.getSimulationContextParameters();
    if (appParams != null && appParams.length > 0) {
        simulationcontext.addContent(getXML(appParams));
    }
    SpatialObject[] spatialObjects = param.getSpatialObjects();
    if (spatialObjects != null && spatialObjects.length > 0) {
        simulationcontext.addContent(getXML(spatialObjects));
    }
    SpatialProcess[] spatialProcesses = param.getSpatialProcesses();
    if (spatialProcesses != null && spatialProcesses.length > 0) {
        simulationcontext.addContent(getXML(spatialProcesses));
    }
    // Add rate rules
    RateRule[] rateRules = param.getRateRules();
    if (param.getRateRules() != null && rateRules.length > 0) {
        simulationcontext.addContent(getXML(rateRules));
    }
    AssignmentRule[] assignmentRules = param.getAssignmentRules();
    if (param.getAssignmentRules() != null && assignmentRules.length > 0) {
        simulationcontext.addContent(getXML(assignmentRules));
    }
    // Add Datacontext
    if (param.getDataContext() != null && param.getDataContext().getDataSymbols().length > 0) {
        simulationcontext.addContent(getXML(param.getDataContext(), param.getModel().getUnitSystem()));
    }
    // Add Metadata (if any)
    if (param.getVersion() != null) {
        simulationcontext.addContent(getXML(param.getVersion(), param));
    }
    // Add microscope measurements
    simulationcontext.addContent(getXML(param.getMicroscopeMeasurement()));
    return simulationcontext;
}
Also used : Element(org.jdom.Element) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) RateRule(cbit.vcell.mapping.RateRule) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) Application(cbit.vcell.mapping.SimulationContext.Application) AssignmentRule(cbit.vcell.mapping.AssignmentRule) SimulationContext(cbit.vcell.mapping.SimulationContext) SimulationContextParameter(cbit.vcell.mapping.SimulationContext.SimulationContextParameter) ParameterEstimationTask(cbit.vcell.modelopt.ParameterEstimationTask) Simulation(cbit.vcell.solver.Simulation) AnalysisTask(cbit.vcell.modelopt.AnalysisTask) BioEvent(cbit.vcell.mapping.BioEvent) NetworkConstraints(org.vcell.model.rbm.NetworkConstraints)

Example 3 with AssignmentRule

use of cbit.vcell.mapping.AssignmentRule in project vcell by virtualcell.

the class XmlReader method getAssignmentRules.

public AssignmentRule[] getAssignmentRules(SimulationContext simContext, Element assignmentRulesElement) throws XmlParseException {
    Iterator<Element> assignmentRulesIterator = assignmentRulesElement.getChildren(XMLTags.AssignmentRuleTag, vcNamespace).iterator();
    Vector<AssignmentRule> assignmentRulesVector = new Vector<AssignmentRule>();
    while (assignmentRulesIterator.hasNext()) {
        Element rrElement = (Element) assignmentRulesIterator.next();
        AssignmentRule newAssignmentRule = null;
        try {
            String rrName = unMangle(rrElement.getAttributeValue(XMLTags.NameAttrTag));
            String varname = rrElement.getAttributeValue(XMLTags.AssignmentRuleVariableAttrTag);
            SymbolTableEntry rrVar = simContext.getEntry(varname);
            Expression rrExp = unMangleExpression(rrElement.getText());
            newAssignmentRule = new AssignmentRule(rrName, rrVar, rrExp, simContext);
            newAssignmentRule.bind();
        } catch (ExpressionBindingException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException(e.getMessage());
        }
        if (newAssignmentRule != null) {
            assignmentRulesVector.add(newAssignmentRule);
        }
    }
    return ((AssignmentRule[]) BeanUtils.getArray(assignmentRulesVector, AssignmentRule.class));
}
Also used : SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) Expression(cbit.vcell.parser.Expression) AssignmentRule(cbit.vcell.mapping.AssignmentRule) Element(org.jdom.Element) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) Vector(java.util.Vector)

Example 4 with AssignmentRule

use of cbit.vcell.mapping.AssignmentRule in project vcell by virtualcell.

the class SimContextTable method readAppComponents.

/**
 * readAppComponents : reads the additional simContext components like bioevents/application related flags (for stochastic, at the moment), if present, and sets them on simContext.
 * @param con
 * @param simContext
 * @return
 * @throws SQLException
 * @throws DataAccessException
 * @throws PropertyVetoException
 */
public void readAppComponents(Connection con, SimulationContext simContext, DatabaseSyntax dbSyntax) throws SQLException, DataAccessException, PropertyVetoException {
    try {
        Element appComponentsElement = getAppComponentsElement(con, simContext.getVersion().getVersionKey(), dbSyntax);
        if (appComponentsElement != null) {
            Element appRelatedFlags = appComponentsElement.getChild(XMLTags.ApplicationSpecificFlagsTag);
            if (appRelatedFlags != null) {
                // for now, only reading the 'randomizeInitCondition' attribute, since 'isStoch' and 'isUsingconcentration' are read in by other means; so not messing with those fields of simContext.
                boolean bRandomizeInitCondition = false;
                if ((appRelatedFlags.getAttributeValue(XMLTags.RandomizeInitConditionTag) != null) && (appRelatedFlags.getAttributeValue(XMLTags.RandomizeInitConditionTag).equals("true"))) {
                    bRandomizeInitCondition = true;
                }
                simContext.setRandomizeInitConditions(bRandomizeInitCondition);
            }
            if ((appComponentsElement.getAttributeValue(XMLTags.InsufficientIterationsTag) != null) && (appComponentsElement.getAttributeValue(XMLTags.InsufficientIterationsTag).equals("true"))) {
                simContext.setInsufficientIterations(true);
            } else {
                simContext.setInsufficientIterations(false);
            }
            if ((appComponentsElement.getAttributeValue(XMLTags.InsufficientMaxMoleculesTag) != null) && (appComponentsElement.getAttributeValue(XMLTags.InsufficientMaxMoleculesTag).equals("true"))) {
                simContext.setInsufficientMaxMolecules(true);
            } else {
                simContext.setInsufficientMaxMolecules(false);
            }
            if ((appComponentsElement.getAttributeValue(XMLTags.MassConservationModelReductionTag) != null) && (appComponentsElement.getAttributeValue(XMLTags.MassConservationModelReductionTag).equals("true"))) {
                simContext.setUsingMassConservationModelReduction(true);
            } else {
                simContext.setUsingMassConservationModelReduction(false);
            }
            XmlReader xmlReader = new XmlReader(false);
            NetworkConstraints nc = null;
            Element ncElement = appComponentsElement.getChild(XMLTags.RbmNetworkConstraintsTag);
            if (ncElement != null) {
                // one network constraint element
                nc = xmlReader.getAppNetworkConstraints(ncElement, simContext.getModel());
            }
            simContext.setNetworkConstraints(nc);
            // get spatial objects
            Element spatialObjectsElement = appComponentsElement.getChild(XMLTags.SpatialObjectsTag);
            if (spatialObjectsElement != null) {
                SpatialObject[] spatialObjects = xmlReader.getSpatialObjects(simContext, spatialObjectsElement);
                simContext.setSpatialObjects(spatialObjects);
            }
            // get application parameters
            Element appParamsElement = appComponentsElement.getChild(XMLTags.ApplicationParametersTag);
            if (appParamsElement != null) {
                SimulationContextParameter[] appParams = xmlReader.getSimulationContextParams(appParamsElement, simContext);
                simContext.setSimulationContextParameters(appParams);
            }
            // get bioEvents
            Element bioEventsElement = appComponentsElement.getChild(XMLTags.BioEventsTag);
            if (bioEventsElement != null) {
                BioEvent[] bioEvents = xmlReader.getBioEvents(simContext, bioEventsElement);
                simContext.setBioEvents(bioEvents);
            }
            // get spatial processes
            Element spatialProcessesElement = appComponentsElement.getChild(XMLTags.SpatialProcessesTag);
            if (spatialProcessesElement != null) {
                SpatialProcess[] spatialProcesses = xmlReader.getSpatialProcesses(simContext, spatialProcessesElement);
                simContext.setSpatialProcesses(spatialProcesses);
            }
            // get microscope measurements
            Element element = appComponentsElement.getChild(XMLTags.MicroscopeMeasurement);
            if (element != null) {
                xmlReader.getMicroscopeMeasurement(element, simContext);
            }
            // get rate rules
            Element rateRulesElement = appComponentsElement.getChild(XMLTags.RateRulesTag);
            if (rateRulesElement != null) {
                RateRule[] rateRules = xmlReader.getRateRules(simContext, rateRulesElement);
                simContext.setRateRules(rateRules);
            }
            Element assignmentRulesElement = appComponentsElement.getChild(XMLTags.AssignmentRulesTag);
            if (assignmentRulesElement != null) {
                AssignmentRule[] assignmentRules = xmlReader.getAssignmentRules(simContext, assignmentRulesElement);
                simContext.setAssignmentRules(assignmentRules);
            }
            // get reaction rule specs
            Element reactionRuleSpecsElement = appComponentsElement.getChild(XMLTags.ReactionRuleSpecsTag);
            if (reactionRuleSpecsElement != null) {
                ReactionRuleSpec[] reactionRuleSpecs = xmlReader.getReactionRuleSpecs(simContext, reactionRuleSpecsElement);
                simContext.getReactionContext().setReactionRuleSpecs(reactionRuleSpecs);
            }
        }
    } catch (XmlParseException e) {
        throw new DataAccessException("Error retrieving bioevents : " + e.getMessage(), e);
    }
}
Also used : AssignmentRule(cbit.vcell.mapping.AssignmentRule) ReactionRuleSpec(cbit.vcell.mapping.ReactionRuleSpec) Element(org.jdom.Element) XmlReader(cbit.vcell.xml.XmlReader) XmlParseException(cbit.vcell.xml.XmlParseException) SimulationContextParameter(cbit.vcell.mapping.SimulationContext.SimulationContextParameter) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) RateRule(cbit.vcell.mapping.RateRule) BioEvent(cbit.vcell.mapping.BioEvent) DataAccessException(org.vcell.util.DataAccessException) NetworkConstraints(org.vcell.model.rbm.NetworkConstraints)

Example 5 with AssignmentRule

use of cbit.vcell.mapping.AssignmentRule in project vcell by virtualcell.

the class BioModelParametersPanel method initialize.

private void initialize() {
    addNewButton = new JButton("New Global Parameter");
    addNewButton.addActionListener(eventHandler);
    addNewButton2 = new JButton("New Application Parameter");
    // addNewButton2.setIcon(downArrow);
    addNewButton2.setHorizontalTextPosition(SwingConstants.LEFT);
    addNewButton2.addActionListener(eventHandler);
    deleteButton = new JButton("Delete");
    deleteButton.setEnabled(false);
    deleteButton.addActionListener(eventHandler);
    changeUnitsButton = new JButton("Change Unit System");
    changeUnitsButton.addActionListener(eventHandler);
    textFieldSearch = new JTextField(10);
    textFieldSearch.getDocument().addDocumentListener(eventHandler);
    textFieldSearch.putClientProperty("JTextField.variant", "search");
    parametersFunctionsTable = new EditorScrollTable();
    parametersFunctionsTableModel = new BioModelParametersTableModel(parametersFunctionsTable);
    parametersFunctionsTable.setModel(parametersFunctionsTableModel);
    globalParametersCheckBox = new JCheckBox("Global");
    globalParametersCheckBox.setSelected(true);
    globalParametersCheckBox.addActionListener(eventHandler);
    reactionsCheckBox = new JCheckBox("Reactions and Rules");
    reactionsCheckBox.setSelected(true);
    reactionsCheckBox.addActionListener(eventHandler);
    applicationsCheckBox = new JCheckBox("Applications");
    applicationsCheckBox.setSelected(true);
    applicationsCheckBox.addActionListener(eventHandler);
    applicationComboBox = new JComboBox<ApplicationSelection>();
    applicationComboBox.setSelectedItem("All");
    applicationComboBox.addActionListener(eventHandler);
    applicationComboBox.setModel(applicationComboBoxModel);
    applicationComboBox.setRenderer(new ApplicationComboBoxRenderer());
    constantsCheckBox = new JCheckBox("Parameters");
    constantsCheckBox.setSelected(true);
    constantsCheckBox.addActionListener(eventHandler);
    functionsCheckBox = new JCheckBox("Functions");
    functionsCheckBox.setSelected(true);
    functionsCheckBox.addActionListener(eventHandler);
    predefinedSymbolsTable = new EditorScrollTable();
    predefinedSymbolsTableModel = new PredefinedSymbolsTableModel(predefinedSymbolsTable);
    predefinedSymbolsTable.setModel(predefinedSymbolsTableModel);
    GuiUtils.flexResizeTableColumns(predefinedSymbolsTable);
    modelUnitSystemTable = new EditorScrollTable();
    modelUnitSystemTableModel = new ModelUnitSystemTableModel(modelUnitSystemTable);
    modelUnitSystemTable.setModel(modelUnitSystemTableModel);
    GuiUtils.flexResizeTableColumns(modelUnitSystemTable);
    tabbedPane = new JTabbedPaneEnhanced();
    tabbedPane.addChangeListener(eventHandler);
    ParametersPanelTab[] parametersPanelTabs = new ParametersPanelTab[ParametersPanelTabID.values().length];
    parametersPanelTabs[ParametersPanelTabID.parameters_functions.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.parameters_functions, getParametersFunctionsPanel(), null);
    parametersPanelTabs[ParametersPanelTabID.predefined.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.predefined, getPredefinedSymbolsPanel(), null);
    parametersPanelTabs[ParametersPanelTabID.modelUnitSystem.ordinal()] = new ParametersPanelTab(ParametersPanelTabID.modelUnitSystem, getModelUnitSystemPanel(), null);
    for (ParametersPanelTab tab : parametersPanelTabs) {
        tab.component.setBorder(GuiConstants.TAB_PANEL_BORDER);
        tabbedPane.addTab(tab.id.title, tab.icon, tab.component);
    }
    JPanel buttonPanel = new JPanel(new GridBagLayout());
    int gridy = 0;
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(addNewButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(addNewButton2, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(deleteButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.insets = new Insets(4, 4, 4, 4);
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_END;
    buttonPanel.add(changeUnitsButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.gridy = gridy;
    gbc.anchor = GridBagConstraints.LINE_END;
    gbc.insets = new Insets(4, 50, 4, 4);
    buttonPanel.add(new JLabel("Search"), gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = GridBagConstraints.RELATIVE;
    gbc.gridy = gridy;
    gbc.weightx = 1.0;
    gbc.gridwidth = 2;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(4, 4, 4, 4);
    buttonPanel.add(textFieldSearch, gbc);
    setLayout(new BorderLayout());
    add(tabbedPane, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);
    parametersFunctionsTable.getSelectionModel().addListSelectionListener(eventHandler);
    parametersFunctionsTable.setDefaultRenderer(NameScope.class, new DefaultScrollTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (value instanceof NameScope) {
                NameScope nameScope = (NameScope) value;
                String text = nameScope.getPathDescription();
                setText(text);
            }
            return this;
        }
    });
    DefaultScrollTableCellRenderer nameTableCellRenderer = new DefaultScrollTableCellRenderer() {

        final Color lightBlueBackground = new Color(214, 234, 248);

        int PADDING = 3;

        @Override
        public void setBounds(int x, int y, int width, int height) {
            super.setBounds(x, y, width, height);
            if (getIcon() != null) {
                int textWidth = getFontMetrics(getFont()).stringWidth(getText());
                Insets insets = getInsets();
                // TODO: check that the text width is not bigger than the cell width and truncate the name
                int iconTextGap = width - textWidth - getIcon().getIconWidth() - insets.left - insets.right - PADDING;
                setIconTextGap(iconTextGap);
            } else {
                setIconTextGap(0);
            }
        }

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if (table.getModel() instanceof BioModelParametersTableModel) {
                BioModelParametersTableModel tableModel = (BioModelParametersTableModel) table.getModel();
                Object selectedObject = tableModel.getValueAt(row);
                setToolTipText(null);
                if (selectedObject instanceof ModelParameter || selectedObject instanceof SpeciesContext) {
                    SymbolTableEntry ste = (SymbolTableEntry) selectedObject;
                    RateRule rr = null;
                    AssignmentRule ar = null;
                    for (SimulationContext simContext : bioModel.getSimulationContexts()) {
                        rr = simContext.getRateRule(ste);
                        ar = simContext.getAssignmentRule(ste);
                        if (rr != null || ar != null) {
                            break;
                        }
                    }
                    Icon icon = null;
                    if (rr != null) {
                        String text = "<html>The default value of this entity is being overriden by a Rate Rule in one or more applications</html>";
                        icon = VCellIcons.ruleRateIcon;
                        setToolTipText(text);
                    } else if (ar != null) {
                        String text = "<html>The default value of this entity is being overriden by an Assignment Rule in one or more applications</html>";
                        icon = VCellIcons.ruleAssignIcon;
                        setToolTipText(text);
                    }
                    setIcon(icon);
                    this.setHorizontalTextPosition(SwingConstants.LEFT);
                    if (isSelected) {
                        setBackground(lightBlueBackground);
                        setForeground(Color.BLACK);
                    }
                }
            }
            return this;
        }
    };
    parametersFunctionsTable.getColumnModel().getColumn(BioModelParametersTableModel.COLUMN_NAME).setCellRenderer(nameTableCellRenderer);
    {
        // make double click on units panel bring up editing box
        JPanel p = getModelUnitSystemPanel();
        VCAssert.assertValid(p);
        EditorScrollTable est = GuiUtils.findFirstChild(p, EditorScrollTable.class);
        VCAssert.assertValid(est);
        MouseListener ml = new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    changeUnitsButtonPressed();
                }
            }
        };
        est.addMouseListener(ml);
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) SpeciesContext(cbit.vcell.model.SpeciesContext) JTextField(javax.swing.JTextField) JTabbedPaneEnhanced(org.vcell.util.gui.JTabbedPaneEnhanced) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) EditableSymbolTableEntry(cbit.vcell.model.EditableSymbolTableEntry) MouseListener(java.awt.event.MouseListener) BorderLayout(java.awt.BorderLayout) RateRule(cbit.vcell.mapping.RateRule) Component(java.awt.Component) JComponent(javax.swing.JComponent) MouseEvent(java.awt.event.MouseEvent) NameScope(cbit.vcell.parser.NameScope) AssignmentRule(cbit.vcell.mapping.AssignmentRule) Color(java.awt.Color) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) SimulationContext(cbit.vcell.mapping.SimulationContext) JCheckBox(javax.swing.JCheckBox) ModelParameter(cbit.vcell.model.Model.ModelParameter) JTable(javax.swing.JTable) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) EditorScrollTable(org.vcell.util.gui.EditorScrollTable) Icon(javax.swing.Icon) DownArrowIcon(org.vcell.util.gui.DownArrowIcon)

Aggregations

AssignmentRule (cbit.vcell.mapping.AssignmentRule)18 RateRule (cbit.vcell.mapping.RateRule)11 BioEvent (cbit.vcell.mapping.BioEvent)8 SimulationContext (cbit.vcell.mapping.SimulationContext)7 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)7 SpatialObject (cbit.vcell.mapping.spatial.SpatialObject)7 SpatialProcess (cbit.vcell.mapping.spatial.processes.SpatialProcess)7 SpeciesContext (cbit.vcell.model.SpeciesContext)7 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)6 StructureMapping (cbit.vcell.mapping.StructureMapping)5 Structure (cbit.vcell.model.Structure)5 NetworkConstraints (org.vcell.model.rbm.NetworkConstraints)5 Geometry (cbit.vcell.geometry.Geometry)4 GeometryContext (cbit.vcell.mapping.GeometryContext)4 SimulationContextParameter (cbit.vcell.mapping.SimulationContext.SimulationContextParameter)4 MathDescription (cbit.vcell.math.MathDescription)4 MathModel (cbit.vcell.mathmodel.MathModel)4 Model (cbit.vcell.model.Model)4 ReactionRule (cbit.vcell.model.ReactionRule)4 ReactionStep (cbit.vcell.model.ReactionStep)4