Blackjack

com.amoebacode.blackjack.display
Class HandDisplay

java.lang.Object
  |
  +--com.amoebacode.blackjack.display.DisplayElement
        |
        +--com.amoebacode.blackjack.display.HandDisplay
All Implemented Interfaces:
BlackjackEventListener, java.util.EventListener, HandEventListener
Direct Known Subclasses:
DealerHandDisplay, PlayerHandDisplay

public abstract class HandDisplay
extends DisplayElement
implements HandEventListener

HandDisplay handles the display of a dealer or player hand, including the cards and current score label.

Version:
0.9
Author:
Jason Gurney

Field Summary
private  java.util.List cardDisplays
          The list of card displays
protected  LabelWrapper currentScore
          The wrapper for the label that draws the current score
private  IHand hand
          The hand being displayed
private  boolean isAnimating
          Indicates whether this hand is currently animating a card
protected  int xPos
          The horizontal position of this hand
protected  int yPos
          The vertical position of this hand
 
Fields inherited from class com.amoebacode.blackjack.display.DisplayElement
parent
 
Constructor Summary
protected HandDisplay(ParticipantDisplay display)
          Default protected constructor.
 
Method Summary
 void addCard(BlackjackEvent event)
          Adds a card to this hand display object.
 void clear(BlackjackEvent event)
          Clears this hand display object.
 void clearCards()
          Removes this hand's cards from the primary layered pane.
 void clearCurrentScore()
          Removes this hand's score label from the primary layered pane.
private  void drawCard(CardDisplay aCard, int index)
          Draws the specified card at the specified index.
protected  void drawCard(IHand hand, int index)
          Draws the specified card in this hand.
 void drawCards(int cardIndex)
          Draws the cards in this hand up to the specified index.
protected  CardDisplay getCardDisplay(ICard card)
          Returns the card display corresponding to the specified card.
protected  CardDisplay getCardDisplayAt(int index)
          Returns the card display at the specified index.
protected abstract  Coordinate getCoordinates()
          Returns the horizontal and vertical position of this hand.
 int getCurrentScoreXPos()
          Returns the horizontal position of the current score label.
abstract  int getCurrentScoreYPos()
          Returns the vertical position of the current score label.
protected  IHand getHand()
          Returns the hand being displayed.
protected  int getNumberOfCardDisplays()
          Returns the number of card displays in this hand.
 void performAddCardAction(CardDisplay cd)
          Adds the specified card to this hand and starts the card animation.
 void removeCard(BlackjackEvent event)
          Removes a card from this hand display object.
 void resume(int cardIndex)
          Draws the card at the specified index and when appropriate, plays the corresponding audio clip (called when card animation finishes).
private  void setCoordinates()
          Sets the horizontal and vertical position of this hand.
protected  void setHand(IHand hand)
          Sets the hand to display.
protected  void setupDisplay()
          Sets up this hand's location and current score label.
protected  void startAnimatedCard()
          Sets up the animation for the most recently added card.
protected  void stopAnimatedCard()
          Turns off the card animation.
 
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

xPos

protected int xPos
The horizontal position of this hand

yPos

protected int yPos
The vertical position of this hand

isAnimating

private boolean isAnimating
Indicates whether this hand is currently animating a card

currentScore

protected LabelWrapper currentScore
The wrapper for the label that draws the current score

hand

private IHand hand
The hand being displayed

cardDisplays

private java.util.List cardDisplays
The list of card displays
Constructor Detail

HandDisplay

protected HandDisplay(ParticipantDisplay display)
Default protected constructor.
Parameters:
display - the parent ParticipantDisplay
Method Detail

setupDisplay

protected void setupDisplay()
Sets up this hand's location and current score label.

startAnimatedCard

protected void startAnimatedCard()
Sets up the animation for the most recently added card.

stopAnimatedCard

protected void stopAnimatedCard()
Turns off the card animation.

drawCard

private void drawCard(CardDisplay aCard,
                      int index)
Draws the specified card at the specified index.
Parameters:
aCard - CardDisplay the card to draw
index - the index of the card to draw

setCoordinates

private void setCoordinates()
Sets the horizontal and vertical position of this hand.

getCurrentScoreXPos

public int getCurrentScoreXPos()
Returns the horizontal position of the current score label.

getCoordinates

protected abstract Coordinate getCoordinates()
Returns the horizontal and vertical position of this hand.
Returns:
the horizontal and vertical Coordinate

drawCards

public void drawCards(int cardIndex)
Draws the cards in this hand up to the specified index.
Parameters:
cardIndex - the index of the last card to draw

drawCard

protected void drawCard(IHand hand,
                        int index)
Draws the specified card in this hand.
Parameters:
index - the index of the card to draw

addCard

public void addCard(BlackjackEvent event)
Description copied from interface: HandEventListener
Adds a card to this hand display object.
Specified by:
addCard in interface HandEventListener
See Also:
HandEventListener.addCard(BlackjackEvent)

performAddCardAction

public void performAddCardAction(CardDisplay cd)
Adds the specified card to this hand and starts the card animation.
Parameters:
cd - the CardDisplay to add

clear

public void clear(BlackjackEvent event)
Description copied from interface: HandEventListener
Clears this hand display object.
Specified by:
clear in interface HandEventListener
See Also:
HandEventListener.clear(BlackjackEvent)

clearCurrentScore

public void clearCurrentScore()
Removes this hand's score label from the primary layered pane.

clearCards

public void clearCards()
Removes this hand's cards from the primary layered pane.

getCurrentScoreYPos

public abstract int getCurrentScoreYPos()
Returns the vertical position of the current score label.
Returns:
the vertical current score position

getHand

protected IHand getHand()
Returns the hand being displayed.
Returns:
the IHand being displayed

setHand

protected void setHand(IHand hand)
Sets the hand to display.
Parameters:
hand - the IHand to display

getCardDisplayAt

protected CardDisplay getCardDisplayAt(int index)
Returns the card display at the specified index.
Parameters:
index - the index of the card display to return
Returns:
the CardDisplay at the specified index

getCardDisplay

protected CardDisplay getCardDisplay(ICard card)
Returns the card display corresponding to the specified card.
Parameters:
card - the ICard to match
Returns:
the CardDisplay corresponding to the specified ICard

removeCard

public void removeCard(BlackjackEvent event)
Description copied from interface: HandEventListener
Removes a card from this hand display object.
Specified by:
removeCard in interface HandEventListener
See Also:
HandEventListener.removeCard(BlackjackEvent)

resume

public void resume(int cardIndex)
Draws the card at the specified index and when appropriate, plays the corresponding audio clip (called when card animation finishes).
Parameters:
cardIndex - the card to draw

getNumberOfCardDisplays

protected int getNumberOfCardDisplays()
Returns the number of card displays in this hand.
Returns:
the number of card displays

Blackjack

Copyright © 2002 amoebacode.com.