## 3. MapBean

The MapBean is a drawing canvas that derives from the Swing JComponent class. Because the MapBean is a Swing component, it can be added to a Java window hierarchy like any other Swing windowing component. The MapBean manages a hierarchy of layers which can paint themselves to the canvas and a projection object to manage the view.

Layers are the only component that can be added to a MapBean. When a Layer is added, it becomes a ProjectionListener to the MapBean, and receives a ProjectionEvent whenever the map is panned, zoomed, or resized.

## 3.1 BufferedMapBean

The BufferedMapBean extends the MapBean by forcing its layers to paint their graphics into a buffer. This drawing buffer is then rendered whenever the AWT causes a redraw. This dramatically increases performance for window exposes since it avoids the (potentially expensive) Layer painting process. Of course if a layer causes a redraw, then we regenerate the drawing buffer with the graphics and render the new image.

The OpenMap Viewer application uses the BufferedMapBean instead of the MapBean precisely because of the increased performance.