I'm currently scaling the thickness of my edges based on their weights and would like the thicker edges to end up on top of the thinner, more plentiful edges.
How can I accomplish this?
[SOLVED] How to specify Z order of edges?
- 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: How to specify Z order of edges?
That should be quite easy to do. If you look at the Preview SPI you'll see an ItemBuilder interface. That is what is building the Preview objects. It returns a list of items and this list is later used for drawing, in the same order.
By sorting this list by edge weight it will do the job. You can write a plugin that will overwrite (and extend) the default EdgeBuilder class (located in the PreviewPlugin module).
It should look like this:
By sorting this list by edge weight it will do the job. You can write a plugin that will overwrite (and extend) the default EdgeBuilder class (located in the PreviewPlugin module).
It should look like this:
Code: Select all
@ServiceProvider(service = ItemBuilder.class, supersedes = "org.gephi.preview.plugin.builders.EdgeBuilder")
public class MyEdgeItemBuilder extends EdgeBuilder {
@Override
public Item[] getItems(Graph graph, AttributeModel attributeModel) {
EdgeItem[] items = (EdgeItem[]) super.getItems(graph, attributeModel);
Arrays.sort(items, new Comparator<EdgeItem>() {
@Override
public int compare(EdgeItem o1, EdgeItem o2) {
Float w1 = o1.getData(EdgeItem.WEIGHT);
Float w2 = o2.getData(EdgeItem.WEIGHT);
return w1.compareTo(w2);
}
});
return items;
}
}