com.threerings.puzzle.drop.client

## Class DropBoardView

- java.lang.Object
- - java.awt.Component
  - - java.awt.Container
    - - javax.swing.JComponent
      - - com.threerings.media.MediaPanel
        - - com.threerings.media.VirtualMediaPanel
          - - com.threerings.puzzle.client.PuzzleBoardView
            - - com.threerings.puzzle.drop.client.DropBoardView

All Implemented Interfaces:
  com.threerings.media.FrameParticipant, com.threerings.media.MediaConstants, com.threerings.media.MediaHost, DropPieceCodes, com.threerings.util.DirectionCodes, ImageObserver, MenuContainer, Serializable

    public abstract class DropBoardView
    extends PuzzleBoardView
    implements DropPieceCodes

The drop board view displays a drop puzzle game in progress for a single player.

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
`static Color` `CHAIN_COLOR` The color used to render chain reward scoring text.
`static Color` `SCORE_COLOR` The color used to render normal scoring text.

### 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.puzzle.drop.data.DropPieceCodes

`DROP_BLOCK_PIECE_COUNT, PIECE_NONE`

### Fields inherited from interface com.threerings.util.DirectionCodes

`CARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST`

### 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
`DropBoardView(PuzzleContext ctx, int pwid, int phei)` Constructs a drop board view.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`void` `clearPiece(int xx, int yy)` Clears out a piece from the board along with its piece sprite.
`void` `clearPieceSprite(int xx, int yy)` Clears the specified piece from the board.
`void` `createPiece(int piece, int sx, int sy)` Creates a new piece sprite and places it directly in its correct position.
`void` `createPiece(int piece, int sx, int sy, int tx, int ty, long duration)` Creates a new piece sprite and moves it into position on the board.
`DropSprite` `createPieces(int col, int row, int[] pieces, int dist)` Creates a new drop sprite used to animate the given pieces falling in the specified column.
`ScoreAnimation` `createScoreAnimation(String score, Color color, Font font)` Creates and returns an animation showing the specified score floating up the view, with the label initially centered within the view.
`ScoreAnimation` `createScoreAnimation(String score, Color color, Font font, int x, int y, int width, int height)` Creates and returns an animation showing the specified score floating up the view.
`void` `dirtySegment(int dir, int col, int row, int len)` Dirties the rectangle encompassing the segment with the given direction and length whose bottom-leftmost corner is at `(col, row)`.
`int` `getPieceHeight()` Returns the height in pixels of a single board piece.
`com.threerings.media.image.Mirage` `getPieceImage(int piece)` Returns the image used to display the given piece at coordinates `(0, 0)` with an orientation of `DirectionCodes.NORTH`.
`abstract com.threerings.media.image.Mirage` `getPieceImage(int piece, int col, int row, int orient)` Returns the image used to display the given piece at the specified column and row with the given orientation.
`void` `getPiecePosition(int col, int row, Point pos)` Called by the `DropSprite` to populate `pos` with the screen coordinates in pixels at which a piece at `(col, row)` in the board should be drawn.
`Dimension` `getPieceSegmentSize(int col, int row, int orient, int len)` Called by the `DropSprite` to get the dimensions of the area that will be occupied by rendering a piece segment of the given orientation and length whose bottom-leftmost corner is at `(col, row)`.
`com.threerings.media.sprite.Sprite` `getPieceSprite(int xx, int yy)` Returns the piece sprite at the specified location.
`int` `getPieceWidth()` Returns the width in pixels of a single board piece.
`Dimension` `getPreferredSize()`
`boolean` `inBounds(int col, int row)` Returns true if the specified coordinate is within the bounds of the board, false if it is not.
`void` `init(GameConfig config)` Initializes the board with the board dimensions.
`com.threerings.media.sprite.Sprite` `movePiece(int sx, int sy, int tx, int ty, long duration)` Instructs the view to move the piece at the specified starting position to the specified destination position.
`void` `paintBetween(Graphics2D gfx, Rectangle dirtyRect)`
`void` `rotateDropBlock(DropBlockSprite sprite, int orient)` Rotates the given drop block sprite to the specified orientation, updating the image as necessary.
`void` `setBoard(Board board)` Sets the board to be displayed.
`void` `updatePiece(int sx, int sy)` Refreshes the piece sprite at the specified location, if no sprite exists at the location, one will be created.
`void` `updatePiece(int piece, int sx, int sy)` Updates the piece sprite at the specified location, if no sprite exists at the location, one will be created.

### Methods inherited from class com.threerings.puzzle.client.PuzzleBoardView

`abortAnimation, addActionAnimation, addActionSprite, clearAnimations, clearSprites, createScoreAnimation, dumpActors, getActionAnimationCount, getActionCount, getActionSpriteCount, paintBehind, removeSprite, setBackgroundImage, setController, setPaused, trackAvoidAnimation`

### 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, 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, 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

#### SCORE_COLOR

    public static final Color SCORE_COLOR

The color used to render normal scoring text.

#### CHAIN_COLOR

    public static final Color CHAIN_COLOR

The color used to render chain reward scoring text.

### Constructor Detail

#### DropBoardView

    public DropBoardView(PuzzleContext ctx,
                         int pwid,
                         int phei)

Constructs a drop board view.

### Method Detail

#### init

    public void init(GameConfig config)

Initializes the board with the board dimensions.

Overrides:
  `init` in class `PuzzleBoardView`

#### getPieceWidth

    public int getPieceWidth()

Returns the width in pixels of a single board piece.

#### getPieceHeight

    public int getPieceHeight()

Returns the height in pixels of a single board piece.

#### getPiecePosition

    public void getPiecePosition(int col,
                                 int row,
                                 Point pos)

Called by the `DropSprite` to populate `pos` with the screen coordinates in pixels at which a piece at `(col, row)` in the board should be drawn. Derived classes may wish to override this method to allow specialized positioning of sprites.

#### getPieceSegmentSize

    public Dimension getPieceSegmentSize(int col,
                                         int row,
                                         int orient,
                                         int len)

Called by the `DropSprite` to get the dimensions of the area that will be occupied by rendering a piece segment of the given orientation and length whose bottom-leftmost corner is at `(col, row)`.

#### createPiece

    public void createPiece(int piece,
                            int sx,
                            int sy)

Creates a new piece sprite and places it directly in its correct position.

#### updatePiece

    public void updatePiece(int sx,
                            int sy)

Refreshes the piece sprite at the specified location, if no sprite exists at the location, one will be created. Note: this method assumes the default `ImageSprite` is being used to display pieces. If `createPieceSprite(int, int, int)` is overridden to return a non-ImageSprite, this method must also be customized.

#### updatePiece

    public void updatePiece(int piece,
                            int sx,
                            int sy)

Updates the piece sprite at the specified location, if no sprite exists at the location, one will be created. Note: this method assumes the default `ImageSprite` is being used to display pieces. If `createPieceSprite(int, int, int)` is overridden to return a non-ImageSprite, this method must also be customized.

#### createPiece

    public void createPiece(int piece,
                            int sx,
                            int sy,
                            int tx,
                            int ty,
                            long duration)

Creates a new piece sprite and moves it into position on the board.

#### movePiece

    public com.threerings.media.sprite.Sprite movePiece(int sx,
                                                        int sy,
                                                        int tx,
                                                        int ty,
                                                        long duration)

Instructs the view to move the piece at the specified starting position to the specified destination position. There must be a sprite at the starting position, if there is a sprite at the destination position, it must also be moved immediately following this call (as in the case of a swap) to avoid badness.

Returns:
  the piece sprite that is being moved.

#### getPieceImage

    public com.threerings.media.image.Mirage getPieceImage(int piece)

Returns the image used to display the given piece at coordinates `(0, 0)` with an orientation of `DirectionCodes.NORTH`. This serves as a convenience routine for those puzzles that don't bother rendering their pieces differently when placed at different board coordinates or in different orientations.

#### getPieceImage

    public abstract com.threerings.media.image.Mirage getPieceImage(int piece,
                                                                    int col,
                                                                    int row,
                                                                    int orient)

Returns the image used to display the given piece at the specified column and row with the given orientation.

#### setBoard

    public void setBoard(Board board)

Description copied from class: `PuzzleBoardView`
Sets the board to be displayed.

Overrides:
  `setBoard` in class `PuzzleBoardView`

#### getPieceSprite

    public com.threerings.media.sprite.Sprite getPieceSprite(int xx,
                                                             int yy)

Returns the piece sprite at the specified location.

#### clearPieceSprite

    public void clearPieceSprite(int xx,
                                 int yy)

Clears the specified piece from the board.

#### clearPiece

    public void clearPiece(int xx,
                           int yy)

Clears out a piece from the board along with its piece sprite.

#### createPieces

    public DropSprite createPieces(int col,
                                   int row,
                                   int[] pieces,
                                   int dist)

Creates a new drop sprite used to animate the given pieces falling in the specified column.

#### dirtySegment

    public void dirtySegment(int dir,
                             int col,
                             int row,
                             int len)

Dirties the rectangle encompassing the segment with the given direction and length whose bottom-leftmost corner is at `(col, row)`.

#### createScoreAnimation

    public ScoreAnimation createScoreAnimation(String score,
                                               Color color,
                                               Font font)

Creates and returns an animation showing the specified score floating up the view, with the label initially centered within the view.

Parameters:
  `score` - the score text to display.
  `color` - the color of the text.
  `font` - the font.

#### createScoreAnimation

    public ScoreAnimation createScoreAnimation(String score,
                                               Color color,
                                               Font font,
                                               int x,
                                               int y,
                                               int width,
                                               int height)

Creates and returns an animation showing the specified score floating up the view.

Parameters:
  `score` - the score text to display.
  `color` - the color of the text.
  `font` - the font to use.
  `x` - the left coordinate in board coordinates of the rectangle within which the score is to be centered.
  `y` - the bottom coordinate in board coordinates of the rectangle within which the score is to be centered.
  `width` - the width in board coordinates of the rectangle within which the score is to be centered.
  `height` - the height in board coordinates of the rectangle within which the score is to be centered.

#### rotateDropBlock

    public void rotateDropBlock(DropBlockSprite sprite,
                                int orient)

Rotates the given drop block sprite to the specified orientation, updating the image as necessary. Derived classes that make use of block dropping functionality should override this method to do the right thing.

#### paintBetween

    public void paintBetween(Graphics2D gfx,
                             Rectangle dirtyRect)

Overrides:
  `paintBetween` in class `PuzzleBoardView`

#### getPreferredSize

    public Dimension getPreferredSize()

Overrides:
  `getPreferredSize` in class `JComponent`

#### inBounds

    public boolean inBounds(int col,
                            int row)

Returns true if the specified coordinate is within the bounds of the board, false if it is not.