use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.
the class DataSymbolsTableModel method simulationContextChange.
/**
* Sets the simulationContext property (cbit.vcell.mapping.SimulationContext) value.
* @param simulationContext The new value for the property.
* @see #getSimulationContext
*/
@Override
protected void simulationContextChange(java.beans.PropertyChangeEvent evt) {
super.simulationContextChange(evt);
SimulationContext oldValue = (SimulationContext) evt.getOldValue();
if (oldValue != null) {
oldValue.getDataContext().removePropertyChangeListener(this);
for (DataSymbol ds : oldValue.getDataContext().getDataSymbols()) {
ds.removePropertyChangeListener(this);
}
}
SimulationContext newValue = (SimulationContext) evt.getNewValue();
if (newValue != null) {
newValue.getDataContext().addPropertyChangeListener(this);
for (DataSymbol ds : newValue.getDataContext().getDataSymbols()) {
ds.addPropertyChangeListener(this);
}
}
}
use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.
the class ElectricalMembraneMappingPanel method setsimulationContext1.
/**
* Set the simulationContext1 to a new value.
* @param newValue cbit.vcell.mapping.SimulationContext
*/
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void setsimulationContext1(SimulationContext newValue) {
if (ivjsimulationContext1 != newValue) {
try {
SimulationContext oldValue = getsimulationContext1();
ivjsimulationContext1 = newValue;
connPtoP2SetSource();
connEtoM1(ivjsimulationContext1);
connEtoM6(ivjsimulationContext1);
firePropertyChange("simulationContext", oldValue, newValue);
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
;
}
use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.
the class ElectricalMembraneMappingPanel method setSimulationContext.
/**
* Sets the simulationContext property (cbit.vcell.mapping.SimulationContext) value.
* @param simulationContext The new value for the property.
* @see #getSimulationContext
*/
public void setSimulationContext(SimulationContext simulationContext) {
SimulationContext oldValue = fieldSimulationContext;
fieldSimulationContext = simulationContext;
firePropertyChange("simulationContext", oldValue, simulationContext);
}
use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.
the class ElectricalStimulusPanel method setSimulationContext.
/**
* Sets the simulationContext property (cbit.vcell.mapping.SimulationContext) value.
* @param simulationContext The new value for the property.
* @see #getSimulationContext
*/
public void setSimulationContext(SimulationContext simulationContext) {
SimulationContext oldValue = fieldSimulationContext;
fieldSimulationContext = simulationContext;
firePropertyChange("simulationContext", oldValue, simulationContext);
}
use of cbit.vcell.mapping.SimulationContext in project vcell by virtualcell.
the class GeneratedReactionTableRow method deriveRule.
private void deriveRule(String inputString, Model tempModel) {
if (owner != null && owner.getSimulationContext() != null) {
List<MolecularType> mtList = owner.getSimulationContext().getModel().getRbmModelContainer().getMolecularTypeList();
try {
tempModel.getRbmModelContainer().setMolecularTypeList(mtList);
} catch (PropertyVetoException e1) {
e1.printStackTrace();
throw new RuntimeException("Unexpected exception setting " + MolecularType.typeName + " list: " + e1.getMessage(), e1);
}
} else {
// This should not be possible
throw new RuntimeException("Owner or SimulationContext are null.");
}
int arrowIndex = inputString.indexOf("<->");
boolean bReversible = true;
if (arrowIndex < 0) {
arrowIndex = inputString.indexOf("->");
bReversible = false;
}
String left = inputString.substring(0, arrowIndex).trim();
String right = inputString.substring(arrowIndex + (bReversible ? 3 : 2)).trim();
if (left.length() == 0 && right.length() == 0) {
return;
}
String name = reactionObject.getRuleName();
if (name.contains(GeneratedReactionTableModel.reverse)) {
name = name.substring(GeneratedReactionTableModel.reverse.length());
}
if (name.endsWith(ReactionRule.DirectHalf)) {
name = name.substring(0, name.indexOf(ReactionRule.DirectHalf));
}
if (name.endsWith(ReactionRule.InverseHalf)) {
name = name.substring(0, name.indexOf(ReactionRule.InverseHalf));
}
// try to get the name of the original structure from the original rule and make here another structure with the same name
String strStructure = null;
Structure ruleStructure;
SimulationContext sc = owner.getSimulationContext();
ReactionRule rr = sc.getModel().getRbmModelContainer().getReactionRule(name);
if (rr != null && rr.getStructure() != null) {
strStructure = rr.getStructure().getName();
}
if (strStructure != null) {
if (tempModel.getStructure(strStructure) == null) {
try {
tempModel.addFeature(strStructure);
} catch (ModelException | PropertyVetoException e) {
e.printStackTrace();
}
}
ruleStructure = tempModel.getStructure(strStructure);
} else {
throw new RuntimeException("Failed to recover a Structure name from the Reaction Rule: " + name);
}
// making the fake rules just for display purpose, actually they are the flattened reactions resulted from bngl
// the name is probably not unique, it's likely that many flattened reactions are derived from the same rule
reactionRule = tempModel.getRbmModelContainer().createReactionRule(name, ruleStructure, bReversible);
String regex = "[^!]\\+";
String[] patterns = left.split(regex);
for (String spString : patterns) {
try {
spString = spString.trim();
// if compartments are present, we're making some fake compartments in the tempModel just for compartment name display purposes
SpeciesPattern speciesPattern = (SpeciesPattern) RbmUtils.parseSpeciesPattern(spString, tempModel);
strStructure = RbmUtils.parseCompartment(spString, tempModel);
speciesPattern.resolveBonds();
Structure structure;
if (strStructure != null) {
if (tempModel.getStructure(strStructure) == null) {
tempModel.addFeature(strStructure);
}
structure = tempModel.getStructure(strStructure);
} else {
// if nothing explicit for a participant, we use by default the structure of the rule
structure = ruleStructure;
}
reactionRule.addReactant(new ReactantPattern(speciesPattern, structure));
} catch (Throwable ex) {
ex.printStackTrace();
return;
}
}
patterns = right.split(regex);
for (String spString : patterns) {
try {
spString = spString.trim();
SpeciesPattern speciesPattern = (SpeciesPattern) RbmUtils.parseSpeciesPattern(spString, tempModel);
strStructure = RbmUtils.parseCompartment(spString, tempModel);
speciesPattern.resolveBonds();
Structure structure;
if (strStructure != null) {
if (tempModel.getStructure(strStructure) == null) {
tempModel.addFeature(strStructure);
}
structure = tempModel.getStructure(strStructure);
} else {
structure = ruleStructure;
}
reactionRule.addProduct(new ProductPattern(speciesPattern, structure));
} catch (Throwable ex) {
ex.printStackTrace();
return;
}
}
}
Aggregations