Class LeGaGameCanvas

java.lang.Object
  extended byGameCanvas
      extended byLeGaGameCanvas
All Implemented Interfaces:
java.lang.Runnable

public class LeGaGameCanvas
extends GameCanvas
implements java.lang.Runnable

Custom grahpical MIDP 2.0 canvas Created by IntelliJ IDEA. User: ofsdahl Date: 23.feb.2007 Time: 14:34:33 To change this template use File | Settings | File Templates.

See Also:
Serialized Form

Field Summary
private  boolean answerSent
           
private  ClientNetworkThread clientNetwork
           
private  CommandListener cmdL
           
private  java.lang.String[] currentAlternatives
           
private  boolean currentAnswerWasCorrect
           
private  java.lang.String currentMaxScore
           
private  java.lang.String currentQuestion
           
private  java.lang.String currentScore
           
(package private)  java.lang.String[] drawStringList
           
private  java.lang.String lastResults
           
protected  Image middleBarLine
           
private  int nextFreeStringIndex
           
protected  boolean readyToClose
           
private  long resultTimer
           
protected  int scoreCounter
           
private  int screenState
           
private  boolean timesUp
           
protected  Image topBarLine
           
 
Constructor Summary
protected LeGaGameCanvas(boolean b)
          Load pictures
 
Method Summary
 void answerSent()
          Flag telling the graphical rendering that the answer has been sent.
private  void drawEndResults(Graphics g)
          Draws the en result when the game is about to finish.
private  void drawIdleScreen(Graphics g)
          Draws the idle screen.
 void drawQuestion(Graphics g)
          Draws a quesiton and the appropriate alternatives.
 void drawResults(Graphics g)
          Draw the temporary result after a question is answered.
protected  void keyPressed(int keyCode)
          Interprets keystrokes
 void readyToClose()
          Flags the program as ready to close after the user has seen his final score.
 void resetTimesUp()
          Reset the times up flag after usage.
 void run()
          The forever running gaphical rendering thread runs here.
 void setCommandListener(CommandListener cmdL)
          Set the apporpriate commandlistener interface class.
 void setCurrentAlternatives(java.lang.String[] alternatives)
          Set the alterniatives to be displayed
 void setCurrentQuestion(java.lang.String string)
          Set the question to be displayed
 void setNetwork(ClientNetworkThread clientNetwork)
          Makes a member reference to the network Thread.
 void timesUp()
          Triggered from a timertask when the time is up to display the appropriate graphics.
private  void updateGameScreen(Graphics g)
          Routs the graphical processing to the appropriate methods according to the current state of the program.
 void updateLastResults(java.lang.String s, java.lang.String m)
          Updates the logical representation of the end score before displaying it to the user.
 void updateReslts(boolean isCorrect, java.lang.String currentScore, java.lang.String maxScore)
          Updates the logical representation of the current score before displaying it to the user.
 void updateScreenState(int i)
          Update the current screen state according to the logical flow in the program.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

drawStringList

java.lang.String[] drawStringList

screenState

private int screenState

nextFreeStringIndex

private int nextFreeStringIndex

currentQuestion

private java.lang.String currentQuestion

currentAlternatives

private java.lang.String[] currentAlternatives

cmdL

private CommandListener cmdL

answerSent

private boolean answerSent

resultTimer

private long resultTimer

timesUp

private boolean timesUp

currentAnswerWasCorrect

private boolean currentAnswerWasCorrect

currentScore

private java.lang.String currentScore

currentMaxScore

private java.lang.String currentMaxScore

lastResults

private java.lang.String lastResults

clientNetwork

private ClientNetworkThread clientNetwork

topBarLine

protected Image topBarLine

middleBarLine

protected Image middleBarLine

scoreCounter

protected int scoreCounter

readyToClose

protected boolean readyToClose
Constructor Detail

LeGaGameCanvas

protected LeGaGameCanvas(boolean b)
Load pictures

Parameters:
b - supress keystrokes
Method Detail

setCommandListener

public void setCommandListener(CommandListener cmdL)
Set the apporpriate commandlistener interface class.

Parameters:
cmdL -

setCurrentAlternatives

public void setCurrentAlternatives(java.lang.String[] alternatives)
Set the alterniatives to be displayed

Parameters:
alternatives -

setCurrentQuestion

public void setCurrentQuestion(java.lang.String string)
Set the question to be displayed

Parameters:
string -

run

public void run()
The forever running gaphical rendering thread runs here.

Specified by:
run in interface java.lang.Runnable

updateGameScreen

private void updateGameScreen(Graphics g)
Routs the graphical processing to the appropriate methods according to the current state of the program.

Parameters:
g - grahpics object for rendering.

drawIdleScreen

private void drawIdleScreen(Graphics g)
Draws the idle screen.

Parameters:
g -

drawEndResults

private void drawEndResults(Graphics g)
Draws the en result when the game is about to finish.

Parameters:
g -

drawQuestion

public void drawQuestion(Graphics g)
Draws a quesiton and the appropriate alternatives.

Parameters:
g -

keyPressed

protected void keyPressed(int keyCode)
Interprets keystrokes

Parameters:
keyCode -

drawResults

public void drawResults(Graphics g)
Draw the temporary result after a question is answered.

Parameters:
g -

updateScreenState

public void updateScreenState(int i)
Update the current screen state according to the logical flow in the program.

Parameters:
i - The constant describing the state.

answerSent

public void answerSent()
Flag telling the graphical rendering that the answer has been sent.


updateReslts

public void updateReslts(boolean isCorrect,
                         java.lang.String currentScore,
                         java.lang.String maxScore)
Updates the logical representation of the current score before displaying it to the user.

Parameters:
isCorrect -
currentScore -
maxScore -

updateLastResults

public void updateLastResults(java.lang.String s,
                              java.lang.String m)
Updates the logical representation of the end score before displaying it to the user.

Parameters:
s -
m -

readyToClose

public void readyToClose()
Flags the program as ready to close after the user has seen his final score. This flags triggers a message on screen and listening for the user to exit by pressing a key.


timesUp

public void timesUp()
Triggered from a timertask when the time is up to display the appropriate graphics.


resetTimesUp

public void resetTimesUp()
Reset the times up flag after usage.


setNetwork

public void setNetwork(ClientNetworkThread clientNetwork)
Makes a member reference to the network Thread.

Parameters:
clientNetwork -