|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
com.threerings.media.MediaPanel
com.threerings.media.VirtualMediaPanel
com.threerings.parlor.card.client.CardPanel
public abstract class CardPanel
Extends VirtualMediaPanel to provide services specific to rendering and manipulating playing cards.
| 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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int NONE
public static final int SINGLE
public static final int MULTIPLE
protected int _cardWidth
protected MouseEvent _mouseEvent
protected CardSprite _activeCardSprite
protected ArrayList<CardSprite> _handSprites
protected ArrayList<CardSprite> _selectedHandSprites
protected int _handSelectionMode
protected com.google.common.base.Predicate<CardSprite> _handSelectionPredicate
protected ObserverList<CardPanel.CardSelectionObserver> _handSelectionObservers
protected Point _handLocation
protected int _handSpacing
protected int _selectableCardOffset
protected int _selectedCardOffset
protected ArrayList<CardSprite> _boardSprites
protected CardPanel.HandSpriteObserver _handSpriteObserver
protected com.threerings.media.sprite.PathAdapter _pathEndRemover
protected static final Comparator<CardSprite> CARD_COMP
protected static final Color DEFAULT_BACKGROUND
| Constructor Detail |
|---|
public CardPanel(com.threerings.media.FrameManager frameManager)
frameManager - the frame manager| Method Detail |
|---|
public abstract com.threerings.media.image.Mirage getCardBackImage()
public abstract com.threerings.media.image.Mirage getCardImage(Card card)
public abstract com.threerings.media.image.Mirage getMicroCardBackImage()
public abstract com.threerings.media.image.Mirage getMicroCardImage(Card card)
public void setHandLocation(int x,
int y)
public void setHandSpacing(int spacing)
public void setSelectableCardOffset(int offset)
public void setSelectedCardOffset(int offset)
public void setHandSelectionMode(int mode)
public void setHandSelectionPredicate(com.google.common.base.Predicate<CardSprite> pred)
public CardSprite getSelectedHandSprite()
public CardSprite[] getSelectedHandSprites()
public void selectHandSprite(CardSprite sprite)
public void deselectHandSprite(CardSprite sprite)
public void clearHandSelection()
public void addHandSelectionObserver(CardPanel.CardSelectionObserver obs)
public void removeHandSelectionObserver(CardPanel.CardSelectionObserver obs)
public void setHand(Hand hand,
long fadeDuration)
hand - the hand of cardsfadeDuration - the amount of time to spend fading in the entire hand
public void setHand(int size,
long fadeDuration)
size - the size of the handfadeDuration - the amount of time to spend fading in each cardpublic void showHand(Hand hand)
hand - the hand of cardspublic CardSprite getHandSprite(Card card)
public void clearHand()
public void clearBoard()
public void flyFromHand(CardSprite[] cards,
Point dest,
long flightDuration,
float fadePortion)
cards - the card sprites to remove from the handdest - the point to fly the cards toflightDuration - the duration of the cards' flightfadePortion - the amount of time to spend fading out as a proportion of the flight
duration
public void flyIntoHand(Card[] cards,
Point src,
long flightDuration,
long pauseDuration,
long dropDuration,
float fadePortion)
cards - the cards to add to the handsrc - the point to fly the cards fromflightDuration - the duration of the cards' flightpauseDuration - the duration of the pause before dropping into the handdropDuration - the duration of the cards' drop into the handfadePortion - the amount of time to spend fading in as a proportion of the flight
duration
public void flyAcross(Card[] cards,
Point src,
Point dest,
long flightDuration,
long cardDelay,
float fadePortion)
cards - the cards to fly acrosssrc - the point to fly the cards fromdest - the point to fly the cards toflightDuration - the duration of the cards' flightcardDelay - the amount of time to wait between cardsfadePortion - the amount of time to spend fading in and out as a proportion of the
flight duration
public void flyAcross(int number,
Point src,
Point dest,
long flightDuration,
long cardDelay,
float fadePortion)
number - the number of cards to fly acrosssrc - the point to fly the cards fromdest - the point to fly the cards toflightDuration - the duration of the cards' flightcardDelay - the amount of time to wait between cardsfadePortion - the amount of time to spend fading in and out as a proportion of the
flight duration
public void flyFromHandToBoard(CardSprite card,
Point dest,
long flightDuration)
card - the sprite to remove from the handdest - the point to fly the card toflightDuration - the duration of the card's flight
public void flyToBoard(Card card,
Point src,
Point dest,
long flightDuration,
float fadePortion)
card - the card to add to the boardsrc - the point to fly the card fromdest - the point to fly the card toflightDuration - the duration of the card's flightfadePortion - the amount of time to spend fading in as a proportion of the flight
duration
public void addToBoard(Card card,
Point dest)
card - the card to add to the boarddest - the point at which to add the card
public void flyFromBoard(CardSprite[] cards,
Point dest,
long flightDuration,
float fadePortion)
cards - the cards to remove from the boarddest - the point to fly the cards toflightDuration - the duration of the cards' flightfadePortion - the amount of time to spend fading out as a proportion of the flight
duration
public void flyFromBoard(CardSprite[] cards,
Point dest1,
Point dest2,
long flightDuration,
float fadePortion)
cards - the cards to remove from the boarddest1 - the first point to fly the cards todest2 - the final destination of the cardsflightDuration - the duration of the cards' flightfadePortion - the amount of time to spend fading out as a proportion of the flight
duration
protected CardSprite getCardSprite(List<CardSprite> list,
Card card)
protected boolean shouldSortHand()
protected void adjustHand(long adjustDuration,
boolean updateLayers)
adjustDuration - the amount of time to spend settling the cards into their new
locationsupdateLayers - whether or not to update the layers of the cardsprotected void removeFromHand(CardSprite card)
protected void updateHandOffsets()
protected int getHandX(int size,
int idx)
protected int getHandY(CardSprite sprite)
protected boolean isSelectable(CardSprite sprite)
protected boolean isOnlySelectable(CardSprite sprite)
protected void lowerBoardSprites(int layer)
protected int getHighestBoardLayer()
protected void clearSprites(List<CardSprite> sprites)
protected void updateActiveCardSprite()
protected void paintBehind(Graphics2D gfx,
Rectangle dirtyRect)
paintBehind in class com.threerings.media.VirtualMediaPanel
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||