org.deken.game.component
Class GLabel

java.lang.Object
  extended by org.deken.game.sprites.Sprite
      extended by org.deken.game.component.GComponent
          extended by org.deken.game.component.GTextContainer
              extended by org.deken.game.component.GLabel
All Implemented Interfaces:
InputMouseListener, Updateable

public class GLabel
extends GTextContainer

Title: GLabel

Description: The GLabel is a light weight component that display either an Animation or a GText in the component layer (top most layer). Even though this implements the InputMouseListener as part of the GComponent, it is not supported in this class, because this is a display only object.

Copyright: Copyright (c) Mar 6, 2011

Version:
1.0
Author:
Gary Deken

Nested Class Summary
 
Nested classes/interfaces inherited from class org.deken.game.component.GComponent
GComponent.Alignment, GComponent.MouseActions
 
Field Summary
 
Fields inherited from class org.deken.game.component.GTextContainer
baseAnimation, gText
 
Fields inherited from class org.deken.game.component.GComponent
horizontalAlignment, id, invalid, keyPolling, mouseActions, parent, requestKeyPolling, screenHeight, screenWidth, verticalAlignment, xOffSet, yOffSet
 
Fields inherited from class org.deken.game.sprites.Sprite
boundingBox, collisionMap, location, size
 
Constructor Summary
GLabel(Animation animation)
           
GLabel(GText gText)
           
GLabel(java.lang.String text)
           
GLabel(java.lang.String text, java.awt.Font font, java.awt.Color fontColor)
           
 
Method Summary
 void addAnimation(int id, Animation animation)
           
 void addFontColor(int id, java.awt.Color color)
           
 void addGText(GText gText)
           
 GLabel copy()
           
 void draw(java.awt.Graphics2D graphics, int xOffset, int yOffset)
          Draws the sprite with the current offset.
 void notifyListener(InputMouseAction inputMouseAction)
          notifyListener
 void setGameText(GText gText)
           
 void setMonitored(boolean active)
           
 void setText(java.lang.String text)
          Convenience method for setting the text.
protected  void spriteCollison(Sprite collideSprite)
          Handle the collision with another sprite.
 void update(long elapseTime)
          update
 void validate(java.awt.Graphics2D graphics)
           
 
Methods inherited from class org.deken.game.component.GTextContainer
getBaseAnimation, getGText, hasListeners, setInvalid
 
Methods inherited from class org.deken.game.component.GComponent
addMouseAction, copyBase, getHorizontalAlignment, getMouseActions, getParent, getVerticalAlignment, getXLocation, getYLocation, isEnabled, positionHorizontalAlignment, positionVerticalAlignment, requestKeyPolling, setEnabled, setHorizontalAlignment, setKeyPolling, setParent, setVerticalAlignment
 
Methods inherited from class org.deken.game.sprites.Sprite
getBounds, getDepth, getHeight, getLocation, getName, getSize, getWidth, removeFromMap, setBoundingBox, setBoundingBox, setCollisionMap, setLocation, setName, setSize, toString, updateLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GLabel

public GLabel(java.lang.String text)
Parameters:
text -

GLabel

public GLabel(java.lang.String text,
              java.awt.Font font,
              java.awt.Color fontColor)
Parameters:
text -
font -
fontColor -

GLabel

public GLabel(GText gText)
Parameters:
gText -

GLabel

public GLabel(Animation animation)
Parameters:
animation -
Method Detail

addAnimation

public void addAnimation(int id,
                         Animation animation)
Specified by:
addAnimation in class GTextContainer

addFontColor

public void addFontColor(int id,
                         java.awt.Color color)
Specified by:
addFontColor in class GTextContainer

addGText

public void addGText(GText gText)
Specified by:
addGText in class GTextContainer

copy

public GLabel copy()
Specified by:
copy in class GComponent
Returns:
GameLabel

draw

public void draw(java.awt.Graphics2D graphics,
                 int xOffset,
                 int yOffset)
Description copied from class: GComponent
Draws the sprite with the current offset.

Specified by:
draw in class GComponent

notifyListener

public void notifyListener(InputMouseAction inputMouseAction)
Description copied from interface: InputMouseListener
notifyListener

This method is called when any Mouse Motion event occurs.

Parameters:
inputMouseAction - InputMouseAction

setGameText

public void setGameText(GText gText)

setMonitored

public void setMonitored(boolean active)
Specified by:
setMonitored in class GComponent

setText

public void setText(java.lang.String text)
Convenience method for setting the text.

Parameters:
text -

update

public void update(long elapseTime)
Description copied from class: GComponent
update

This method takes the elapse time, and calculates the new current frame of the animation.

Specified by:
update in interface Updateable
Specified by:
update in class GComponent
Parameters:
elapseTime -

validate

public void validate(java.awt.Graphics2D graphics)
Specified by:
validate in class GComponent
Parameters:
graphics -

spriteCollison

protected void spriteCollison(Sprite collideSprite)
Description copied from class: Sprite
Handle the collision with another sprite.

Specified by:
spriteCollison in class Sprite