Possible to set dynamic node label (or size) in a generator?

Extensions and customization
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
kaigephi
Posts:11
Joined:18 Mar 2011 12:28
[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
Possible to set dynamic node label (or size) in a generator?

Post by kaigephi » 23 Apr 2011 12:56

I am aware of discussions that dynamic visual attributes are not supported yet. However, they all used gexf file whereas I try do it in a generator plugin.

Looking at DynamicGraph.java, it is possible to change the edge weight/width dynamically. I used a similar approach (replace the attribute column with a dynamic one) to create a dynamic label and below is my code:

Code: Select all

NodeDraft node = container.factory().newNodeDraft();

AttributeColumn oldLabelCol = container.getAttributeModel().getNodeTable().getColumn(PropertiesColumn.NODE_LABEL.getIndex());
AttributeColumn dynamicLabelCol = container.getAttributeModel().getNodeTable().replaceColumn(oldLabelCol,PropertiesColumn.NODE_LABEL.getId(),PropertiesColumn.NODE_LABEL.getTitle(),AttributeType.DYNAMIC_STRING,AttributeOrigin.PROPERTY,null);

Random random = new Random();
DynamicString dynamicLable = new DynamicString(new Interval<String>(2000,2001,false,true,""+random.nextInt(20)));
for (int j=1; j<10; j++) {
      dynamicLable = new DynamicString(dynamicLable, new Interval<String>(2000+j,2001+j,false,true,""+random.nextInt(20)));
}
dynamicLable = new DynamicString(dynamicLable, new Interval<String>(2010,2011,false,false,""+random.nextInt(20)));

node.addAttributeValue(dynamicLabelCol, dynamicLable);

container.addNode(node);
The plugin runs fine (no error reported). However, once finished, Gephi always returns the following error:

Code: Select all

java.lang.NumberFormatException: empty String
	at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:992)
	at java.lang.Double.parseDouble(Double.java:510)
	at org.gephi.data.attributes.api.AttributeType.parseDynamic(AttributeType.java:220)
	at org.gephi.data.attributes.api.AttributeType.parse(AttributeType.java:172)
	at org.gephi.data.attributes.AttributeTableImpl.replaceColumn(AttributeTableImpl.java:180)
	at uk.ac.mdx.idc.DynamicLabelTestGenerator.generate(DynamicLabelTestGenerator.java:35)
	at org.gephi.desktop.generate.DesktopGeneratorController$3.run(DesktopGeneratorController.java:106)
[catch] at org.gephi.utils.longtask.api.LongTaskExecutor$RunningLongTask.run(LongTaskExecutor.java:230)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
	at java.util.concurrent.FutureTask.run(FutureTask.java:138)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)

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