I am using the prefuse visualization toolkit, The GraphView Demo in the toolkit is amazing providing a variety of controls to visualize the data.
I am able to generate GraphML for my dataset and visualize it using GraphView, One additional thing that i would love to have is to label the edges with weights or color coding to demonstrate the strength between two nodes.
Any input about the same are greatly appreciated..Thanks..
Disclaimer: I haven't worked with the API just checked the documentation:) It seems that the API has an EdgeRenderer interface that you should implement to achieve the desired behaviour.
Ref: http://prefuse.org/doc/manual/introduction/example/, http://prefuse.org/doc/api/prefuse/render/DefaultRendererFactory.html
Update: First a correction: in fact EdgeRenderer is not an iterface but a class. I've made a simple demo to illustrate how to implement custom edge rendering.
Feature
Add label to edges containing the initials of the node labels
Method
I made a quick and dirty solution, that is copied LabelRenderer and modified in order to handle edges.
Code
I named the class as
MyEdgeRenderer
:use the original
EdgeRenderer
to draw edge lines (seerender()
below for the renderer in action):modify
getText()
to get the initials from nodes:modified
getAlignedPoint()
to position the label half way on the edge:modify
render()
to (I) first draw the line and (II) use black color:For testing I modified the sample found on the Prefuse website (http://prefuse.org/doc/manual/introduction/example/Example.java):
This is just a demo to illustrate custom rendering. In real you would probably retrieve label text and color from the graph model, ie:
EdgeItem.getString(), getTextColor()
. I guess both attribute could come from the GraphML data. Also the example code shows how to set colors for nodes, it might be adapted for edges as well (though I haven't tried):