Search in sources :

Example 1 with AnnotationQualifier

use of org.vcell.sybil.models.AnnotationQualifier in project vcell by virtualcell.

the class BioModelCellRenderer method getTreeCellRendererComponent.

/**
 * Insert the method's description here.
 * Creation date: (7/27/2000 6:41:57 PM)
 * @return java.awt.Component
 */
public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    // 
    try {
        if (value instanceof DateNode) {
            DateNode dateNode = (DateNode) value;
            AnnotationQualifier qualifier = dateNode.getDateQualifier();
            String colorString = (sel) ? "white" : "black";
            component.setText("<html>" + qualifier.getDescription() + "&nbsp;<font color=\"" + colorString + "\">" + dateNode.getDate().getDateString() + "</font></html>");
        } else if (value instanceof LinkNode) {
            LinkNode ln = (LinkNode) value;
            String link = ln.getLink();
            String text = ln.getText();
            String qualifier = ln.getMiriamQualifier().getDescription();
            if (link != null) {
                String colorString = (sel) ? "white" : "blue";
                component.setToolTipText("Double-click to open link");
                component.setText("<html>" + qualifier + "&nbsp;<font color=\"" + colorString + "\"><a href=" + link + ">" + text + "</a></font></html>");
            } else {
                String colorString = (sel) ? "white" : "black";
                component.setText("<html>" + qualifier + "&nbsp;<font color=\"" + colorString + "\">" + text + "</font></html>");
            }
        } else if (value instanceof BioModelNode) {
            BioModelNode node = (BioModelNode) value;
            Object userObject = node.getUserObject();
            if (userObject instanceof User) {
                String label = null;
                if (sessionUser != null && sessionUser.compareEqual((User) userObject)) {
                    label = "My BioModels (" + ((User) userObject).getName() + ") (" + node.getChildCount() + ")";
                } else {
                    label = ((User) userObject).getName() + "(abcdefghijklmnopq)(000000)";
                }
                component.setToolTipText(label);
                component.setText(label);
            } else if (userObject instanceof BioModelInfo) {
                BioModelInfo biomodelInfo = (BioModelInfo) userObject;
                if (biomodelInfo.getVersion().getFlag().compareEqual(org.vcell.util.document.VersionFlag.Archived)) {
                    component.setText("(Archived) " + component.getText());
                } else if (biomodelInfo.getVersion().getFlag().compareEqual(org.vcell.util.document.VersionFlag.Published)) {
                    component.setText("(Published) " + component.getText());
                }
            } else if (userObject instanceof Geometry) {
                Geometry geo = (Geometry) userObject;
                String label = "";
                // geomety info, when spatial--shows name+1D/2D/3D
                if (geo.getDimension() > 0) {
                    label = geo.getName() + " (" + geo.getDimension() + "D)";
                } else {
                    label = BioModelChildSummary.COMPARTMENTAL_GEO_STR;
                }
                component.setToolTipText("Geometry");
                component.setText(label);
                setIcon(fieldGeometryIcon);
            } else if (userObject instanceof String && "AppType".equals(node.getRenderHint("type"))) {
                String label = (String) userObject;
                component.setToolTipText("Application type");
                component.setText(label);
                setIcon(VCellIcons.mathTypeIcon);
            } else if (userObject instanceof VCDocumentInfoNode) {
                VCDocumentInfoNode infonode = (VCDocumentInfoNode) userObject;
                User nodeUser = infonode.getVCDocumentInfo().getVersion().getOwner();
                String modelName = infonode.getVCDocumentInfo().getVersion().getName();
                String username = nodeUser.getName();
                if (nodeUser.compareEqual(sessionUser) || username.equals(VCDocumentDbTreeModel.USER_tutorial) || username.equals(VCDocumentDbTreeModel.USER_Education) || username.equals(VCDocumentDbTreeModel.USER_tutorial610) || username.equals(VCDocumentDbTreeModel.USER_tutorial611)) {
                    component.setText(modelName);
                } else {
                    component.setText("<html><b>" + username + " </b> : " + modelName + "</html>");
                }
            }
        }
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
    // 
    if (component.getToolTipText() == null || component.getToolTipText().length() == 0) {
        component.setToolTipText(component.getText());
    }
    return component;
}
Also used : Geometry(cbit.vcell.geometry.Geometry) DateNode(cbit.vcell.xml.gui.MiriamTreeModel.DateNode) AnnotationQualifier(org.vcell.sybil.models.AnnotationQualifier) User(org.vcell.util.document.User) BioModelInfo(org.vcell.util.document.BioModelInfo) JLabel(javax.swing.JLabel) LinkNode(cbit.vcell.xml.gui.MiriamTreeModel.LinkNode)

Aggregations

Geometry (cbit.vcell.geometry.Geometry)1 DateNode (cbit.vcell.xml.gui.MiriamTreeModel.DateNode)1 LinkNode (cbit.vcell.xml.gui.MiriamTreeModel.LinkNode)1 JLabel (javax.swing.JLabel)1 AnnotationQualifier (org.vcell.sybil.models.AnnotationQualifier)1 BioModelInfo (org.vcell.util.document.BioModelInfo)1 User (org.vcell.util.document.User)1