In my prefuse visualization I want to add label to edges. I followed some examples proposed here on SO, but I can't bring it to work:
I use this Renderer for my edges:
private class CustomEdgeRenderer extends LabelRenderer {
private EdgeRenderer edgeRenderer = new EdgeRenderer();
@Override
public String getText(VisualItem item) {
System.out.println("edgerenderer");
return "test";
}
@Override
public void render(Graphics2D g, VisualItem item) {
edgeRenderer.render(g, item);
item.setTextColor(BLACK);
}
}
The problem now is, that the text isn't displayed, but the edges are drawn in a weird form. That is they aren't correctly drawn. If I don't overwrite render, then the text is drawn, but no edges. How can i make this work?
Following the architecture of prefuse you would create a separate group of visual items for the labels, so called DecoratorItem
.
An example can be found in the TreeMap demo: https://github.com/prefuse/Prefuse/blob/master/demos/prefuse/demos/TreeMap.java