Version 2.3.30 of ANIMAL introduces a new, easy to use yet expressive feature: automatic visualization of read- and write-accesses to data structures at the animation author's request!
For an example, see the following screenshot taken from an (unspectacular) execution of Selection Sort:
The interesting information here are the two bars indicating the number of assignments and (read) accesses on the array, so far - 6 and 42, respectively.
You might ask yourself what the animation author has to do to get this functionality… Well - the answer is: not much!
Here is the complete code, which will be explained in a moment:
counter = lang.newCounter(array); // array holds a reference to the actual array.
CounterProperties cp = new CounterProperties();
view = lang.newCounterView(counter, 200, 100, cp, true, true);
First, we create a new counter on the array used to hold the values. This creates a new counter that will now monitor read and write accesses to the array.
Then, we create and specify the visual properties of the counter. It shall be filled (line 3) and the actual fill color shall be 4 (line 4).
Finally, we create a view for the counter. This receives the counter itself (created in line 1), the x and y coordinate, the counter properties created in line 2, and two final boolean parameters indicating whether we want to see the numeric value and/or the bars. Here, we want to see both, and thus pass in true twice. And… that's it! All future accesses to the array will now be counted and visualized, until you use view.hide(); to hide the complete visualization from the end user.