Search in sources :

Example 1 with ReactionRuleParticipantLocal

use of cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.ReactionRuleParticipantLocal in project vcell by virtualcell.

the class RbmReactionParticipantTreeCellRenderer method getTreeCellRendererComponent.

@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    setBorder(null);
    if (value instanceof BioModelNode) {
        BioModelNode node = (BioModelNode) value;
        Object userObject = node.getUserObject();
        obj = userObject;
        String text = null;
        Icon icon = null;
        String toolTip = null;
        if (userObject instanceof ReactionRule) {
            ReactionRule rr = (ReactionRule) userObject;
            text = toHtml(rr);
            toolTip = toHtmlWithTip(rr);
            icon = rr.isReversible() ? VCellIcons.rbmReactRuleReversIcon : VCellIcons.rbmReactRuleDirectIcon;
        } else if (userObject instanceof ReactionRuleParticipantLocal) {
            ReactionRuleParticipantLocal rrp = (ReactionRuleParticipantLocal) userObject;
            text = toHtml(rrp, true);
            toolTip = toHtmlWithTip(rrp, true);
            icon = rrp.type == ReactionRuleParticipantType.Reactant ? VCellIcons.rbmReactantIcon : VCellIcons.rbmProductIcon;
        } else if (userObject instanceof MolecularTypePattern) {
            MolecularTypePattern molecularTypePattern = (MolecularTypePattern) userObject;
            text = toHtml(molecularTypePattern, true);
            toolTip = toHtmlWithTip(molecularTypePattern, true);
            if (owner == null) {
                icon = VCellIcons.rbmMolecularTypeSimpleIcon;
                ;
            } else {
                Graphics gc = owner.getGraphics();
                icon = new MolecularTypeSmallShape(1, 5, molecularTypePattern.getMolecularType(), null, gc, molecularTypePattern.getMolecularType(), null, issueManager);
            }
        } else if (userObject instanceof MolecularComponentPattern) {
            MolecularComponentPattern mcp = (MolecularComponentPattern) userObject;
            text = toHtml(mcp, true);
            toolTip = toHtmlWithTip(mcp, true);
            icon = VCellIcons.rbmComponentGrayIcon;
            if (mcp.getMolecularComponent().getComponentStateDefinitions().size() > 0) {
                icon = VCellIcons.rbmComponentGrayStateIcon;
            }
            if (mcp.isbVisible()) {
                icon = VCellIcons.rbmComponentGreenIcon;
                if (mcp.getMolecularComponent().getComponentStateDefinitions().size() > 0) {
                    icon = VCellIcons.rbmComponentGreenStateIcon;
                }
            }
            ComponentStatePattern csp = mcp.getComponentStatePattern();
            if (csp != null && !csp.isAny()) {
                icon = VCellIcons.rbmComponentGreenIcon;
                if (mcp.getMolecularComponent().getComponentStateDefinitions().size() > 0) {
                    icon = VCellIcons.rbmComponentGreenStateIcon;
                }
            }
            BioModelNode parent = (BioModelNode) ((BioModelNode) value).getParent().getParent().getParent();
            if (parent == null) {
                icon = VCellIcons.rbmComponentErrorIcon;
                return this;
            }
        } else if (userObject instanceof StateLocal) {
            StateLocal sl = (StateLocal) userObject;
            text = toHtml(sl, true);
            toolTip = toHtmlWithTip(sl, true);
            icon = VCellIcons.rbmComponentStateIcon;
        } else if (userObject instanceof BondLocal) {
            BondLocal bl = (BondLocal) userObject;
            text = toHtml(bl, sel);
            toolTip = toHtmlWithTip(bl, true);
            icon = VCellIcons.rbmBondIcon;
        } else if (userObject instanceof ParticipantMatchLabelLocal) {
            ParticipantMatchLabelLocal pmll = (ParticipantMatchLabelLocal) userObject;
            text = toHtml(pmll, sel);
            toolTip = toHtmlWithTip(pmll, true);
            icon = VCellIcons.rbmBondIcon;
        } else {
            if (userObject != null) {
                System.out.println(userObject.toString());
                text = userObject.toString();
            } else {
                text = "null user object";
            }
        }
        setText(text);
        setIcon(icon);
        setToolTipText(toolTip == null ? text : toolTip);
    }
    return this;
}
Also used : ReactionRule(cbit.vcell.model.ReactionRule) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) ComponentStatePattern(org.vcell.model.rbm.ComponentStatePattern) StateLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.StateLocal) ParticipantMatchLabelLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.ParticipantMatchLabelLocal) BioModelNode(cbit.vcell.desktop.BioModelNode) Graphics(java.awt.Graphics) MolecularTypeSmallShape(cbit.vcell.graph.MolecularTypeSmallShape) BondLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.BondLocal) ReactionRuleParticipantLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.ReactionRuleParticipantLocal) Icon(javax.swing.Icon) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern)

Example 2 with ReactionRuleParticipantLocal

use of cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.ReactionRuleParticipantLocal in project vcell by virtualcell.

the class ReactionRuleEditorPropertiesPanel method delete.

public void delete() {
    Object obj = rightClickSourceTree.getLastSelectedPathComponent();
    if (obj == null || !(obj instanceof BioModelNode)) {
        return;
    }
    BioModelNode selectedNode = (BioModelNode) obj;
    TreeNode parent = selectedNode.getParent();
    if (!(parent instanceof BioModelNode)) {
        return;
    }
    BioModelNode parentNode = (BioModelNode) parent;
    Object selectedUserObject = selectedNode.getUserObject();
    if (selectedUserObject instanceof ReactionRuleParticipantLocal) {
        ReactionRuleParticipantLocal reactionRuleParticipant = (ReactionRuleParticipantLocal) selectedUserObject;
        switch(reactionRuleParticipant.type) {
            case Reactant:
                reactionRule.removeReactant((ReactantPattern) (reactionRuleParticipant.speciesPattern));
                break;
            case Product:
                reactionRule.removeProduct((ProductPattern) (reactionRuleParticipant.speciesPattern));
                break;
        }
    } else if (selectedUserObject instanceof MolecularTypePattern) {
        MolecularTypePattern mtp = (MolecularTypePattern) selectedUserObject;
        Object parentObject = parentNode.getUserObject();
        if (parentObject instanceof ReactionRuleParticipantLocal) {
            ReactionRuleParticipantLocal rrp = (ReactionRuleParticipantLocal) parentObject;
            rrp.speciesPattern.getSpeciesPattern().removeMolecularTypePattern(mtp);
            if (rrp.type == ReactionRuleParticipantType.Reactant) {
                // we reset the "opposite" tree because it too might have changed
                productTreeModel.populateTree();
            } else if (rrp.type == ReactionRuleParticipantType.Product) {
                reactantTreeModel.populateTree();
            }
        }
    }
}
Also used : TreeNode(javax.swing.tree.TreeNode) ReactionRuleParticipantLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.ReactionRuleParticipantLocal) RbmObject(org.vcell.model.rbm.RbmObject) BioModelNode(cbit.vcell.desktop.BioModelNode) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern)

Aggregations

ReactionRuleParticipantLocal (cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.ReactionRuleParticipantLocal)2 BioModelNode (cbit.vcell.desktop.BioModelNode)2 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)2 BondLocal (cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.BondLocal)1 ParticipantMatchLabelLocal (cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.ParticipantMatchLabelLocal)1 StateLocal (cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.StateLocal)1 MolecularTypeSmallShape (cbit.vcell.graph.MolecularTypeSmallShape)1 ReactionRule (cbit.vcell.model.ReactionRule)1 Graphics (java.awt.Graphics)1 Icon (javax.swing.Icon)1 TreeNode (javax.swing.tree.TreeNode)1 ComponentStatePattern (org.vcell.model.rbm.ComponentStatePattern)1 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)1 RbmObject (org.vcell.model.rbm.RbmObject)1