[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 583: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/session.php on line 639: sizeof(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4516: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3262)
Gephi forums •Adding attribute latitude and longitude
Page 1 of 1

Adding attribute latitude and longitude

Posted: 31 May 2016 02:15
by gsthakur
Can some one help me use Java API (0.9x) to add two attributes - latitude and longitude ?

I am unable to add them using the Java API.

current snapshot of the code looks below. I want to add two attributes to this code.

Code: Select all

// Init a project - and therefore a workspace
		ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
		pc.newProject();
		Workspace workspace = pc.getCurrentWorkspace();

		// Get a graph model - it exists because we have a workspace
		GraphModel graphModel = Lookup.getDefault().lookup(GraphController.class).getGraphModel();
                Node v1 = graphModel.factory().newNode(source);
	        v1.setLabel(source);

Re: Adding attribute latitude and longitude

Posted: 31 May 2016 08:12
by eduramiba
HI,

You need to use setAttribute of elements (nodes and edges). https://gephi.org/gephi/0.9.1/apidocs/o ... ement.html

Re: Adding attribute latitude and longitude

Posted: 01 Jun 2016 20:56
by gsthakur
Thank you very much. It worked. Need to lookup the Table as well and add columns

Code: Select all

		
		Table table = Lookup.getDefault().lookup(Table.class);
		table = graphModel.getNodeTable();
		table.addColumn("latitude", Double.class);
		table.addColumn("longitude", Double.class);
		.......
		.......
		Node v1 = graphModel.factory().newNode(source);
		v1.setLabel(source);
		v1.setAttribute("latitude", 34.56);
		v1.setAttribute("longitude", 22.34);