oxfordinternetinstitute / gephi-plugins

Switch to the sigmaexporter-plugin branch (https://github.com/oxfordinternetinstitute/gephi-plugins/tree/sigmaexporter-plugin/modules/sigmaExporter) or jsonexporter-plugin branch (https://github.com/oxfordinternetinstitute/gephi-plugins/tree/jsonexporter-plugin/modules/JsonExporter) for the relevant code.
http://blogs.oii.ox.ac.uk/vis/
63 stars 28 forks source link

SigmaExporter with Gephi Tookint #52

Closed kercos closed 9 years ago

kercos commented 9 years ago

Hi,

I was wondering if it is possible to use the SigmaExporter plugin for Gephi without the UI, i.e., using the Gephi toolkit. I've managed to import the SigmaExporter.jar in my Eclipse project, but don't know how to output the file.

For exporting a graaph to SVG I use the following: ExportController ec = Lookup.getDefault().lookup(ExportController.class); ec.exportFile(new File("data/output.svg"));

Is there something similar for SigmaExporter, along the following lines? SigmaExporter se=(SigmaExporter)ec.getExporter("data/test"); se.setWorkspace(workspace); se.execute();

Thanks in advance

computermacgyver commented 9 years ago

Hi Kercos,

I haven't done this, but it should be possible. I just followed the standard exporter plugin template. The exporter basically does three things: 1) Extract a zip file of all the standard HTML/JavaScript that doesn't change from one visualization to the next. 2) Write a JSON file (data.json) of all the nodes and edges in the network 3) Write a JSON file (config.json) that gives the titles, options, etc. set in the dialogue box.

You would need to get an instance of the SigmaExporter class and set the workspace, output path, and config file before calling the execute method.

The config.json file is just a matter of populating the variables in the ConfigFile class.

If you don't want to deal with the whole SigmaExporter class, you may find that the JSONExporter plugin is easier. That would just produce the data.json file, but all that needs to happen then is add the config file and the files in the zip linked above. I write the config file to JSON using Google's GSON library, but anything similar would work just fine.

kercos commented 9 years ago

Thanks computermacgyver!

I've finally managed to solve the issue:

ProjectController pc = Lookup.getDefault().lookup(ProjectController.class); pc.newProject(); Workspace workspace = pc.getCurrentWorkspace(); ... // do standard things with workspace (build graph) SigmaExporter se = new SigmaExporter();
se.setWorkspace(workspace); ConfigFile cf = new ConfigFile(); cf.setDefaults(); se.setConfigFile(cf, "data/", false); se.execute();

computermacgyver commented 9 years ago

Awesome. Thank you for sharing back the working example. I've added it to the Wiki in this repository.