Structured Graphics

Programming graphical displays is complex. A program has to manage what gets drawn onto the display,

how it gets drawn, and when it gets drawn.

The programmer is really only interested in

what

gets drawn, not

how

and

when

drawing is performed.

Therefore:

Allow the user to specify what gets drawn as an aggregation of objects and provide reusable mechanisms that control how and when those objects get drawn onto the display.

Each graphical object encapsulates an element of the display (an image, circle, rectangle, piece of text, etc.). Provide reusable code to draw the objects onto the display whenever necessary (in response to expose events or changes to the graphical objects, for example).

The programmer can then easily define the "what" of the drawing code, and reuse code that handles the "how" and "when".

It is easy to define compound graphical objects by using the Composite Pattern. Groups of multiple graphical objects are then indistinguishable from individual graphical objects. Graphical objects can be structured as a Scene Graph if sophisticated graphical composition is required.

The Visitor Pattern can be used, if the programmer needs to define new operations that can be applied to graphical objects.

The drawing algorithm can use Deferred Updates, draw onto a Double Buffer, and Buffer Graphic Commands to optimize display updates when multiple graphical objects are changed per update.

Known uses include Hot Draw, Inter Views, Unidraw Framework, Scene Beans, Visio, Microsoft Powerpoint, and a myriad of other graphical toolkits and applications.


See original on c2.com