org.deken.game.component
Class GMenuPopout

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.GMenuPopout
All Implemented Interfaces:
ButtonListener, InputMouseListener, Updateable

public class GMenuPopout
extends GContainer
implements ButtonListener

Title: GMenuPopout

Description: The GMenuPopout is a button that when clicked will pop out a menu. If the popped out menu looses focus it will close, or when the button is clicked again.

The GMenuPopout can also be set to change based on the menu option selected. This may cause the button to change size. Copyright: Copyright (c) Dec 26, 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
protected  GButton btnController
           
protected  java.util.List<java.lang.String> buttons
           
protected  java.lang.String controllerName
           
protected  GMenu menuPopOut
           
protected  boolean menuShown
           
 
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
GMenuPopout(int screenWidth, int screenHeight)
           
GMenuPopout(int screenWidth, int screenHeight, Animation animation)
           
GMenuPopout(int screenWidth, int screenHeight, Animation animation, Animation animationHighlight)
           
GMenuPopout(int screenWidth, int screenHeight, GText controllingButton)
           
 
Method Summary
 void add(GComponent component)
           
 boolean addControllingButtonListener(ButtonListener listener)
           
 void addMenu(GMenu gMenu)
          Adds a GMenu to this pop out menu.
 GComponent copy()
           
 void draw(java.awt.Graphics2D graphics, int xOffset, int yOffset)
          Draws the sprite with the current offset.
 java.util.List<? extends GComponent> getChildren()
           
 GComponent getComponentByName(java.lang.String name)
           
 java.lang.String getControllingButtonName()
           
 SpriteSize getSize()
           
 boolean isMenuOpen()
           
 void notifyButtonListener(java.lang.String name)
           
 void notifyListener(InputMouseAction inputMouseAction)
          notifyListener
 void remove(GComponent gameComponent)
           
 void setBackgroundColor(java.awt.Color backgroundColor)
           
 void setChangeToSelected(boolean changeToSelected)
           
 void setCloseOnSelect(boolean closeOnSelect)
           
 void setControllingButton(GButton button)
          Copies the attributes from the button passed in, into the GMenuPopout's controlling button.
 void setHighLightColor(java.awt.Color highLightColor)
          Sets the color when the mouse is on the button.
 void setLocation(GameLocation location)
           
 void setMenuOffset(int menuOffset)
           
 void setMonitored(boolean active)
           
 void setSize(SpriteSize size)
           
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, 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, getWidth, removeFromMap, setBoundingBox, setBoundingBox, setCollisionMap, setName, toString, updateLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

buttons

protected java.util.List<java.lang.String> buttons

btnController

protected GButton btnController

controllerName

protected java.lang.String controllerName

menuPopOut

protected GMenu menuPopOut

menuShown

protected boolean menuShown
Constructor Detail

GMenuPopout

public GMenuPopout(int screenWidth,
                   int screenHeight)

GMenuPopout

public GMenuPopout(int screenWidth,
                   int screenHeight,
                   GText controllingButton)

GMenuPopout

public GMenuPopout(int screenWidth,
                   int screenHeight,
                   Animation animation)

GMenuPopout

public GMenuPopout(int screenWidth,
                   int screenHeight,
                   Animation animation,
                   Animation animationHighlight)
Method Detail

add

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

addControllingButtonListener

public boolean addControllingButtonListener(ButtonListener listener)

addMenu

public void addMenu(GMenu gMenu)
Adds a GMenu to this pop out menu. If this pop out menu has no menu items, it will copy the added menu's properties, background color, Menu orientation etc. It does not copy over Listeners.

Parameters:
gMenu -

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<? extends 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

getControllingButtonName

public java.lang.String getControllingButtonName()

getSize

public SpriteSize getSize()
Overrides:
getSize in class Sprite
Returns:
SpriteSize

isMenuOpen

public boolean isMenuOpen()

notifyButtonListener

public void notifyButtonListener(java.lang.String name)
Specified by:
notifyButtonListener in interface ButtonListener

notifyListener

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

This method is called when any Mouse Motion event occurs.

Specified by:
notifyListener in interface InputMouseListener
Parameters:
inputMouseAction - InputMouseAction

remove

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

setBackgroundColor

public void setBackgroundColor(java.awt.Color backgroundColor)
Overrides:
setBackgroundColor in class GContainer

setChangeToSelected

public void setChangeToSelected(boolean changeToSelected)

setControllingButton

public void setControllingButton(GButton button)
Copies the attributes from the button passed in, into the GMenuPopout's controlling button.

Parameters:
button -

setHighLightColor

public void setHighLightColor(java.awt.Color highLightColor)
Sets the color when the mouse is on the button.

Parameters:
highLightColor -

setCloseOnSelect

public void setCloseOnSelect(boolean closeOnSelect)

setLocation

public void setLocation(GameLocation location)
Overrides:
setLocation in class Sprite
Parameters:
location - GameLocation

setMenuOffset

public void setMenuOffset(int menuOffset)

setMonitored

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

setSize

public void setSize(SpriteSize size)
Overrides:
setSize in class Sprite
Parameters:
size - 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