Search in sources :

Example 1 with StateLocal

use of cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.StateLocal 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 StateLocal

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

the class RbmSpeciesContextTreeCellRenderer 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 SpeciesContext) {
            SpeciesContext sc = (SpeciesContext) userObject;
            text = toHtml(sc);
            toolTip = toHtml(sc);
            if (sc.hasSpeciesPattern()) {
                icon = VCellIcons.rbmSpeciesBlueIcon;
            } else {
                icon = VCellIcons.rbmSpeciesGreenIcon;
            }
        } else if (userObject instanceof MolecularTypePattern) {
            MolecularTypePattern molecularTypePattern = (MolecularTypePattern) userObject;
            text = toHtml(molecularTypePattern, true);
            toolTip = toHtml(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.rbmComponentGreenIcon;
            if (mcp.getMolecularComponent().getComponentStateDefinitions().size() > 0) {
                icon = VCellIcons.rbmComponentGreenStateIcon;
            }
        } else if (userObject instanceof StateLocal) {
            // this code is still here but we don't show the states or the bonds in the tree anymore
            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 != 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 : Graphics(java.awt.Graphics) MolecularTypeSmallShape(cbit.vcell.graph.MolecularTypeSmallShape) BondLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.BondLocal) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) StateLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.StateLocal) BioModelNode(cbit.vcell.desktop.BioModelNode) Icon(javax.swing.Icon) SpeciesContext(cbit.vcell.model.SpeciesContext) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern)

Example 3 with StateLocal

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

the class RbmObservableTreeCellRenderer 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 RbmObservable) {
            RbmObservable ob = (RbmObservable) userObject;
            text = toHtml(ob);
            toolTip = toHtmlWithTip(ob);
            icon = VCellIcons.rbmObservableIcon;
        } else if (userObject instanceof SpeciesPatternLocal) {
            SpeciesPatternLocal spl = (SpeciesPatternLocal) userObject;
            text = toHtml(spl, true);
            toolTip = toHtmlWithTip(spl, true);
            icon = 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;
            }
            Object parentObject = parent.getUserObject();
            if (!(parentObject instanceof RbmObservable)) {
                icon = VCellIcons.rbmComponentErrorIcon;
                return this;
            }
            if (hasErrorIssues((RbmObservable) parentObject, mcp, mcp.getMolecularComponent())) {
                icon = VCellIcons.rbmComponentErrorIcon;
            }
        } 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 != 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 : MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) RbmObservable(cbit.vcell.model.RbmObservable) ComponentStatePattern(org.vcell.model.rbm.ComponentStatePattern) StateLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.StateLocal) BioModelNode(cbit.vcell.desktop.BioModelNode) Graphics(java.awt.Graphics) MolecularTypeSmallShape(cbit.vcell.graph.MolecularTypeSmallShape) SpeciesPatternLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.SpeciesPatternLocal) BondLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.BondLocal) Icon(javax.swing.Icon) MolecularTypePattern(org.vcell.model.rbm.MolecularTypePattern)

Example 4 with StateLocal

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

the class RbmTreeCellRenderer method toHtmlWithTip.

public static final String toHtmlWithTip(MolecularComponentPattern mcp, boolean bShowWords) {
    String text = (bShowWords ? MolecularComponent.typeName : "") + " <b>" + mcp.getMolecularComponent().getName() + "</b>";
    MolecularComponent mc = mcp.getMolecularComponent();
    if (mc.getComponentStateDefinitions().size() > 0) {
        // we don't show the state if nothing to choose from
        StateLocal sl = new StateLocal(mcp);
        text += "&#160;&#160;&#160;" + toHtmlWorkShort(sl);
    }
    BondLocal bl = new BondLocal(mcp);
    text += "&#160;&#160;&#160;" + toHtmlWorkShort(bl);
    String htmlText = text + VCellErrorMessages.RightClickComponentToEdit;
    htmlText = "<html>" + htmlText + "</html>";
    return htmlText;
}
Also used : BondLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.BondLocal) MolecularComponent(org.vcell.model.rbm.MolecularComponent) StateLocal(cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.StateLocal)

Aggregations

BondLocal (cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.BondLocal)4 StateLocal (cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.StateLocal)4 BioModelNode (cbit.vcell.desktop.BioModelNode)3 MolecularTypeSmallShape (cbit.vcell.graph.MolecularTypeSmallShape)3 Graphics (java.awt.Graphics)3 Icon (javax.swing.Icon)3 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)3 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)3 ComponentStatePattern (org.vcell.model.rbm.ComponentStatePattern)2 ParticipantMatchLabelLocal (cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.ParticipantMatchLabelLocal)1 ReactionRuleParticipantLocal (cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.ReactionRuleParticipantLocal)1 SpeciesPatternLocal (cbit.vcell.client.desktop.biomodel.RbmDefaultTreeModel.SpeciesPatternLocal)1 RbmObservable (cbit.vcell.model.RbmObservable)1 ReactionRule (cbit.vcell.model.ReactionRule)1 SpeciesContext (cbit.vcell.model.SpeciesContext)1 MolecularComponent (org.vcell.model.rbm.MolecularComponent)1