Blackjack

com.amoebacode.blackjack.display
Class DisplayManager

java.lang.Object
  |
  +--com.amoebacode.blackjack.display.DisplayManager

public class DisplayManager
extends java.lang.Object

DisplayManager encapsulates generation of visual and audio elements.

Version:
0.9
Author:
Jason Gurney

Field Summary
static java.lang.String BACKGROUND_IMAGE
          The name of the background image
private static java.lang.Integer BACKGROUND_LAYER
          The pane layer used for the background image
static java.lang.String BLANK_CARD_IMAGE
          The name of the blank card image
private static java.lang.Integer CARD_LAYER
          The pane layer used for cards
private  java.util.Map imageMap
          The collection of images, used to display backgrounds and cards
private  javax.swing.JLayeredPane layeredPane
          The primary layered pane, which includes all visual components
private  java.util.Map soundMap
          The collection of sounds, used for audio clip playback
private static java.lang.Integer VIOLATOR_LAYER
          The pane layer used for violator elements (buttons, labels, select boxes)
 
Constructor Summary
DisplayManager(javax.swing.JLayeredPane layeredPane, java.util.Map soundMap, java.util.Map imageMap)
          Default public constructor.
 
Method Summary
private  void addBackgroundComponent(java.awt.Component component)
          Adds the specified component to the background layer of the primary layered pane.
private  void addCardComponent(java.awt.Component component)
          Adds the specified component to the card layer of the primary layered pane.
protected  void addCardComponent(java.awt.Component component, int position)
          Adds the specified component in the specified position to the card layer of the primary layered pane.
 void addViolatorComponent(java.awt.Component component)
          Adds the specified component to the violator layer of the primary layered pane.
private  void drawBackground()
          Draws the background image for the primary layered pane.
protected  javax.swing.JLabel getBlankCardLabel()
          Creates a blank card label and adds it to the card layer of the primary layered pane.
protected  javax.swing.ImageIcon getImage(java.lang.String imageName)
          Retrieves the specified image from the images map
protected  void playClip(java.lang.String clipStr)
          Plays the specified audio clip from the sound map.
 void removeComponent(java.awt.Component component)
          Removes the specified component from the primary layered pane.
protected  void setComponentPosition(java.awt.Component component, int position)
          Sets the position of the specified component in the primary layered pane.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

layeredPane

private javax.swing.JLayeredPane layeredPane
The primary layered pane, which includes all visual components

soundMap

private java.util.Map soundMap
The collection of sounds, used for audio clip playback

imageMap

private java.util.Map imageMap
The collection of images, used to display backgrounds and cards

BACKGROUND_LAYER

private static final java.lang.Integer BACKGROUND_LAYER
The pane layer used for the background image

CARD_LAYER

private static final java.lang.Integer CARD_LAYER
The pane layer used for cards

VIOLATOR_LAYER

private static final java.lang.Integer VIOLATOR_LAYER
The pane layer used for violator elements (buttons, labels, select boxes)

BLANK_CARD_IMAGE

public static final java.lang.String BLANK_CARD_IMAGE
The name of the blank card image

BACKGROUND_IMAGE

public static final java.lang.String BACKGROUND_IMAGE
The name of the background image
Constructor Detail

DisplayManager

public DisplayManager(javax.swing.JLayeredPane layeredPane,
                      java.util.Map soundMap,
                      java.util.Map imageMap)
Default public constructor.
Parameters:
layeredPane - the primary layered pane
soundMap - a Map of sounds
imageMap - a Map of images
Method Detail

drawBackground

private void drawBackground()
Draws the background image for the primary layered pane.

playClip

protected void playClip(java.lang.String clipStr)
Plays the specified audio clip from the sound map.
Parameters:
clipStr - the name of the clip to play

getBlankCardLabel

protected javax.swing.JLabel getBlankCardLabel()
Creates a blank card label and adds it to the card layer of the primary layered pane.
Returns:
the blank card JLabel

getImage

protected javax.swing.ImageIcon getImage(java.lang.String imageName)
Retrieves the specified image from the images map
Parameters:
imagePath - the name of the image
Returns:
the corresponding ImageIcon

addBackgroundComponent

private void addBackgroundComponent(java.awt.Component component)
Adds the specified component to the background layer of the primary layered pane.
Parameters:
component - the component to add

addViolatorComponent

public void addViolatorComponent(java.awt.Component component)
Adds the specified component to the violator layer of the primary layered pane.
Parameters:
component - the component to add

addCardComponent

protected void addCardComponent(java.awt.Component component,
                                int position)
Adds the specified component in the specified position to the card layer of the primary layered pane.
Parameters:
component - the component to add
position - the int representing the position within the layer

addCardComponent

private void addCardComponent(java.awt.Component component)
Adds the specified component to the card layer of the primary layered pane.
Parameters:
component - the component to add

removeComponent

public void removeComponent(java.awt.Component component)
Removes the specified component from the primary layered pane.
Parameters:
component - the component to remove

setComponentPosition

protected void setComponentPosition(java.awt.Component component,
                                    int position)
Sets the position of the specified component in the primary layered pane.
Parameters:
component - the component to update
position - the int representing the new position within the layer

Blackjack

Copyright © 2002 amoebacode.com.