views:

629

answers:

4

Hi,

I need to dynamically draw (star) topologies in a Java GUI application. By star topology, I mean something like this:

network topology

It doesn't need to be over-fancy, but I don't want to do it too ugly and crude. By dynamically I mean that the topology changes infrequently over time, but as the number of nodes is very small, a complete repaint won't hurt.

I googled around for some time, but I couldn't find anything helpful - maybe I'm just googling the wrong keywords. I'm also using JFreeChart, but from what I can see, there's no class included for something like that. A friend of mine suggested searching for mindmapping libraries for Java, but I can just find complete applications, which is an overkill.

I can't believe there is no alternative to mess around with Shapes, Lines etc.? I'm currently using a JTree, but I can't believe there aren't any better ways to do that.

Additional infos: I have a small number (<10) of root nodes and possibly a small number of leafs (<10). It's about a VM<->Server mapping, so the leafs will change their parent over time. Some "animation" while live migration would be cool, but is not required in the first step.

Thanks, and please excuse anything I missed - this is my first question here.

+2  A: 

Perhaps GraphViz would work for you?

EDIT:

OK, what about JGraphT

Amir Afghani
Doesn't directly support Java, and the so-called wrapper that they do have is dead and their description of it (and Java) does not engender desire to incorporate it into any Java app.
Software Monkey
+1  A: 

I believe that one of the demos in the JDK is a dynamic graph layout (not 100% sure, it's been years since I've run them). You probably wouldn't need its whiz-bang animation, but I bet the code is fairly small and definitely self-contained.

Perhaps you could adapt it so that the steps it takes toward finding a layout aren't animated; it just displays the final state.

erickson
After looking closer into JGraph(T), I found out it's an overkill for my needs. You were right, here is some example code to start from: http://java.sun.com/applets/jdk/1.4/index.html (GraphLayout)
+1  A: 

Here's a nice implementation of a StarLayout.

trashgod
+1  A: 

NetBeans offers a nice graphical library (visual library). E.g. the maven plugin uses this to draw all the dependencies

Karussell