de.kosi.gui.view.game
Class CardContainer

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--de.kosi.gui.view.game.CardContainer
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, ResourceBundleChangeListener, java.io.Serializable

public class CardContainer
extends javax.swing.JPanel
implements ResourceBundleChangeListener

The CardContainer class displays the cards and name of a player.

ChangeLog:

 $Log: CardContainer.java,v $
 Revision 1.15  2001/07/13 10:49:06  jiriki
 Started fix for Bugs 440155 and 440333.

 Revision 1.14  2001/06/27 11:58:50  jiriki
 Re-added LandF menu. Some code cleanup

 Revision 1.13  2001/06/20 12:44:34  jiriki
 Added Background

 Revision 1.12  2001/06/15 15:01:13  jiriki
 Cards are displayed after game

 Revision 1.11  2001/06/15 13:42:30  jiriki
 Tricks are displayed during the game.

 Revision 1.10  2001/06/14 14:41:01  jiriki
 Code maintanance
 (Updated docs, removed unused code, improved code style)

 

Version:
$Revision: 1.15 $ ($Date: 2001/07/13 10:49:06 $)
Author:
Jan-Christian Marinesse, Niklas Mehner
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static int[][] SUIT_ORDER
          Order of suits, for a given trump suit.
static int UNKNOWN_SUIT
          Index of cards, for which the suit is unknown.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CardContainer(int orientation, CardDimension cardDimension, java.awt.event.ActionListener listener)
          Creates a new CardContainer.
 
Method Summary
 void clear()
          Removes all cards from this container.
 void disableCards()
          Disables all cards.
 void enableCards(int suitToFollow)
          Enable cards for the given suit to follow.
 java.util.Collection getCardsAllowedToPlay(int suitToFollow)
          Returns all card components the user is allowed to play.
 void init()
          Initializes the component with Card.NUM_CARDS_PER_PLAYER unknown cards.
 CardComponent playCard(Card card)
          Plays a card.
 void resourceBundleChanged(CResourceBundle resourceBundle)
          Invoked when the resource bundle has been changed.
 void setCards(java.util.List cards)
          Sets the cards in this cardContainer.
 void setDummy(boolean isDummy)
          Sets wether this cardContainer displays the dummy cards.
 void setName(java.lang.String name)
          Set the name of the player.
 void setNumberOfCards(int number)
           
 void setTrumpSuit(int trumpSuit)
          Sets the current trump suit.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN_SUIT

public static final int UNKNOWN_SUIT
Index of cards, for which the suit is unknown.

SUIT_ORDER

public static final int[][] SUIT_ORDER
Order of suits, for a given trump suit.
Constructor Detail

CardContainer

public CardContainer(int orientation,
                     CardDimension cardDimension,
                     java.awt.event.ActionListener listener)
Creates a new CardContainer.
Parameters:
orientation - The orientation for the cardContainer. This determines the layout of the cards. It has to be the value of oone of the CConstant.ORIENTATION_* contants.
cardDimension - Contains the dimensions for the cards.
listener - Listener that is called, when a card is to be played.
Method Detail

enableCards

public void enableCards(int suitToFollow)
Enable cards for the given suit to follow. If the suitContainer for the given suit contains cards, only cards of this suit are enabled, otherwise all cards are enabled.
Parameters:
suitToFollow - Suit to follow.

getCardsAllowedToPlay

public java.util.Collection getCardsAllowedToPlay(int suitToFollow)
Returns all card components the user is allowed to play.
Parameters:
suitToFollow - Suit that has to be followed.
Returns:
Collection of CardComponents, that are possible to be played.

disableCards

public void disableCards()
Disables all cards.

setCards

public void setCards(java.util.List cards)
Sets the cards in this cardContainer.
Parameters:
cards - List containing de.kosi.model.game.Card objects.

setNumberOfCards

public void setNumberOfCards(int number)

init

public void init()
Initializes the component with Card.NUM_CARDS_PER_PLAYER unknown cards.

clear

public void clear()
Removes all cards from this container.

playCard

public CardComponent playCard(Card card)
Plays a card. The card is removed from the cards, If this component contains only unknown cards, a random card of the unknown cards is removed.
Parameters:
card - To be played.
Returns:
CardComponent that has been removed from the cardContainer.

setTrumpSuit

public void setTrumpSuit(int trumpSuit)
Sets the current trump suit. This determines the order of the suits.
Parameters:
trumpSuit - The new trump suit.

setDummy

public void setDummy(boolean isDummy)
Sets wether this cardContainer displays the dummy cards.
Parameters:
isDummy - wether this cardContainer displays the dummy cards.

setName

public void setName(java.lang.String name)
Set the name of the player.
Overrides:
setName in class java.awt.Component
Parameters:
name - Name of the player.

resourceBundleChanged

public void resourceBundleChanged(CResourceBundle resourceBundle)
Description copied from interface: ResourceBundleChangeListener
Invoked when the resource bundle has been changed.
Specified by:
resourceBundleChanged in interface ResourceBundleChangeListener
Following copied from interface: de.kosi.gui.util.ResourceBundleChangeListener
Parameters:
resource - bundle the new resource bundle.