We can switch between visualizations by adding and removing them over time. In the following example, we start with one active visualization and then every few seconds, toggle a random visualization on or off.
First, add an
activate method to the abstract
Visualization class, which takes a Boolean enabled parameter. The Boolean active variable is read-only:
public boolean active = true; public abstract void activate(boolean enabled);
Its implementation will depend on the specific visualization.
RenderBox library provides an
enabled flag that's used when we render objects. The ones that instantiate a single
Plane component are the easiest, such as
FFTVisualization. To each of these, add the following ...