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);
}
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;
}
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);
}
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> </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;
}
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;
}
Aggregations