Search in sources :

Example 21 with MolecularComponentPattern

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

the class RbmReactionParticipantTreeCellRenderer method paintComponent.

@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    int x = 4;
    int y = 16;
    if (!(obj instanceof MolecularComponentPattern)) {
        return;
    }
    MolecularComponentPattern mcp = (MolecularComponentPattern) obj;
    Graphics2D g2 = (Graphics2D) g;
    Color colorOld = g2.getColor();
    if (mcp.getBondType() == BondType.Specified) {
        Color bondColor = GraphConstants.bondHtmlColors[mcp.getBondId()];
        g2.setColor(bondColor);
        // 2 lines, L-shaped
        g2.drawLine(x, y, x, y + 2);
        g2.drawLine(x + 1, y, x + 1, y + 2);
        g2.drawLine(x, y + 2, x + 7, y + 2);
        g2.drawLine(x, y + 3, x + 7, y + 3);
    } else if (mcp.getBondType().equals(BondType.Exists)) {
        // draw a green '+' sign
        g2.setColor(AbstractComponentShape.plusSignGreen);
        // vertical only
        g2.drawLine(x, y - 1, x, y + 4);
        g2.drawLine(x - 1, y - 1, x - 1, y + 4);
    }
    g2.setColor(colorOld);
}
Also used : MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) Color(java.awt.Color) Graphics2D(java.awt.Graphics2D)

Example 22 with MolecularComponentPattern

use of org.vcell.model.rbm.MolecularComponentPattern 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 23 with MolecularComponentPattern

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

the class RbmSpeciesContextTreeCellRenderer method paintComponent.

@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    int x = 4;
    int y = 16;
    if (!(obj instanceof MolecularComponentPattern)) {
        return;
    }
    MolecularComponentPattern mcp = (MolecularComponentPattern) obj;
    Graphics2D g2 = (Graphics2D) g;
    Color colorOld = g2.getColor();
    if (mcp.getBondType() == BondType.Specified) {
        Color bondColor = GraphConstants.bondHtmlColors[mcp.getBondId()];
        g2.setColor(bondColor);
        // 2 lines, L-shaped
        g2.drawLine(x, y, x, y + 2);
        g2.drawLine(x + 1, y, x + 1, y + 2);
        g2.drawLine(x, y + 2, x + 7, y + 2);
        g2.drawLine(x, y + 3, x + 7, y + 3);
    }
    g2.setColor(colorOld);
}
Also used : MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) Color(java.awt.Color) Graphics2D(java.awt.Graphics2D)

Example 24 with MolecularComponentPattern

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

the class RbmTreeCellRenderer method toHtmlWorkShort.

private static final String toHtmlWorkShort(BondLocal bl) {
    // used for tooltips
    MolecularComponentPattern mcp = bl.getMolecularComponentPattern();
    String bondText = "";
    String colorTextStart = "<font color=" + "\"rgb(" + GraphConstants.red.getRed() + "," + GraphConstants.red.getGreen() + "," + GraphConstants.red.getBlue() + ")\">";
    String colorTextEnd = "</font>";
    bondText = colorTextStart + "<b>" + "(unbound)" + "</b>" + colorTextEnd;
    if (mcp != null) {
        BondType bondType = mcp.getBondType();
        if (bondType == BondType.Specified) {
            Bond bond = mcp.getBond();
            if (bond == null) {
                colorTextStart = "<font color=" + "\"rgb(" + GraphConstants.red.getRed() + "," + GraphConstants.red.getGreen() + "," + GraphConstants.red.getBlue() + ")\">";
                colorTextEnd = "</font>";
                bondText = colorTextStart + "<b>" + "bond (missing)" + "</b>" + colorTextEnd;
            } else {
                int id = mcp.getBondId();
                colorTextStart = "<font color=" + "\"rgb(" + GraphConstants.bondHtmlColors[id].getRed() + "," + GraphConstants.bondHtmlColors[id].getGreen() + "," + GraphConstants.bondHtmlColors[id].getBlue() + ")\">";
                colorTextEnd = "</font>";
                // <sub>&nbsp;</sub>
                bondText = colorTextStart + "<b>" + "Bond<sub>" + id + "</sub></b>" + colorTextEnd;
            }
        } else if (bondType == BondType.None) {
            bondText = "Unbound";
        // bondText =  "<b>" + "unbound" + "</b>";
        } else if (bondType == BondType.Exists) {
            Color c = AbstractComponentShape.plusSignGreen;
            colorTextStart = "<font color=" + "\"rgb(" + c.getRed() + "," + c.getGreen() + "," + c.getBlue() + ")\">";
            colorTextEnd = "</font>";
            // green '+'
            bondText = colorTextStart + "<b>" + mcp.getBondType().symbol + "</b>" + colorTextEnd;
            bondText = "Bond: '" + bondText + "'";
        } else if (bondType == BondType.Possible) {
            Color c = Color.gray;
            colorTextStart = "<font color=" + "\"rgb(" + c.getRed() + "," + c.getGreen() + "," + c.getBlue() + ")\">";
            colorTextEnd = "</font>";
            // gray '?'
            bondText = colorTextStart + "<b>" + mcp.getBondType().symbol + "</b>" + colorTextEnd;
            bondText = "Bond: '" + bondText + "'";
        }
    }
    return bondText;
}
Also used : BondType(org.vcell.model.rbm.MolecularComponentPattern.BondType) MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) Color(java.awt.Color) Bond(org.vcell.model.rbm.SpeciesPattern.Bond)

Example 25 with MolecularComponentPattern

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

the class RbmTreeCellRenderer method toHtmlWorkShort.

private static final String toHtmlWorkShort(StateLocal sl) {
    String stateText = "";
    MolecularComponentPattern mcp = sl.getMolecularComponentPattern();
    ComponentStatePattern csp = mcp.getComponentStatePattern();
    if (mcp != null) /*&& !mcp.isImplied()*/
    {
        if (mcp.getMolecularComponent().getComponentStateDefinitions().size() == 0) {
            // no states possible because none defined
            ;
        } else if (csp != null && csp.isAny()) {
            stateText = ComponentStateDefinition.typeName + ": <b>" + ComponentStatePattern.strAny + "</b>";
        // stateText = ComponentStateDefinition.typeName + ": " + ComponentStatePattern.strAny;
        } else if (csp != null && csp.getComponentStateDefinition() != null) {
            stateText = ComponentStateDefinition.typeName + ": <b>" + csp.getComponentStateDefinition().getName() + "</b>";
        }
    }
    return stateText;
}
Also used : MolecularComponentPattern(org.vcell.model.rbm.MolecularComponentPattern) ComponentStatePattern(org.vcell.model.rbm.ComponentStatePattern)

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