Size: 5741
Comment:
|
Size: 5397
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 18: | Line 18: |
'''''Not yet completely written''''' | revised 19 May 2006 (Allan Kuchinsky) |
Line 33: | Line 33: |
I've got a redesigned scheme for context menus somewhat working for the renderer. I have a test case working where I've been able to bring up the node context menus in a modified version of the Agilent literature search tool. This works for node context menus but not yet for edge context menus -- for edges, I am waiting until we find out or determine how to query for edge intersection. | Cytoscape 2.3 will feature a redesigned scheme for context menus which are designed to work with the new renderer. |
Line 35: | Line 35: |
The scheme is based upon a new interface called Node''''''Context''''''Menu''''''Listener, which has one method: | The scheme is based upon two new interfaces called Node''''''Context''''''Menu''''''Listener and Edge''''''Context''''''Menu''''''Listener, each of which has one method for adding menu items to a context menu: |
Line 37: | Line 37: |
{{{void addNodeContextMenuItems (Point pt, Object nodeView, JPopupMenu menu);}}} | {{{void addNodeContextMenuItems (NodeView nodeView, JPopupMenu menu);}}} |
Line 39: | Line 39: |
When you have a class that implements this interface, you add it to the current network view, e.g. in the literature search tool I make a call: | {{{void addEdgeContextMenuItems (EdgeView edgeView, JPopupMenu menu);}}} |
Line 41: | Line 41: |
{{{((DGraphView) Cytoscape.getCurrentNetworkView()).addNodeContextMenuListener(this);}}} | The Cy''''''Network interface defines methods for adding node and edge context listeners, so when you have a class that implements these interfaces, you add objects of that class to the current network view, e.g. |
Line 43: | Line 43: |
I am thinking about whether this should be pushed up to the Cy''''''Network level to eliminate the need for typecasting, but initially I couldn't get this to work without moving the associated mouse handling code up to the Cytoscape level, where I don't think it should be. In any event, I think we can worry about this detail later. | {{{Cytoscape.getCurrentNetworkView().addNodeContextMenuListener(this);}}} |
Line 45: | Line 45: |
The routine for building the context menu is in the Inner''''''Canvas class. Basic idea is that the Inner''''''Canvas instantiates the popup menu, calls the addNodeContextMenuItems() method on each Node''''''Context''''''Menu''''''Listener, then shows the menu. | {{{Cytoscape.getCurrentNetworkView().addEdgeContextMenuListener(this);}}} |
Line 47: | Line 47: |
Each Node''''''Context''''''Menu''''''Listener can add J''''''Menu''''''Items, separators, basically do whatever it wants with the J''''''Popup''''''Menu that is passed in to it, all of this using the conventional swing methods for building up menu items. Under the current scheme, each Node''''''Context''''''Menu''''''Listener is responsible for checking whether the JMenuItem already exists on the menu and doing other sanity checks. I am considering whether some global management of the J''''''Popup''''''Menu should be done in the Inner''''''Canvas routine that instantiates and shows the menu, but I'm not sure if that makes sense. | The routines for building the context menus are in the Inner''''''Canvas class. Basic idea is that the Inner''''''Canvas instantiates the popup menu, then, depending upon whether a Node''''''View or Edge''''''View is the object right-clicked upon, calls the addNodeContextMenuItems() method on each Node''''''Context''''''Menu''''''Listener or the addEdgeContextMenuItems() method on each Edge''''''Context''''''Menu''''''Listener , then shows the menu. |
Line 49: | Line 49: |
I think this is a more direct and simpler scheme than what has been done for context menus under Cytoscape 2.2. |
Each Node''''''Context''''''Menu''''''Listener and Edge''''''Context''''''Menu''''''Listener can add J''''''Menu''''''Items, separators, basically do whatever it wants with the J''''''Popup''''''Menu that is passed in to it, all of this using the conventional swing methods for building up menu items. Under the current scheme, each Node''''''Context''''''Menu''''''Listener and Edge''''''Context''''''Menu''''''Listener is responsible for checking whether the JMenuItem already exists on the menu and doing other sanity checks. This is a more direct and simpler scheme than what has been done for context menus under Cytoscape 2.2. |
Line 53: | Line 55: |
It appears possible to add tooltip functionality to the renderer without requiring any changes to plugins and other code that uses tooltips. | We have been able to add Node''''''View tooltip functionality to the renderer without requiring any changes to plugins and other code that uses tooltips. |
Line 55: | Line 57: |
The renderer's Inner''''''Canvas class is a J''''''Component, thus one can setToolTipText() on it. I modified the D''''''Node''''''View class -- not a J''''''Component -- to maintain an instance variable that is set whenever a call to setToolTip() is made, e.g. when the literature search calls Node''''''View.setToolTip(). Then, when the mouse hovers over a node on the canvas, the canvas does a call to DNodeView.getToolTip() for that node, then does a setToolTipText() on itself using the text retrieved from the D''''''Node''''''View. |
The renderer's Inner''''''Canvas class is a J''''''Component, thus one can setToolTipText() on it. We modified the D''''''Node''''''View class -- not a J''''''Component -- to maintain an instance variable that is set whenever a call to setToolTip() is made, e.g. when the literature search calls Node''''''View.setToolTip(). Then, when the mouse hovers over a node on the canvas, the canvas does a call to DNodeView.getToolTip() for that node, then does a setToolTipText() on itself using the text retrieved from the D''''''Node''''''View. For performance reasons, tooltips on Edge''''''Views are '''not''' implemented in Cytoscape 2.3. |
Line 61: | Line 65: |
For testing purposes, an experimental version of the renderer's view package, ding.view, can be obtained in the attachment attachment:ding.jar Place this ding.jar file in the cytoscape/lib directory and rebuild cytoscape. An experimental version of the Cytoscape''''''Editor, which contains context menu items and has been updated to drag and drop Nodes and Edges to the ding Inner''''''Canvas, can be obtained in the attachment attachment:CytoscapeEditor.jar Place the Cytoscape''''''Editor.jar file in the cytoscape/plugins/core directory. |
|
Line 86: | Line 83: |
The changes to context menu handling are '''not''' backward compatible with earlier versions of Cytoscape. There is '''no''' migration path for the previous context menu handling methods, which were tightly coupled to Piccolo. We should give plugin writers ample time to accommodate these changes and test their plugins. |
RFC Name : ... |
Editor(s): ... |
About this document
This is an official Request for Comment (RFC) for adding tooltip and context menu functionality to the Cytoscape 2.3 renderer.
For details on RFCs in general, check out the [http://www.answers.com/main/ntquery?method=4&dsid=2222&dekey=Request+for+Comments&gwp=8&curtab=2222_1&linktext=Request%20for%20Comments Wikipedia Entry: Request for Comments (RFCs)]
Status
revised 19 May 2006 (Allan Kuchinsky)
How to Comment
To view/add comments, click on any of 'Comment' links below. By adding your ideas to the Wiki directly, we can more easily organize everyone's ideas, and keep clear records. Be sure to include today's date and your name for each comment. Here is an example to get things started: ["/Comment"].
Try to keep your comments as concrete and constructive as possible. For example, if you find a part of the RFC makes no sense, please say so, but don't stop there. Take the extra step and propose alternatives.
Proposal
Context Menus
Cytoscape 2.3 will feature a redesigned scheme for context menus which are designed to work with the new renderer.
The scheme is based upon two new interfaces called NodeContextMenuListener and EdgeContextMenuListener, each of which has one method for adding menu items to a context menu:
void addNodeContextMenuItems (NodeView nodeView, JPopupMenu menu);
void addEdgeContextMenuItems (EdgeView edgeView, JPopupMenu menu);
The CyNetwork interface defines methods for adding node and edge context listeners, so when you have a class that implements these interfaces, you add objects of that class to the current network view, e.g.
Cytoscape.getCurrentNetworkView().addNodeContextMenuListener(this);
Cytoscape.getCurrentNetworkView().addEdgeContextMenuListener(this);
The routines for building the context menus are in the InnerCanvas class. Basic idea is that the InnerCanvas instantiates the popup menu, then, depending upon whether a NodeView or EdgeView is the object right-clicked upon, calls the addNodeContextMenuItems() method on each NodeContextMenuListener or the addEdgeContextMenuItems() method on each EdgeContextMenuListener , then shows the menu.
Each NodeContextMenuListener and EdgeContextMenuListener can add JMenuItems, separators, basically do whatever it wants with the JPopupMenu that is passed in to it, all of this using the conventional swing methods for building up menu items. Under the current scheme, each NodeContextMenuListener and EdgeContextMenuListener is responsible for checking whether the JMenuItem already exists on the menu and doing other sanity checks.
This is a more direct and simpler scheme than what has been done for context menus under Cytoscape 2.2.
Tooltips
We have been able to add NodeView tooltip functionality to the renderer without requiring any changes to plugins and other code that uses tooltips.
The renderer's InnerCanvas class is a JComponent, thus one can setToolTipText() on it. We modified the DNodeView class -- not a JComponent -- to maintain an instance variable that is set whenever a call to setToolTip() is made, e.g. when the literature search calls NodeView.setToolTip(). Then, when the mouse hovers over a node on the canvas, the canvas does a call to DNodeView.getToolTip() for that node, then does a setToolTipText() on itself using the text retrieved from the DNodeView.
For performance reasons, tooltips on EdgeViews are not implemented in Cytoscape 2.3.
Biological Questions / Use Cases
General Notes
Requirements
Deferred Items
Open Issues
Are we supposed to use the m_spacial index in DGraphView to figure out which node(s) have been clicked on? Is that the right approach?
How do we figure out what edges have been clicked on?
What's with all of the bitwise complements? Why are these necessary?
What is the reason for the star shaped polygon requirement?
Backward Compatibility
The changes to context menu handling are not backward compatible with earlier versions of Cytoscape. There is no migration path for the previous context menu handling methods, which were tightly coupled to Piccolo.
We should give plugin writers ample time to accommodate these changes and test their plugins.
Expected growth and plan for growth
References
Implementation Plan
- ["/Implementation Plan"]