Class SameView

java.lang.Object
  extended by SameView

public class SameView
extends java.lang.Object

This class works on the game's view. It paints the view, changes it, displays it.

Version:
1.3
Author:
Afzal Bhamjee

Nested Class Summary
 class SameView.Box
          An inner class that represents the Box.
 
Constructor Summary
SameView(SameModel model)
          The constructor takes the model as the only parameter
 
Method Summary
 void changeSameHover()
          Called when a mouse cursor hovers over a Box, will highlight the said Box (and nearby matching boxes), and update the score Called when the mouse enters a Box
 void changeSameHovered()
          When the mouse has exited the hovered boxes, the highlight Boolean is set to false for all boxes Called when the mouse exits a Box
 void changeSameNew()
          Calls the newGame method, and then closes the Dialog box Called when the New Game button is pressed or OK is pressed on the Dialog box
 void exitFrame()
          Disposes existing frames, called during JUnit tests as each test creates a new frame window
 void gameOver()
          Will show the game over Dialog box, after setting the score in the label
 javax.swing.JButton gameOverButton()
          Returns the Game Over button
 SameView.Box getBox(int panelNum)
          Returns the Box specified in the parameter
 int getBoxNum(java.awt.event.MouseEvent event)
          The MouseEvent Parameter, is used to work out the index position of the Box the MouseEvent occured upon Here again, the controller and view are kept seperate, where each of them only carry out the parts of the code that are specific to them
 int getDimention()
          Returns the current value in the dimention JSpinner
 int getNumColours()
          Returns the current value in the numColours JSpinner
 javax.swing.JButton hintButton()
          Returns the Hint button
 void newGame()
          Sets some variables that have to be reset, when a new game is started
 javax.swing.JButton newGameButton()
          Returns the New Game button
 void reColourBoxes()
          Loops through the Box'es and sets the colour for the Box
 void repaintFrame()
          Repaints the frame
 void updateScores()
          Upadtes the score and hoverScore with the latest values from the the model
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SameView

public SameView(SameModel model)
The constructor takes the model as the only parameter

Parameters:
SameModel, - the model the game view will retrieve data from
Method Detail

changeSameHover

public void changeSameHover()
Called when a mouse cursor hovers over a Box, will highlight the said Box (and nearby matching boxes), and update the score Called when the mouse enters a Box


changeSameHovered

public void changeSameHovered()
When the mouse has exited the hovered boxes, the highlight Boolean is set to false for all boxes Called when the mouse exits a Box


changeSameNew

public void changeSameNew()
Calls the newGame method, and then closes the Dialog box Called when the New Game button is pressed or OK is pressed on the Dialog box


exitFrame

public void exitFrame()
Disposes existing frames, called during JUnit tests as each test creates a new frame window


gameOver

public void gameOver()
Will show the game over Dialog box, after setting the score in the label


gameOverButton

public javax.swing.JButton gameOverButton()
Returns the Game Over button

Returns:
Game Over button

getBox

public SameView.Box getBox(int panelNum)
Returns the Box specified in the parameter

Parameters:
int - index position of Box
Returns:
The Box that was requested

getBoxNum

public int getBoxNum(java.awt.event.MouseEvent event)
The MouseEvent Parameter, is used to work out the index position of the Box the MouseEvent occured upon Here again, the controller and view are kept seperate, where each of them only carry out the parts of the code that are specific to them

Parameters:
MouseEvent -
Returns:
index position int calculated from MouseEvent

getDimention

public int getDimention()
Returns the current value in the dimention JSpinner

Returns:
Current int value from dimention JSpinner

getNumColours

public int getNumColours()
Returns the current value in the numColours JSpinner

Returns:
Current int value from numColours JSpinner

hintButton

public javax.swing.JButton hintButton()
Returns the Hint button

Returns:
Hint button

newGame

public void newGame()
Sets some variables that have to be reset, when a new game is started


newGameButton

public javax.swing.JButton newGameButton()
Returns the New Game button

Returns:
New Game button

reColourBoxes

public void reColourBoxes()
Loops through the Box'es and sets the colour for the Box


repaintFrame

public void repaintFrame()
Repaints the frame


updateScores

public void updateScores()
Upadtes the score and hoverScore with the latest values from the the model