Skip to main content

Class visualization module for NetBeans

Posted by timboudreau on February 28, 2008 at 2:13 PM PST

Last week I wrote a little module that uses the NetBeans Visual Library and the Javac Tree API to create a graph of the contents of a Java file, showing dependencies between class members. It's now available on the NetBeans daily build update center - if you're running a daily build of NetBeans, just go to Tools | Plugins and download Graphical Class Viewer.

My question is, would anybody actually find this useful? It was mostly an experiment to get more fluent with a couple of APIs I need to know well - but it seems like it could be handy if you're going to edit a class you didn't write and want to see where the action is - or if you've got a bunch of encapsulated fields and want to quickly see if anything is not using the getters and setters.

What it does:

  • Shows a graph (see screenshot below)
  • If you hover the mouse over, say, a method, then the path to things that method calls/uses will be shown in red, and things that call that method are shown in blue
  • You can click the arrow button on the widget for any class member and see its source code

Feel free to try it out and let me know if you think it's something worth putting more work into.

Also, if anyone knows of any speedy and good hub-and-spoke or other layout algorithms for the case where you have n nodes each of which can have up to n-1 connections to other nodes, feel free to let me know - what it does now is less than optimal. At some point I may think through the geometry to do it nicely, but I'm not sure when.

The sources are in NetBeans contrib mercurial repository.

Comments? Reply on the NetBeans DZone thread about it.


Class visualization module

Hi, I have just seen this greate picture. I did not use it rigth now. But please allow me a few words.
Documentation is a big issue. Doxygen with Graphix a very nice way to keep documents with code in sync. So you are on a right trak.
1. there is certainly a demand for good code analyzers able to draw diagrams; best UML diagrams
2. drawing diagrams in a UML standard way woule be perfect.
3. drawing models from classes representing static issues class diagrams, showing inheritance, showing relations, is somehow covered by many tool
4. automating the modelling task of UML sequence diagrams, collaboration diagrams, object interaction diagrams is a bit GAP
5. automating the modelling task of UML task diagrams helping on multi threaded isses would be a next goal, maby also state transition diagrams of objects ...
6. after all, in short, if you can generate all the known UML diagrams that would be very fine.
7. store it in a format that other case tools like UML in NetBeans, Inovatior, Rational, etc. can catch on it and continue with i..e forward and reverse engineering.
8. traking dependencies i.e. from Use case to code is another big issue to get a risk ide for changes.
9. automatic drawing possibel deployment diagrams would help further (mayby on all mentioned diagram aspects you need to introduce some marks in code)
Definitly thankls to you and hope I get soon the time to look closer at your work.
Josef Stadelmann / SW Architect and Developer