us.the.mac.board
Class Board

java.lang.Object
  extended by android.view.View
      extended by android.view.ViewGroup
          extended by android.widget.FrameLayout
              extended by us.the.mac.board.Board
All Implemented Interfaces:
Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, View.OnClickListener, ViewManager, ViewParent, TimerCallback
Direct Known Subclasses:
GuideBoard

public abstract class Board
extends FrameLayout
implements View.OnClickListener, TimerCallback

The Board class contains all added pieces, internal squares, and handles
the functions that make up the Android User Experience.

It is used as a parent class of other types of boards (Chess, Xiangqi, etc.),
and receives piece logic to provide the game functionality.


Nested Class Summary
static class Board.Color
          The Color enum contains the color of a piece.

For Example: If a piece is White its value will be, Board.Color.WHITE.
static interface Board.EndGamePiece
          The EndGamePiece interface handles the callback for the type of piece that ends the game.

For Example: In games like Chess or Xiangqi, this interface is implemented by the King pieces.
static class Board.LayoutParams
           
protected static class Board.PGNEvent
           
static class Board.Piece
          This class contains all the general functions of a piece.

It is used as a parent class of other types of pieces (Knight, Pawn, etc.),
and contains all the board data.
protected  class Board.Player
          The player class is used to allow a piece to be selected of a specific color.
static class Board.Report
           
static class Board.ServerConnection
           
 class Board.Square
          The Square class contains all needed squares, and handles the piece
that is on it through its moves data to interact with other squares.
 
Nested classes/interfaces inherited from class android.view.ViewGroup
ViewGroup.MarginLayoutParams, ViewGroup.OnHierarchyChangeListener
 
Nested classes/interfaces inherited from class android.view.View
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener
 
Field Summary
static boolean client
          FOR CREATING AND UPDATING ALL BOARD SQUARE INSTANCES
protected  Board.Color mCurrentColor
          FOR CONTAINING FIRST BOARD PLAYER
static boolean moveReceivedFromOpponent
          FOR CREATING AND UPDATING ALL BOARD SQUARE INSTANCES
protected  Board.Color mPrimaryColor
          FOR CONTAINING FIRST BOARD PLAYER
static boolean STARTED_CONNECTION
           
 
Fields inherited from class android.view.ViewGroup
CLIP_TO_PADDING_MASK, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE
 
Fields inherited from class android.view.View
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, INVISIBLE, KEEP_SCREEN_ON, NO_ID, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET
 
Constructor Summary
Board(Context context, AttributeSet attrs)
          This constructor is used to access a Board from android xml layout files.

 
Method Summary
 void cancelGame()
           
protected  boolean checkLayoutParams(ViewGroup.LayoutParams p)
          
 String convertToFEN()
          8/8/8/8/3n4/8/8/8 w - - 0 1
protected  void currentPieceMovement(Board.Square squ)
          This method is used to access the current Square selected after selecting a piece.

protected  void currentPieceMovement(int squ)
          This method is used to access the current Square selected after selecting a piece.

protected  void currentSelection(Board.Square squ)
          This method is used to access the current Square selected before selecting a piece.

protected  void currentSelection(int squ)
          This method is used to access the current Square selected before selecting a piece.

protected  Board.LayoutParams generateDefaultLayoutParams()
          Returns a set of layout parameters with a width of ViewGroup.LayoutParams.MATCH_PARENT, a height of ViewGroup.LayoutParams.WRAP_CONTENT and no spanning.
 Board.LayoutParams generateLayoutParams(AttributeSet attrs)
          
protected  Board.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
          
 BoardDisplay getBoardDisplay()
           
 String getGameID()
           
protected  Board.Piece[] getPieces()
           
static Board.Square getSquareAt(int p)
          This method accesses the squares container
 void initializeGame(boolean normalPlay, String userName01, String userName02, int seconds)
           
static Board Instance()
           
static int invertPosition(int pos)
           
 boolean isBackward(int pos)
           
static boolean isClient()
           
 void onClick(View v)
           
protected  void onLayout(boolean changed, int left, int top, int right, int bottom)
          Accepts and lays out all child views e.g.
 void pgnMovement(String movement, boolean back)
          This method is used to access the current pgn move and reset the pieces to their proper state.

 void resetBoard()
           
 void resetBoardOrder()
          Resets the z order of all the pieces on the board by looping through each square and by using the method Square.sendPieceToBack, which is an altered version of View.bringToFront().

The method will send the piece to the back by changing the z order
 void resetFile()
          Resets the z order of all the pieces on the board by looping through each square and by using the method bringPieceToFront, which is an altered version of bringToFront().

The method will bring the piece to the front by changing the z order

REFERENCED FROM: http://developer.android.com/reference/android/view/View.html#bringToFront()
 void restartToMenu()
           
static void setAsClient()
           
static void setAsReceivedMove()
           
static void setAsRegularMove()
           
protected  void setTutorialPlayer()
           
protected  void setTutorialPlayer(Board.Color c)
           
 void setUpHistory(int size)
           
 void startActivityForResult(Intent enableIntent, int requestEnableBt)
           
protected  void wipeBoard()
           
 
Methods inherited from class android.widget.FrameLayout
draw, drawableStateChanged, gatherTransparentRegion, getConsiderGoneChildrenWhenMeasuring, getForeground, onMeasure, onSizeChanged, setForeground, setForegroundGravity, setMeasureAllChildren, verifyDrawable
 
Methods inherited from class android.view.ViewGroup
addFocusables, addFocusables, addStatesFromChildren, addTouchables, addView, addView, addView, addView, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, canAnimate, childDrawableStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDraw, dispatchFreezeSelfOnly, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchPopulateAccessibilityEvent, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetPressed, dispatchSetSelected, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, drawChild, findFocus, fitSystemWindows, focusableViewAvailable, focusSearch, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getPersistentDrawingCache, hasFocus, hasFocusable, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawingOrderEnabled, isChildrenDrawnWithCacheEnabled, measureChild, measureChildren, measureChildWithMargins, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAnimationEnd, onAnimationStart, onCreateDrawableState, onInterceptTouchEvent, onRequestFocusInDescendants, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestTransparentRegion, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawingOrderEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setOnHierarchyChangeListener, setPadding, setPersistentDrawingCache, setStaticTransformationsEnabled, showContextMenuForChild, startLayoutAnimation, updateViewLayout
 
Methods inherited from class android.view.View
awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, cancelLongPress, checkInputConnectionProxy, clearAnimation, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createContextMenu, destroyDrawingCache, findViewById, findViewWithTag, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getKeyDispatcherState, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTag, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInEditMode, isInTouchMode, isLayoutRequested, isLongClickable, isOpaque, isPaddingOffsetRequired, isPressed, isSaveEnabled, isScrollbarFadingEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAttachedToWindow, onCheckIsTextEditor, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onDetachedFromWindow, onDisplayHint, onDraw, onDrawScrollBars, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onRestoreInstanceState, onSaveInstanceState, onScrollChanged, onSetAlpha, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onVisibilityChanged, onWindowFocusChanged, onWindowVisibilityChanged, performClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setContentDescription, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFocusable, setFocusableInTouchMode, setHapticFeedbackEnabled, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setKeepScreenOn, setLayoutParams, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPressed, setSaveEnabled, setScrollbarFadingEnabled, setScrollBarStyle, setScrollContainer, setSelected, setSoundEffectsEnabled, setTag, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface us.the.mac.board.TimerCallback
onTimerEnded, onTimerUpdate
 
Methods inherited from interface android.view.ViewParent
createContextMenu, getParent, isLayoutRequested, requestLayout
 

Field Detail

STARTED_CONNECTION

public static boolean STARTED_CONNECTION

client

public static boolean client
FOR CREATING AND UPDATING ALL BOARD SQUARE INSTANCES


moveReceivedFromOpponent

public static boolean moveReceivedFromOpponent
FOR CREATING AND UPDATING ALL BOARD SQUARE INSTANCES


mPrimaryColor

protected Board.Color mPrimaryColor
FOR CONTAINING FIRST BOARD PLAYER


mCurrentColor

protected Board.Color mCurrentColor
FOR CONTAINING FIRST BOARD PLAYER

Constructor Detail

Board

public Board(Context context,
             AttributeSet attrs)
This constructor is used to access a Board from android xml layout files.

Parameters:
context - The Application/Activity context
attrs - The xml attributes passed
Method Detail

startActivityForResult

public void startActivityForResult(Intent enableIntent,
                                   int requestEnableBt)

restartToMenu

public void restartToMenu()

resetBoard

public void resetBoard()

setAsReceivedMove

public static void setAsReceivedMove()

setAsRegularMove

public static void setAsRegularMove()

isClient

public static boolean isClient()

invertPosition

public static int invertPosition(int pos)

setAsClient

public static void setAsClient()

Instance

public static Board Instance()

getBoardDisplay

public BoardDisplay getBoardDisplay()

convertToFEN

public String convertToFEN()
8/8/8/8/3n4/8/8/8 w - - 0 1


initializeGame

public void initializeGame(boolean normalPlay,
                           String userName01,
                           String userName02,
                           int seconds)

cancelGame

public void cancelGame()

getGameID

public String getGameID()

setTutorialPlayer

protected void setTutorialPlayer()

setTutorialPlayer

protected void setTutorialPlayer(Board.Color c)

onLayout

protected void onLayout(boolean changed,
                        int left,
                        int top,
                        int right,
                        int bottom)
Accepts and lays out all child views e.g. TextView, Square, Piece, etc.

Overrides:
onLayout in class FrameLayout

resetFile

public void resetFile()
Resets the z order of all the pieces on the board by looping through each square and by using the method bringPieceToFront, which is an altered version of bringToFront().

The method will bring the piece to the front by changing the z order

REFERENCED FROM: http://developer.android.com/reference/android/view/View.html#bringToFront()


resetBoardOrder

public void resetBoardOrder()
Resets the z order of all the pieces on the board by looping through each square and by using the method Square.sendPieceToBack, which is an altered version of View.bringToFront().

The method will send the piece to the back by changing the z order


getSquareAt

public static Board.Square getSquareAt(int p)
This method accesses the squares container

Parameters:
p - the position of the square to access
Returns:
The #Square that is available, otherwise null

getPieces

protected Board.Piece[] getPieces()

currentSelection

protected void currentSelection(int squ)
This method is used to access the current Square selected before selecting a piece.

Parameters:
squ - The currently selected Square

currentPieceMovement

protected void currentPieceMovement(int squ)
This method is used to access the current Square selected after selecting a piece.

Parameters:
squ - The currently selected Square

onClick

public void onClick(View v)
Specified by:
onClick in interface View.OnClickListener

currentSelection

protected void currentSelection(Board.Square squ)
This method is used to access the current Square selected before selecting a piece.

Parameters:
squ - The currently selected Square

currentPieceMovement

protected void currentPieceMovement(Board.Square squ)
This method is used to access the current Square selected after selecting a piece.

Parameters:
squ - The currently selected Square

pgnMovement

public void pgnMovement(String movement,
                        boolean back)
This method is used to access the current pgn move and reset the pieces to their proper state.

Parameters:
movement - The currently selected Square

setUpHistory

public void setUpHistory(int size)

isBackward

public boolean isBackward(int pos)

wipeBoard

protected void wipeBoard()

generateLayoutParams

public Board.LayoutParams generateLayoutParams(AttributeSet attrs)

Overrides:
generateLayoutParams in class FrameLayout

generateDefaultLayoutParams

protected Board.LayoutParams generateDefaultLayoutParams()
Returns a set of layout parameters with a width of ViewGroup.LayoutParams.MATCH_PARENT, a height of ViewGroup.LayoutParams.WRAP_CONTENT and no spanning.

Overrides:
generateDefaultLayoutParams in class FrameLayout

checkLayoutParams

protected boolean checkLayoutParams(ViewGroup.LayoutParams p)

Overrides:
checkLayoutParams in class FrameLayout

generateLayoutParams

protected Board.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)

Overrides:
generateLayoutParams in class FrameLayout