问题
In my app i want to set every egde with diffrent style. It can be edge colour or edge thickness. I've read about transformers in JUNG, but i didn't find anytging useful.
Do you know any way to set specific colour or line thickness to specific edge? It can be some kind of Transformer or class having methods like setWidth() or setColour(). Example would be nice;)
回答1:
Thank's, and here is 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);
回答2:
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 in applet form on the JUNG website.
来源:https://stackoverflow.com/questions/9649949/jung2-how-to-set-custom-egde-color-thick-transformer