A glitch with Edge label offset

2019-07-23 05:05发布

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.enter image description here

So I decided to offset the label:

vv.getRenderContext().setLabelOffset(20);

And the Effect:

enter image description here

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

0条回答
登录 后发表回答