Search in sources :

Example 61 with MolecularComponentPattern

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

the class SpeciesContext method findStateUsage.

public void findStateUsage(MolecularType mt, MolecularComponent mc, ComponentStateDefinition csd, Map<String, Pair<Displayable, SpeciesPattern>> usedHere) {
    if (!hasSpeciesPattern()) {
        return;
    }
    SpeciesPattern sp = getSpeciesPattern();
    for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
        if (mtp.getMolecularType() == mt) {
            List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
            for (MolecularComponentPattern mcp : componentPatterns) {
                if (mcp.getMolecularComponent() == mc) {
                    // here some state is always in use if available
                    ComponentStatePattern csp = mcp.getComponentStatePattern();
                    if (csp == null) {
                        System.out.println("This component " + mc.getName() + " should have had some State specified.");
                        continue;
                    }
                    if ((csp.getComponentStateDefinition() == csd) && (mcp.getBond() != null)) {
                        // we only care if there's a bond
                        String key = sp.getDisplayName();
                        key = getDisplayType() + getDisplayName() + key;
                        usedHere.put(key, new Pair<Displayable, SpeciesPattern>(this, sp));
                    }
                }
            }
        }
    }
}
Also used : Displayable(org.vcell.util.Displayable) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) ComponentStatePattern(org.vcell.model.rbm.ComponentStatePattern) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Example 62 with MolecularComponentPattern

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

the class SpeciesContext method deleteStateFromPatterns.

public boolean deleteStateFromPatterns(MolecularType mt, MolecularComponent mc, ComponentStateDefinition csd) {
    if (!hasSpeciesPattern()) {
        return true;
    }
    SpeciesPattern sp = getSpeciesPattern();
    for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
        if (mtp.getMolecularType() == mt) {
            List<MolecularComponentPattern> componentPatterns = mtp.getComponentPatternList();
            for (MolecularComponentPattern mcp : componentPatterns) {
                if (!(mcp.getMolecularComponent() == mc)) {
                    continue;
                }
                ComponentStatePattern csp = mcp.getComponentStatePattern();
                if (csp == null) {
                    continue;
                }
                if (csp.isAny()) {
                    if (mc.getComponentStateDefinitions().size() == 1) {
                        mcp.setComponentStatePattern(null);
                    }
                    continue;
                }
                if (csp.getComponentStateDefinition() == csd) {
                    if (mc.getComponentStateDefinitions().size() == 1) {
                        // we are about to delete the last possible state, so we set the ComponentStatePattern to null
                        mcp.setComponentStatePattern(null);
                    } else {
                        // set to Any (may result in an Issue being raised)
                        csp = new ComponentStatePattern();
                        mcp.setComponentStatePattern(csp);
                    }
                }
            }
        }
    }
    return true;
}
Also used : MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) ComponentStatePattern(org.vcell.model.rbm.ComponentStatePattern) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern)

Aggregations

MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)62 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)49 SpeciesPattern (org.vcell.model.rbm.SpeciesPattern)30 ComponentStatePattern (org.vcell.model.rbm.ComponentStatePattern)25 Graphics (java.awt.Graphics)16 MolecularComponent (org.vcell.model.rbm.MolecularComponent)14 Point (java.awt.Point)13 MolecularType (org.vcell.model.rbm.MolecularType)12 ComponentStateDefinition (org.vcell.model.rbm.ComponentStateDefinition)10 Icon (javax.swing.Icon)9 BondType (org.vcell.model.rbm.MolecularComponentPattern.BondType)9 Bond (org.vcell.model.rbm.SpeciesPattern.Bond)8 List (java.util.List)7 BioModelNode (cbit.vcell.desktop.BioModelNode)6 MolecularTypeLargeShape (cbit.vcell.graph.MolecularTypeLargeShape)6 MolecularTypeSmallShape (cbit.vcell.graph.MolecularTypeSmallShape)6 RuleAnalysisChanged (cbit.vcell.graph.ReactionCartoon.RuleAnalysisChanged)6 SpeciesPatternLargeShape (cbit.vcell.graph.SpeciesPatternLargeShape)6 SpeciesPatternSmallShape (cbit.vcell.graph.SpeciesPatternSmallShape)6 ZoomShapeIcon (cbit.vcell.graph.gui.ZoomShapeIcon)6