Monday, January 30, 2012

A Complex Widget : Waterfall Display

A waterfall display (aka Spectrogram) is a moving bitmap image that shows the history of the recorded spectra. As time proceeds, old samples will be scrolled out of view. I think it is a complex widget (at least for me). I developed it to explore the JavaFX capabilities. The problem is that JavaFX Image and ImageView classes are rather simple to perform complex image operations. Therefore I used AWT classes then converted the buffered image to a JavaFX image in PNG format with the PngEncoder which is developed by J. David Eisenberg (PngEncoder).

The waterfall display is refreshed at intervals between 200 and 3200 ms. The intensity data is stored in a byte array. At each refresh time the last line is added to the array, and the image is regenerated in the memory with the timestamps and the overlay texts if exist.

In this process, first the waterfall part and the timestamp part of the image are created as buffered images. The waterfall part contains the byte array which has the intensity data normalized to 0 – 127. The data are colored with an indexed color model spanned between a first color and a second color. Then both parts are combined into a full buffered image on which the texts are drawn. Last operation is the conversion of the buffered image to an PNG format so it can be handled by JavaFX Image class. Whole generation process runs in the background so the mouse movements are not affected. I implemented JavaFX Task class for threading and think it is easy to implement.

An extended cross hairs is added to get the intensity value at desired points. It is also used to add overlay texts on the image. They can be entered by right click.

The source code can be downloaded from : javafx-widgets

1 comment:

  1. This looks nice too. And it is not painful to look at. I think I can use this with my blue widget app. I am sure it will look great too.