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 CompositePattern. Groups of multiple graphical objects are then indistinguishable from individual graphical objects. Graphical objects can be structured as a SceneGraph if sophisticated graphical composition is required.

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

The drawing algorithm can use DeferredUpdates, draw onto a DoubleBuffer, and BufferGraphicCommands to optimize display updates when multiple graphical objects are changed per update.

Known uses include HotDraw, InterViews, UnidrawFramework, SceneBeans, Visio, Microsoft Powerpoint, and a myriad of other graphical toolkits and applications.


Also see GraphicsPatterns.

CategoryGraphicsPattern CategoryPattern


EditText of this page (last edited December 18, 2014) or FindPage with title or text search