[Gephi-plugins] Creating a new graph

Mathieu Bastian mathieu.bastian at gmail.com
Fri Nov 4 16:33:46 CET 2011


Hi Amanda,

Gephi uses the Lookup (http://wiki.netbeans.org/AboutLookup) to retrieve
implementations dynamically. For instance this is how to get the project
controller, which is a singleton:

ProjectController controller =
Lookup.getDefault().lookup(ProjectController.class);

To do what you what you have two choices. You can either create a new
workspace (from the Project Controller) and copy yourself the data from one
workspace to another or use the FIlters API.

The first solution would look like this:

ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
Workspace currentWorkspace = pc.getCurrentWorkspace();
Workspace newWorkspace = pc.newWorkspace(pc.getCurrentProject());

Graph currentGraph = gc.getModel(currentWorkspace).getGraph();
//Copy the complete graph to the new workspace
gc.getModel(newWorkspace).pushFrom(currentGraph);

The second solution is creating a filter (see
http://wiki.gephi.org/index.php/Toolkit_-_Filter) and the use the *
exportToNewWorkspace<http://gephi.org/docs/api/org/gephi/filters/api/FilterController.html#exportToNewWorkspace(org.gephi.filters.api.Query)>
*() method in the FiltersController. That will not change the original
graph and create a new workspace with directly the good elements.

Mathieu

On Fri, Nov 4, 2011 at 6:46 AM, Amanda Lannie <alanniebu at yahoo.com> wrote:

>  Hi,
>
> I'm trying to write a plug-in that takes the graph on the current
> worksheet and creates a new one from it by removing nodes and edges. I need
> the original graph to make comparisons to the new graph, so I can't
> overwrite the original.  What I can't figure out how to do is create a new
> graph since everything in the API is an interface.  From my reading, it
> seems that I need a new model and worksheet, but again those are
> interfaces.  Any help would be greatly appreciated.
>
> Amanda
>
> _______________________________________________
> gephi-plugins mailing list
> gephi-plugins at lists.gephi.org
> http://gephi.org/mailman/listinfo/gephi-plugins
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gephi.org/pipermail/gephi-plugins/attachments/20111104/7f2819b2/attachment-0001.html>


More information about the gephi-plugins mailing list