vglRendererRenders VGL Documents |
When render() is subsequently called on the VGLDocumentRenderer, the VGLDocument will be rendered to the device, against a background of grid lines. VGLDocumentRenderer has a VGLElementRenderer, with which it visits and renders each VGLElement in the VGLDocument, and a VGLGridLines, with which it renders the grid lines. Both of these classes need the VGLViewport and VGLWindow that the VGLDocumentRenderer was configured with, and these are supplied to them via a RenderContext, which also provides convenient methods for these classes to map coordinates from window to viewport-space. Incidentally, I originally implemented GridLines and VGLElementRenderer as inner classes of VGLDocumentRenderer. This allowed them direct access to the VGLViewport and VGLWindow held by the VGLDocumentRenderer, but caused them to be hidden in the UML class diagram. It also allowed surrupticous coupling, a risky thing. I factored them out as seperate classes so that they would appear in the diagram and could be discussed. To allow this, I created RenderContext so they could each access the VGLViewport and VGLWindow. Two more classes remain to be described: VGLRenderingStrategy and Constants. VGLRenderingStrategy, as the name implies, is a Strategy which is to implemented by users of VGLDocumentRenderer to do the low-level drawing of primitives such as lines and polygons. It's contract requires that it be a state machine that renders elements with the last colour or font that it was given. To use VGLDocumentRenderer with the AWT, for example, a user would supply an Adapter object which adapts a java.awt.Graphics context object to VGLRenderContext interface. This technique makes the package portable across many window managers, and allows it's architecture to be implemented in C++ on top of OpenGL, for example. Constants simply holds a constant by which the long integer coordinates of VGLElement subclasses are scaled up by before arithmetic, then scaled down by afterward. This is a standard trick to approximate floating-point arithmatic using integers, as explained in more detail in Optimisations. The instance diagram shows how instances of these classes plug together to form the document renderer.
|

The main player in this package is VGLDocumentRenderer. Before use, it is configured with
Post new comment