[Gephi-plugins] obtain the selected nodes from a plugin ?

Mathieu Bastian mathieu.bastian at gmail.com
Thu Jan 20 17:27:39 CET 2011


Here is the way to do that, it doesn't look good, it's old non modular code:

Add VisualizationModule to dependencies,

AbstractEngine engine = VizController.getInstance().getEngine();
GraphController graphController =
Lookup.getDefault().lookup(GraphController.class);
Graph = graphController.getModel().getGraphVisible();

ModelImpl[] selectedNodeModels =
engine.getSelectedObjects(AbstractEngine.CLASS_NODE);
for (int i = 0; i < selectedNodeModels.length; i++) {
Node node = ((NodeData)
selectedNodeModels[i].getObj()).getNode(graph.getView().getViewId());
if (node != null) {
   //Selected node
}

You can also get events from the viz engine, in the sane way the tools
module receive them, it's a bit low-level but it works good:

AbstractEngine engine = VizController.getInstance().getEngine();
VizEventManager evtManager = engine.getVizEventManager();
VizEventListener vizListener = new VizEventListener() {
   //Implement methods
};
evtManager.addListener(vizListener);

Mathieu

On Thu, Jan 20, 2011 at 8:05 AM, Erwan Demairy
<erwan.demairy at imap.inria.fr> wrote:
> Hello,
> Maybe being more specific will help someone  to give me a clue:
> - I would like to write a layout plugin where a specific node can be clicked
> and used as the starting point for the layout algorithm (it is for a
> tree-based layout algorithm).
> - I cannot figure out how to interact with the visualisation window from a
> layout plugin. I was thinking to install a NodeClickEventListener, but if
> you are not inside a tool plugin, I do not see how to do it.
> - another way would be to be able to call the existing selection tools, but
> here also I am stucked and do not see in the interfaces of the
> SelectionManager what could help me to (i) call the mouse selection and (ii)
> retrieve what was selected.
> Any advice would be greatly appreciated :)
> Erwan
> _______________________________________________
> gephi-plugins mailing list
> gephi-plugins at lists.gephi.org
> http://gephi.org/mailman/listinfo/gephi-plugins
>


More information about the gephi-plugins mailing list