In previous issues in this series, I deliberately kept the user experience somewhat spartan with line being the only shape available to be added to the canvas. This allowed the application design to be modified with a mimimum of effort. Now we will spice up the application a little by adding points, ellipses and bezier curves. As a natural consequence, there needs to be some way for users to tell the Doodle application what shape they want to draw next. This task will be handled by a new application class called Control.
A demonstration of the technique can be seen here.
Start With the Document, Again
The enumeration of shape types looks more sensible now with more than one type. Let's take a look at the new shape types.
The Point class constructor calls the Shape constructor explicitly since this isn't handled automatically. Although nothing is done yet in the Shape constructor, that may change and it will be important for anything derived from the Shape class to benefit.
The document classes all follow a fairly simple pattern; after construction, the shape can be initialized and modified using accessors. Later, when we consider persistence, each document shape will need to learn how to serialize itself into a form that can be saved.