A glitch with Edge label offset

雨燕双飞 提交于 2020-01-04 10:38:11

问题


I have peculiar problem when I tried to offset the edge label in my Jung2 network.

As shown in figure below the label causes the self loop difficult to see.

So I decided to offset the label:

vv.getRenderContext().setLabelOffset(20);

And the Effect:

Offset is effective for all the edges except for the edge that I need: the self loop. Anyone has a solution or a workaround ?

EDIT:

Does anyone know what the EdgeLabelClosenessTransformer does? And how to use it? This may solve my problem.

 vv.getRenderer().getVertexLabelRenderer().setEdgeLabelClosenessTransfomer();

UPDATE:

I tried this, but the self loop label is unaffected.

 vv.getRenderContext().setEdgeLabelClosenessTransformer(
            new Transformer<Context<Graph<Node, Edge>, Edge>, Number>() {
                /**
                 * @see Transformer#transform(Object)
                 */
                public Number transform(
                        Context<Graph<Node, Edge>, Edge> context) {
                    Graph<Node, Edge> graph = context.graph;
                    Edge e = context.element;
                    return e.getCloseness();
                }
            });

来源:https://stackoverflow.com/questions/26639303/a-glitch-with-edge-label-offset

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