Genuts API

com.genuts.gameui
Class SpriteLabel

java.lang.Object
  extended bycom.genuts.gameui.Sprite
      extended bycom.genuts.gameui.SpriteLabel
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
SpriteCounter

public class SpriteLabel
extends Sprite

A Label object is a sprite for placing text in a playfield. A label displays a single line of read-only text. The text can be changed by the application, but a user cannot edit it directly.

By default, the label is a background sprite.

To represent text, the label use the default font of the playfield.


Constructor Summary
SpriteLabel(java.lang.String text)
          Initializes the label.
 
Method Summary
 int getBaseline()
          Gets the baseline of this label.
 java.awt.Color getColor()
          Gets the color of this label.
 java.awt.Font getFont()
          Gets the font of this label.
 java.lang.String getText()
          Gets the text of this label.
protected  void initSprite()
          Initializes the label sprite.
 void paint(java.awt.Graphics g)
          Paint this label.
 void setBaseline(int base)
          Sets the baseline for this label.
 void setColor(java.awt.Color color)
          Sets the color for this label.
 void setFont(java.awt.Font f)
          Gets the font for this label.
protected  void setParent(PlayField parent)
          Sets the parent playfield of this sprite.
 void setText(java.lang.String text)
          Sets the text for this label.
 
Methods inherited from class com.genuts.gameui.Sprite
checkCollision, cloneSprite, collisionWith, getActionSprite, getBackground, getBottomCollisionOffset, getBounds, getFinalActionSprite, getFinalWrapper, getHeight, getId, getImage, getLeftCollisionOffset, getParent, getPosition, getRightCollisionOffset, getRotation, getSize, getTopCollisionOffset, getWidth, getWrapper, getX, getY, invalidate, isBackgroundSprite, isPremode, isSpriteAt, isValidate, isVisible, preCollisionWith, repaint, setBackground, setBackgroundSprite, setBottomCollisionOffset, setBounds, setBounds, setId, setImage, setLeftCollisionOffset, setPosition, setPremode, setRightCollisionOffset, setRotation, setSize, setTopCollisionOffset, setVisible, setWrapper, toString, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SpriteLabel

public SpriteLabel(java.lang.String text)
Initializes the label.

Method Detail

initSprite

protected void initSprite()
Initializes the label sprite.


setParent

protected void setParent(PlayField parent)
Description copied from class: Sprite
Sets the parent playfield of this sprite.

Overrides:
setParent in class Sprite
Parameters:
parent - Parent playfield of this sprite.

setText

public void setText(java.lang.String text)
Sets the text for this label.

Parameters:
text - Text to set.

getText

public java.lang.String getText()
Gets the text of this label.

Returns:
The text of the label.

setColor

public void setColor(java.awt.Color color)
Sets the color for this label.

Parameters:
color - Color for this label.

getColor

public java.awt.Color getColor()
Gets the color of this label.

Returns:
The color of this label.

getFont

public java.awt.Font getFont()
Gets the font of this label.

Returns:
This label's font. If a font has not been set for this label, the font of its parent playfield is returned.

setFont

public void setFont(java.awt.Font f)
Gets the font for this label.

Parameters:
f - The font to become this label's font.

setBaseline

public void setBaseline(int base)
Sets the baseline for this label.

If the baseline is equal to -1, this means that the size of the label is not set.


getBaseline

public int getBaseline()
Gets the baseline of this label.

If the baseline is equal to -1, this means that the size of the label is not set.


paint

public void paint(java.awt.Graphics g)
Paint this label.

Overrides:
paint in class Sprite
Parameters:
g - The graphics context to use for painting.

Genuts API

Genuts API