Layered Graphics

A graphical program often needs to overlay graphical displays onto one another. Data might need to be obtained from different sources or rendered using different algorithms. The user might need to toggle the visibility of each type of data.

A single class that manages all different combinations of displayable data and rendering ends up large, complex and hard to maintain.

Therefore:

Reify the concept of layers.

Each layer knows how to obtain and render one form of data into the display. The display does nothing but draw layers in order, depending on their visibility. Layers are also responsible for asking the display to repaint when their data changes or the user toggles their visibility.

However, if the user must interact with data in the layers, additional support must be explicitly programmed into each layer to support interaction by checking whether the user has clicked on data displayed by the layer, etc. Alternatively, the user can select the active layer, and all input will go to that layer (this approach is used by PhotoShop and the GIMP, for example).

Known uses include Adobe Photoshop, the GIMP, Visio, and many others.


Also see GraphicsPatterns.

CategoryGraphicsPattern CategoryPattern


EditText of this page (last edited September 5, 2003) or FindPage with title or text search