Accesing GraphModel from TopComponent class

Please use a mailing-list, see http://gephi.org/developers/
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
rmaestrem
Posts:1
Joined:27 Jan 2012 09:32
[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
Accesing GraphModel from TopComponent class

Post by rmaestrem » 27 Jan 2012 09:37

Hi everyone!
Our team has developed a tool for analize realtime information using the "time" component. We have added a UI using TopComponent (http://wiki.gephi.org/index.php/Plugin_ ... 5_minutes)) but i do not find how can interacte with Graphmodel ... adding nodes and edges, deleting nodes and edges, etc ... ¿Is is necessary another class ... may a generator ?

Best regards.

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: Accesing GraphModel from TopComponent class

Post by mbastian » 01 Feb 2012 08:40

Hi

You you'll need to add Lookup API to the dependencies of your module and use Lookup to find the Graph Controller:

Code: Select all

GraphController gc = Lookup.getDefault().lookup(GraphController.class);
GraphModel graphModel = gc.getModel();
Graph graph = graphModel.getGraph();
Lookup is a the tool to find controllers within Gephi, and in general any implementation of a service. It allows to separate the APIs and their implementation in an elegant way. All controllers in Gephi are singletons so the graph controller is always the same. The models are attached to the current workspace and when you do "getModel()" it gets the model for the current workspace. If you look at some of the Gephi modules (DesktopFilters, DesktopRanking...) you'll see that the UI (usually the TopComponent or a UI Controller) listens to workspace events to be notified when the user selects a different workspace. The action taken is usually to refresh the data in the view using the new 'current' model.

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