com.alienfactory.javamappy.viewer.render
Class MIDP20Renderer

java.lang.Object
  extended by com.alienfactory.javamappy.viewer.render.MIDP20Renderer
All Implemented Interfaces:
Renderer

public class MIDP20Renderer
extends java.lang.Object

A Renderer for MIDP v2.0 compatible devices.

Author:
Steve Eynon

Field Summary
protected  int blockHeight
           
protected  int blockWidth
           
protected  int halfBlockWidth
           
 
Fields inherited from interface com.alienfactory.javamappy.viewer.render.Renderer
DRAW_LEFT_SIDE_ONLY, DRAW_RIGHT_SIDE_ONLY, NONE
 
Constructor Summary
MIDP20Renderer(Map map)
          Uses the raw pixel data and colour map from the given Map to create the tilemap image.
MIDP20Renderer(Map map, java.lang.String tileSheetFileName, boolean block0included)
          Initialises itself from the given tileset image.
 
Method Summary
 void drawImage(java.lang.Object objGFX, int imageIndex, int dstPixX, int dstPixY, boolean transparency, int modification)
          Renders a tile image at the given coordinates.
 void restoreClip(java.lang.Object objGFX)
          This is called after a Layer is drawn to restore the clipping region to what it used to be.
 void setClip(java.lang.Object objGFX, int x, int y, int width, int height)
          This is called just before a Layer is drawn to allow the Renderer to set the desired clipping region.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

blockWidth

protected final int blockWidth

blockHeight

protected final int blockHeight

halfBlockWidth

protected final int halfBlockWidth
Constructor Detail

MIDP20Renderer

public MIDP20Renderer(Map map)
               throws java.lang.IllegalArgumentException
Uses the raw pixel data and colour map from the given Map to create the tilemap image.

For J2ME optimisation, after initialisation this Renderer clears the PixelData and Colours objects in the given Map.

Parameters:
map - the Map containing the image data to be rendered
Throws:
java.lang.IllegalArgumentException - if Map is null

MIDP20Renderer

public MIDP20Renderer(Map map,
                      java.lang.String tileSheetFileName,
                      boolean block0included)
               throws java.io.IOException,
                      java.lang.IllegalArgumentException
Initialises itself from the given tileset image. Useful when loading .fma files so the same tile image may be used for multiple maps. Also useful because a .fma + .png is a lot smaller than a .fmp.

Note that, despite the MIDP specification and only if your device supports it, transparent areas of the tilemap will be rendered as transparent. Please bear in mind that transparent rendering can increase the rendering time.

Parameters:
map - the Map to be rendered
tileSheetFileName - the fileName of the tileImage to load - should start with a leading '/'
block0included - set to true if the tile image includes block 0
Throws:
java.io.IOException
java.lang.IllegalArgumentException
Method Detail

drawImage

public final void drawImage(java.lang.Object objGFX,
                            int imageIndex,
                            int dstPixX,
                            int dstPixY,
                            boolean transparency,
                            int modification)
                     throws java.lang.IllegalArgumentException
Renders a tile image at the given coordinates. Marked final as a compiler optimisation.

Parameters:
objGFX - an instance of javax.microedition.lcdui.Graphics
transparency - is ignored
imageIndex - the index of the image to draw - see Map.getImageData()
dstPixX - the coordinate of where the image should be rendered
dstPixY - the coordinate of where the image should be rendered
modification - any modification style should be applied to the image
Throws:
java.lang.IllegalArgumentException - if objGFX is null

setClip

public void setClip(java.lang.Object objGFX,
                    int x,
                    int y,
                    int width,
                    int height)
             throws java.lang.IllegalArgumentException
Description copied from interface: Renderer
This is called just before a Layer is drawn to allow the Renderer to set the desired clipping region.

Specified by:
setClip in interface Renderer
Parameters:
objGFX - the gfx object specific to the Renderer
x - the start coordinate of the clipping region
y - the start coordinate of the clipping region
width - the width of the clipping region
height - the height of the clipping region
Throws:
java.lang.IllegalArgumentException - if objGFX is null

restoreClip

public void restoreClip(java.lang.Object objGFX)
                 throws java.lang.IllegalArgumentException
Description copied from interface: Renderer
This is called after a Layer is drawn to restore the clipping region to what it used to be.

Specified by:
restoreClip in interface Renderer
Parameters:
objGFX - the gfx object specific to the Renderer
Throws:
java.lang.IllegalArgumentException - if objGFX is null


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