game.graphics.text
Class CBitmapFont

java.lang.Object
  extended by game.graphics.image.CImageProcessor
      extended by game.graphics.text.CBitmapFont

public class CBitmapFont
extends CImageProcessor

Variable width font constructed from an image.

Author:
seb

Field Summary
private  int[] m_aCharOffsets
           
private  boolean m_bNoLowerCase
           
private  int m_charHeight
           
private  int m_firstChar
           
private  java.awt.Image[] m_imgChars
           
private  int m_quadratin
           
private  int m_space
           
private  int m_tabSize
           
private  int m_thinSpace
           
 
Fields inherited from class game.graphics.image.CImageProcessor
A_MASK, A_OFFSET, B_MASK, B_OFFSET, BYTE_MASK, G_MASK, G_OFFSET, H, m_aBasePixels, m_bufferedImage, R_MASK, R_OFFSET, RGB_MASK, SCAN_SIZE, W
 
Constructor Summary
CBitmapFont(CBitmapFont rhs)
          Copy a font.
CBitmapFont(java.awt.Image imgFont)
          Constructs a variable width font from an image.
 
Method Summary
private  void applyGradient()
           
 void drawString(java.awt.Graphics g, java.lang.String str, int x, int y)
          Draws a string.
private  int getCharIndex(char c)
          Returns the index of the char in the image array.
private  int getCharWidth(int index)
          Retrieves a char width assuming it has an image.
 int getHeight()
           
private  int getSpaceWidth(char c)
          Returns a whitespace (eg. ' ' or '\t') width, assuming c represents a whitespace.
 int getStringWidth(java.lang.String str)
          String measuring tool.
private  void init()
          Inits char width and spacing relative data.
 
Methods inherited from class game.graphics.image.CImageProcessor
affineTransform, affineTransformAA, colorAdd, colorFilter, convolve, createARGBImage, createCompatibleImage, drawImage, fourCornersGradient, getA, getARGB, getB, getBlurKernel, getBufferedImage, getEdgeKernel, getEmbossKernel, getG, getGaussianBlurKernel, getGraphics, getImageOffsets, getR, getSharpenKernel, interleave, invert, mul, mul, mul, restablishTransparency, rotate, rotate, safeComponent, saveCurrentPixels, scrollH, setAlpha, split, split, wave, zoom, zoom
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_imgChars

private java.awt.Image[] m_imgChars

m_aCharOffsets

private int[] m_aCharOffsets

m_bNoLowerCase

private boolean m_bNoLowerCase

m_firstChar

private final int m_firstChar
See Also:
Constant Field Values

m_quadratin

private int m_quadratin

m_thinSpace

private final int m_thinSpace
See Also:
Constant Field Values

m_space

private int m_space

m_tabSize

private final int m_tabSize
See Also:
Constant Field Values

m_charHeight

private int m_charHeight
Constructor Detail

CBitmapFont

public CBitmapFont(java.awt.Image imgFont)
Constructs a variable width font from an image.

Parameters:
imgFont - the image containing the chars' graphics.

CBitmapFont

public CBitmapFont(CBitmapFont rhs)
Copy a font. Image data is copied too (thus can be processed independantly of the original font).

Parameters:
rhs -
Method Detail

init

private final void init()
Inits char width and spacing relative data.


getStringWidth

public final int getStringWidth(java.lang.String str)
String measuring tool.

Parameters:
str -
Returns:
the string image length in pixels

getHeight

public final int getHeight()

getCharIndex

private final int getCharIndex(char c)
Returns the index of the char in the image array.

Parameters:
c - the char whom index you seek
Returns:
the said index

getCharWidth

private final int getCharWidth(int index)
Retrieves a char width assuming it has an image.

Parameters:
index - the index of the char in the image array.
Returns:
the corresponding char's image width in pixels.

getSpaceWidth

private final int getSpaceWidth(char c)
Returns a whitespace (eg. ' ' or '\t') width, assuming c represents a whitespace.

Parameters:
c -
Returns:
the width in pixels

drawString

public void drawString(java.awt.Graphics g,
                       java.lang.String str,
                       int x,
                       int y)
Draws a string.

Parameters:
g - the Graphics to draw to
str - the text to be drawn
x - where to (upper left corner)
y - idem

applyGradient

private final void applyGradient()