antichess.viewgui
Class ChessGUI

java.lang.Object
  extended by antichess.viewgui.ChessGUI
All Implemented Interfaces:
BoardObserver, ActionListener, Runnable, EventListener

public class ChessGUI
extends Object
implements BoardObserver, ActionListener, Runnable

ChessGUI is a GUI for displaying a game of Chess, Antichess, or any other chess game that uses a ChessBoard. Features supported by the ChessGUI: Starting new games of Chess or Antichess with human or AI players. A variety of times are available as well. @see NewGameWindow Saving a current AntichessGame in the format specified Loading an Antichess game in the format specified Pausing a game Ending a game early or resigning Setting options for the ChessBoardView including: showing legal moves once a piece has been selected disco mode While saving, loading, or creating a new game, the game is automatically paused. Upon exiting the game is not longer paused. ChessGUI has an icon stored in images/antichessicon.bmp if this file does not exist no special icon is loaded. For creating the ChessBoardView, ChessGUI relies on these files existing: images/RAntiking.gif images/RBishop.gif images/RKing.gif images/RKnight.gif images/RPawn.gif images/RQueen.gif images/RRook.gif images/WAntiking.gif images/WBishop.gif images/WKing.gif images/WKnight.gif images/WPawn.gif images/WQueen.gif images/WRook.gif images/board.gif and optionally: images/kitty.gif Most of the functionality is documented in the User Manual

Author:
nlharr
Specification Fields

Method Summary
 void actionPerformed(ActionEvent e)
          Handles these events for the ChessGUI: Exiting Saving Loading Starting a new game Pausing Ending the game Setting Possible Moves Visible Disco Mode For a better description of these see the specifications for the class.
static ChessGUI createGUI(ChessBoard board, GameClock gameClock, ControllerMaster master)
          Creates a ChessGUI suitable for Chess or Antichess playing on.
 void destroy()
          Closes the GUI
 BoardView getBoardView()
           
 void postRefresh()
          ChessGUI is a BoardObserver so this method is called whenever the currentBoard deems it necesary.
 void run()
          Calls showGUI().
 void showGUI()
          Shows this GUI.
 void switchViewedGame(ChessBoard newBoard, GameClock clock)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

destroy

public void destroy()
Closes the GUI


getBoardView

public BoardView getBoardView()
Returns:
boardView

switchViewedGame

public void switchViewedGame(ChessBoard newBoard,
                             GameClock clock)
Effects:
board = newBoard, clock = newClock, notifiedGameOver = false
Modifies:
board, clock, notifiedGameOver

postRefresh

public void postRefresh()
ChessGUI is a BoardObserver so this method is called whenever the currentBoard deems it necesary. This method handles switching the text color for the White and Black labels, and displaying a dialogue for the end of the game.

Specified by:
postRefresh in interface BoardObserver

actionPerformed

public void actionPerformed(ActionEvent e)
Handles these events for the ChessGUI: Exiting Saving Loading Starting a new game Pausing Ending the game Setting Possible Moves Visible Disco Mode For a better description of these see the specifications for the class.

Specified by:
actionPerformed in interface ActionListener

createGUI

public static ChessGUI createGUI(ChessBoard board,
                                 GameClock gameClock,
                                 ControllerMaster master)
Creates a ChessGUI suitable for Chess or Antichess playing on. For the GUI returned: board is the board that this GUI is monitoring view is the boardView that this GUI uses clock is the clock that this GUI monitors master is the ControllerMaster directing this GUI isPaused = false; notifiedGameOver = false;

Returns:
a ChessGUI

showGUI

public void showGUI()
Shows this GUI.


run

public void run()
Calls showGUI(). Used to start a thread for the GUI.

Specified by:
run in interface Runnable