jme.geometry.hud.text
Class Font2D

java.lang.Object
  extended byjme.geometry.hud.text.Font2D

public class Font2D
extends java.lang.Object

Font2D maintains display lists for each ASCII character defined by an image. Font2D assumes that the texture is 256x256 and that the characters are 16 pixels high by 16 pixels wide. The order of the characters is also important:

After the font is loaded, it can be used with a call to print. The Font2D class is also printed in Ortho mode and billboarded, as well as depth buffering turned off. This means that the font will be placed at a two dimensional coordinate that corresponds to screen coordinates.

Version:
$Id: Font2D.java,v 1.4 2003/09/05 15:43:13 mojomonkey Exp $
Author:
Mark Powell

Field Summary
static int ITALICS
           
static int NORMAL
           
 
Constructor Summary
Font2D(java.lang.String texture)
          Constructor takes a path to the texture to use of the font base.
 
Method Summary
 void buildDisplayList()
          buildDisplayList sets up the 256 display lists that are used to render each font character.
 void deleteFont()
          deleteFont deletes the current display list of font objects.
 void print(int x, int y, java.lang.String text, int set)
          print renders the specified string to a given (x,y) location.
 void setColor(float r, float g, float b, float a)
          setColor sets the RGBA values to render the font as.
 void setFontTexture(java.lang.String texture)
          setFontTexture sets the texture the Font2D object to that which is passed in.
 java.lang.String toString()
          toString returns the string representation of this font object in the Format:

jme.geometry.hud.text.Font2D@1c282a1
Color: {RGBA COLOR}
Blended: {BOOLEAN VALUE}
Texture: {IMAGE FILE}
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NORMAL

public static final int NORMAL
See Also:
Constant Field Values

ITALICS

public static final int ITALICS
See Also:
Constant Field Values
Constructor Detail

Font2D

public Font2D(java.lang.String texture)
Constructor takes a path to the texture to use of the font base. This image format must be compatible with TextureManager's image types.

Parameters:
texture - the path to the image that defines the fonts.
See Also:
TextureManager
Method Detail

setFontTexture

public void setFontTexture(java.lang.String texture)
setFontTexture sets the texture the Font2D object to that which is passed in.

Parameters:
texture - the new texture to use.

setColor

public void setColor(float r,
                     float g,
                     float b,
                     float a)
setColor sets the RGBA values to render the font as. By default the color is white with no transparency.

Parameters:
r - the red component of the color.
g - the green component of the color.
b - the blue component of the color.
a - the alpha component of the color.

deleteFont

public void deleteFont()
deleteFont deletes the current display list of font objects. The font will be useless until a call to buildDisplayLists is made.


print

public void print(int x,
                  int y,
                  java.lang.String text,
                  int set)
print renders the specified string to a given (x,y) location. The x, y location is in terms of screen coordinates. There are currently two sets of fonts supported: NORMAL and ITALICS.

Parameters:
x - the x screen location to start the string render.
y - the y screen location to start the string render.
text - the String to render.
set - the mode of font: NORMAL or ITALICS.

buildDisplayList

public void buildDisplayList()
buildDisplayList sets up the 256 display lists that are used to render each font character. Each list quad is 16x16, as defined by the font image size.


toString

public java.lang.String toString()
toString returns the string representation of this font object in the Format:

jme.geometry.hud.text.Font2D@1c282a1
Color: {RGBA COLOR}
Blended: {BOOLEAN VALUE}
Texture: {IMAGE FILE}

Returns:
the string representation of this object.