com.threerings.puzzle.client
Class PuzzleBoardView

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.puzzle.client.PuzzleBoardView
All Implemented Interfaces:
com.threerings.media.FrameParticipant, com.threerings.media.MediaConstants, com.threerings.media.MediaHost, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
DropBoardView

public abstract class PuzzleBoardView
extends com.threerings.media.VirtualMediaPanel

The puzzle board view displays a view of a puzzle game.

See Also:
Serialized Form

Nested Class Summary
 
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 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.media.MediaConstants
ALL, BACK, FRONT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PuzzleBoardView(PuzzleContext ctx)
          Constructs a puzzle board view.
 
Method Summary
 void abortAnimation(com.threerings.media.animation.Animation anim)
           
 void addActionAnimation(com.threerings.media.animation.Animation anim)
          Adds the given animation to the set of animations currently present on the board.
 void addActionSprite(com.threerings.media.sprite.Sprite sprite)
          Adds the given sprite to the set of sprites currently present on the board.
 void clearAnimations()
           
 void clearSprites()
           
 ScoreAnimation createScoreAnimation(String score, Color color, Font font, int x, int y)
          Creates and returns an animation displaying the given string with the specified parameters, floating it a short distance up the view.
 void dumpActors()
          Dumps to the logs, a list of interesting sprites and animations currently active on the puzzle board.
 int getActionAnimationCount()
          Returns the number of action animations on the board.
 int getActionCount()
          Returns the count of action sprites and animations on the board.
 int getActionSpriteCount()
          Returns the number of action sprites on the board.
 void init(GameConfig config)
          Initializes the board with the board dimensions.
 void paintBehind(Graphics2D gfx, Rectangle dirty)
           
 void paintBetween(Graphics2D gfx, Rectangle dirty)
           
 void removeSprite(com.threerings.media.sprite.Sprite sprite)
           
 void setBackgroundImage(com.threerings.media.image.Mirage image)
          Sets the background image displayed by the board view.
 void setBoard(Board board)
          Sets the board to be displayed.
 void setController(PuzzleController pctrl)
          Provides the board view with a reference to its controller so that it may communicate directly rather than by posting actions up the interface hierarchy which sometimes fails if the puzzle board view is hidden before we get a chance to post our actions.
 void setPaused(boolean paused)
          Set whether this puzzle is paused or not.
 void trackAvoidAnimation(com.threerings.media.animation.Animation anim)
          Positions the supplied animation so as to avoid any active animations previously registered with this method, and adds the animation to the list of animations to be avoided by any future avoid animations.
 
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
addAnimation, addObscurer, addSprite, createGraphics, getAnimationManager, getComponent, getRegionManager, getSpriteManager, getTimeStamp, isManaged, isManaged, needsPaint, paint, removeObscurer, repaint, setOpaque, tick
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, 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, 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, transferFocusBackward, 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, 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, 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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PuzzleBoardView

public PuzzleBoardView(PuzzleContext ctx)
Constructs a puzzle board view.

Method Detail

init

public void init(GameConfig config)
Initializes the board with the board dimensions.


setBoard

public void setBoard(Board board)
Sets the board to be displayed.


setController

public void setController(PuzzleController pctrl)
Provides the board view with a reference to its controller so that it may communicate directly rather than by posting actions up the interface hierarchy which sometimes fails if the puzzle board view is hidden before we get a chance to post our actions.


setBackgroundImage

public void setBackgroundImage(com.threerings.media.image.Mirage image)
Sets the background image displayed by the board view.


setPaused

public void setPaused(boolean paused)
Set whether this puzzle is paused or not. If paused, a label will be displayed with the component's font, which may be set with setFont().

Overrides:
setPaused in class com.threerings.media.MediaPanel

addActionAnimation

public void addActionAnimation(com.threerings.media.animation.Animation anim)
Adds the given animation to the set of animations currently present on the board. The animation will be added to a list of action animations whose count can be queried with getActionAnimationCount(). The animation will automatically be removed from the action list when it completes.


abortAnimation

public void abortAnimation(com.threerings.media.animation.Animation anim)
Overrides:
abortAnimation in class com.threerings.media.MediaPanel

addActionSprite

public void addActionSprite(com.threerings.media.sprite.Sprite sprite)
Adds the given sprite to the set of sprites currently present on the board. The sprite will be added to a list of action sprites whose count can be queried with getActionSpriteCount(). Callers should be sure to remove the sprite when their work with it is done via removeSprite(com.threerings.media.sprite.Sprite).


removeSprite

public void removeSprite(com.threerings.media.sprite.Sprite sprite)
Overrides:
removeSprite in class com.threerings.media.MediaPanel

clearSprites

public void clearSprites()
Overrides:
clearSprites in class com.threerings.media.MediaPanel

clearAnimations

public void clearAnimations()
Overrides:
clearAnimations in class com.threerings.media.MediaPanel

getActionAnimationCount

public int getActionAnimationCount()
Returns the number of action animations on the board.


getActionSpriteCount

public int getActionSpriteCount()
Returns the number of action sprites on the board.


getActionCount

public int getActionCount()
Returns the count of action sprites and animations on the board.


dumpActors

public void dumpActors()
Dumps to the logs, a list of interesting sprites and animations currently active on the puzzle board.


createScoreAnimation

public ScoreAnimation createScoreAnimation(String score,
                                           Color color,
                                           Font font,
                                           int x,
                                           int y)
Creates and returns an animation displaying the given string with the specified parameters, floating it a short distance up the view.

Parameters:
score - the score text to display.
color - the color of the text.
font - the font with which to create the score animation.
x - the x-position at which the score is to be placed.
y - the y-position at which the score is to be placed.

trackAvoidAnimation

public void trackAvoidAnimation(com.threerings.media.animation.Animation anim)
Positions the supplied animation so as to avoid any active animations previously registered with this method, and adds the animation to the list of animations to be avoided by any future avoid animations.


paintBehind

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

paintBetween

public void paintBetween(Graphics2D gfx,
                         Rectangle dirty)
Overrides:
paintBetween in class com.threerings.media.MediaPanel


Copyright © 2011. All Rights Reserved.