Source File Visualizers

The history of source file visualizers on the NetBeans Platform consists, in addition to the UML, Visual Web, and Mobility support, of three significant moments—Vadiraj Deshpande's Part 3 - XML Multiview + Visual Library, Toni Epple's A Visual Datbase Explorer for NetBeans, and Damir Tesanovic's DDL Visualizer - Visualize sql script with NetBeans.

Of them all, I've looked most closely at the latter of the three, recently. The basic framework of a visualizer can be extracted from that blog entry. Then one needs to incorporate some way of parsing the source in question. For HTML, you'd need some kind of HTML parser, etc. (By the way, the NetBeans APIs provide an HTML parser too, did you know that? See the HTML Lexer API, and the isHyperlinkPoint class in the NetBeans Hyperlink Navigation Tutorial.) If you want to parse XML files, see the NetBeans XML Editor Extension Module Tutorial, because that tutorial includes complete code for an XML parser. For parsing Java source files, the NetBeans Java Language Infrastructure Tutorial is incredibly useful. By combining the code from that tutorial with the information from Damir Tesanovic's blog entry, I made a visualizer for Java source files:

The visual scene shows information about the constructor, methods, and fields of a class. The scene is created when you right-click inside a Java source file and choose "Visualize". Then a new TopComponent opens, with a Visual Library API scene created within it, and then the nodes are added to the scene, with the pins added to the nodes.

If you are creating a visualizer, I recommend working backwards through the three blog entries listed above. Start with the one by Damir Tesanovic, then the one by Toni Epple, and then look through the one by Vadiraj Deshpande.


Will you be releasing this as a netbeans module?

Posted by guest on January 16, 2008 at 05:00 AM PST #

Maybe I'm mistaken, but I think the Reverse Engineer menu item on Java files (i.e., this is UML) does the job already. Or do you need this for something specific,

Posted by Geertjan on January 16, 2008 at 10:59 AM PST #

Hi Geertjan, am sorry this comment is off the topic but i saw the DJ Native swing project and was hoping for a netbeans plugin that can allow one to preview HTML files within Netbeans so that as I edit in Netbeans, I can click on a button and then a tab showing the preview of my HTML opens that uses the DJ component internally. Any such thing in perspective soon? Will it be trivial to build

Posted by dabar on January 16, 2008 at 08:35 PM PST #

Hi I have put something together but I dont know how to continue from thier. Please provide me links on how I can trigger editor action, write clean-up code when an editor is closed.

I have a screenshot at


Posted by dabar on January 16, 2008 at 10:54 PM PST #

Can you send me all your sources in a ZIP? I've created the other half...

Posted by Geertjan on January 16, 2008 at 11:00 PM PST #

Actually, why don't you read the blog entries I referred to above? The one by Damir Tesanovic should give you everything you need.

Posted by Geertjan on January 16, 2008 at 11:34 PM PST #

I have uploaded the zip of what I have here Actually my headache has being how to plug in the NativeCode Initialization routine which is supposed to be called at the init of the GUI application. I used ModuleInstall but it is not yet stable, it loads up, works a bit and the test platform stops responding after a while. I think you may also need to get the DJ libraries to resolve the project dependencies

Posted by dabar on January 17, 2008 at 12:56 AM PST #

Thanks. Looking at your code now. See my today's blog entry for my progress, but using a different 3rd party library.

Posted by Geertjan on January 17, 2008 at 01:50 AM PST #

It's going to take me some time to set up the DJ native browser and then to learn how to use it. Hoping to do it by the end of the weekend. Hope that's acceptable. In general though, my guess is you shouldn't be using a module installer at all. But that's just a guess.

Posted by Geertjan on January 17, 2008 at 02:02 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« July 2016