JUNG2 - how to customize your own color / fat egde transformer
In my application, I want to install each egde with a different style. This can be the color of the edges or the thickness of the edges. I read about transformers in JUNG but I didn't find anything useful.
Do you know of any way to set a specific color or line weight for a specific edge? It could be some kind of transformer or a class that has methods like setWidth () or setColour (). An example would be nice;)
+3
przebar
source
to share
2 answers
Thanks and here's a working example:
private Transformer<String, Paint> edgePaint = new Transformer<String, Paint>() {
public Paint transform(String s) {
return Color.RED;
}
};
private Transformer<String, Stroke> edgeStroke = new Transformer<String, Stroke>() {
float dash[] = { 10.0f };
public Stroke transform(String s) {
return new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
}
};
(...)
vv.getRenderContext().setEdgeDrawPaintTransformer(edgePaint);
vv.getRenderContext().setEdgeStrokeTransformer(edgeStroke);
+6
przebar
source
to share
The class you want is PluggableRendererContext. There is an example that uses it extensively (PluggableRendererDemo), whose source code is in the distribution, and which is demonstrated as an applet on the JUNG website.
+2
Joshua O'Madadhain
source
to share