Search in sources :

Example 36 with MolecularComponent

use of org.vcell.model.rbm.MolecularComponent in project vcell by virtualcell.

the class MolecularTypeTreeModel method setMolecularType.

public void setMolecularType(MolecularType newValue) {
    if (newValue == molecularType) {
        return;
    }
    MolecularType oldValue = molecularType;
    if (oldValue != null) {
        oldValue.removePropertyChangeListener(this);
        for (MolecularComponent molecularComponent : oldValue.getComponentList()) {
            molecularComponent.removePropertyChangeListener(this);
            for (ComponentStateDefinition componentState : molecularComponent.getComponentStateDefinitions()) {
                componentState.removePropertyChangeListener(this);
            }
        }
    }
    molecularType = newValue;
    populateTree();
    if (newValue != null) {
        newValue.addPropertyChangeListener(this);
        for (MolecularComponent molecularComponent : newValue.getComponentList()) {
            molecularComponent.addPropertyChangeListener(this);
            for (ComponentStateDefinition componentState : molecularComponent.getComponentStateDefinitions()) {
                componentState.addPropertyChangeListener(this);
            }
        }
    }
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) MolecularComponent(org.vcell.model.rbm.MolecularComponent) ComponentStateDefinition(org.vcell.model.rbm.ComponentStateDefinition)

Example 37 with MolecularComponent

use of org.vcell.model.rbm.MolecularComponent in project vcell by virtualcell.

the class ObservableTableModel method propertyChange.

@Override
public void propertyChange(PropertyChangeEvent evt) {
    super.propertyChange(evt);
    Object source = evt.getSource();
    // if (source == getModel().getRbmModelContainer()) {
    if (source == getModel()) {
        if (evt.getPropertyName().equals(RbmModelContainer.PROPERTY_NAME_OBSERVABLE_LIST)) {
            refreshData();
            List<RbmObservable> oldValue = (List<RbmObservable>) evt.getOldValue();
            if (oldValue != null) {
                for (RbmObservable observable : oldValue) {
                    observable.removePropertyChangeListener(this);
                    SpeciesPattern speciesPattern = observable.getSpeciesPattern(0);
                    RbmUtils.removePropertyChangeListener(speciesPattern, this);
                }
            }
            List<RbmObservable> newValue = (List<RbmObservable>) evt.getNewValue();
            if (newValue != null) {
                for (RbmObservable observable : newValue) {
                    observable.addPropertyChangeListener(this);
                    SpeciesPattern speciesPattern = observable.getSpeciesPattern(0);
                    RbmUtils.addPropertyChangeListener(speciesPattern, this);
                }
            }
        } else if (evt.getPropertyName().equals(RbmModelContainer.PROPERTY_NAME_MOLECULAR_TYPE_LIST)) {
            // we need this?
            refreshData();
        }
    } else if (source instanceof RbmObservable) {
        RbmObservable mt = (RbmObservable) source;
        int changeRow = getRowIndex(mt);
        if (changeRow >= 0) {
            fireTableRowsUpdated(changeRow, changeRow);
        }
    // if (evt.getPropertyName().equals(RbmObservable.PROPERTY_NAME_SPECIES_PATTERN_LIST)) {
    // SpeciesPattern oldValue = (SpeciesPattern) evt.getOldValue();
    // if (oldValue != null) {
    // RbmUtils.removePropertyChangeListener(oldValue, this);
    // }
    // SpeciesPattern newValue = (SpeciesPattern) evt.getNewValue();
    // if (newValue != null) {
    // RbmUtils.addPropertyChangeListener(newValue, this);
    // }
    // }
    } else if (source instanceof SpeciesPattern) {
        fireTableRowsUpdated(0, getRowCount() - 1);
        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) {
        fireTableRowsUpdated(0, getRowCount() - 1);
        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) {
        fireTableRowsUpdated(0, getRowCount() - 1);
        if (source.equals(MolecularComponentPattern.PROPERTY_NAME_COMPONENT_STATE)) {
            ComponentStateDefinition oldValue = (ComponentStateDefinition) evt.getOldValue();
            if (oldValue != null) {
                oldValue.removePropertyChangeListener(this);
            }
            ComponentStateDefinition newValue = (ComponentStateDefinition) evt.getNewValue();
            if (newValue != null) {
                newValue.addPropertyChangeListener(this);
            }
        }
    } else if (evt.getSource() instanceof MolecularComponent) {
        fireTableRowsUpdated(0, getRowCount() - 1);
    } else if (evt.getSource() instanceof ComponentStateDefinition) {
        fireTableRowsUpdated(0, getRowCount() - 1);
    }
// updateStructureComboBox();
}
Also used : MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularComponent(org.vcell.model.rbm.MolecularComponent) RbmObservable(cbit.vcell.model.RbmObservable) ArrayList(java.util.ArrayList) JList(javax.swing.JList) List(java.util.List) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) ComponentStateDefinition(org.vcell.model.rbm.ComponentStateDefinition)

Example 38 with MolecularComponent

use of org.vcell.model.rbm.MolecularComponent in project vcell by virtualcell.

the class ObservableTreeModel method createMolecularTypePatternNode.

private BioModelNode createMolecularTypePatternNode(MolecularTypePattern molecularTypePattern) {
    MolecularType molecularType = molecularTypePattern.getMolecularType();
    BioModelNode node = new BioModelNode(molecularTypePattern, true);
    for (MolecularComponent mc : molecularType.getComponentList()) {
        if (bShowDetails || molecularTypePattern.getMolecularComponentPattern(mc).isbVisible()) {
            BioModelNode n = createMolecularComponentPatternNode(molecularTypePattern.getMolecularComponentPattern(mc));
            if (n != null) {
                node.add(n);
            }
        }
    }
    return node;
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) MolecularComponent(org.vcell.model.rbm.MolecularComponent) BioModelNode(cbit.vcell.desktop.BioModelNode)

Example 39 with MolecularComponent

use of org.vcell.model.rbm.MolecularComponent in project vcell by virtualcell.

the class RbmObservable method checkComponentStateConsistency.

public void checkComponentStateConsistency(IssueContext issueContext, List<Issue> issueList, MolecularTypePattern mtpThis) {
    if (issueList == null) {
        // this may be called during parsing before the model is consistent
        return;
    }
    MolecularType mtThat = mtpThis.getMolecularType();
    for (MolecularComponentPattern mcpThis : mtpThis.getComponentPatternList()) {
        if (mcpThis.isImplied()) {
        // continue;
        }
        ComponentStatePattern cspThis = mcpThis.getComponentStatePattern();
        String mcNameThis = mcpThis.getMolecularComponent().getName();
        if (cspThis == null && mcpThis.getMolecularComponent().getComponentStateDefinitions().size() > 0) {
            // String msg = "Component pattern " + mcNameThis + " is in no State while the component has possible States defined.";
            String msg = "One of the possible States must be chosen for " + MolecularComponentPattern.typeName + " " + mcNameThis + ".";
            issueList.add(new Issue(this, mcpThis, issueContext, IssueCategory.Identifiers, msg, null, Issue.SEVERITY_WARNING));
        }
        MolecularComponent[] mcThatList = mtThat.getMolecularComponents(mcNameThis);
        if (mcThatList.length == 0) {
            System.out.println("we already fired an issue about component missing");
            // nothing to do here, we already fired an issue about component missing
            continue;
        } else if (mcThatList.length > 1) {
            String msg = "Multiple " + MolecularComponent.typeName + "s with the same name are not yet supported.";
            issueList.add(new Issue(this, mcpThis, issueContext, IssueCategory.Identifiers, msg, null, Issue.SEVERITY_ERROR));
        } else {
            // found exactly 1 component
            MolecularComponent mcThat = mcThatList[0];
            List<ComponentStateDefinition> csdListThat = mcThat.getComponentStateDefinitions();
            if (csdListThat.size() == 0) {
                // component has no states, we check if mcpThis has any states... it shouldn't
                if (cspThis == null) {
                    // all is well
                    continue;
                }
                if (!cspThis.isAny() || (cspThis.getComponentStateDefinition() != null)) {
                    String msg = MolecularComponentPattern.typeName + " " + mcNameThis + " is in an invalid State.";
                    issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.SEVERITY_WARNING));
                }
            } else {
                // we check if mcpThis has any of these states... it should!
                if ((cspThis == null) || cspThis.isAny() || (cspThis.getComponentStateDefinition() == null)) {
                // String msg = "Component pattern " + mcNameThis + " must be in an explicit State.";
                // issueList.add(new Issue(this, IssueCategory.Identifiers, msg, Issue.SEVERITY_WARNING));
                } else {
                    String csdNameThis = cspThis.getComponentStateDefinition().getName();
                    if (csdNameThis.isEmpty() || (mcThat.getComponentStateDefinition(csdNameThis) == null)) {
                        String msg = "Invalid State " + csdNameThis + " " + MolecularComponentPattern.typeName + " " + mcNameThis;
                        issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.SEVERITY_WARNING));
                    }
                }
            }
        }
    }
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) Issue(org.vcell.util.Issue) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularComponent(org.vcell.model.rbm.MolecularComponent) ComponentStatePattern(org.vcell.model.rbm.ComponentStatePattern) ArrayList(java.util.ArrayList) List(java.util.List)

Example 40 with MolecularComponent

use of org.vcell.model.rbm.MolecularComponent in project vcell by virtualcell.

the class ReactionRule method checkComponentStateConsistency.

public void checkComponentStateConsistency(IssueContext issueContext, List<Issue> issueList, MolecularTypePattern mtpThis) {
    if (issueList == null) {
        // this may be called during parsing before the model is consistent
        return;
    }
    issueContext = issueContext.newChildContext(ContextType.ReactionRule, this);
    MolecularType mtThat = mtpThis.getMolecularType();
    for (MolecularComponentPattern mcpThis : mtpThis.getComponentPatternList()) {
        if (mcpThis.isImplied()) {
            continue;
        }
        ComponentStatePattern cspThis = mcpThis.getComponentStatePattern();
        String mcNameThis = mcpThis.getMolecularComponent().getName();
        MolecularComponent[] mcThatList = mtThat.getMolecularComponents(mcNameThis);
        if (mcThatList.length == 0) {
            System.out.println("we already fired an issue about component missing");
            // nothing to do here, we already fired an issue about component missing
            continue;
        } else if (mcThatList.length > 1) {
            String msg = "Multiple " + MolecularComponent.typeName + "s with the same name are not yet supported.";
            issueList.add(new Issue(this, mcpThis, issueContext, IssueCategory.Identifiers, msg, msg, Issue.SEVERITY_ERROR));
        } else {
            // found exactly 1 component
            MolecularComponent mcThat = mcThatList[0];
            List<ComponentStateDefinition> csdListThat = mcThat.getComponentStateDefinitions();
            if (csdListThat.size() == 0) {
                // component has no states, we check if mcpThis has any states... it shouldn't
                if (cspThis == null) {
                    // all is well
                    continue;
                }
                if (!cspThis.isAny() || (cspThis.getComponentStateDefinition() != null)) {
                    String msg = MolecularComponentPattern.typeName + " " + mcNameThis + " is in an invalid State.";
                    issueList.add(new Issue(this, mcpThis, issueContext, IssueCategory.Identifiers, msg, msg, Issue.SEVERITY_WARNING));
                }
            } else {
                // we check if mcpThis has any of these states... it should!
                if ((cspThis == null) || cspThis.isAny() || (cspThis.getComponentStateDefinition() == null)) {
                // String msg = "Component pattern " + mcNameThis + " must be in an explicit State.";
                // issueList.add(new Issue(this, IssueCategory.Identifiers, msg, Issue.SEVERITY_WARNING));
                } else {
                    String csdNameThis = cspThis.getComponentStateDefinition().getName();
                    if (csdNameThis.isEmpty() || (mcThat.getComponentStateDefinition(csdNameThis) == null)) {
                        String msg = "Invalid State " + csdNameThis + " for component pattern " + mcNameThis;
                        issueList.add(new Issue(this, mcpThis, issueContext, IssueCategory.Identifiers, msg, msg, Issue.SEVERITY_WARNING));
                    }
                }
            }
        }
    }
}
Also used : MolecularType(org.vcell.model.rbm.MolecularType) Issue(org.vcell.util.Issue) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) MolecularComponent(org.vcell.model.rbm.MolecularComponent) ComponentStatePattern(org.vcell.model.rbm.ComponentStatePattern) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

MolecularComponent (org.vcell.model.rbm.MolecularComponent)42 ComponentStateDefinition (org.vcell.model.rbm.ComponentStateDefinition)23 MolecularType (org.vcell.model.rbm.MolecularType)23 BioModelNode (cbit.vcell.desktop.BioModelNode)17 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)14 SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)11 ComponentStatePattern (org.vcell.model.rbm.ComponentStatePattern)10 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)10 LinkedHashMap (java.util.LinkedHashMap)7 Icon (javax.swing.Icon)7 BondType (org.vcell.model.rbm.MolecularComponentPattern.BondType)7 Point (java.awt.Point)6 List (java.util.List)6 ParticleMolecularComponent (cbit.vcell.math.ParticleMolecularComponent)5 ArrayList (java.util.ArrayList)5 RbmObservable (cbit.vcell.model.RbmObservable)4 ReactionRule (cbit.vcell.model.ReactionRule)4 Structure (cbit.vcell.model.Structure)4 Graphics (java.awt.Graphics)4 ActionEvent (java.awt.event.ActionEvent)4