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.
Accesing GraphModel from TopComponent class
- 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
Hi
You you'll need to add Lookup API to the dependencies of your module and use Lookup to find the Graph Controller:
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.
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();