As you build more complex applications, you will need to create multiple algorithms that can be combined together in order to accomplish some advanced tasks. Consequently, to properly set up the application and have all the classes communicate together will become more and more complex. It then becomes advantageous to centralize the control of the application in a single class. This is the idea behind the Controller design pattern. A Controller is a particular object that plays a central role in an application, and we will explore this in this recipe.
Using your favorite IDE, create a simple dialog-based application with two buttons; one button to select an image, and another button to start the processing, shown as follows:
Here, we use the
ColorDetector class of the previous recipe.