com.alienfactory.javamappy.viewer
Class LayerViewer

java.lang.Object
  extended by com.alienfactory.javamappy.viewer.Viewer
      extended by com.alienfactory.javamappy.viewer.LayerViewer

public class LayerViewer
extends Viewer

Renders a Layer of a Map onto the screen. This class may be used independently (or even without) a MapViewer.

See MapViewer for a discussion on offsets.

Author:
Steve Eynon

Field Summary
 
Fields inherited from class com.alienfactory.javamappy.viewer.Viewer
mapHeader, pillarRiserMode, pixelX, pixelY, renderer, viewHeight, viewOffsetX, viewOffsetY, viewWidth
 
Constructor Summary
LayerViewer(Layer layer, MapHeader mapHeader, Renderer renderer, int viewWidth, int viewHeight)
          Creates a LayerViewer and places the viewing area at the top left corner.
LayerViewer(Layer layer, MapHeader mapHeader, Renderer renderer, int viewWidth, int viewHeight, int viewOffsetX, int viewOffsetY)
          Creates a LayerViewer and places the viewing area at the given offset.
 
Method Summary
 int calculateTallestPillar()
          Calculates the height of the tallest pillar - used when drawing Isometric maps with Pillar Riser Mode turned on.
 void draw(java.lang.Object objGFX, boolean transparency)
          Renders the Background and Foreground layers of all the visible blocks onto the screen.
 void draw(java.lang.Object objGFX, boolean transparency, int x, int y, int width, int height)
          Renders a partial area of the Layer using the given GFX object.
 void drawBackground(java.lang.Object objGFX, boolean transparency)
          Renders the background layer of all the visible block onto the screen.
 void drawBackground(java.lang.Object objGFX, boolean transparency, int x, int y, int width, int height)
           
 void drawForeground(java.lang.Object objGfx, int blockLayer)
          Renders a foreground layer of all the visible blocks onto the screen.
 void drawForeground(java.lang.Object objGfx, int blockLayer, int x, int y, int width, int height)
           
 Layer getLayer()
          Returns the Layer associated with this Viewer.
 
Methods inherited from class com.alienfactory.javamappy.viewer.Viewer
addBlockX, addBlockY, addPixelX, addPixelY, getBlockX, getBlockY, getMapHeader, getPixelX, getPixelY, getRenderer, getViewHeight, getViewOffsetX, getViewOffsetY, getViewWidth, isPillarRiserMode, setBlockX, setBlockY, setPillarRiserMode, setPixelX, setPixelY, setViewHeight, setViewOffsetX, setViewOffsetY, setViewWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LayerViewer

public LayerViewer(Layer layer,
                   MapHeader mapHeader,
                   Renderer renderer,
                   int viewWidth,
                   int viewHeight)
Creates a LayerViewer and places the viewing area at the top left corner.

Parameters:
layer - the Layer to be viewed
mapHeader - contains useful information
renderer - the Renderer to use when drawing the map
viewWidth - the width of the viewing area in pixels
viewHeight - the height of the viewing area in pixels

LayerViewer

public LayerViewer(Layer layer,
                   MapHeader mapHeader,
                   Renderer renderer,
                   int viewWidth,
                   int viewHeight,
                   int viewOffsetX,
                   int viewOffsetY)
Creates a LayerViewer and places the viewing area at the given offset.

Parameters:
layer - the Layer to be viewed
mapHeader - contains useful information
renderer - the Renderer to use when drawing the map
viewWidth - the width of the viewing area in pixels
viewHeight - the height of the viewing area in pixels
viewOffsetX - the initial offset in pixels of the viewing area from the top left hand corner of the screen
viewOffsetY - the initial offset in pixels of the viewing area from the top left hand corner of the screen
Method Detail

calculateTallestPillar

public int calculateTallestPillar()
Calculates the height of the tallest pillar - used when drawing Isometric maps with Pillar Riser Mode turned on.

Returns:
the height of the tallest pillar in pixels

drawBackground

public void drawBackground(java.lang.Object objGFX,
                           boolean transparency)
Renders the background layer of all the visible block onto the screen.

Parameters:
objGFX - the gfx object specific to the Renderer
transparency - whether or not the layer should be rendered using their transparent pixels

drawBackground

public void drawBackground(java.lang.Object objGFX,
                           boolean transparency,
                           int x,
                           int y,
                           int width,
                           int height)
                    throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

drawForeground

public void drawForeground(java.lang.Object objGfx,
                           int blockLayer)
                    throws java.lang.IllegalArgumentException
Renders a foreground layer of all the visible blocks onto the screen. Transparency is always turned on when rendering foreground block layers.

Parameters:
objGfx - the gfx object specific to the Renderer
blockLayer - the foreground layer to render
Throws:
java.lang.IllegalArgumentException - if blockLayer is out of bounds or objGfx is null

drawForeground

public void drawForeground(java.lang.Object objGfx,
                           int blockLayer,
                           int x,
                           int y,
                           int width,
                           int height)
                    throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

draw

public void draw(java.lang.Object objGFX,
                 boolean transparency)
Renders the Background and Foreground layers of all the visible blocks onto the screen.

Specified by:
draw in class Viewer
Parameters:
objGFX - the gfx object specific to the Renderer
transparency - whether or not the background layer of the blocks should be rendered honouring their transparent pixels

draw

public void draw(java.lang.Object objGFX,
                 boolean transparency,
                 int x,
                 int y,
                 int width,
                 int height)
Renders a partial area of the Layer using the given GFX object.

Specified by:
draw in class Viewer
x - the pixel x coordinate from the left hand side of the viewing area
y - the pixel y coordinate from the top of the viewing area
width - the width, in pixels, of the viewing area to render
height - the height, in pixels, of the viewing area to render

getLayer

public Layer getLayer()
Returns the Layer associated with this Viewer.

Returns:
the Layer associated with this Viewer


Copyright © 2001-2009 Alien-Factory Ltd. All Rights Reserved.