|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jogre.client.JogreController
Adapter game controller class which creates empty methods for the MouseListener, MouseMotionListener and KeyListener event interfaces. This class also contains a link to the JogreModel, a connection thread to the server and also a JogreComponent where the mouse movements/key presses are taking place on.
To use this controller a class must extend it e.g. ChessController and
then override one of its event methods, update the correct model and send
communication to other users. To use the controller on a JogreComponent
a JogreComponent calls its public void setController (JogreController
controller)
method.
Any of the following methods can be overwritten to do something:
This class also contains a link to the ClientConnectionThread. This allows access to the UserList and TableList object which allow access to what is happening on the server. This class also provides various useful methods such as returning the table number, current player, current player's seat number, this players seat number, etc.
Field Summary | |
protected ClientConnectionThread |
conn
Link to the client's connection thread. |
protected JogreComponent |
JogreComponent
Link to the JogreComponent this is controlling . |
protected JogreModel |
model
Link to the game model. |
protected int |
tableNum
Table number which this controller is controlling. |
Constructor Summary | |
JogreController(JogreModel model,
JogreComponent JogreComponent)
Default constructor class which doesn't set up the network connection. |
Method Summary | |
int |
getCurrentPlayerSeatNum()
Return the player num (between 0 and the number of players). |
String |
getPlayer(int seatNum)
Return the player name from a seat num. |
int |
getSeatNum()
Return the seat number of a user. |
int |
getSeatNum(String player)
Return the seat number of a specified player. |
int |
getTableNum()
Return the table number. |
boolean |
isGamePlaying()
Return true/false if the game is started or not. |
boolean |
isThisPlayersTurn()
Return new if it is this players turn. |
void |
keyPressed(KeyEvent e)
Invoked when a key has been pressed. |
void |
keyReleased(KeyEvent e)
Invoked when a key has been released. |
void |
keyTyped(KeyEvent e)
Invoked when a key has been typed. |
void |
mouseClicked(MouseEvent e)
Invoked when the mouse has been clicked on a JogreComponent. |
void |
mouseDragged(MouseEvent e)
Invoked when a mouse button is pressed on a JogreComponent and then dragged. |
void |
mouseEntered(MouseEvent e)
Invoked when the mouse enters a JogreJogreComponent. |
void |
mouseExited(MouseEvent e)
Invoked when the mouse exits a JogreComponent. |
void |
mouseMoved(MouseEvent e)
Invoked when the mouse button has been moved on a JogreComponent (with no buttons no down). |
void |
mousePressed(MouseEvent e)
Invoked when a mouse button has been pressed on a JogreComponent. |
void |
mouseReleased(MouseEvent e)
Invoked when a mouse button has been released on a JogreComponent. |
void |
nextPlayer()
Method which tells the server that it is next players turn. |
void |
setConnection(ClientConnectionThread conn,
int tableNum)
Set up a network connection for this controller. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected JogreModel model
protected JogreComponent JogreComponent
protected ClientConnectionThread conn
protected int tableNum
Constructor Detail |
public JogreController(JogreModel model, JogreComponent JogreComponent)
model
- Model which the controller can update depending on
what the user input is.JogreComponent
- The JogreComponent which the controller is
listening on.Method Detail |
public void setConnection(ClientConnectionThread conn, int tableNum)
conn
- Link to the ClientConnectionThread.tableNum
- public int getCurrentPlayerSeatNum()
public int getTableNum()
public int getSeatNum()
public String getPlayer(int seatNum)
seatNum
- Seat number of the user.public int getSeatNum(String player)
player
- Name of the playerpublic boolean isGamePlaying()
public boolean isThisPlayersTurn()
public void nextPlayer()
public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
e
- public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
e
- public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
e
- public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
e
- public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
e
- public void mouseMoved(MouseEvent e)
mouseMoved
in interface MouseMotionListener
e
- public void mouseDragged(MouseEvent e)
mouseDragged
in interface MouseMotionListener
e
- public void keyPressed(KeyEvent e)
keyPressed
in interface KeyListener
e
- public void keyReleased(KeyEvent e)
keyReleased
in interface KeyListener
e
- public void keyTyped(KeyEvent e)
keyTyped
in interface KeyListener
e
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |