Question

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;)

Was it helpful?

Solution

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);

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top