[SOLVED] Accessing AttributeModel in StatisticsUI panel

Computing metrics, community detection and data handling
Post Reply [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
srubin
Posts:1
Joined:21 Feb 2011 21:52
[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
[SOLVED] Accessing AttributeModel in StatisticsUI panel

Post by srubin » 21 Feb 2011 21:58

I'm trying to write a statistics plugin that calculates a metric based on a user-selected node attribute. It would be ideal for me to, in the metric's UI, include a JComboBox that had an option for each node attribute. To do this, I would need access to the graph's AttributeModel in the MetricPanel class (and actually, having access to the GraphModel would be nice too). Is this possible? Am I missing something obvious?

Thanks!

admin
Gephi Community Manager
Posts:964
Joined:09 Dec 2009 14:41
[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: Accessing AttributeModel in StatisticsUI panel

Post by admin » 21 Feb 2011 22:44

That's right!

Here is the snippet to list node attribute columns:

Code: Select all

AttributeController ac = Lookup.getDefault().lookup(AttributeController.class);
AttributeModel model = ac.getModel();
for (AttributeColumn col : model.getNodeTable().getColumns()) {
    //do what you want here
}

User avatar
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: Accessing AttributeModel in StatisticsUI panel

Post by mbastian » 22 Feb 2011 04:12

And here for the GraphModel:

Code: Select all

GraphController gc = Lookup.getDefault().lookup(GraphController.class);
GraphModel model = gc.getModel();
Add GraphAPI as a dependency of you module also

Post Reply
[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
[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