com.threerings.parlor.card.client
Class CardPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.threerings.media.MediaPanel
                  extended by com.threerings.media.VirtualMediaPanel
                      extended by com.threerings.parlor.card.client.CardPanel
All Implemented Interfaces:
com.threerings.media.FrameParticipant, com.threerings.media.MediaConstants, com.threerings.media.MediaHost, CardCodes, 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
protected  class CardPanel.CardListener
          Listens for mouse interactions with cards.
static interface CardPanel.CardSelectionObserver
          A listener for card selection/deselection.
protected static class CardPanel.CardSpriteClickedOp
          Calls CardSpriteObserver.cardSpriteClicked.
protected static class CardPanel.CardSpriteDraggedOp
          Calls CardSpriteObserver.cardSpriteDragged.
protected static class CardPanel.CardSpriteEnteredOp
          Calls CardSpriteObserver.cardSpriteEntered.
protected static class CardPanel.CardSpriteExitedOp
          Calls CardSpriteObserver.cardSpriteExited.
protected  class CardPanel.HandSpriteObserver
          Listens for interactions with cards in hand.
 
Nested classes/interfaces inherited from class com.threerings.media.MediaPanel
com.threerings.media.MediaPanel.ActionSpriteHandler, com.threerings.media.MediaPanel.Obscurer
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  CardSprite _activeCardSprite
          The currently active card sprite (the one that the mouse is over).
protected  ArrayList<CardSprite> _boardSprites
          The sprites for cards on the board.
protected  int _cardWidth
          The width of the playing cards.
protected  Point _handLocation
          The location of the center of the hand's upper edge.
protected  int _handSelectionMode
          The current selection mode for the hand.
protected  ObserverList<CardPanel.CardSelectionObserver> _handSelectionObservers
          Observers of hand card selection/deselection.
protected  com.google.common.base.Predicate<CardSprite> _handSelectionPredicate
          The predicate that determines which cards are selectable (if null, all cards are selectable).
protected  int _handSpacing
          The horizontal distance between cards in the hand.
protected  CardPanel.HandSpriteObserver _handSpriteObserver
          The hand sprite observer instance.
protected  ArrayList<CardSprite> _handSprites
          The sprites for cards within the hand.
protected  MouseEvent _mouseEvent
          The last motion/entrance/exit event received from the mouse.
protected  com.threerings.media.sprite.PathAdapter _pathEndRemover
          A path observer that removes the sprite at the end of its path.
protected  int _selectableCardOffset
          The vertical distance to offset cards that are selectable.
protected  int _selectedCardOffset
          The vertical distance to offset cards that are selected.
protected  ArrayList<CardSprite> _selectedHandSprites
          The sprites for cards within the hand that have been selected.
protected static Comparator<CardSprite> CARD_COMP
          Compares two card sprites based on their underlying card.
protected static Color DEFAULT_BACKGROUND
          A nice default green card table background color.
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
_abounds, _background, _dx, _dy, _fmode, _fpath, _nx, _ny, _trackers, _vbounds, CENTER_ON_PATHABLE, ENCLOSE_PATHABLE, TRACK_PATHABLE
 
Fields inherited from class com.threerings.media.MediaPanel
_actionHandler, _actionSpriteCount, _animmgr, _metamgr, _obscurerList, _remgr, _spritemgr, _tickPaintPending
 
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 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
CardPanel(com.threerings.media.FrameManager frameManager)
          Constructor.
 
Method Summary
 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.
protected  void adjustHand(long adjustDuration, boolean updateLayers)
          Expands or collapses the hand to accommodate new cards or cover the space left by removed cards.
 void clearBoard()
          Clears all cards from the board.
 void clearHand()
          Clears all cards from the hand.
 void clearHandSelection()
          Clears any existing hand sprite selection.
protected  void clearSprites(List<CardSprite> sprites)
          Clears an array of sprites from the specified list and from the panel.
 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.
protected  CardSprite getCardSprite(List<CardSprite> list, Card card)
          Returns the first card sprite in the specified list that represents the specified card, or null if there is no such sprite in the list.
 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.
protected  int getHandX(int size, int idx)
          Given the location and spacing of the hand, returns the x location of the card at the specified index within a hand of the specified size.
protected  int getHandY(CardSprite sprite)
          Determines the y location of the specified card sprite, given its selection state.
protected  int getHighestBoardLayer()
          Returns the highest render order of any sprite on the board.
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).
protected  boolean isOnlySelectable(CardSprite sprite)
          Determines whether the specified sprite is the only selectable sprite in the hand according to the selection predicate.
protected  boolean isSelectable(CardSprite sprite)
          Given the current selection mode and predicate, determines if the specified sprite is selectable.
protected  void lowerBoardSprites(int layer)
          Lowers all board sprites so that they are rendered at or below the specified layer.
protected  void paintBehind(Graphics2D gfx, Rectangle dirtyRect)
           
protected  void removeFromHand(CardSprite card)
          Removes a card from the hand.
 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(com.google.common.base.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.
protected  boolean shouldSortHand()
          Returns whether the user's hand should be sorted when displayed.
 void showHand(Hand hand)
          Shows a hand that was previous set face-down.
protected  void updateActiveCardSprite()
          Updates the active card sprite based on the location of the mouse pointer.
protected  void updateHandOffsets()
          Updates the offsets of all the cards in the hand.
 
Methods inherited from class com.threerings.media.VirtualMediaPanel
addObscurerDirtyRegion, addViewTracker, adjustBoundsCenter, clearPathable, constrainToBounds, didTick, dirtyScreenRect, doLayout, findRootBounds, getViewBounds, paint, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeViewTracker, setBackground, setBounds, setFollowsPathable, setViewLocation, trackPathable, viewLocationDidChange
 
Methods inherited from class com.threerings.media.MediaPanel
abortAnimation, addAnimation, addObscurer, addObscurerDirtyRegions, addSprite, clearAnimations, clearSprites, clipToDirtyRegion, createActionSpriteHandler, createGraphics, getAnimationManager, getComponent, getRegionManager, getSpriteManager, getTimeStamp, isManaged, isManaged, needsPaint, paint, paintBetween, paintBits, paintDirtyRect, paintInFront, removeObscurer, removeSprite, repaint, setOpaque, setPaused, tick, willTick
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, 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, hide, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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

_cardWidth

protected int _cardWidth
The width of the playing cards.


_mouseEvent

protected MouseEvent _mouseEvent
The last motion/entrance/exit event received from the mouse.


_activeCardSprite

protected CardSprite _activeCardSprite
The currently active card sprite (the one that the mouse is over).


_handSprites

protected ArrayList<CardSprite> _handSprites
The sprites for cards within the hand.


_selectedHandSprites

protected ArrayList<CardSprite> _selectedHandSprites
The sprites for cards within the hand that have been selected.


_handSelectionMode

protected int _handSelectionMode
The current selection mode for the hand.


_handSelectionPredicate

protected com.google.common.base.Predicate<CardSprite> _handSelectionPredicate
The predicate that determines which cards are selectable (if null, all cards are selectable).


_handSelectionObservers

protected ObserverList<CardPanel.CardSelectionObserver> _handSelectionObservers
Observers of hand card selection/deselection.


_handLocation

protected Point _handLocation
The location of the center of the hand's upper edge.


_handSpacing

protected int _handSpacing
The horizontal distance between cards in the hand.


_selectableCardOffset

protected int _selectableCardOffset
The vertical distance to offset cards that are selectable.


_selectedCardOffset

protected int _selectedCardOffset
The vertical distance to offset cards that are selected.


_boardSprites

protected ArrayList<CardSprite> _boardSprites
The sprites for cards on the board.


_handSpriteObserver

protected CardPanel.HandSpriteObserver _handSpriteObserver
The hand sprite observer instance.


_pathEndRemover

protected com.threerings.media.sprite.PathAdapter _pathEndRemover
A path observer that removes the sprite at the end of its path.


CARD_COMP

protected static final Comparator<CardSprite> CARD_COMP
Compares two card sprites based on their underlying card.


DEFAULT_BACKGROUND

protected static final Color DEFAULT_BACKGROUND
A nice default green card table background color.

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(com.google.common.base.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

getCardSprite

protected CardSprite getCardSprite(List<CardSprite> list,
                                   Card card)
Returns the first card sprite in the specified list that represents the specified card, or null if there is no such sprite in the list.


shouldSortHand

protected boolean shouldSortHand()
Returns whether the user's hand should be sorted when displayed. By default, hands are sorted.


adjustHand

protected void adjustHand(long adjustDuration,
                          boolean updateLayers)
Expands or collapses the hand to accommodate new cards or cover the space left by removed cards. Skips unmanaged sprites. Clears out any selected cards.

Parameters:
adjustDuration - the amount of time to spend settling the cards into their new locations
updateLayers - whether or not to update the layers of the cards

removeFromHand

protected void removeFromHand(CardSprite card)
Removes a card from the hand.


updateHandOffsets

protected void updateHandOffsets()
Updates the offsets of all the cards in the hand. If there is only one selectable card, that card will always be raised slightly.


getHandX

protected int getHandX(int size,
                       int idx)
Given the location and spacing of the hand, returns the x location of the card at the specified index within a hand of the specified size.


getHandY

protected int getHandY(CardSprite sprite)
Determines the y location of the specified card sprite, given its selection state.


isSelectable

protected boolean isSelectable(CardSprite sprite)
Given the current selection mode and predicate, determines if the specified sprite is selectable.


isOnlySelectable

protected boolean isOnlySelectable(CardSprite sprite)
Determines whether the specified sprite is the only selectable sprite in the hand according to the selection predicate.


lowerBoardSprites

protected void lowerBoardSprites(int layer)
Lowers all board sprites so that they are rendered at or below the specified layer.


getHighestBoardLayer

protected int getHighestBoardLayer()
Returns the highest render order of any sprite on the board.


clearSprites

protected void clearSprites(List<CardSprite> sprites)
Clears an array of sprites from the specified list and from the panel.


updateActiveCardSprite

protected void updateActiveCardSprite()
Updates the active card sprite based on the location of the mouse pointer.


paintBehind

protected void paintBehind(Graphics2D gfx,
                           Rectangle dirtyRect)
Overrides:
paintBehind in class com.threerings.media.VirtualMediaPanel