use of org.vcell.model.rbm.MolecularTypePattern in project vcell by virtualcell.
the class ReactionRuleEditorPropertiesPanel method reflectStateToProduct.
private void reflectStateToProduct(MolecularComponentPattern mcpReactant, ComponentStatePattern cspReactant) {
MolecularTypePattern mtpReactant = reactionRule.getReactantMoleculeOfComponent(mcpReactant);
MolecularTypePattern mtpProduct = reactionRule.getMatchingProductMolecule(mtpReactant);
if (mtpProduct == null) {
return;
}
for (MolecularComponentPattern mcpProduct : mtpProduct.getComponentPatternList()) {
if (mcpProduct.getMolecularComponent() != mcpReactant.getMolecularComponent()) {
continue;
}
// use this if isAny
ComponentStatePattern csp = new ComponentStatePattern();
if (!cspReactant.isAny()) {
ComponentStateDefinition csd = cspReactant.getComponentStateDefinition();
csp = new ComponentStatePattern(csd);
}
mcpProduct.setComponentStatePattern(csp);
}
}
use of org.vcell.model.rbm.MolecularTypePattern in project vcell by virtualcell.
the class ReactionRulePropertiesTreeModel method populateTree.
public void populateTree() {
if (reactionRule == null) {
// this may be legit, for example when there's a plain reaction rather than a reaction rule
System.out.println("ReactionRulePropertiesTreeModel: reactionRule is null.");
return;
}
if (bioModel == null) {
System.out.println("ReactionRulePropertiesTreeModel: bioModel is null.");
return;
}
rootNode.setUserObject(reactionRule);
rootNode.removeAllChildren();
int count = 0;
List<? extends ReactionRuleParticipant> patterns = participantType == ReactionRuleParticipantType.Reactant ? reactionRule.getReactantPatterns() : reactionRule.getProductPatterns();
for (ReactionRuleParticipant rrp : patterns) {
BioModelNode rrNode = new BioModelNode(new ReactionRuleParticipantLocal(participantType, rrp, ++count));
for (MolecularTypePattern mtp : rrp.getSpeciesPattern().getMolecularTypePatterns()) {
BioModelNode node = createMolecularTypePatternNode(mtp);
rrNode.add(node);
}
rootNode.add(rrNode);
}
nodeStructureChanged(rootNode);
// GuiUtils.treeExpandAll(ownerTree, rootNode, true);
GuiUtils.treeExpandAllRows(ownerTree);
// we fire a dummy event because the species properties panel and the bio model editor species table model
// will repaint the shape and respectively the table row for any speciesContext property change event
reactionRule.firePropertyChange("entityChange", null, "bbb");
}
use of org.vcell.model.rbm.MolecularTypePattern in project vcell by virtualcell.
the class ReactionRulePropertiesTreeModel method propertyChange.
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(PropertyConstants.PROPERTY_NAME_NAME)) {
nodeChanged(rootNode);
} else if (evt.getPropertyName().equals("entityChange")) {
nodeChanged(rootNode);
} else if (evt.getSource() == reactionRule || evt.getSource() instanceof SpeciesPattern || evt.getSource() instanceof MolecularTypePattern) {
populateTree();
Object source = evt.getSource();
if (source == reactionRule) {
if (participantType == ReactionRuleParticipantType.Reactant && evt.getPropertyName().equals(ReactionRule.PROPERTY_NAME_REACTANT_PATTERNS)) {
List<ReactantPattern> oldValue = (List<ReactantPattern>) evt.getOldValue();
if (oldValue != null) {
for (ReactantPattern sp : oldValue) {
RbmUtils.removePropertyChangeListener(sp.getSpeciesPattern(), this);
}
}
List<ReactantPattern> newValue = (List<ReactantPattern>) evt.getNewValue();
if (newValue != null) {
for (ReactantPattern sp : newValue) {
RbmUtils.addPropertyChangeListener(sp.getSpeciesPattern(), this);
}
}
} else if (participantType == ReactionRuleParticipantType.Product && evt.getPropertyName().equals(ReactionRule.PROPERTY_NAME_PRODUCT_PATTERNS)) {
List<ProductPattern> oldValue = (List<ProductPattern>) evt.getOldValue();
if (oldValue != null) {
for (ProductPattern sp : oldValue) {
RbmUtils.removePropertyChangeListener(sp.getSpeciesPattern(), this);
}
}
List<ProductPattern> newValue = (List<ProductPattern>) evt.getNewValue();
if (newValue != null) {
for (ProductPattern sp : newValue) {
RbmUtils.addPropertyChangeListener(sp.getSpeciesPattern(), this);
}
}
}
} else if (source instanceof SpeciesPattern) {
if (evt.getPropertyName().equals(SpeciesPattern.PROPERTY_NAME_MOLECULAR_TYPE_PATTERNS)) {
List<MolecularTypePattern> oldValue = (List<MolecularTypePattern>) evt.getOldValue();
if (oldValue != null) {
for (MolecularTypePattern mtp : oldValue) {
RbmUtils.removePropertyChangeListener(mtp, this);
}
}
List<MolecularTypePattern> newValue = (List<MolecularTypePattern>) evt.getNewValue();
if (newValue != null) {
for (MolecularTypePattern mtp : newValue) {
RbmUtils.addPropertyChangeListener(mtp, this);
}
}
}
} else if (source instanceof MolecularTypePattern) {
if (evt.getPropertyName().equals(MolecularTypePattern.PROPERTY_NAME_COMPONENT_PATTERN_LIST)) {
List<MolecularComponentPattern> oldValue = (List<MolecularComponentPattern>) evt.getOldValue();
if (oldValue != null) {
for (MolecularComponentPattern mcp : oldValue) {
RbmUtils.removePropertyChangeListener(mcp, this);
}
}
List<MolecularComponentPattern> newValue = (List<MolecularComponentPattern>) evt.getNewValue();
if (newValue != null) {
for (MolecularComponentPattern mcp : newValue) {
RbmUtils.addPropertyChangeListener(mcp, this);
}
}
}
} else if (source instanceof MolecularComponentPattern) {
if (evt.getSource().equals(MolecularComponentPattern.PROPERTY_NAME_COMPONENT_STATE)) {
ComponentStatePattern oldValue = (ComponentStatePattern) evt.getOldValue();
if (oldValue != null) {
oldValue.removePropertyChangeListener(this);
}
ComponentStatePattern newValue = (ComponentStatePattern) evt.getNewValue();
if (newValue != null) {
newValue.addPropertyChangeListener(this);
}
}
}
}
}
use of org.vcell.model.rbm.MolecularTypePattern in project vcell by virtualcell.
the class ReactionRulePropertiesTreeModel method valueForPathChanged.
@Override
public void valueForPathChanged(TreePath path, Object newValue) {
Object obj = path.getLastPathComponent();
if (obj == null || !(obj instanceof BioModelNode)) {
return;
}
BioModelNode selectedNode = (BioModelNode) obj;
BioModelNode parentNode = (BioModelNode) selectedNode.getParent();
Object userObject = selectedNode.getUserObject();
try {
if (newValue instanceof String) {
String inputString = (String) newValue;
if (inputString == null || inputString.length() == 0) {
return;
}
if (userObject instanceof ReactionRule) {
// TODO: untested!!!
((ReactionRule) userObject).setName(inputString);
}
} else if (newValue instanceof MolecularComponentPattern) {
MolecularComponentPattern newMcp = (MolecularComponentPattern) newValue;
Object parentObject = parentNode == null ? null : parentNode.getUserObject();
if (parentObject instanceof MolecularTypePattern) {
MolecularTypePattern mtp = (MolecularTypePattern) parentObject;
MolecularComponent mc = newMcp.getMolecularComponent();
MolecularComponentPattern mcp = mtp.getMolecularComponentPattern(mc);
mcp.setComponentStatePattern(newMcp.getComponentStatePattern());
BondType bp = mcp.getBondType();
BondType newbp = newMcp.getBondType();
mcp.setBondType(newbp);
// specified -> specified
if (bp == BondType.Specified && newbp == BondType.Specified) {
// bond didn't change
} else if (bp == BondType.Specified && newbp != BondType.Specified) {
// specified -> non specified
// change the partner to possible
mcp.getBond().molecularComponentPattern.setBondType(BondType.Possible);
mcp.setBond(null);
} else if (bp != BondType.Specified && newbp == BondType.Specified) {
// non specified -> specified
int newBondId = newMcp.getBondId();
mcp.setBondId(newBondId);
mcp.setBond(newMcp.getBond());
mcp.getBond().molecularComponentPattern.setBondId(newBondId);
for (ReactantPattern rp : reactionRule.getReactantPatterns()) {
rp.getSpeciesPattern().resolveBonds();
}
for (ProductPattern pp : reactionRule.getProductPatterns()) {
pp.getSpeciesPattern().resolveBonds();
}
} else {
}
}
}
} catch (Exception ex) {
DialogUtils.showErrorDialog(ownerTree, ex.getMessage());
}
}
use of org.vcell.model.rbm.MolecularTypePattern in project vcell by virtualcell.
the class SpeciesPropertiesTreeModel method populateTree.
public void populateTree() {
if (speciesContext == null || bioModel == null) {
return;
}
rootNode.setUserObject(speciesContext);
rootNode.removeAllChildren();
int count = 0;
if (speciesContext.getSpeciesPattern() == null) {
nodeStructureChanged(rootNode);
return;
}
SpeciesPattern sp = speciesContext.getSpeciesPattern();
// BioModelNode spNode = new BioModelNode(new SpeciesPatternLocal(sp, ++count));
for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
BioModelNode node = createMolecularTypePatternNode(mtp);
rootNode.add(node);
// spNode.add(node);
}
// rootNode.add(spNode);
nodeStructureChanged(rootNode);
GuiUtils.treeExpandAllRows(ownerTree);
// we fire a "dummy" event because the species properties panel and the bio model editor species table model
// will repaint the shape and respectively the table row for any speciesContext property change event
speciesContext.firePropertyChange("entityChange", null, "bbb");
}
Aggregations