ch.aplu.jgamegrid
Class GGCheckButton

java.lang.Object
  extended by ch.aplu.jgamegrid.Actor
      extended by ch.aplu.jgamegrid.GGButtonBase
          extended by ch.aplu.jgamegrid.GGCheckButton
All Implemented Interfaces:
GGActorCollisionListener, GGBorderListener, GGTileCollisionListener, java.util.EventListener

public class GGCheckButton
extends GGButtonBase

Class that implements a check button actor with standard behavior. Events are generated when the button changes its state due to a mouse click from checked to unchecked or vise versa. In order to align several check buttons, the actor's image is centered in the middle of the check box and extends the same size to the left and right determined by the text length. The left part is always transparent. The default hot spot area is the square that surrounds the cross. Use Actor.setLocationOffset() to fine tune the button location.


Field Summary
 
Fields inherited from class ch.aplu.jgamegrid.Actor
gameGrid, nbCycles
 
Constructor Summary
GGCheckButton(java.lang.String text)
          Creates a unchecked check button with the given text annotation, black text and white background colors.
GGCheckButton(java.lang.String text, boolean isChecked)
          Creates a check button with the given text annotation, black text and and white background colors.
GGCheckButton(java.lang.String text, java.awt.Color textColor, java.awt.Color bkColor)
          Creates a unchecked check button with the given text annotation and given text and background colors.
GGCheckButton(java.lang.String text, java.awt.Color textColor, java.awt.Color bkColor, boolean isChecked)
          Creates a check button with the given text annotation and given text and background colors.
 
Method Summary
 void addCheckButtonListener(GGCheckButtonListener listener)
          Registers a GGCheckButtonListener to get notifications when the button is manipulated.
 boolean isChecked()
          Returns the current state of the button.
 void reset()
          Overrides the actor's reset() called when the button is added to the game grid.
 void setChecked(boolean b)
          Sets the button in the checked/unchecked state.
 
Methods inherited from class ch.aplu.jgamegrid.GGButtonBase
isEnabled, setEnabled, setHotspotArea, setRefreshEnabled
 
Methods inherited from class ch.aplu.jgamegrid.Actor
act, addActorCollisionListener, addBorderListener, addCollisionActor, addCollisionActors, addCollisionActors, addCollisionTile, addCollisionTiles, addCollisionTiles, addMouseTouchListener, addMouseTouchListener, addTileCollisionListener, collide, collide, delay, displace, getBackground, getCollisionActors, getCollisionActorsInRange, getCollisionTiles, getCurrentImage, getDirection, getDirectionStart, getDisplacePosition, getHeight, getIdVisible, getImage, getImage, getIntDirection, getLocation, getLocationOffset, getLocationStart, getNbCycles, getNbHorzCells, getNbSprites, getNbVertCells, getNeighbours, getNeighbours, getNextMoveLocation, getPixelColor, getPixelLocation, getRotatedPosition, getRotationIndex, getScaledImage, getScaledImage, getScaledImage, getSlowDown, getWidth, getX, getXStart, getY, getYStart, hide, isActEnabled, isActorCollisionEnabled, isHorzMirror, isInGrid, isMoveValid, isNearBorder, isRemoved, isRotatable, isTileCollisionEnabled, isVertMirror, isVisible, move, move, nearBorder, removeSelf, rotate, rotate, setActEnabled, setActorCollisionEnabled, setCollisionCircle, setCollisionCircle, setCollisionImage, setCollisionImage, setCollisionLine, setCollisionLine, setCollisionRectangle, setCollisionRectangle, setCollisionSpot, setCollisionSpot, setDirection, setDirection, setDisplacePosition, setHorzMirror, setLocation, setLocationOffset, setLocationOffset, setMouseTouchCircle, setMouseTouchCircle, setMouseTouchEnabled, setMouseTouchImage, setMouseTouchImage, setMouseTouchRectangle, setMouseTouchRectangle, setOnBottom, setOnTop, setPixelLocation, setSlowDown, setTileCollisionEnabled, setVertMirror, setX, setY, show, show, showNextSprite, showPreviousSprite, turn
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GGCheckButton

public GGCheckButton(java.lang.String text)
Creates a unchecked check button with the given text annotation, black text and white background colors.

Parameters:
text - the text annotation

GGCheckButton

public GGCheckButton(java.lang.String text,
                     boolean isChecked)
Creates a check button with the given text annotation, black text and and white background colors.

Parameters:
text - the text annotation
isChecked - if true, the check box is initially checked

GGCheckButton

public GGCheckButton(java.lang.String text,
                     java.awt.Color textColor,
                     java.awt.Color bkColor)
Creates a unchecked check button with the given text annotation and given text and background colors. For transparent background use sRGB color with alpha = 0.

Parameters:
text - the text annotation
textColor - the color of the annotation text
bkColor - the background color

GGCheckButton

public GGCheckButton(java.lang.String text,
                     java.awt.Color textColor,
                     java.awt.Color bkColor,
                     boolean isChecked)
Creates a check button with the given text annotation and given text and background colors. For transparent background use sRGB color with alpha = 0.

Parameters:
text - the text annotation
textColor - the color of the annotation text
bkColor - the background color
isChecked - if true, the check box is initially checked
Method Detail

reset

public void reset()
Overrides the actor's reset() called when the button is added to the game grid.

Overrides:
reset in class Actor

isChecked

public boolean isChecked()
Returns the current state of the button.

Returns:
true, if the button is checked

setChecked

public void setChecked(boolean b)
Sets the button in the checked/unchecked state. Does not generate a notification event. If automatic refresh is enabled, refreshs the game grid.

Parameters:
b - if true, the button is checked; otherwise it is unchecked

addCheckButtonListener

public void addCheckButtonListener(GGCheckButtonListener listener)
Registers a GGCheckButtonListener to get notifications when the button is manipulated.

Parameters:
listener - the GGCheckButtonListener to register