Fork me on GitHub

Design Patterns Applied in VGLViewer

An index of Gang of Four patterns applied in VGLViewer

What's a design pattern?
Check out the Wikipedia definition and the canonical book Design Patterns: Elements of Reusable Object-Oriented Software (ISBN 0-201-63361-2).

Category Pattern VGLViewer Package How applied

Creational

Builder vglDocument.utils Defines VGLDocumentBuilder, which implements a Builder.
Factory Method vglDocument Users of package vglDocument are required to implement AbstractVGLFontFactory, which creates VGLFonts
vglViewer AWT_VGLFontFactory implements AbstractVGLFontFactory to create VGLFonts with VGLFontMetrics compatible with AWT.

Structural

Adapter vglviewer SDAZDocViewPanelSubject adapts a DocViewPanel to a SDAZSubject.
Composite boundaryMap BoundaryMap implements a KD-tree for fast intersection tests and is the Composite, Leaf and Component particpant in the Composite design pattern.
Decorator vglViewer MultiErrorHandler decorates an ErrorHandler to buffer multiple error messages.
Flyweight vglDocument Multiple VGLElements can save memory by sharing the same VGLStyle instances.
Behavioural Observer docViewPanel A RepaintObserver can be attached to a DocViewPanel, to be notified whenever the DocViewPanel has painted itself.
vglViewer A ViewPanel attaches a DocViewMouseListener to its DocViewPanel, to be notified of any mouse events on DocViewPanel
State vglDocument.utils Package vglDocument.utils defines VGLDocumentBuilder which switches internally between different implementations of AbstractBuilderState as it builds different types of document element.
sdaz SDAZDriver switches between three implementations of SDAZState for its Dormant, Zooming and Restoring phases
vglViewer DocViewMouseListener has two states: it is either listening for SDAZ mouse events or for marquee-zoom mouse events.
Strategy vglDocument.utils VGLDocumentLoader drives a user-supplied VGLDocumentBuilder to construct a VGLDocument as it parses XML.
vglRenderer VGLDocumentRenderer requires that a user supplies an implementation of VGLRenderingStrategy with whichit can render graphics primitives.
docViewPanel DocViewPanel supplies AWTRenderingStrategy, an implementation of VGLRenderingStrategy, to its aggregated VGLRenderer.
Template Method boundaryMap Interface BoundaryMapElement, which requires that implementors define a method to bisect themselves to assist the algorithm within BoundaryMap.
docViewpanel DoubleBufferedPanel defines paintBuffer, to be implemented by subclass DocViewPanel.
Visitor vglDocument VGLElements within a VGLDocument can be visited with a VGLElementVisitor.

The patterns identified here are described in detail in the book Design Patterns: Elements of Reusable Object-Oriented Software (ISBN 0-201-63361-2).