JUNG2 - how to set custom egde color/thick transformer

妖精的绣舞 提交于 2019-12-07 16:23:20

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!