Search in sources :

Example 56 with SpeciesPattern

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

the class XmlReader method getRbmObservables.

private RbmObservable getRbmObservables(Element e, Model newModel) {
    String n = e.getAttributeValue(XMLTags.NameAttrTag);
    if (n == null || n.isEmpty()) {
        System.out.println("XMLReader: getRbmObservables: name is missing.");
        return null;
    }
    String t = e.getAttributeValue(XMLTags.RbmObservableTypeTag);
    if (t == null || t.isEmpty()) {
        System.out.println("XMLReader: getRbmObservables: type is missing.");
        return null;
    }
    RbmObservable.ObservableType ot = RbmObservable.ObservableType.Molecules;
    if (!t.equals(ot.name())) {
        ot = RbmObservable.ObservableType.Species;
    }
    Structure structure = null;
    String structureName = e.getAttributeValue(XMLTags.StructureAttrTag);
    if (structureName == null || structureName.isEmpty()) {
        // the tag is missing
        if (newModel.getStructures().length == 1) {
            // possible old single compartment model where we were not saving the structure for observable
            structure = newModel.getStructure(0);
        } else {
            throw new RuntimeException("XMLReader: structure missing for observable " + n);
        }
    } else {
        structure = newModel.getStructure(structureName);
    }
    RbmObservable o = new RbmObservable(newModel, n, structure, ot);
    // Sequence
    RbmObservable.Sequence se = RbmObservable.Sequence.Multimolecular;
    String ses = e.getAttributeValue(XMLTags.RbmObservableSequenceAttrTag);
    if (ses != null && ses.equals(RbmObservable.Sequence.PolymerLengthEqual.name())) {
        se = RbmObservable.Sequence.PolymerLengthEqual;
    } else if (ses != null && ses.equals(RbmObservable.Sequence.PolymerLengthGreater.name())) {
        se = RbmObservable.Sequence.PolymerLengthGreater;
    }
    o.setSequence(se);
    String lens = e.getAttributeValue(XMLTags.RbmObservableLenEqualAttrTag);
    if (lens != null) {
        // may be null for older models in which case the observable has default initial values
        int len = Integer.parseInt(lens);
        o.setSequenceLength(RbmObservable.Sequence.PolymerLengthEqual, len);
    }
    lens = e.getAttributeValue(XMLTags.RbmObservableLenGreaterAttrTag);
    if (lens != null) {
        int len = Integer.parseInt(lens);
        o.setSequenceLength(RbmObservable.Sequence.PolymerLengthGreater, len);
    }
    // Element element = e.getChild(XMLTags.RbmSpeciesPatternTag, vcNamespace);
    // SpeciesPattern sp = getSpeciesPattern(element, newModel);
    List<Element> children = e.getChildren(XMLTags.RbmSpeciesPatternTag, vcNamespace);
    for (Element e2 : children) {
        SpeciesPattern sp = getSpeciesPattern(e2, newModel);
        // setSpeciesPattern() will call resolveBonds()
        if (sp != null) {
            o.addSpeciesPattern(sp);
        }
    }
    return o;
}
Also used : RbmObservable(cbit.vcell.model.RbmObservable) Element(org.jdom.Element) Structure(cbit.vcell.model.Structure) ParticleSpeciesPattern(cbit.vcell.math.ParticleSpeciesPattern) VolumeParticleSpeciesPattern(cbit.vcell.math.VolumeParticleSpeciesPattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 57 with SpeciesPattern

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

the class Xmlproducer method getXML.

/**
 * This method returns a XML representation of a SpeciesContext object.
 * Creation date: (2/26/2001 11:26:37 AM)
 * @return Element
 * @param param cbit.vcell.model.SpeciesContext
 */
private Element getXML(SpeciesContext param) {
    Element speciecontext = new Element(XMLTags.SpeciesContextTag);
    // Add atributes
    speciecontext.setAttribute(XMLTags.NameAttrTag, mangle(param.getName()));
    speciecontext.setAttribute(XMLTags.SpeciesRefAttrTag, mangle(param.getSpecies().getCommonName()));
    speciecontext.setAttribute(XMLTags.StructureAttrTag, mangle(param.getStructure().getName()));
    speciecontext.setAttribute(XMLTags.HasOverrideAttrTag, true + "");
    // If keyFlag is on print the Keyvalue
    if (param.getKey() != null && this.printKeysFlag) {
        speciecontext.setAttribute(XMLTags.KeyValueAttrTag, param.getKey().toString());
    }
    SpeciesPattern sp = param.getSpeciesPattern();
    if (sp != null) {
        speciecontext.addContent(getXML(sp));
    }
    return speciecontext;
}
Also used : Element(org.jdom.Element) ParticleSpeciesPattern(cbit.vcell.math.ParticleSpeciesPattern) VolumeParticleSpeciesPattern(cbit.vcell.math.VolumeParticleSpeciesPattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 58 with SpeciesPattern

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

the class Xmlproducer method getXML.

// private Element getXMLShort(SpeciesPattern param) {
// Element e = new Element(XMLTags.RbmSpeciesPatternTag);
// e.setAttribute(XMLTags.NameAttrTag, mangle(param.getId()));
// return e;
// }
private Element getXML(RbmObservable param) {
    // if RbmObservableEmbedded we don't save the model or the structure
    // we know which they are once we use the XmlReader to recreate the object
    Element e = new Element(XMLTags.RbmObservableTag);
    e.setAttribute(XMLTags.NameAttrTag, mangle(param.getName()));
    RbmObservable.ObservableType ot = param.getType();
    e.setAttribute(XMLTags.RbmObservableTypeTag, mangle(ot.name()));
    String sequenceName = param.getSequence().name();
    e.setAttribute(XMLTags.RbmObservableSequenceAttrTag, sequenceName);
    e.setAttribute(XMLTags.RbmObservableLenEqualAttrTag, "" + param.getSequenceLength(RbmObservable.Sequence.PolymerLengthEqual));
    e.setAttribute(XMLTags.RbmObservableLenGreaterAttrTag, "" + param.getSequenceLength(RbmObservable.Sequence.PolymerLengthGreater));
    e.setAttribute(XMLTags.StructureAttrTag, mangle(param.getStructure().getName()));
    // SpeciesPattern sp = param.getSpeciesPattern(0);
    // Element e1 = new Element(XMLTags.RbmSpeciesPatternTag);
    // e1.setAttribute(XMLTags.NameAttrTag, mangle(sp.getId()));
    // e.addContent(getXML(sp));
    List<SpeciesPattern> spl = param.getSpeciesPatternList();
    for (SpeciesPattern sp : spl) {
        e.addContent(getXML(sp));
    }
    return e;
}
Also used : Element(org.jdom.Element) RbmObservable(cbit.vcell.model.RbmObservable) ParticleSpeciesPattern(cbit.vcell.math.ParticleSpeciesPattern) VolumeParticleSpeciesPattern(cbit.vcell.math.VolumeParticleSpeciesPattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 59 with SpeciesPattern

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

the class SpeciesPropertiesTreeModel method propertyChange.

public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals(PropertyConstants.PROPERTY_NAME_NAME)) {
        nodeChanged(rootNode);
    // } else if (evt.getSource() == seedSpecies && evt.getPropertyName().equals(SeedSpecies.PROPERTY_NAME_TYPE)){
    // nodeChanged(rootNode);
    } else if (evt.getPropertyName().equals("entityChange")) {
        nodeChanged(rootNode);
    } else {
        populateTree();
        Object source = evt.getSource();
        if (source == speciesContext) {
            if (evt.getPropertyName().equals(SeedSpecies.PROPERTY_NAME_SPECIES_PATTERN)) {
                SpeciesPattern oldValue = (SpeciesPattern) evt.getOldValue();
                if (oldValue != null) {
                    RbmUtils.removePropertyChangeListener(oldValue, this);
                }
                SpeciesPattern newValue = (SpeciesPattern) evt.getNewValue();
                if (newValue != null) {
                    // TODO
                    RbmUtils.addPropertyChangeListener(newValue, 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)) {
                // it's componentStatePattern
                ComponentStateDefinition oldValue = (ComponentStateDefinition) evt.getOldValue();
                if (oldValue != null) {
                    oldValue.removePropertyChangeListener(this);
                }
                ComponentStateDefinition newValue = (ComponentStateDefinition) evt.getNewValue();
                if (newValue != null) {
                    newValue.addPropertyChangeListener(this);
                }
            }
        }
    }
}
Also used : MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) List(java.util.List) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) ComponentStateDefinition(org.vcell.model.rbm.ComponentStateDefinition)

Example 60 with SpeciesPattern

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

the class ReactionRuleEditorPropertiesPanel method addReactant.

public void addReactant() {
    ReactantPattern reactant = new ReactantPattern(new SpeciesPattern(), reactionRule.getStructure());
    reactionRule.addReactant(reactant);
    final TreePath path = reactantTreeModel.findObjectPath(null, reactant);
    reactantTree.setSelectionPath(path);
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            reactantTree.scrollPathToVisible(path);
        // productTreeModel.populateTree();
        }
    });
}
Also used : TreePath(javax.swing.tree.TreePath) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) ReactantPattern(cbit.vcell.model.ReactantPattern)

Aggregations

SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)93 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)39 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)30 MolecularType (org.vcell.model.rbm.MolecularType)25 RbmObservable (cbit.vcell.model.RbmObservable)22 SpeciesContext (cbit.vcell.model.SpeciesContext)22 Structure (cbit.vcell.model.Structure)22 Point (java.awt.Point)18 ReactionRule (cbit.vcell.model.ReactionRule)16 ArrayList (java.util.ArrayList)16 ComponentStatePattern (org.vcell.model.rbm.ComponentStatePattern)16 Graphics (java.awt.Graphics)13 PropertyVetoException (java.beans.PropertyVetoException)13 SpeciesPatternLargeShape (cbit.vcell.graph.SpeciesPatternLargeShape)12 ProductPattern (cbit.vcell.model.ProductPattern)12 ReactantPattern (cbit.vcell.model.ReactantPattern)12 Dimension (java.awt.Dimension)12 ComponentStateDefinition (org.vcell.model.rbm.ComponentStateDefinition)12 Model (cbit.vcell.model.Model)11 ModelException (cbit.vcell.model.ModelException)11