JTP
Class TilePainter

java.lang.Object
  extended by JTP.TilePainter

public class TilePainter
extends Object

Handles tile rendering

Author:
V.Termanis

Constructor Summary
TilePainter(Images imgData, ScreenFrames frames, Screen screen, Font numberFont, Font charFont, Color numColor, Color charColor, Color gridColor, Color gridHighlight, Graphics2D g)
          Constructs a new TilePainter instance with the given attributes.
 
Method Summary
 void drawGTiles(GameTile[][] tiles, Point activePos, Point activePos2, boolean numbered, Graphics2D g)
          Renders the given tiles (in-game).
 void drawMenuString(String s, boolean raised, Rectangle location, Graphics2D g)
          Draws a string with each letter on a separate tile.
 void drawScoreString(String s, boolean appendCursor, boolean first, int x, int y, Graphics2D g)
          Variation of drawMenuString.
 void drawTiles(Tile[][] tiles, Point activePos, Point activePos2, Point oldPos, Point player2Start, boolean dualStart, Graphics2D g)
          Renders the given tiles (editor).
protected  void drawTiles(Tile[][] tiles, Rectangle gridArea, int tileSize, Point activePos, Point activePos2, Point oldPos, Point player2Start, boolean drawP2Start, boolean dualStart, boolean numbered, Graphics2D g)
          Renders the given tiles (editor/level-chooser).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TilePainter

public TilePainter(Images imgData,
                   ScreenFrames frames,
                   Screen screen,
                   Font numberFont,
                   Font charFont,
                   Color numColor,
                   Color charColor,
                   Color gridColor,
                   Color gridHighlight,
                   Graphics2D g)
            throws NullPointerException
Constructs a new TilePainter instance with the given attributes.

Parameters:
imgData - graphics resources
frames - geometry information
numberFont - font to use for tile numbering
charFont - font to use for all other characters
numColor - color of numbers on tiles
charColor - color of all other characters on tiles
gridColor - color to draw grid with (editor)
gridHighlight - color to use for highlighting grid position
g - graphics context for calculating font positioning
Throws:
NullPointerException - if any of the supplied parameters are null.
Method Detail

drawTiles

public void drawTiles(Tile[][] tiles,
                      Point activePos,
                      Point activePos2,
                      Point oldPos,
                      Point player2Start,
                      boolean dualStart,
                      Graphics2D g)
Renders the given tiles (editor). Warning: For optimum performance no checks are performed on any of the parameters (i.e. this method might not fail gracefully) though some of the parameters can be set to null if they do not apply.

Parameters:
tiles - the tiles to render
activePos - currently active grid position
activePos2 - second active position. Used in conjuction with activePos to highlight a whole area
oldPos - specifies previously active position. Only having to render over the top of one grid position improves performance.
player2Start - location of second player
dualStart - indicates both players start from the same position
g - graphics context for drawing

drawGTiles

public void drawGTiles(GameTile[][] tiles,
                       Point activePos,
                       Point activePos2,
                       boolean numbered,
                       Graphics2D g)
Renders the given tiles (in-game). Warning: For optimum performance no checks are performed on any of the parameters (i.e. this method might not fail gracefully) though some of the parameters can be set to null if they do not apply.

Parameters:
tiles - the tiles to render
activePos - position of first player
activePos2 - position of second player
numbered - toggle tile height numbers
g - graphics context for drawing

drawTiles

protected void drawTiles(Tile[][] tiles,
                         Rectangle gridArea,
                         int tileSize,
                         Point activePos,
                         Point activePos2,
                         Point oldPos,
                         Point player2Start,
                         boolean drawP2Start,
                         boolean dualStart,
                         boolean numbered,
                         Graphics2D g)
Renders the given tiles (editor/level-chooser). Warning: For optimum performance no checks are performed on any of the parameters (i.e. this method might not fail gracefully) though some of the parameters can be set to null if they do not apply.

Parameters:
tiles - the tiles to render
gridArea - absolute location and dimesions of the grid
tileSize - size of each individual grid slot
activePos - currently active grid position
activePos2 - second active position. Used in conjuction with activePos to highlight a whole area
oldPos - specifies previously active position. Only having to render over the top of one grid position improves performance.
player2Start - location of second player
drawP2Start - toggle drawing of second player's start position. Note: Above parameter required to distinguish between players' start positions.
dualStart - indicates both players start from the same position
numbered - toggle tile height numbers
g - graphics context for drawing

drawMenuString

public void drawMenuString(String s,
                           boolean raised,
                           Rectangle location,
                           Graphics2D g)
Draws a string with each letter on a separate tile. Warning: For optimum performance no checks are performed on any of the parameters (i.e. this method might not fail gracefully).

Parameters:
s - the string to render
raised - indicates whether each letter has a 'base' or not.
location - and dimensions for this string.
g - graphics context for drawing.

drawScoreString

public void drawScoreString(String s,
                            boolean appendCursor,
                            boolean first,
                            int x,
                            int y,
                            Graphics2D g)
Variation of drawMenuString. This is used to draw entries in the highscore table. Warning: For optimum performance no checks are performed on any of the parameters (i.e. this method might not fail gracefully).

Parameters:
s - the string to render
appendCursor - indicates whether to add a cursor to the end of the string.
first - highest score is highlighted.
x - absolute horizontal location to render to.
y - absolute vertical location to render to.
g - graphics context for drawing.