ch.aplu.jgamegrid
Class GGRadioButton

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

public class GGRadioButton
extends GGButtonBase

Class that implements a radio button actor with standard behavior. Events are generated when the button changes its state due to a mouse click from selected to deselected or vise versa. In order to align several radio buttons, the actor's image is centered in the middle of the radio 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 bounding square of the circle. Use Actor.setLocationOffset() to fine tune the button location.


Field Summary
 
Fields inherited from class ch.aplu.jgamegrid.Actor
gameGrid, nbCycles
 
Constructor Summary
GGRadioButton(java.lang.String text)
          Creates a deselected radio button with the given text annotation, black text and white background colors.
GGRadioButton(java.lang.String text, boolean isSelected)
          Creates a radio button with the given text annotation, black text and and white background colors.
GGRadioButton(java.lang.String text, java.awt.Color textColor, java.awt.Color bkColor)
          Creates a deselected radio button with the given text annotation and given text and background colors.
GGRadioButton(java.lang.String text, java.awt.Color textColor, java.awt.Color bkColor, boolean isSelected)
          Creates a radio button with the given text annotation and given text and background colors.
 
Method Summary
 void addRadioButtonListener(GGRadioButtonListener listener)
          Registers a GGRadioListener to get notifications when the button is manipulated.
 boolean isSelected()
          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 setSelected(boolean selected)
          Sets the button in the selected/deselected 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

GGRadioButton

public GGRadioButton(java.lang.String text)
Creates a deselected radio button with the given text annotation, black text and white background colors.

Parameters:
text - the text annotation

GGRadioButton

public GGRadioButton(java.lang.String text,
                     boolean isSelected)
Creates a radio button with the given text annotation, black text and and white background colors.

Parameters:
text - the text annotation
isSelected - if true, the radio button is initially selected

GGRadioButton

public GGRadioButton(java.lang.String text,
                     java.awt.Color textColor,
                     java.awt.Color bkColor)
Creates a deselected radio button with the given text annotation and given text and background colors.

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

GGRadioButton

public GGRadioButton(java.lang.String text,
                     java.awt.Color textColor,
                     java.awt.Color bkColor,
                     boolean isSelected)
Creates a radio button with the given text annotation and given text and background colors.

Parameters:
text - the text annotation
textColor - the color of the annotation text
bkColor - the background color
isSelected - if true, the radio button is initially selected
Method Detail

isSelected

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

Returns:
true, if the button is selected

setSelected

public void setSelected(boolean selected)
Sets the button in the selected/deselected state. If the button is selected and it is part of a radio button group, any other selected buttons in the group are deselected. Does not generate a notification event. If automatic refresh is enabled, refreshs the game grid.

Parameters:
selected - if true, the button is selected; otherwise it is deselected

reset

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

Overrides:
reset in class Actor

addRadioButtonListener

public void addRadioButtonListener(GGRadioButtonListener listener)
Registers a GGRadioListener to get notifications when the button is manipulated.

Parameters:
listener - the GGRadioButtonListener to register