Double-click action on edges

45 views
Skip to first unread message

tainlan

unread,
Dec 22, 2009, 10:32:36 PM12/22/09
to cytoscape-discuss
Hi,
My plugin need to define a own action when double - clicking on
edges.
However, in cytoscape editor, the double-click action is that the
editor's SIF-interpreter is invoked.

Is there any way to remove or inhibit the SIF-interpreter action from
a network?
If so, how could I do this?

Thanks!

Tain

Jing Gao

unread,
Dec 23, 2009, 10:46:15 AM12/23/09
to cytoscape-discuss
Hi,
Here is how I did:
1. Create a mouse listener class:
public class ListenMouse implements MouseListener, MouseMotionListener
{

2. Add mouse listener to network:
public ListenMouse(){

view=Cytoscape.getCurrentNetworkView();
((DGraphView) view).getCanvas().addMouseListener(this);
((DGraphView) view).getCanvas().addMouseMotionListener
(this);

}

3. Detect mouse click:
public void mouseClicked(MouseEvent e){
EdgeView ev =((DGraphView) view).getPickedEdgeView
(e.getPoint ());
if (ev!=null){//if click on an edge, do something here}


Hope this helps.
Jing

tainlan

unread,
Dec 23, 2009, 5:35:28 PM12/23/09
to cytoscape-discuss
Hi, Jing
Really helpful!!

Thanks alot!! Happy holiday!!

Alvin

unread,
Mar 28, 2012, 2:54:09 AM3/28/12
to cytoscap...@googlegroups.com
Hi,
 
I would like to enquire about the things to add to my code shown below.
I want to get my mouse listener to detect and display a message when the mouse cursor enters a node.
How should I add the mouse listener?
 
public class MouseTest extends CytoscapePlugin

    public MouseTest()
    {
        MouseListenerTest mlt = new MouseListenerTest(this);
       
        Cytoscape.getDesktop().addMouseListener(mlt);      
        
    }
   
    public class MouseListenerTest implements MouseListener   
    {
        CyNetworkView view;
        public MouseListenerTest(MouseTest myPlugin)
        {
            view = Cytoscape.getCurrentNetworkView();
            ((DGraphView) view).getCanvas().addMouseListener(this);
         }
        public void mouseClicked(MouseEvent e)  { }
        public void mousePressed(MouseEvent e) { }
        public void mouseReleased(MouseEvent e) {}
        public void mouseEntered(MouseEvent e)
        {
                         JOptionPane.showMessageDialog(Cytoscape.getDesktop(), "Mouse Entered");
        }
        public void mouseExited(MouseEvent e) {}
}
 
Thanks!
Reply all
Reply to author
Forward
0 new messages