### Graphics Class Architecture

The 2D graphic classes derive from IMDrawable. IMDrawable specifies the minimal protocol for drawing and streaming a 2D graphic. As shown in the figure, IMGraphic is an abstract base class that derives from IMDrawable:

IMDrawable provides the protocol for drawing a 2D graphic. IMGraphic provides the protocol common to all 2D graphics obtaining attribute information which it uses at rendering time, transforming the graphic, and finding the bounds of the graphic.

All IMGraphic derived classes use a drawing port (IGrafPort) to render the graphic; own an attribute bundle (IGrafBundle); and know the transformation matrix for a graphic (IGrafMatrix).

All IMGraphic derived classes know how to draw themselves. The graphics provide the geometry, attribute, and transformation information to the drawing port when the draw function of the graphic is called. This is a pure virtual function for IMGraphic, and all IMGraphic subclasses have to override this functionality.

### IMGraphic Class Architecture

The 2D graphic classes whose names specify a geometry, such as ILine, ICurve, IEllipse, and so on, are derived from IMGraphic. As shown in the figure, a 2D graphics class has a geometry class that provides the shape for the graphic. A graphics class has public functions specific to that graphic that allow the graphic to interact with its referenced geometry.

The graphics classes are wrappers for their referenced geometry classes. The graphics classes have functions that let you manipulate the geometry from within the graphic without accessing the geometry functions directly. The advantage to the wrapper architecture is that the 2D graphics classes bring together the functionality of the geometry classes and the high-level functionality of the IMGraphic class.

All IMGraphic-derived classes use a drawing port (IGrafPort) to render the graphic; own an attribute bundle (IGrafBundle); and know the transformation matrix for itself.

IMGraphic Models