jfreerails.client.renderer
Class BufferedTiledBackgroundRenderer

java.lang.Object
  extended by jfreerails.client.renderer.BufferedTiledBackgroundRenderer
All Implemented Interfaces:
MapLayerRenderer
Direct Known Subclasses:
SquareTileBackgroundRenderer

public abstract class BufferedTiledBackgroundRenderer
extends java.lang.Object
implements MapLayerRenderer

This abstract class stores a buffer of the background of the current visible rectangle of the map. Code that is independent of how tiles are represented, e.g. whether they are square or isometric, should go here.

Version:
1.0
Author:
Luke Lindsay 06 October 2001

Field Summary
(package private)  java.awt.image.VolatileImage backgroundBuffer
          An offscreen image storing the background of a region of the map.
(package private)  java.awt.Graphics bg
          Used to draw on the backbuffer.
(package private)  java.awt.Rectangle bufferRect
          The bounds and location of the map region that is stored in the offscreen Image backgraoundBuffer.
private  java.awt.GraphicsConfiguration defaultConfig
          This is used to create images that are compatible with the default graphics configuration.
private  java.awt.Graphics translatedBg
          Used to draw on the backbuffer.
 
Constructor Summary
BufferedTiledBackgroundRenderer()
           
 
Method Summary
protected abstract  void paintBufferRectangle(int x, int y, int width, int height)
           
 void paintRect(java.awt.Graphics outputGraphics, java.awt.Rectangle newVisibleRectectangle)
          Updates the backbuffer as necessay, then draws it on to the Graphics object passed.
 void refreshAll()
           
private  void refreshBackground()
           
private  void scrollbackgroundBuffer(int dx, int dy)
           
private  void setbackgroundBuffer(int w, int h)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jfreerails.client.renderer.MapLayerRenderer
paintTile, refreshTile
 

Field Detail

defaultConfig

private final java.awt.GraphicsConfiguration defaultConfig
This is used to create images that are compatible with the default graphics configuration. Such images can be drawn to the screen quickly since no conversion is needed.


bg

java.awt.Graphics bg
Used to draw on the backbuffer.


translatedBg

private java.awt.Graphics translatedBg
Used to draw on the backbuffer. It is translated so that to its users, it appears they are drawing on the actual map, not a buffered region of the map. translatedBg equals bg.translate(-bufferRect.x , -bufferRect.y);


bufferRect

final java.awt.Rectangle bufferRect
The bounds and location of the map region that is stored in the offscreen Image backgraoundBuffer.


backgroundBuffer

java.awt.image.VolatileImage backgroundBuffer
An offscreen image storing the background of a region of the map.

Constructor Detail

BufferedTiledBackgroundRenderer

public BufferedTiledBackgroundRenderer()
Method Detail

paintRect

public void paintRect(java.awt.Graphics outputGraphics,
                      java.awt.Rectangle newVisibleRectectangle)
Updates the backbuffer as necessay, then draws it on to the Graphics object passed.

Specified by:
paintRect in interface MapLayerRenderer
Parameters:
outputGraphics - Once it has been updated, the backbuffer is drawn onto this Graphics object.
newVisibleRectectangle - The region of the map that the backbuffer must be updated to display.

refreshBackground

private void refreshBackground()

refreshAll

public void refreshAll()
Specified by:
refreshAll in interface MapLayerRenderer

setbackgroundBuffer

private void setbackgroundBuffer(int w,
                                 int h)

paintBufferRectangle

protected abstract void paintBufferRectangle(int x,
                                             int y,
                                             int width,
                                             int height)

scrollbackgroundBuffer

private void scrollbackgroundBuffer(int dx,
                                    int dy)