I am using JUNG for displaying network devices as graphs. Each edge is a link between two network elements. I want to add a picture exactly in the middle of the link. Currently my link looks like this: enter image description here
The code for it is:
vv.getRenderContext().setEdgeLabelTransformer(new Function<GraphLink,String>() {
URL url = getClass().getResource("/icons/model/conn.radio.png");
public String apply(GraphLink input) {
return "<html><img src="+url+" height=14 width=14>";
}});
As you can see the icon is adjacent with the link. Is there any option so the link could split the icon in two equals parts?
tl;dr You want to tweak the edge label offset.
The position of the edge label is specified by a couple of properties, both accessible via the RenderContext :
You can see how these properties are used (by default) in BasicEdgeLabelRenderer .
By default, the edge label offset is set to 10, which should make the edge label fairly close to, but not on top of, the edge. If you set it to 0:
vv.getRenderContext().setLabelOffset(0);
Then that should do what you want.
You may find it useful to experiment with EdgeLabelDemo .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.