This post is a mini tutorial on how to create an application based on NetBeans Platform that uses the WorldWind Java virtual globe. Before to continue, you need to have some knowledge about NetBeans Platform, WWJ and JOGL.
NetBeans Platform, similar to Eclipse RCP, is a platform which offers a set of basic functions and functionallities that are common in almost all project. The most clear examples of applications developed with these platforms are NetBeans IDE and Eclipse IDE themselves.
In the case of NetBeans Platform some features that likes me are:
WordlWind Java is a Java API to create and work with a virtual globe, something common on these days and not so easy to implement.
In contrast to WorldWind .NET which is a desktop application, WWJ is only an API, a set of classes you can use to create your own based application.
One impotant thing is WWJ works thanks to JOGL (Java binding for OpenGL API), which is a Java API to work with OpenGL and that uses a native library implementation depending on your system.
Nice question. Ok, if we can say there is any problem it will be: how to create a NetBeans module which includes the JOGL JAR files and also the native libraries so my application will be portable?
Follow the next steps and you will see there is not problem to achieve that.
Here is the list of software and versions I'm using for this example:
Install NetBeans if you don't have installed. Download WWJ and JOGL and uncompress it at some place.
Ok next is the important part of this article. The basic idea is to create a new NetBeans Platform application with two library modules, containing required JAR files for JOGL and WorldWindJava:
Open the code of your TopComponent and in the init() method add the next lines:
Model model = (Model)WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME); WorldWindowGLCanvas wwj = new WorldWindowGLCanvas(); wwj.setModel(model);
setLayout(new BorderLayout()); add(wwj, BorderLayout.CENTER);
You will need to import the required packages from WWJ module, which you must set as a dependency previously.
If you have followed the above steps the result you must get must be something similar to:
In addition, the benefit of using this approach is your application, once you build a ZIP distribution, will run on different machines thanks to the native libraries attached in the 'lib' folder.