com.alienfactory.javamappy.viewer
Class MapViewer

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

public class MapViewer
extends Viewer

Renders a Map onto the screen. A MapViewer creates a LayerViewer for each of the Layers in the Map.

Updating the coordinates of a MapViewer also updates the coordinates of all the underlying LayerViewers.

Note that the coordinates of a MapViewer are held independently of the coordinates held by the underlying LayerViewers. i.e. If you were to change the coordinates of the LayerViewers, the coordinates held by the MapViewer would remain unchanged.

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
MapViewer(Map map, Renderer renderer, int viewWidth, int viewHeight)
          Creates a LayerViewer for each of the Layers in the Map.
MapViewer(Map map, Renderer renderer, int viewWidth, int viewHeight, int viewOffsetX, int viewOffsetY)
          Creates a LayerViewer for each of the Layers in the Map and places the viewing area at the given offset.
 
Method Summary
 void addBlockX(int blockX)
          Increments the X coordinate by the given block amount.
 void addBlockY(int blockY)
          Increments the Y coordinate by the given block amount.
 void addPixelX(int deltaX)
          Increments the X coordinate by the given pixel amount.
 void addPixelY(int deltaY)
          Increments the Y coordinate by the given pixel amount.
 void draw(java.lang.Object objGFX, boolean transparency)
          Renders the Map using the given GFX object.
 void draw(java.lang.Object objGFX, boolean transparency, int x, int y, int width, int height)
          Renders a partial area of the Map using the given GFX object.
 LayerViewer[] getLayerViewers()
          Returns an array of LayerViewers.
 Map getMap()
          Returns the Map associated with this viewer.
 void setBlockX(int blockX)
          Sets the X coordinate in blocks of the top left hand corner of the viewing area.
 void setBlockY(int blockY)
          Sets the Y coordinate in blocks of the top left hand corner of the viewing area.
 void setPillarRiserMode(boolean pillarRiserMode)
          Sets the Pillar Riser Mode, as used in isometric maps.
 void setPixelX(int pixelX)
          Sets the X coordinate in pixels of the top left hand corner of the viewing area.
 void setPixelY(int pixelY)
          Sets the Y coordinate in pixels of the top left hand corner of the viewing area.
 void updateAnimBlocks()
          A helper method that updates the animation of all the AnimBlocks in the Map.
 
Methods inherited from class com.alienfactory.javamappy.viewer.Viewer
getBlockX, getBlockY, getMapHeader, getPixelX, getPixelY, getRenderer, getViewHeight, getViewOffsetX, getViewOffsetY, getViewWidth, isPillarRiserMode, setViewHeight, setViewOffsetX, setViewOffsetY, setViewWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapViewer

public MapViewer(Map map,
                 Renderer renderer,
                 int viewWidth,
                 int viewHeight)
Creates a LayerViewer for each of the Layers in the Map. The viewing area defaults to the top left hand corner of the screen.

Parameters:
map - the Map to be viewed
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

MapViewer

public MapViewer(Map map,
                 Renderer renderer,
                 int viewWidth,
                 int viewHeight,
                 int viewOffsetX,
                 int viewOffsetY)
Creates a LayerViewer for each of the Layers in the Map and places the viewing area at the given offset.

Parameters:
map - the Map to be viewed
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

getLayerViewers

public LayerViewer[] getLayerViewers()
Returns an array of LayerViewers.


getMap

public Map getMap()
Returns the Map associated with this viewer.


setPixelX

public void setPixelX(int pixelX)
Description copied from class: Viewer
Sets the X coordinate in pixels of the top left hand corner of the viewing area.

Overrides:
setPixelX in class Viewer
Parameters:
pixelX - the new X coordinate in pixels

addPixelX

public void addPixelX(int deltaX)
Description copied from class: Viewer
Increments the X coordinate by the given pixel amount. Negative values are allowed.

Overrides:
addPixelX in class Viewer
Parameters:
deltaX - the amount to add to the X coordinate in pixels

setPixelY

public void setPixelY(int pixelY)
Description copied from class: Viewer
Sets the Y coordinate in pixels of the top left hand corner of the viewing area.

Overrides:
setPixelY in class Viewer
Parameters:
pixelY - the new Y coordinate in pixels

addPixelY

public void addPixelY(int deltaY)
Description copied from class: Viewer
Increments the Y coordinate by the given pixel amount. Negative values are allowed.

Overrides:
addPixelY in class Viewer
Parameters:
deltaY - the amount to add to the Y coordinate in pixels

setBlockX

public void setBlockX(int blockX)
Description copied from class: Viewer
Sets the X coordinate in blocks of the top left hand corner of the viewing area.

Overrides:
setBlockX in class Viewer
Parameters:
blockX - the new X coordinate in blocks

addBlockX

public void addBlockX(int blockX)
Description copied from class: Viewer
Increments the X coordinate by the given block amount. Negative values are allowed.

Overrides:
addBlockX in class Viewer
Parameters:
blockX - the amount to add to the X coordinate in blocks

setBlockY

public void setBlockY(int blockY)
Description copied from class: Viewer
Sets the Y coordinate in blocks of the top left hand corner of the viewing area.

Overrides:
setBlockY in class Viewer
Parameters:
blockY - the new Y coordinate in blocks

addBlockY

public void addBlockY(int blockY)
Description copied from class: Viewer
Increments the Y coordinate by the given block amount. Negative values are allowed.

Overrides:
addBlockY in class Viewer
Parameters:
blockY - the amount to add to the Y coordinate in blocks

updateAnimBlocks

public void updateAnimBlocks()
A helper method that updates the animation of all the AnimBlocks in the Map.


draw

public void draw(java.lang.Object objGFX,
                 boolean transparency)
Renders the Map using the given GFX object.

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 Map 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

setPillarRiserMode

public void setPillarRiserMode(boolean pillarRiserMode)
Description copied from class: Viewer
Sets the Pillar Riser Mode, as used in isometric maps.

Overrides:
setPillarRiserMode in class Viewer


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