|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.deken.game.sprites.Sprite
org.deken.game.component.GComponent
org.deken.game.component.GTextContainer
org.deken.game.component.GButton
public class GButton
Title: GButton
Description: The GButton component is a lightweight sprite that display a GText or Animation. It is wired into the MouseListener to determine when to display a roll over text or image.
Copyright: Copyright (c) 2005
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.deken.game.component.GComponent |
---|
GComponent.Alignment, GComponent.MouseActions |
Field Summary | |
---|---|
static int |
ANIMATION_DEFAULT
Button Effects. |
static int |
ANIMATION_DIABLED
|
static int |
ANIMATION_PRESSED
|
static int |
ANIMATION_ROLLOVER
|
protected int |
animationIndex
|
protected java.util.List<ButtonListener> |
buttonListeners
|
protected ButtonNotify |
buttonNotify
|
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 | |
---|---|
GButton()
GButton is created with the Mouse action of button 1 pressed. |
|
GButton(Animation animation)
GButton is created with the Mouse action of button 1 pressed. |
|
GButton(GText gText)
GButton is created with the Mouse action of button 1 pressed. |
|
GButton(GText gText,
java.awt.Color fontHighlightColor)
GButton is created with the Mouse action of button 1 pressed. |
|
GButton(java.lang.String text)
GButton is created with the Mouse action of button 1 pressed. |
|
GButton(java.lang.String text,
java.awt.Font font,
java.awt.Color fontColor,
java.awt.Color fontHighlightColor)
GButton is created with the Mouse action of button 1 pressed. |
Method Summary | |
---|---|
void |
addAnimation(int id,
Animation animation)
|
void |
addFontColor(int id,
java.awt.Color color)
|
void |
addGText(GText gText)
|
void |
addInputAction(InputAction inputAction)
add an InputAction for monitoring. |
void |
addKeyAction(InputAction keyAction)
Add a key input action, that will trigger this button. |
boolean |
addListener(ButtonListener listener)
Listeners for when this button is pressed. |
GButton |
copy()
|
protected void |
copyGButtonBase(GButton that)
Copies the animations and fontColors |
void |
draw(java.awt.Graphics2D graphics,
int xOffset,
int yOffset)
Draws the sprite with the current offset. |
GComponent.Alignment |
getAlignment()
getAlignment |
Animation |
getAnimation()
|
Animation |
getAnimation(int buttonEffect)
|
java.awt.Color |
getFontHighlightColor()
|
java.awt.Image |
getImage()
getImage |
int[] |
getInputActionIds()
Gets the Key IDs. |
java.lang.String |
getKeyAssociated()
|
boolean |
hasListeners()
Convenience method for determining if child has InputListeners. |
void |
notifyListener(InputAction inputAction)
Receive Key actions. |
void |
notifyListener(InputMouseAction inputMouseAction)
Receive Mouse actions. |
void |
setAlignment(GComponent.Alignment alignment)
setAlignment |
void |
setAnimation(Animation animation,
int buttonEffect)
Sets the animation to one of the four button effects: The default, rollover, pressed and disabled. |
void |
setEnabled(boolean b)
setEnabled |
void |
setFontHighlightColor(java.awt.Color fontHighlightColor)
|
void |
setGText(GText gText)
|
void |
setKeyAssociated(java.lang.String keyAssociated)
|
void |
setMonitored(boolean active)
|
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, setInvalid |
Methods inherited from class org.deken.game.component.GComponent |
---|
addMouseAction, copyBase, getHorizontalAlignment, getMouseActions, getParent, getVerticalAlignment, getXLocation, getYLocation, isEnabled, positionHorizontalAlignment, positionVerticalAlignment, requestKeyPolling, 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 |
Field Detail |
---|
public static final int ANIMATION_DEFAULT
public static final int ANIMATION_ROLLOVER
public static final int ANIMATION_PRESSED
public static final int ANIMATION_DIABLED
protected int animationIndex
protected java.util.List<ButtonListener> buttonListeners
protected ButtonNotify buttonNotify
Constructor Detail |
---|
public GButton()
public GButton(java.lang.String text)
text
- Stringpublic GButton(Animation animation)
animation
- Animationpublic GButton(java.lang.String text, java.awt.Font font, java.awt.Color fontColor, java.awt.Color fontHighlightColor)
text
- font
- fontColor
- fontHighlightColor
- public GButton(GText gText)
gText
- public GButton(GText gText, java.awt.Color fontHighlightColor)
gText
- fontHighlightColor
- Method Detail |
---|
public void addAnimation(int id, Animation animation)
addAnimation
in class GTextContainer
public void addFontColor(int id, java.awt.Color color)
addFontColor
in class GTextContainer
public void addGText(GText gText)
addGText
in class GTextContainer
public void addInputAction(InputAction inputAction)
InputListener
addInputAction
in interface InputListener
public void addKeyAction(InputAction keyAction)
keyAction
- public boolean addListener(ButtonListener listener)
listener
-
public GButton copy()
copy
in class GComponent
public void draw(java.awt.Graphics2D graphics, int xOffset, int yOffset)
GComponent
draw
in class GComponent
graphics
- xOffset
- yOffset
- public boolean hasListeners()
hasListeners
in class GTextContainer
public void notifyListener(InputAction inputAction)
notifyListener
in interface InputListener
inputAction
- public void notifyListener(InputMouseAction inputMouseAction)
notifyListener
in interface InputMouseListener
inputMouseAction
- public GComponent.Alignment getAlignment()
public Animation getAnimation()
public Animation getAnimation(int buttonEffect)
public java.awt.Image getImage()
Returns the current image for the button.
public int[] getInputActionIds()
InputListener
getInputActionIds
in interface InputListener
public java.lang.String getKeyAssociated()
public java.awt.Color getFontHighlightColor()
public void setAlignment(GComponent.Alignment alignment)
alignment
- Alignmentpublic void setAnimation(Animation animation, int buttonEffect)
animation
- buttonEffect
- public void setEnabled(boolean b)
Calls the super method, and set the current animation to the enabled or disabled.
setEnabled
in class GComponent
b
- booleanpublic void setFontHighlightColor(java.awt.Color fontHighlightColor)
public void setGText(GText gText)
public void setKeyAssociated(java.lang.String keyAssociated)
public void setMonitored(boolean active)
setMonitored
in class GComponent
public void update(long elapseTime)
Update the button animation.
update
in interface Updateable
update
in class GComponent
elapseTime
- longpublic void validate(java.awt.Graphics2D graphics)
validate
in class GComponent
graphics
- protected void copyGButtonBase(GButton that)
that
- protected void spriteCollison(Sprite collideSprite)
Sprite
spriteCollison
in class Sprite
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |