Search in sources :

Example 1 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class MIRIAMAnnotationEditor method getJTreeMIRIAM.

private JTree getJTreeMIRIAM() {
    if (jTreeMIRIAM == null) {
        try {
            DefaultTreeSelectionModel ivjLocalSelectionModel;
            ivjLocalSelectionModel = new DefaultTreeSelectionModel();
            ivjLocalSelectionModel.setSelectionMode(1);
            jTreeMIRIAM = new JTree();
            jTreeMIRIAM.setName("JTree1");
            jTreeMIRIAM.setToolTipText("");
            jTreeMIRIAM.setBounds(0, 0, 357, 405);
            jTreeMIRIAM.setMinimumSize(new java.awt.Dimension(100, 72));
            jTreeMIRIAM.setSelectionModel(ivjLocalSelectionModel);
            jTreeMIRIAM.setRowHeight(0);
            // Add cellRenderer
            DefaultTreeCellRenderer dtcr = new BioModelCellRenderer(null) {

                @Override
                public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
                    // System.out.println(MIRIAMAnnotationEditor.this.getClass().getName()+".getJTreeMiriam():BioModelCellRenderer  "+value.getClass()+" "+
                    // (value instanceof cbit.vcell.desktop.BioModelNode?
                    // ((cbit.vcell.desktop.BioModelNode)value).getUserObject().getClass():""));
                    JLabel component = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
                    if (value instanceof BioModelNode && ((BioModelNode) value).getUserObject() instanceof Annotation) {
                        component.setToolTipText("(Double-click to edit notes)");
                        Annotation annotation = (Annotation) ((BioModelNode) value).getUserObject();
                        if (annotation.toString() == null || annotation.toString().length() == 0) {
                            component.setText("(Double-click to edit notes)");
                        }
                    }
                    return component;
                }
            };
            jTreeMIRIAM.setCellRenderer(dtcr);
            MouseListener mouseListener = new MouseAdapter() {

                @Override
                public void mouseClicked(MouseEvent e) {
                    // TODO Auto-generated method stub
                    super.mouseClicked(e);
                    TreePath closestMousePath = jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
                    showPopup(e, closestMousePath);
                }

                @Override
                public void mouseReleased(MouseEvent e) {
                    // TODO Auto-generated method stub
                    super.mouseReleased(e);
                    TreePath closestMousePath = jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
                    showPopup(e, closestMousePath);
                }

                public void mousePressed(MouseEvent e) {
                    TreePath closestMousePath = jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
                    jTreeMIRIAM.setSelectionPath(closestMousePath);
                    showPopup(e, closestMousePath);
                    if (e.getClickCount() == 2) {
                        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTreeMIRIAM.getLastSelectedPathComponent();
                        if (node instanceof LinkNode) {
                            showBrowseToLink((LinkNode) node);
                        } else if (isNodeFreeHandTextEditable(node)) {
                            showEditFreehandText(node);
                        }
                    }
                }
            };
            jTreeMIRIAM.addMouseListener(mouseListener);
        } catch (java.lang.Throwable ivjExc) {
            ivjExc.printStackTrace(System.out);
        }
    }
    return jTreeMIRIAM;
}
Also used : MouseEvent(java.awt.event.MouseEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) BioModelNode(cbit.vcell.desktop.BioModelNode) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) Annotation(cbit.vcell.desktop.Annotation) JTree(javax.swing.JTree) Dimension(java.awt.Dimension) MouseListener(java.awt.event.MouseListener) DefaultTreeSelectionModel(javax.swing.tree.DefaultTreeSelectionModel) TreePath(javax.swing.tree.TreePath) BioModelCellRenderer(cbit.vcell.desktop.BioModelCellRenderer) LinkNode(cbit.vcell.xml.gui.MiriamTreeModel.LinkNode)

Example 2 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class MiriamTreeModel method createTree.

private void createTree() {
    MiriamManager miriamManager = vcMetaData.getMiriamManager();
    TreeMap<Identifiable, Map<MiriamRefGroup, MIRIAMQualifier>> miriamDescrHeir = miriamManager.getMiriamTreeMap();
    Map<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>> dateMapMap = miriamManager.getDublinCoreDateMap();
    Set<Identifiable> identifiables = vcMetaData.getIdentifiableProvider().getAllIdentifiables();
    TreeSet<Identifiable> sortedIdentifiables = new TreeSet<Identifiable>(new IdentifiableComparator(vcMetaData.getIdentifiableProvider()));
    sortedIdentifiables.addAll(identifiables);
    ((DefaultMutableTreeNode) getRoot()).removeAllChildren();
    for (Identifiable identifiable : sortedIdentifiables) {
        Map<MiriamRefGroup, MIRIAMQualifier> refGroupMap = miriamDescrHeir.get(identifiable);
        Map<DateQualifier, Set<DublinCoreDate>> dateMap = dateMapMap.get(identifiable);
        VCID vcid = vcMetaData.getIdentifiableProvider().getVCID(identifiable);
        String modelComponentType = vcid.getClassName();
        String modelComponentName = vcid.getLocalName();
        IdentifiableNode modelComponentNode = new IdentifiableNode(identifiable, modelComponentType + " : " + modelComponentName);
        String freeTextAnnotation = vcMetaData.getFreeTextAnnotation(identifiable);
        if (freeTextAnnotation != null) {
            modelComponentNode.add(new BioModelNode(new Annotation(freeTextAnnotation), false));
        } else {
            modelComponentNode.add(new BioModelNode(new Annotation(""), false));
        }
        if (refGroupMap != null) {
            for (MiriamRefGroup refGroup : refGroupMap.keySet()) {
                MIRIAMQualifier qualifier = refGroupMap.get(refGroup);
                for (MiriamResource miriamResource : refGroup.getMiriamRefs()) {
                    LinkNode linkNode = new LinkNode(qualifier, miriamResource);
                    modelComponentNode.add(linkNode);
                }
            }
        }
        if (dateMap != null) {
            for (DublinCoreQualifier.DateQualifier qualifier : dateMap.keySet()) {
                Set<DublinCoreDate> dates = dateMap.get(qualifier);
                for (DublinCoreDate date : dates) {
                    modelComponentNode.add(new DateNode(qualifier, date));
                }
            }
        }
        ((DefaultMutableTreeNode) getRoot()).add(modelComponentNode);
    }
}
Also used : IdentifiableComparator(cbit.vcell.biomodel.meta.IdentifiableComparator) MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) Set(java.util.Set) TreeSet(java.util.TreeSet) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) BioModelNode(cbit.vcell.desktop.BioModelNode) DateQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) TreeSet(java.util.TreeSet) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup) VCID(cbit.vcell.biomodel.meta.VCID) DublinCoreDate(org.vcell.sybil.models.dublincore.DublinCoreDate) Annotation(cbit.vcell.desktop.Annotation) Identifiable(org.vcell.util.document.Identifiable) DateQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier) DublinCoreQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier) TreeMap(java.util.TreeMap) Map(java.util.Map) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier)

Example 3 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class BioModelEditorSabioPanel method initialize.

private void initialize() {
    responseTree = new JTree();
    responseTreeModel = new ResponseTreeModel();
    responseTree.setModel(responseTreeModel);
    ToolTipManager.sharedInstance().registerComponent(responseTree);
    setLayout(new BorderLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    // ------- panel 1 ---------------
    JLabel categoryLabel1 = new JLabel("Role: ");
    panel1 = new JPanel();
    panel1.setBorder(BorderFactory.createTitledBorder(" Search "));
    panel1.setLayout(new GridBagLayout());
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(categoryLabel1, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(entityName1, gbc);
    gbc = new GridBagConstraints();
    searchSabioDatabaseButton = new JButton("Search");
    searchSabioDatabaseButton.addActionListener(eventHandler);
    searchSabioDatabaseButton.setEnabled(true);
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets = new Insets(2, 4, 4, 4);
    panel1.add(searchSabioDatabaseButton, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    p.add(panel1);
    // ------- panel 2 -----------------
    panel2 = new CollapsiblePanel(" Advanced Search ", false, BorderFactory.createLineBorder(new Color(213, 223, 229)));
    panel2.getContentPanel().setLayout(new GridBagLayout());
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.insets = new Insets(4, 4, 4, 1);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.LINE_START;
    JLabel categoryLabel2 = new JLabel("Category");
    categoryList2.setSelectedIndex(3);
    categoryList2.addActionListener(eventHandler);
    JLabel entityLabel2 = new JLabel("Entity");
    entityName2.addActionListener(eventHandler);
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(2, 2, 2, 0);
    panel2.getContentPanel().add(categoryLabel2, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(0, 2, 2, 0);
    panel2.getContentPanel().add(categoryList2, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(2, 2, 2, 0);
    panel2.getContentPanel().add(entityLabel2, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(0, 0, 2, 2);
    panel2.getContentPanel().add(entityName2, gbc);
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    p.add(panel2, gbc);
    // ------- tree ------------------
    JPanel p1 = new JPanel(new BorderLayout());
    p1.add(new JScrollPane(responseTree));
    // ------- the panels -------------
    add(p, BorderLayout.NORTH);
    add(p1, BorderLayout.CENTER);
    ResponseTreeCellRenderer renderer = new ResponseTreeCellRenderer();
    // also available kineticLaw2Icon more colorful
    renderer.setLeafIcon(VCellIcons.kineticLawIcon);
    responseTree.setCellRenderer(renderer);
    responseTree.setRootVisible(false);
    responseTree.getSelectionModel().addTreeSelectionListener(eventHandler);
    // responseTree.addMouseListener( new MouseAdapter(){
    // public void mouseClicked(MouseEvent e){
    // if (e.getClickCount() <= 1) {
    // return;
    // }
    // treeSelectionChanged();	// for double click
    // }
    // });
    responseTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            Object obj = responseTree.getLastSelectedPathComponent();
            if (obj == null || !(obj instanceof BioModelNode)) {
                return;
            }
            BioModelNode selectedNode = (BioModelNode) obj;
            Object userObject = selectedNode.getUserObject();
            setSelectedObjects(new Object[] { userObject });
        }
    });
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) BoxLayout(javax.swing.BoxLayout) Color(java.awt.Color) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) TreeSelectionListener(javax.swing.event.TreeSelectionListener) BioModelNode(cbit.vcell.desktop.BioModelNode) CollapsiblePanel(org.vcell.util.gui.CollapsiblePanel) JTree(javax.swing.JTree) BorderLayout(java.awt.BorderLayout) PathwayStringObject(cbit.vcell.client.desktop.biomodel.BioModelEditorPathwayCommonsPanel.PathwayStringObject) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 4 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class BioModelEditorTreeModel method populateAnnotationNode.

private void populateAnnotationNode() {
    for (BioModelNode node : annotationNodes) {
        if (node.isNodeDescendant(selectedBioModelNode)) {
            selectedBioModelNode = rootNode;
        }
        rootNode.remove(node);
    }
    annotationNodes.clear();
    int childIndex = 0;
    BioModelNode newChild = null;
    Set<MiriamRefGroup> isDescribedByAnnotation = bioModel.getVCMetaData().getMiriamManager().getMiriamRefGroups(bioModel, MIRIAMQualifier.MODEL_isDescribedBy);
    for (MiriamRefGroup refGroup : isDescribedByAnnotation) {
        for (MiriamResource miriamResources : refGroup.getMiriamRefs()) {
            newChild = new MiriamTreeModel.LinkNode(MIRIAMQualifier.MODEL_isDescribedBy, miriamResources);
            rootNode.insert(newChild, childIndex++);
            annotationNodes.add(newChild);
        }
    }
    Set<MiriamRefGroup> isAnnotation = bioModel.getVCMetaData().getMiriamManager().getMiriamRefGroups(bioModel, MIRIAMQualifier.MODEL_is);
    for (MiriamRefGroup refGroup : isAnnotation) {
        for (MiriamResource miriamResources : refGroup.getMiriamRefs()) {
            newChild = new MiriamTreeModel.LinkNode(MIRIAMQualifier.MODEL_is, miriamResources);
            rootNode.insert(newChild, childIndex++);
            annotationNodes.add(newChild);
        }
    }
}
Also used : MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) BioModelNode(cbit.vcell.desktop.BioModelNode) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup) MiriamTreeModel(cbit.vcell.xml.gui.MiriamTreeModel)

Example 5 with BioModelNode

use of cbit.vcell.desktop.BioModelNode in project vcell by virtualcell.

the class BioModelsNetPanel method treeSelectionChanged.

public void treeSelectionChanged() {
    importButton.setEnabled(false);
    Object obj = tree.getLastSelectedPathComponent();
    if (obj == null || !(obj instanceof BioModelNode)) {
        return;
    }
    BioModelNode selectedNode = (BioModelNode) obj;
    Object userObject = selectedNode.getUserObject();
    if (userObject instanceof BioModelsNetModelInfo) {
        importButton.setEnabled(true);
        setSelectedObjects(new Object[] { userObject });
    }
}
Also used : BioModelNode(cbit.vcell.desktop.BioModelNode)

Aggregations

BioModelNode (cbit.vcell.desktop.BioModelNode)82 TreePath (javax.swing.tree.TreePath)22 MolecularComponent (org.vcell.model.rbm.MolecularComponent)17 CSGObject (cbit.vcell.geometry.CSGObject)12 MolecularTypePattern (org.vcell.model.rbm.MolecularTypePattern)11 SimulationContext (cbit.vcell.mapping.SimulationContext)10 MolecularType (org.vcell.model.rbm.MolecularType)10 Point (java.awt.Point)9 Icon (javax.swing.Icon)8 ComponentStateDefinition (org.vcell.model.rbm.ComponentStateDefinition)8 TestSuiteInfoNew (cbit.vcell.numericstest.TestSuiteInfoNew)7 TreeNode (javax.swing.tree.TreeNode)7 DocumentEditorTreeFolderClass (cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass)6 DocumentEditorTreeFolderNode (cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderNode)6 TestCaseNew (cbit.vcell.numericstest.TestCaseNew)6 TestCriteriaNew (cbit.vcell.numericstest.TestCriteriaNew)6 MolecularComponentPattern (org.vcell.model.rbm.MolecularComponentPattern)6 BioPaxObject (org.vcell.pathway.BioPaxObject)6 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)5 Component (java.awt.Component)5