Implement multiple shape objects in such a way that they can be rendered to the screen and manipulated by the mouse. You will practice implementing interfaces, class hierarchies, abstract classes, and ArrayLists. You will also be exposed to polymorphism and graphical user interface programming.
Clicking on any of the “new XYZ” buttons on the top toolbar will create a shape of that type, randomly sized and positioned, on the drawing canvas. The Clear button will delete all shapes. You must be able to create Rectangles, Squares, Circles, Ovals, and Triangles. You may optionally support hexagons and octagons for bonus points.
Objects should respect Z-order, the most recently added shape should be drawn “on top” of other objects. When a shape is clicked on, it should be moved to the front of the Z-order and be drawn on top of all other objects.
When the mouse hovers over a shape, it should become “hot”, and rendered differently. In our case, we will render an object “hot” by filling it with its border color. Non-hot shapes will be filled with white. Multiple objects can be “hot” at the same time if the mouse hovers over overlapping shapes.
When the user performs mouse drag starting on a shape, it will move with the mouse to a new location. It should update in real time as the mouse moves. Only a single shape should be moved at a time, if multiple shapes hit test the topmost one should be grabbed for the drag operation. A drag operation should have no effect on the Z-order.
The background color of the panel should gradually transition from white to black as more shapes are added. This darkening should correspond to the cumulative area of all added shapes as a ratio to the total pane area – 0:1 area is white, 1:1 (or greater) is black.
A toolbar may be implemented that allows the user to change the color of new shapes created, and clicking on a shape will also change its color along with bringing it to the front of the Z-order.
Shape classes
All shapes must implement the Shape interface, as defined here:
You encouraged to implement additional base classes (some of which may be abstract) to implement all required shapes in an effort to eliminate redundancy.
ShapeFactory
The shapes should be created by the ShapeFactory, for which you will complete the implementation. This class should determine a random place to position the new shape along with random parameters (size, width, etc), then call into the constructors for the various Shape classes you implemented. No shape should ever have a shape greater than 25% of the total pane’s area.
DrawingArea
You will need to implement a DrawingArea class, which extends the abstract class DrawingAreaBase and implements the required methods. These methods are:
An ArrayList will probably be helpful.
Modify the ShapePanel class to include a second toolbar for selecting new shape color. See image.