Node Double Click Listener

Please use a mailing-list, see http://gephi.org/developers/
Post Reply
uclatommy
Posts: 3
Joined: 31 Aug 2014 00:24
Location: Los Angeles
Contact:

Node Double Click Listener

Post by uclatommy » 31 Aug 2014 00:31

Hi,

I'm new to the api and I'm trying to write a plugin that would allow me to respond to a double click on a node. Ideally, I'd like the double click to read a node attribute representing a file location and open the file.

Which packages should I look at to best accomplish this?

Thanks,
Thomas

User avatar
eduramiba
Gephi Code Manager
Posts: 975
Joined: 22 Mar 2010 15:30
Location: Madrid, Spain

Re: Node Double Click Listener

Post by eduramiba » 01 Sep 2014 17:32

Hi,

At the moment it can only be done in Preview panel.
Check this thread https://forum.gephi.org/viewtopic.php?f ... =20#p10342

uclatommy
Posts: 3
Joined: 31 Aug 2014 00:24
Location: Los Angeles
Contact:

Re: Node Double Click Listener

Post by uclatommy » 05 Sep 2014 06:59

So I've decided to take a different approach with my plugin-- no more double click to open associated files. Instead, I'm reading the file into a panel and editing the contents from within Gephi. The panel jumps to the correct file when the a node is clicked. The files I'm reading are c++ and the nodes represent functions that are defined in a financial modeling platform called Moses. The editor has buttons to connect to tortoiseSVN which can update, revert, etc.. the files. The edges represent references to other functions similar to performing a function trace in excel. This has turned out to be a really great way to visualize our financial models! Some models can get extremely complex! Here's a brand new model that barely has any functions defined in it:

Image

Right now, the programming is terrible and I would like to refactor it. I also want to implement more functionality but will probably need to use an observer pattern. I'm new to Java, so can someone explain to me what this code snippet is doing?

Code: Select all

    @Override
    public ToolEventListener[] getListeners() {
        return new ToolEventListener[]{new NodeClickEventListener() {

                @Override
                public void clickNodes(Node[] nodes) {
                    if (nodes.length > 0) {
                        edc.editNode(nodes[0]);
                    } else {
                        edc.disableEdit();
                    }
                }
            }};
    }
I found it in https://github.com/gephi/gephi/blob/mas ... /Edit.java. I understand what the @Override means, but I don't understand the return statement.

User avatar
eduramiba
Gephi Code Manager
Posts: 975
Joined: 22 Mar 2010 15:30
Location: Madrid, Spain

Re: Node Double Click Listener

Post by eduramiba » 06 Sep 2014 01:06

Hi,

Right, I forgot you could create a tool and use it to react to clicking on nodes in Overview.

That statement is basically creating an array of event listeners (a single NodeClick listener in this case) for the tool and returning it to the method caller.
This is necessary so the ToolsAPI is able to collect all tools and obtain any event listener that the Tool may need by calling the getListeners method.

So, any ToolPlugin has to implement a common interface: https://github.com/gephi/gephi/blob/mas ... /Tool.java


Eduardo

Post Reply