Blackjack

com.amoebacode.blackjack.display.label
Class LabelWrapper

java.lang.Object
  |
  +--com.amoebacode.blackjack.display.DisplayElement
        |
        +--com.amoebacode.blackjack.display.label.LabelWrapper
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener
Direct Known Subclasses:
BalanceLabel, CurrentScoreLabel, DecksLabel, GameBetLabel, HandBetLabel, StrategyLabel

public abstract class LabelWrapper
extends DisplayElement
implements java.awt.event.ActionListener

LabelWrapper is the base class for all text display labels.

Version:
0.9
Author:
Jason Gurney

Field Summary
private static int BLINK_DELAY
          The number of milliseconds to wait between blinks
private static int BLINK_TIMES
          The number of times this label should blink when updated
private  int blinkCount
          The current number of times the label has blinked
private  boolean blinkOn
          Indicates whether the blink is currently on
private  boolean isBlinking
          Indicates whether this label is currently blinking
protected  javax.swing.JLabel label
          The label display element wrapped by this object
private static int LABEL_HEIGHT
          The height in pixels of this label
private static int LABEL_WIDTH
          The width in pixels of this label
private  javax.swing.Timer timer
          The timer which handles the blink delay
 
Fields inherited from class com.amoebacode.blackjack.display.DisplayElement
parent
 
Constructor Summary
protected LabelWrapper(DisplayElement parent)
          Default protected constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Performs one blink (called when the timer expires).
protected  void blinkOff()
          Turns the blink off (called when the timer expires).
protected  void blinkOn()
          Turns the blink on (called when the timer expires).
protected  boolean blinks()
          Indicates whether this label blinks when updated.
 void clear()
          Cancels blinking and removes this label from the primary layered pane.
protected  int getBlinkDelay()
          Returns the number of milliseconds to wait between blinks.
protected  int getBlinkTimes()
          Returns the number of times this label should blink when updated.
protected  java.awt.Font getLabelFont()
          Returns the font of this label.
protected  int getLabelHeight()
          Returns the height of this label.
protected  int getLabelWidth()
          Returns the width of this label.
protected abstract  int getXPos()
          Returns the horizontal position of the select box.
protected abstract  int getYPos()
          Returns the vertical position of the select box.
protected  void setBackground(java.awt.Color background)
          Sets the background color of this label.
 void setText(java.lang.String text)
          Sets the text of this label.
protected  void setupLabel()
          Creates the label display element with an empty string and adds it to the layered pane.
protected  void setupLabel(java.lang.String text)
          Creates the label display element with the specified text and adds it to the layered pane.
 void setVisible(boolean visible)
          Sets the visibility attribute of this label.
protected  void startBlinking()
          Begins the blinking by starting the timer.
protected  void stopBlinking()
          Finishes the blinking by stopping the timer.
 void updateLocation()
          Updates the location of this label according to the horizontal and vertical coordinates.
 
Methods inherited from class com.amoebacode.blackjack.display.DisplayElement
executeGameCommand, getDisplayManager, getGameDisplay, getParent, hasParent, playGameClip, queueAction, resumeQueue
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

label

protected javax.swing.JLabel label
The label display element wrapped by this object

LABEL_WIDTH

private static final int LABEL_WIDTH
The width in pixels of this label

LABEL_HEIGHT

private static final int LABEL_HEIGHT
The height in pixels of this label

BLINK_TIMES

private static final int BLINK_TIMES
The number of times this label should blink when updated

BLINK_DELAY

private static final int BLINK_DELAY
The number of milliseconds to wait between blinks

blinkCount

private int blinkCount
The current number of times the label has blinked

blinkOn

private boolean blinkOn
Indicates whether the blink is currently on

isBlinking

private boolean isBlinking
Indicates whether this label is currently blinking

timer

private javax.swing.Timer timer
The timer which handles the blink delay
Constructor Detail

LabelWrapper

protected LabelWrapper(DisplayElement parent)
Default protected constructor.
Parameters:
parent - the DisplayElement parent of this label
Method Detail

setupLabel

protected void setupLabel()
Creates the label display element with an empty string and adds it to the layered pane.

setupLabel

protected void setupLabel(java.lang.String text)
Creates the label display element with the specified text and adds it to the layered pane.
Parameters:
text - the String to display on the label

getLabelWidth

protected int getLabelWidth()
Returns the width of this label.
Returns:
the number of horizontal pixels in this label

getLabelHeight

protected int getLabelHeight()
Returns the height of this label.
Returns:
the number of vertical pixels in this label

getLabelFont

protected java.awt.Font getLabelFont()
Returns the font of this label.
Returns:
the Font used to display this label

getXPos

protected abstract int getXPos()
Returns the horizontal position of the select box.
Returns:
the horizontal position in pixels

getYPos

protected abstract int getYPos()
Returns the vertical position of the select box.
Returns:
the vertical position in pixels

setVisible

public void setVisible(boolean visible)
Sets the visibility attribute of this label.
Parameters:
visible - the new visibility value

setBackground

protected void setBackground(java.awt.Color background)
Sets the background color of this label.
Parameters:
background - the new background color

setText

public void setText(java.lang.String text)
Sets the text of this label.
Parameters:
text - the new text

getBlinkTimes

protected int getBlinkTimes()
Returns the number of times this label should blink when updated.
Returns:
the number of blinks

blinks

protected boolean blinks()
Indicates whether this label blinks when updated.
Returns:
true if the label should blink

getBlinkDelay

protected int getBlinkDelay()
Returns the number of milliseconds to wait between blinks.
Returns:
the blink delay

startBlinking

protected void startBlinking()
Begins the blinking by starting the timer.

stopBlinking

protected void stopBlinking()
Finishes the blinking by stopping the timer.

blinkOn

protected void blinkOn()
Turns the blink on (called when the timer expires).

blinkOff

protected void blinkOff()
Turns the blink off (called when the timer expires).

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Performs one blink (called when the timer expires).
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - the ActionEven that triggered this action

updateLocation

public void updateLocation()
Updates the location of this label according to the horizontal and vertical coordinates.

clear

public void clear()
Cancels blinking and removes this label from the primary layered pane.

Blackjack

Copyright © 2002 amoebacode.com.