Writing custom module/plugin

Extensions and customization
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
Warlax
Posts:18
Joined:19 May 2010 20:45
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
Writing custom module/plugin

Post by Warlax » 19 May 2010 20:50

Hi,

We are very impressed with Gephi at our company.
We need to write our own modules for Gephi; basically, I need to write a filter and a metric/statistics/visualization.

I have downloaded the Gephi source code and loaded it in NetBeans - I can see all the different modules and open each one I want to look in as a project - no problem.

Say I wish to start writing my own filter, there are 4 modules with the work 'filter' in them:
1. Filters API
2. Filters Impl
3. Filters Plugin
4. Filters Plugin UI

What is the suggested workflow/approach to start extending the filters plugin to do one extra thing?
Thank you,
Warlax.

User avatar
mbastian
Gephi Architect
Posts:728
Joined:10 Dec 2009 10:11
Location:San Francisco, CA
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Writing custom module/plugin

Post by mbastian » 19 May 2010 23:41

Hi

Welcome here!

Gephi has a modular architecture and therefore features are splitted in separate modules as you can see. Existing filters can be found in the FiltersPlugin and FiltersPluginUI.

For adding a new filter you just add a new module and implement a Filter interface there. First create a new module, it's explained on this page.

I updated the documentation how to create a new filter implementation on the javadoc. See the instructions down. It's not so much for the moment so I can help if you come with some questions.

Once you have written your FilterBuilder and Filter implementations and you declared them with @ServiceProvider it's automatically recognized and your filter will appear in the UI.

Warlax
Posts:18
Joined:19 May 2010 20:45
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Writing custom module/plugin

Post by Warlax » 25 May 2010 18:47

Hi.
I am following your instructions.
Making my own plugin is definitely a better approach than modifying an existing one.
I have two questions:

Question 1: on the Javadoc page it says:
4. Create a new class that implements either NodeFilter, EdgeFilter or ComplexFilter. Set instantiation code in LayoutBuilder.buildLayout().
What do you mean by "Set instantiation code in LayoutBuilder.buildLayout()"? Do I need an inner class in my *Filter implementation named LayoutBuilder?

Question 2: on the Javadoc page it says:
3. Add @ServiceProvider annotation to your builder, that it can be found by the system. Set FilterBuilder as the annotation parameter.
So I did that. But here in this message you said:
Once you have written your FilterBuilder and Filter implementations and you declared them with @ServiceProvider it's automatically recognized and your filter will appear in the UI.
Do you mean the Filter implementation also needs to be annotated with @ServiceProvider? I am looking at the EgoBuilder and EgoFilter classes as examples. The EgoFilter is actually a static inner class inside EgoBuilder and is not annotated with @ServiceProvider. Is it not annotated just because it's inside the Builder class which is annotated? That being said, if I put my Filter implementation in a separate java file, do I need to annotate it?

Thanks for your help.
Very impressive framework.

Warlax
Posts:18
Joined:19 May 2010 20:45
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Writing custom module/plugin

Post by Warlax » 25 May 2010 19:27

By the way:

In your guide for creating a filter, you should mention that the Swing Layout Extension integration library wrapper should be added as a fourth dependency for the new plugin.

User avatar
mbastian
Gephi Architect
Posts:728
Joined:10 Dec 2009 10:11
Location:San Francisco, CA
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Writing custom module/plugin

Post by mbastian » 25 May 2010 21:25

What do you mean by "Set instantiation code in LayoutBuilder.buildLayout()"? Do I need an inner class in my *Filter implementation named LayoutBuilder?
Don't pay attention to this sentence, it's a stupid copy-paste mistake... :?
Do you mean the Filter implementation also needs to be annotated with @ServiceProvider? I
No sorry if I wasn't precise, but only FilterBuilder has to have the @ServiceProvider annotation, as you can observe it with existing filters.
Is it not annotated just because it's inside the Builder class which is annotated?
The EgoFilter is an inner class just because I found it more convenient, you can put your filter in another class, no problem.

To sum up, the builder's role is to create filters. The annotation's role is to say "hey! system...I'm a builder and you can ask me if you need a filter". The system's role is to maintain a list of all builders and ask them to return a filter instance when needed. The filter's role is to filter :D

Warlax
Posts:18
Joined:19 May 2010 20:45
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Writing custom module/plugin

Post by Warlax » 25 May 2010 22:11

Thank you for the quick response.
I am already creating my own filter and am running my build of Gephi to test it out as I write these words.

Another question: is there access to anything like an adjacency matrix for the nodes of the graph?

Adjacency Matrix on Wikipedia:
http://en.wikipedia.org/wiki/Adjacency_matrix

User avatar
mbastian
Gephi Architect
Posts:728
Joined:10 Dec 2009 10:11
Location:San Francisco, CA
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Writing custom module/plugin

Post by mbastian » 25 May 2010 23:00

Cool!
Another question: is there access to anything like an adjacency matrix for the nodes of the graph?
No that is not possible in the Graph API for the moment. I added it to Ideas.

a.oboturov
Posts:4
Joined:06 Apr 2011 10:58
Location:Paris, France
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Writing custom module/plugin

Post by a.oboturov » 19 Apr 2011 09:44

Any further development on adjacent matrices topic or it's still an idea to be developed?

If there's no adjacency matrices - there is, probably, no matrices libraries (for eigenvalues computation) attached to Gephi?

Thanks,
Artem

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable