de.rico.engine.effect.ortho
Class TextRenderer

java.lang.Object
  extended by de.rico.engine.effect.ortho.AbstractOrthoOverlay
      extended by de.rico.engine.effect.ortho.TextRenderer

public class TextRenderer
extends AbstractOrthoOverlay

This class can be used to draw text onto the sceen.

Author:
Frank Bruns

Constructor Summary
TextRenderer()
          Creates a new text renderer with the default color white and the font type HELVETICA_12.
TextRenderer(Color4f color)
          Creates a new text renderer with the specified color and the font type HELVETICA_12.
TextRenderer(Font font)
          Creates a new text renderer with the specified font type and the default text color white.
TextRenderer(Font font, Color4f color)
          Creates a new text renderer with the specified font type and the specified text color.
 
Method Summary
 void drawString(java.lang.String text, int x, int y)
          Draws the specified string at the specified position.
 void drawString(java.lang.String text, int x, int y, Color4f c)
          Draws the specified string at the specified position with the specified color.
 Font getFont()
          Returns the font that is currently used for text rendering by this text renderer object.
 int getStringWidth(java.lang.String text)
          Returns the width of the specified String using the current font.
 void setFont(Font font)
          Sets the font of the text renderer.
 
Methods inherited from class de.rico.engine.effect.ortho.AbstractOrthoOverlay
getColor, setColor
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextRenderer

public TextRenderer()
Creates a new text renderer with the default color white and the font type HELVETICA_12.


TextRenderer

public TextRenderer(Color4f color)
Creates a new text renderer with the specified color and the font type HELVETICA_12.

Parameters:
color - text color

TextRenderer

public TextRenderer(Font font)
Creates a new text renderer with the specified font type and the default text color white.

Parameters:
font - font type (from Font enumeration)

TextRenderer

public TextRenderer(Font font,
                    Color4f color)
Creates a new text renderer with the specified font type and the specified text color.

Parameters:
font - font type (from Font enumeration)
color - text color
Method Detail

setFont

public void setFont(Font font)
Sets the font of the text renderer.

Parameters:
font - new font

getFont

public Font getFont()
Returns the font that is currently used for text rendering by this text renderer object.

Returns:
current font

drawString

public void drawString(java.lang.String text,
                       int x,
                       int y)
Draws the specified string at the specified position.

Note: This method uses Java's original 2d screen coordinates, i.e. (0,0) is the upper left corner.

Parameters:
text - text to draw on screen
x - x-coordinate for starting to draw
y - y-coordinate for starting to draw

drawString

public void drawString(java.lang.String text,
                       int x,
                       int y,
                       Color4f c)
Draws the specified string at the specified position with the specified color.

Note: This method uses Java's original 2d screen coordinates, i.e. (0,0) is the upper left corner.

Parameters:
text - text to draw on screen
x - x-coordinate for starting to draw
y - y-coordinate for starting to draw
c - color to use for the text

getStringWidth

public int getStringWidth(java.lang.String text)
Returns the width of the specified String using the current font.

Parameters:
text - text to calculate width for
Returns:
width of the specified String