Blackjack

com.amoebacode.blackjack.display
Class AnimatedCard

java.lang.Object
  |
  +--com.amoebacode.blackjack.display.DisplayElement
        |
        +--com.amoebacode.blackjack.display.AnimatedCard
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

class AnimatedCard
extends DisplayElement
implements java.awt.event.ActionListener

AnimatedCard handles drawing cards as they move from the deck to the hand.

Version:
0.9
Author:
Jason Gurney

Field Summary
private  Coordinate beginPos
          The intial position of the card to be animated
private  int cardIndex
          The index of this card within its hand
private  javax.swing.JLabel cardLabel
          The label element that draws this animated card
private  Coordinate currentPos
          The current position of the animated card
private  Coordinate endPos
          The final position of the card to be animated
private  HandDisplay hand
          The hand this card belongs to
private  javax.swing.Timer timer
          The timer which handles the animation delay
 
Fields inherited from class com.amoebacode.blackjack.display.DisplayElement
parent
 
Constructor Summary
protected AnimatedCard(HandDisplay hand, int cardIndex, Coordinate beginPos, Coordinate endPos)
          Default protected constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Performs one card movement (called when the timer expires).
private  int getAnimationDelay()
          Returns the animation delay from the Preferences object.
private  int getBeginXPos()
          Returns the initial horizontal position.
private  int getBeginYPos()
          Returns the initial vertical position.
private  int getPixelsPerMove()
          Returns the number of pixels to move from the Preferences object.
private  void setCurrentPosition()
          Moves the current position toward the final position.
 void startAnimation()
          Begins the animation by starting the timer.
private  void stopAnimation()
          Finishes the animation by stopping the timer, then returns control to the hand that contains this card.
 
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

beginPos

private Coordinate beginPos
The intial position of the card to be animated

endPos

private Coordinate endPos
The final position of the card to be animated

currentPos

private Coordinate currentPos
The current position of the animated card

timer

private javax.swing.Timer timer
The timer which handles the animation delay

hand

private HandDisplay hand
The hand this card belongs to

cardLabel

private javax.swing.JLabel cardLabel
The label element that draws this animated card

cardIndex

private int cardIndex
The index of this card within its hand
Constructor Detail

AnimatedCard

protected AnimatedCard(HandDisplay hand,
                       int cardIndex,
                       Coordinate beginPos,
                       Coordinate endPos)
Default protected constructor.
Parameters:
hand - the Hand this card belongs to
cardIndex - the index of this card within its hand
beginPos - the initial position of the card to be animated
endPos - the final position of the card to be animated
Method Detail

actionPerformed

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

startAnimation

public void startAnimation()
Begins the animation by starting the timer.

setCurrentPosition

private void setCurrentPosition()
Moves the current position toward the final position.

stopAnimation

private void stopAnimation()
Finishes the animation by stopping the timer, then returns control to the hand that contains this card.

getBeginXPos

private int getBeginXPos()
Returns the initial horizontal position.
Returns:
the horizontal distance (in pixels) from the upper left corner

getBeginYPos

private int getBeginYPos()
Returns the initial vertical position.
Returns:
the vertical distance (in pixels) from the upper left corner

getAnimationDelay

private int getAnimationDelay()
Returns the animation delay from the Preferences object.
Returns:
the number of milliseconds between movements

getPixelsPerMove

private int getPixelsPerMove()
Returns the number of pixels to move from the Preferences object.
Returns:
the number of pixels to move each time the timer expires

Blackjack

Copyright © 2002 amoebacode.com.