I am creating a directed graph dynamically based on data I receive. I want to colour code the edges automatically at not based on any condition.
Transformer<String, Paint> edgePaint = new Transformer<String, Paint>()
{
private final Color[] palette = {Color.GREEN, Color.YELLOW, Color.RED, Color.GRAY, Color.BLUE, Color.CYAN, Color.WHITE, Color.orange};
int i=0;
@Override
public Paint transform(String graphEdge)
{
if(i == 7)
{
i = 0;
}
else
{
i = i + 1;
}
return palette[i];
}
};
I tried the above code, but each time I zoom - the colour for each edge changes. How can I colour my edges without any condition? I want a random colour to be assigned to each edge. Also, the name of the edge is not predictable and it varies with the kind of data I recieve.
Is there any fix ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you want a consistent (random) color per edge, create a Map<[edge type], Paint> in which you store the colors that you want, and build a Transformer based on that Map. Or create a specialized edge type that contains a field for the color, and base your Transformer on that.
As it is, you're basically asking for a new color every time the graph gets repainted.
(These days, it's better to post questions like this on StackOverflow with the 'jung' tag; they'll get much better visibility that way. SourceForge's RSS feed for discussions is kind of busted.)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am creating a directed graph dynamically based on data I receive. I want to colour code the edges automatically at not based on any condition.
I tried the above code, but each time I zoom - the colour for each edge changes. How can I colour my edges without any condition? I want a random colour to be assigned to each edge. Also, the name of the edge is not predictable and it varies with the kind of data I recieve.
Is there any fix ?
If you want a consistent (random) color per edge, create a Map<[edge type], Paint> in which you store the colors that you want, and build a Transformer based on that Map. Or create a specialized edge type that contains a field for the color, and base your Transformer on that.
As it is, you're basically asking for a new color every time the graph gets repainted.
(These days, it's better to post questions like this on StackOverflow with the 'jung' tag; they'll get much better visibility that way. SourceForge's RSS feed for discussions is kind of busted.)