org.deken.game.component
Class GTableContainer

java.lang.Object
  extended by org.deken.game.sprites.Sprite
      extended by org.deken.game.component.GComponent
          extended by org.deken.game.component.GContainer
              extended by org.deken.game.component.GTableContainer
All Implemented Interfaces:
InputMouseListener, Updateable
Direct Known Subclasses:
ConfigurationMenu

public class GTableContainer
extends GContainer

Title: GTableContainer

Description: The GTableContainer display GComponents within a grid.

Copyright: Copyright (c) Feb 9, 2013

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.GContainer
backgroundColor, grabbed
 
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
GTableContainer(int screenWidth, int screenHeight, int columns, int rows)
           
 
Method Summary
 void add(GComponent component)
           
 void add(GComponent gameComponent, GComponent.Alignment horizontalAlignment, GComponent.Alignment verticalAlignment, int column, int row)
          Add a GameComponent to this GameTable, using the alignment for Horizontal and Vertical placement, in cell at the row and column.
 void add(GComponent gameComponent, GComponent.Alignment horizontalAlignment, int column, int row)
          Add a GameComponent to this GameTable, using the alignment for Horizontal placement, in cell at the row and column.
 void add(GComponent gameComponent, int column, int row)
          Add a GameComponent to this GameTable, using the alignment for Horizontal placement, in cell at the row and column.
 GComponent copy()
           
 void draw(java.awt.Graphics2D graphics, int xOffset, int yOffset)
          Draws the sprite with the current offset.
 java.util.List<GComponent> getChildren()
           
 GComponent getComponentByName(java.lang.String name)
           
 void notifyListener(InputMouseAction inputMouseAction)
          notifyListener
 void remove(GComponent gameComponent)
           
protected  void setLocations(int x, int y)
           
 void setMonitored(boolean active)
           
 void setSize(SpriteSize spriteSize)
          Set the size of this container.
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.GContainer
copyBase, isGrabbed, isSizeSet, setBackgroundColor, setGrabbed, setScreenHeightWidth
 
Methods inherited from class org.deken.game.component.GComponent
addMouseAction, copyBase, getHorizontalAlignment, getMouseActions, getParent, getVerticalAlignment, getXLocation, getYLocation, isEnabled, positionHorizontalAlignment, positionVerticalAlignment, requestKeyPolling, setEnabled, setHorizontalAlignment, setInvalid, 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, toString, updateLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GTableContainer

public GTableContainer(int screenWidth,
                       int screenHeight,
                       int columns,
                       int rows)
Parameters:
screenWidth -
screenHeight -
columns -
rows -
Method Detail

add

public void add(GComponent component)
Specified by:
add in class GContainer

add

public void add(GComponent gameComponent,
                GComponent.Alignment horizontalAlignment,
                int column,
                int row)
Add a GameComponent to this GameTable, using the alignment for Horizontal placement, in cell at the row and column. The alignment is used if it is RIGHT, LEFT or CENTER. Vertical alignment is defaulted to CENTER. If there is an entry already at the specified row and column, it is replaced with this entry.

Parameters:
gameComponent -
horizontalAlignment -
column -
row -

add

public void add(GComponent gameComponent,
                GComponent.Alignment horizontalAlignment,
                GComponent.Alignment verticalAlignment,
                int column,
                int row)
Add a GameComponent to this GameTable, using the alignment for Horizontal and Vertical placement, in cell at the row and column. The alignment is used if it is RIGHT, LEFT or CENTER. If a Vertical alignment is enter, the horizontal defaults to CENTER. If there is an entry already at the specified row and column, it is replaced with this entry.

Parameters:
gameComponent -
horizontalAlignment -
verticalAlignment -
column -
row -

add

public void add(GComponent gameComponent,
                int column,
                int row)
Add a GameComponent to this GameTable, using the alignment for Horizontal placement, in cell at the row and column. The alignment is defaulted to Center alignment. If there is an entry already at the specified row and column, it is replaced with this entry.

Parameters:
gameComponent -
column -
row -

copy

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

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

getChildren

public java.util.List<GComponent> getChildren()
Specified by:
getChildren in class GContainer
Returns:
List of GComponents that this GContainer holds.

getComponentByName

public GComponent getComponentByName(java.lang.String name)
Specified by:
getComponentByName in class GContainer
Returns:
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

remove

public void remove(GComponent gameComponent)
Specified by:
remove in class GContainer
Parameters:
gameComponent -

setMonitored

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

setSize

public void setSize(SpriteSize spriteSize)
Set the size of this container. If the height is zero, the cells will be pushed up against each other.

Overrides:
setSize in class Sprite
Parameters:
spriteSize -

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 - long

validate

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

spriteCollison

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

Specified by:
spriteCollison in class Sprite

setLocations

protected void setLocations(int x,
                            int y)