Drawing graphs on java

nunos picture nunos · Jun 5, 2010 · Viewed 55.1k times · Source

I want to draw graphs (nodes and edges) in Java. However, since I don't know how to go about it, I would like to have some advice before starting.

How should I do this?

use Graphics2D package, right?

How about the labels for the nodes? should I use something like drawString and handle all the "centering" manually or create a JLabel for that? Can I put a JLabel on a Graphics2D environment?

I have searched but haven't found any simple implementation of this. If you know of one, please provide the link in your answer.

edit: The solution I am looking for should be able to remove nodes, drag nodes, edit labels, create nodes, all with mouse events.

Thanks.

Answer

Aryabhatta picture Aryabhatta · Jun 5, 2010

Perhaps this will help: JUNG.

And you will probably need to read this: http://jung.sourceforge.net/doc/JUNGVisualizationGuide.html