Geertjan's Blog

  • January 30, 2011

Visual Scientific Calculator Migration to the NetBeans Platform

Geertjan Wielenga
Product Manager
I've been looking at a very interesting application that someone on one of the recent NetBeans Platform courses has been working on. It is a Swing application, created in Eclipse. The purpose of the application is to provide a visual calculator, for scientific calculations of various kinds. The sources, as I received them, were structured as follows:

Aside from a GUI, the application provides abstract classes that model the objects that need to be calculated. For example, there's an abstract Operator class. Then there are specific implelementations of those abstract classes, such as a Constant class, different kinds of Math classes (e.g., Math Simple, Math Advanced, and Math Trig).

That kind of structure is ideal for porting to a modular application. One module ("GgppService" below) provides the abstract classes, with each implementation in a different module ("GgppProvider-Conditional", "GggppProvider-Constant", "GgppProvider-MathAdvanced", "GgppProvider-MathSimple", "GgppProvider-MathTrig" below):

The main module of the application is named "GgppCore", which provides the custom windows in the application, a Visual Library scene, and a node hierarchy, as well as the classes that haven't been fully migrated yet from the original application.

In addition, some supporting modules have been added: "GgppBranding" (for hiding menu items and toolbar buttons), "GgppCalculationFileSupport" (for supporting a new type of file where calculations can be serialized to), "GgppCalculationProjectSupport" (for enabling the creation of a set of related calculations), "GgppEditor-Source" (an XML editor in a tab within a multiview component), "GgppEditor-Visual" (a Visual Library scene in a tab within a multiview component), and "GgppUtilities" (containing utility classes shared between the other modules).

The above structure and code results in an application that currently looks as follows:

The BeanTreeView on the right, which is the palette in the application (from which you drag and drop into the canvas in the center of the application) is constructed from implementations of the service, registed in the META-INF/services folder of the modules making up the application.

Looking forward to getting further with this application, it could end up being pretty useful. The underlying code, i.e., the calculation code, is mostly there, it would be good to have a few JUnit tests that, apart from testing the code, would illustrate the ways in which the various calculations are meant to function. Also, business rules need to be integrated in a coherent way, e.g., when adding you need to have at least two items to add, etc.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.