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