vooga.gameEngine.graphics
Class TextTexture

java.lang.Object
  extended by vooga.gameEngine.graphics.Texture
      extended by vooga.gameEngine.graphics.TextTexture
All Implemented Interfaces:
java.io.Serializable

public class TextTexture
extends Texture

Class TextTexture allows a string to be rendered on screen. The given string is rendered with as large as a font as possible in the specified dimension. If the string does not fill the entire area then it is rendered top and left justified.

Author:
Justin C. Klaassen
See Also:
Serialized Form

Constructor Summary
TextTexture(java.lang.String text, java.awt.Font f, java.awt.Color c, Dimension d, Position p)
          Creates a new TextTexture with given parameters.
 
Method Summary
 java.lang.String getText()
          Method for getting the text associated with this TextTexture .
protected  java.awt.Shape makeShape()
          Method for a Texture subclass to supply a Shape representing their bounding box.
 void setColor(java.awt.Color color)
           
 void setFont(java.awt.Font f)
           
 void setSize(Dimension d)
          Sets the specified Dimension, d, as this Texture's size.
 void setText(java.lang.String text)
          Sets the text displayed by this Texture.
 
Methods inherited from class vooga.gameEngine.graphics.Texture
getArea, getIndex, getPosition, getRotation, getShape, getSize, paintComponent, setImage, setIndex, setPosition, setRotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextTexture

public TextTexture(java.lang.String text,
                   java.awt.Font f,
                   java.awt.Color c,
                   Dimension d,
                   Position p)
Creates a new TextTexture with given parameters.

Parameters:
text - is the String to be displayed
f - is the Font to be used, the fonts current size (if applicable) will be ignored an a new font size will be calculate that allows the String to take up the specified area
c - is the Color that the text will be rendered in
d - is the Dimension taken up by the text in the game's coordinate system
p - is the Position of the string from the top left corner in the game's coordinate system
Method Detail

setText

public void setText(java.lang.String text)
Sets the text displayed by this Texture.

Parameters:
text - is the String to be displayed

getText

public java.lang.String getText()
Method for getting the text associated with this TextTexture .

Returns:
the String that this represents

setFont

public void setFont(java.awt.Font f)

setColor

public void setColor(java.awt.Color color)

setSize

public void setSize(Dimension d)
Description copied from class: Texture
Sets the specified Dimension, d, as this Texture's size.

Overrides:
setSize in class Texture
Parameters:
d - is the dimension of this game object in the game coordinate system

makeShape

protected java.awt.Shape makeShape()
Description copied from class: Texture
Method for a Texture subclass to supply a Shape representing their bounding box. For efficiency, an object should cache their Shape if possible.

Specified by:
makeShape in class Texture
Returns:
a Shape representing the boundaries of the object