com.threerings.parlor.card.client

## Class CardPanel

- java.lang.Object
- - java.awt.Component
  - - java.awt.Container
    - - javax.swing.JComponent
      - - com.threerings.media.MediaPanel
        - - com.threerings.media.VirtualMediaPanel
          - - com.threerings.parlor.card.client.CardPanel

All Implemented Interfaces:
  com.threerings.media.FrameParticipant, com.threerings.media.MediaConstants, com.threerings.media.MediaHost, CardCodes, com.threerings.presents.data.InvocationCodes, ImageObserver, MenuContainer, Serializable

    public abstract class CardPanel
    extends com.threerings.media.VirtualMediaPanel
    implements CardCodes

Extends VirtualMediaPanel to provide services specific to rendering and manipulating playing cards.

See Also:
  Serialized Form

### Nested Class Summary

Nested Classes
`static interface` `CardPanel.CardSelectionObserver` A listener for card selection/deselection.

### Nested classes/interfaces inherited from class com.threerings.media.MediaPanel

`com.threerings.media.MediaPanel.Obscurer`

### Nested classes/interfaces inherited from class javax.swing.JComponent

`JComponent.AccessibleJComponent`

### Nested classes/interfaces inherited from class java.awt.Component

`Component.BaselineResizeBehavior`

### Field Summary

Fields
`static int` `MULTIPLE` The selection mode in which the user can select multiple cards.
`static int` `NONE` The selection mode in which cards are not selectable.
`static int` `SINGLE` The selection mode in which the user can select a single card.

### Fields inherited from class com.threerings.media.VirtualMediaPanel

`CENTER_ON_PATHABLE, ENCLOSE_PATHABLE, TRACK_PATHABLE`

### Fields inherited from class javax.swing.JComponent

`TOOL_TIP_TEXT_KEY, 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 com.threerings.parlor.card.data.CardCodes

`ACE, BLACK_JOKER, CLUBS, DIAMONDS, HEARTS, JACK, KING, QUEEN, RED_JOKER, SPADES`

### Fields inherited from interface com.threerings.presents.data.InvocationCodes

`ACCESS_DENIED, E_ACCESS_DENIED, E_INTERNAL_ERROR, GLOBAL_GROUP, INTERNAL_ERROR`

### Fields inherited from interface com.threerings.media.MediaConstants

`ALL, BACK, FRONT`

### Fields inherited from interface java.awt.image.ImageObserver

`ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

### Constructor Summary

Constructors
Constructor and Description
`CardPanel(com.threerings.media.FrameManager frameManager)` Constructor.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`void` `addHandSelectionObserver(CardPanel.CardSelectionObserver obs)` Adds an object to the list of observers to notify when cards in the hand are selected/deselected.
`void` `addToBoard(Card card, Point dest)` Adds a card to the board immediately.
`void` `clearBoard()` Clears all cards from the board.
`void` `clearHand()` Clears all cards from the hand.
`void` `clearHandSelection()` Clears any existing hand sprite selection.
`void` `deselectHandSprite(CardSprite sprite)` Programmatically deselects a sprite in the hand.
`void` `flyAcross(Card[] cards, Point src, Point dest, long flightDuration, long cardDelay, float fadePortion)` Flies a set of cards from the ether into the ether.
`void` `flyAcross(int number, Point src, Point dest, long flightDuration, long cardDelay, float fadePortion)` Flies a set of cards from the ether into the ether face-down.
`void` `flyFromBoard(CardSprite[] cards, Point dest, long flightDuration, float fadePortion)` Flies a set of cards from the board into the ether.
`void` `flyFromBoard(CardSprite[] cards, Point dest1, Point dest2, long flightDuration, float fadePortion)` Flies a set of cards from the board into the ether through an intermediate point.
`void` `flyFromHand(CardSprite[] cards, Point dest, long flightDuration, float fadePortion)` Flies a set of cards from the hand into the ether.
`void` `flyFromHandToBoard(CardSprite card, Point dest, long flightDuration)` Flies a card from the hand onto the board.
`void` `flyIntoHand(Card[] cards, Point src, long flightDuration, long pauseDuration, long dropDuration, float fadePortion)` Flies a set of cards from the ether into the hand.
`void` `flyToBoard(Card card, Point src, Point dest, long flightDuration, float fadePortion)` Flies a card from the ether onto the board.
`abstract com.threerings.media.image.Mirage` `getCardBackImage()` Returns the full-sized image for the back of a playing card.
`abstract com.threerings.media.image.Mirage` `getCardImage(Card card)` Returns the full-sized image for the front of the specified card.
`CardSprite` `getHandSprite(Card card)` Returns the first sprite in the hand that corresponds to the specified card, or null if the card is not in the hand.
`abstract com.threerings.media.image.Mirage` `getMicroCardBackImage()` Returns the small-sized image for the back of a playing card.
`abstract com.threerings.media.image.Mirage` `getMicroCardImage(Card card)` Returns the small-sized image for the front of the specified card.
`CardSprite` `getSelectedHandSprite()` Returns the currently selected hand sprite (null if no sprites are selected, the first sprite if multiple sprites are selected).
`CardSprite[]` `getSelectedHandSprites()` Returns an array containing the currently selected hand sprites (returns an empty array if no sprites are selected).
`void` `removeHandSelectionObserver(CardPanel.CardSelectionObserver obs)` Removes an object from the hand selection observer list.
`void` `selectHandSprite(CardSprite sprite)` Programmatically selects a sprite in the hand.
`void` `setHand(Hand hand, long fadeDuration)` Fades a hand of cards in.
`void` `setHand(int size, long fadeDuration)` Fades a hand of cards in face-down.
`void` `setHandLocation(int x, int y)` Sets the location of the hand (the location of the center of the hand's upper edge).
`void` `setHandSelectionMode(int mode)` Sets the selection mode for the hand (NONE, PLAY_SINGLE, SINGLE, or MULTIPLE).
`void` `setHandSelectionPredicate(Predicate<CardSprite> pred)` Sets the selection predicate that determines which cards from the hand may be selected (if null, all cards may be selected).
`void` `setHandSpacing(int spacing)` Sets the horizontal spacing between cards in the hand.
`void` `setSelectableCardOffset(int offset)` Sets the vertical distance to offset cards that are selectable or playable.
`void` `setSelectedCardOffset(int offset)` Sets the vertical distance to offset cards that are selected.
`void` `showHand(Hand hand)` Shows a hand that was previous set face-down.

### Methods inherited from class com.threerings.media.VirtualMediaPanel

`addViewTracker, clearPathable, doLayout, getViewBounds, removeViewTracker, setBackground, setBounds, setFollowsPathable, setViewLocation`

### Methods inherited from class com.threerings.media.MediaPanel

`abortAnimation, addAnimation, addObscurer, addSprite, clearAnimations, clearSprites, createGraphics, getAnimationManager, getComponent, getRegionManager, getSpriteManager, getTimeStamp, isManaged, isManaged, needsPaint, paint, removeObscurer, removeSprite, repaint, setOpaque, setPaused, tick`

### Methods inherited from class javax.swing.JComponent

`addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI`

### Methods inherited from class java.awt.Container

`add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate`

### Methods inherited from class java.awt.Component

`action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### NONE

    public static final int NONE

The selection mode in which cards are not selectable.

See Also:
  Constant Field Values

#### SINGLE

    public static final int SINGLE

The selection mode in which the user can select a single card.

See Also:
  Constant Field Values

#### MULTIPLE

    public static final int MULTIPLE

The selection mode in which the user can select multiple cards.

See Also:
  Constant Field Values

### Constructor Detail

#### CardPanel

    public CardPanel(com.threerings.media.FrameManager frameManager)

Constructor.

Parameters:
  `frameManager` - the frame manager

### Method Detail

#### getCardBackImage

    public abstract com.threerings.media.image.Mirage getCardBackImage()

Returns the full-sized image for the back of a playing card.

#### getCardImage

    public abstract com.threerings.media.image.Mirage getCardImage(Card card)

Returns the full-sized image for the front of the specified card.

#### getMicroCardBackImage

    public abstract com.threerings.media.image.Mirage getMicroCardBackImage()

Returns the small-sized image for the back of a playing card.

#### getMicroCardImage

    public abstract com.threerings.media.image.Mirage getMicroCardImage(Card card)

Returns the small-sized image for the front of the specified card.

#### setHandLocation

    public void setHandLocation(int x,
                                int y)

Sets the location of the hand (the location of the center of the hand's upper edge).

#### setHandSpacing

    public void setHandSpacing(int spacing)

Sets the horizontal spacing between cards in the hand.

#### setSelectableCardOffset

    public void setSelectableCardOffset(int offset)

Sets the vertical distance to offset cards that are selectable or playable.

#### setSelectedCardOffset

    public void setSelectedCardOffset(int offset)

Sets the vertical distance to offset cards that are selected.

#### setHandSelectionMode

    public void setHandSelectionMode(int mode)

Sets the selection mode for the hand (NONE, PLAY_SINGLE, SINGLE, or MULTIPLE). Changing the selection mode does not change the current selection.

#### setHandSelectionPredicate

    public void setHandSelectionPredicate(Predicate<CardSprite> pred)

Sets the selection predicate that determines which cards from the hand may be selected (if null, all cards may be selected). Changing the predicate does not change the current selection.

#### getSelectedHandSprite

    public CardSprite getSelectedHandSprite()

Returns the currently selected hand sprite (null if no sprites are selected, the first sprite if multiple sprites are selected).

#### getSelectedHandSprites

    public CardSprite[] getSelectedHandSprites()

Returns an array containing the currently selected hand sprites (returns an empty array if no sprites are selected).

#### selectHandSprite

    public void selectHandSprite(CardSprite sprite)

Programmatically selects a sprite in the hand.

#### deselectHandSprite

    public void deselectHandSprite(CardSprite sprite)

Programmatically deselects a sprite in the hand.

#### clearHandSelection

    public void clearHandSelection()

Clears any existing hand sprite selection.

#### addHandSelectionObserver

    public void addHandSelectionObserver(CardPanel.CardSelectionObserver obs)

Adds an object to the list of observers to notify when cards in the hand are selected/deselected.

#### removeHandSelectionObserver

    public void removeHandSelectionObserver(CardPanel.CardSelectionObserver obs)

Removes an object from the hand selection observer list.

#### setHand

    public void setHand(Hand hand,
                        long fadeDuration)

Fades a hand of cards in.

Parameters:
  `hand` - the hand of cards
  `fadeDuration` - the amount of time to spend fading in the entire hand

#### setHand

    public void setHand(int size,
                        long fadeDuration)

Fades a hand of cards in face-down.

Parameters:
  `size` - the size of the hand
  `fadeDuration` - the amount of time to spend fading in each card

#### showHand

    public void showHand(Hand hand)

Shows a hand that was previous set face-down.

Parameters:
  `hand` - the hand of cards

#### getHandSprite

    public CardSprite getHandSprite(Card card)

Returns the first sprite in the hand that corresponds to the specified card, or null if the card is not in the hand.

#### clearHand

    public void clearHand()

Clears all cards from the hand.

#### clearBoard

    public void clearBoard()

Clears all cards from the board.

#### flyFromHand

    public void flyFromHand(CardSprite[] cards,
                            Point dest,
                            long flightDuration,
                            float fadePortion)

Flies a set of cards from the hand into the ether. Clears any selected cards.

Parameters:
  `cards` - the card sprites to remove from the hand
  `dest` - the point to fly the cards to
  `flightDuration` - the duration of the cards' flight
  `fadePortion` - the amount of time to spend fading out as a proportion of the flight duration

#### flyIntoHand

    public void flyIntoHand(Card[] cards,
                            Point src,
                            long flightDuration,
                            long pauseDuration,
                            long dropDuration,
                            float fadePortion)

Flies a set of cards from the ether into the hand. Clears any selected cards. The cards will first fly to the selected card offset, pause for the specified duration, and then drop into the hand.

Parameters:
  `cards` - the cards to add to the hand
  `src` - the point to fly the cards from
  `flightDuration` - the duration of the cards' flight
  `pauseDuration` - the duration of the pause before dropping into the hand
  `dropDuration` - the duration of the cards' drop into the hand
  `fadePortion` - the amount of time to spend fading in as a proportion of the flight duration

#### flyAcross

    public void flyAcross(Card[] cards,
                          Point src,
                          Point dest,
                          long flightDuration,
                          long cardDelay,
                          float fadePortion)

Flies a set of cards from the ether into the ether.

Parameters:
  `cards` - the cards to fly across
  `src` - the point to fly the cards from
  `dest` - the point to fly the cards to
  `flightDuration` - the duration of the cards' flight
  `cardDelay` - the amount of time to wait between cards
  `fadePortion` - the amount of time to spend fading in and out as a proportion of the flight duration

#### flyAcross

    public void flyAcross(int number,
                          Point src,
                          Point dest,
                          long flightDuration,
                          long cardDelay,
                          float fadePortion)

Flies a set of cards from the ether into the ether face-down.

Parameters:
  `number` - the number of cards to fly across
  `src` - the point to fly the cards from
  `dest` - the point to fly the cards to
  `flightDuration` - the duration of the cards' flight
  `cardDelay` - the amount of time to wait between cards
  `fadePortion` - the amount of time to spend fading in and out as a proportion of the flight duration

#### flyFromHandToBoard

    public void flyFromHandToBoard(CardSprite card,
                                   Point dest,
                                   long flightDuration)

Flies a card from the hand onto the board. Clears any cards selected.

Parameters:
  `card` - the sprite to remove from the hand
  `dest` - the point to fly the card to
  `flightDuration` - the duration of the card's flight

#### flyToBoard

    public void flyToBoard(Card card,
                           Point src,
                           Point dest,
                           long flightDuration,
                           float fadePortion)

Flies a card from the ether onto the board.

Parameters:
  `card` - the card to add to the board
  `src` - the point to fly the card from
  `dest` - the point to fly the card to
  `flightDuration` - the duration of the card's flight
  `fadePortion` - the amount of time to spend fading in as a proportion of the flight duration

#### addToBoard

    public void addToBoard(Card card,
                           Point dest)

Adds a card to the board immediately.

Parameters:
  `card` - the card to add to the board
  `dest` - the point at which to add the card

#### flyFromBoard

    public void flyFromBoard(CardSprite[] cards,
                             Point dest,
                             long flightDuration,
                             float fadePortion)

Flies a set of cards from the board into the ether.

Parameters:
  `cards` - the cards to remove from the board
  `dest` - the point to fly the cards to
  `flightDuration` - the duration of the cards' flight
  `fadePortion` - the amount of time to spend fading out as a proportion of the flight duration

#### flyFromBoard

    public void flyFromBoard(CardSprite[] cards,
                             Point dest1,
                             Point dest2,
                             long flightDuration,
                             float fadePortion)

Flies a set of cards from the board into the ether through an intermediate point.

Parameters:
  `cards` - the cards to remove from the board
  `dest1` - the first point to fly the cards to
  `dest2` - the final destination of the cards
  `flightDuration` - the duration of the cards' flight
  `fadePortion` - the amount of time to spend fading out as a proportion of the flight duration