bot
Class GraphicInformer

java.lang.Object
  extended bybot.CoreInformer
      extended bybot.GraphicInformer
All Implemented Interfaces:
Informer

public class GraphicInformer
extends CoreInformer
implements Informer

Inform of robot status via graphic display.


Field Summary
static String BOT_IMAGE_NAME
           
static String CLAW_IMAGE_NAME
           
static String FEELER_IMAGE_NAME
           
static String KEY_IMAGE_NAME
           
static double MAXIMUM_TIME_PER_STEP
           
static int MINIMUM_SLEEP_TIME
           
static double MINIMUM_TIME_PER_STEP
           
 int render_speed
          how fast the animation frame rate is.
static String SQUARE_IMAGE_NAME
           
static int STATE_OVER
           
static int STATE_RESET
           
static int STATE_RUNNING
           
static int STATE_STEPPING
           
static int STATE_STOPPED
           
 int step_speed
          How long each step takes in toto (step being any call to this informer).
static String WALL_IMAGE_NAME
           
 
Fields inherited from class bot.CoreInformer
runner
 
Fields inherited from interface bot.Informer
CHAR_BY_CHAR_INPUT, STRING_INPUT
 
Constructor Summary
GraphicInformer(Runner runner)
           
 
Method Summary
 void alert(String s)
          Put up alert message on screen.
protected  void beginAction()
          Begin a step.
 void beginSimulation(boolean pause)
          This waits for the "Go" button to be hit.
 Image botImage()
          The current image the bot is using.
 void endAction()
          End the action.
protected  void endAction(int speed_factor)
           
 void endGame(boolean won)
           
 void feel()
          Bot Action
 Image findThingImage(String name)
          Find a thing's image by name and return it.
 Image findThingImage(Thing thing)
           
 String getInput()
          Returns user input from keyboard.
 void goHit()
           
 void grab()
          Bot Action
 void inform(String s)
          A message of something that transpired (for example, used object.)
 void land()
          Put the bot on the board.
 void paintBot()
           
 void paintBot(Image botimg)
          Paint the bot as the passed image in its given location.
 void paintBot(Point where, Image botimg)
           
 void paintSquare(Point p)
          Paint a square, based on what is currently in it (i.e.
 void paintSquare(Square sq)
           
 void pausing(boolean ison, String why)
          If we want to pause, and display a message.
 void place()
          Bot Action
 void redraw()
          Redraw the board from scratch (for if the board has massivly changed for some reason.)
 void relocate(Point from, Point to)
          Bot Action - when Bot changes position.
protected  void renderSleep()
          Sleep between frames of animation cycle of a single step (i.e.
protected  void renderSleep(long startpoint)
           
 void reset(BotBoard botboard)
          Reset the board back to a new passed board.
 void resetHit()
           
 void resetTick()
           
 void rest()
          Bot Action
 void say(String s)
          Bot Action--it says something
 void selectBoard()
          Inform user that they must select a bot, and then have them select it.
 void selectBot()
          Inform user that they must select a bot, and then have them select it.
 void sendInput(char c)
          Accept input from alternative sources (such as other components getting key events.
 void setAppearance(String toWhat)
          Set bot's appearance.
 void setBoard(Board bd)
          Setting the board to display to passed board.
 void setInputMode(int mode)
          Do we return input at each character?
 void setRenderSpeed(int spd)
           
 void setStepSpeed(int spd)
           
 void setupSquare(Point sqloc)
          Set checkercanvas to have appropriate graphics for the given loc (find square if it exists, and use default if not).
 void setupSquare(Square sq)
          Set checkercanvas to have appropriate graphics for the square.
 void stepHit()
           
 void stopHit()
           
protected  void tick()
           
 void touch(Point where)
          Bot Action Call to say the given point has been modified.
 void turn(int new_direction)
          The bot turns to face the new passed direction.
 void waitForReset()
          Wait for the reset button to be hit.
 
Methods inherited from class bot.CoreInformer
getCurrentTime, getRunner, inAction, waitForGo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bot.Informer
getCurrentTime, getRunner
 

Field Detail

WALL_IMAGE_NAME

public static String WALL_IMAGE_NAME

SQUARE_IMAGE_NAME

public static String SQUARE_IMAGE_NAME

BOT_IMAGE_NAME

public static String BOT_IMAGE_NAME

FEELER_IMAGE_NAME

public static String FEELER_IMAGE_NAME

CLAW_IMAGE_NAME

public static String CLAW_IMAGE_NAME

KEY_IMAGE_NAME

public static final String KEY_IMAGE_NAME
See Also:
Constant Field Values

STATE_RUNNING

public static int STATE_RUNNING

STATE_STOPPED

public static int STATE_STOPPED

STATE_STEPPING

public static int STATE_STEPPING

STATE_OVER

public static int STATE_OVER

STATE_RESET

public static int STATE_RESET

step_speed

public int step_speed
How long each step takes in toto (step being any call to this informer).


render_speed

public int render_speed
how fast the animation frame rate is. (pause between animation images in a single step


MAXIMUM_TIME_PER_STEP

public static final double MAXIMUM_TIME_PER_STEP
See Also:
Constant Field Values

MINIMUM_TIME_PER_STEP

public static final double MINIMUM_TIME_PER_STEP
See Also:
Constant Field Values

MINIMUM_SLEEP_TIME

public static final int MINIMUM_SLEEP_TIME
See Also:
Constant Field Values
Constructor Detail

GraphicInformer

public GraphicInformer(Runner runner)
Method Detail

reset

public void reset(BotBoard botboard)
Reset the board back to a new passed board. So when the user resets back to start.

Specified by:
reset in interface Informer
Overrides:
reset in class CoreInformer

pausing

public void pausing(boolean ison,
                    String why)
If we want to pause, and display a message. ison being false will clear out the pause.

Specified by:
pausing in interface Informer

setBoard

public void setBoard(Board bd)
Setting the board to display to passed board.

Specified by:
setBoard in interface Informer
Overrides:
setBoard in class CoreInformer

redraw

public void redraw()
Redraw the board from scratch (for if the board has massivly changed for some reason.)

Specified by:
redraw in interface Informer

alert

public void alert(String s)
Put up alert message on screen.

Specified by:
alert in interface Informer
Parameters:
s - The message to display.

setupSquare

public void setupSquare(Square sq)
Set checkercanvas to have appropriate graphics for the square.


setupSquare

public void setupSquare(Point sqloc)
Set checkercanvas to have appropriate graphics for the given loc (find square if it exists, and use default if not).


paintSquare

public void paintSquare(Point p)
Paint a square, based on what is currently in it (i.e. go check and find out!


paintSquare

public void paintSquare(Square sq)

paintBot

public void paintBot()

paintBot

public void paintBot(Image botimg)
Paint the bot as the passed image in its given location.


paintBot

public void paintBot(Point where,
                     Image botimg)

findThingImage

public Image findThingImage(Thing thing)

findThingImage

public Image findThingImage(String name)
Find a thing's image by name and return it. also put it in the hashtable cache of images.


beginAction

protected void beginAction()
Begin a step.

Overrides:
beginAction in class CoreInformer

endAction

public void endAction()
End the action. Check to see if the "Stop" button has been hit--if it has, then pause until further notice. Also, if in STEPPING mode, then stop.

Specified by:
endAction in interface Informer
Overrides:
endAction in class CoreInformer

endAction

protected void endAction(int speed_factor)

renderSleep

protected void renderSleep()
Sleep between frames of animation cycle of a single step (i.e. between drawing a feeler and erasing it.


renderSleep

protected void renderSleep(long startpoint)

setInputMode

public void setInputMode(int mode)
Do we return input at each character?

Specified by:
setInputMode in interface Informer

sendInput

public void sendInput(char c)
Accept input from alternative sources (such as other components getting key events.


getInput

public String getInput()
Returns user input from keyboard. If in character mode, returns a single character, else return entire string, but trims off excess whitespace.

Specified by:
getInput in interface Informer

land

public void land()
Put the bot on the board.

Specified by:
land in interface Informer
Overrides:
land in class CoreInformer

setAppearance

public void setAppearance(String toWhat)
Set bot's appearance.

Specified by:
setAppearance in interface Informer
Overrides:
setAppearance in class CoreInformer

relocate

public void relocate(Point from,
                     Point to)
Description copied from interface: Informer
Bot Action - when Bot changes position.

Specified by:
relocate in interface Informer
Overrides:
relocate in class CoreInformer

touch

public void touch(Point where)
Description copied from interface: Informer
Bot Action Call to say the given point has been modified. (Starts an action.)

Specified by:
touch in interface Informer
Overrides:
touch in class CoreInformer

botImage

public Image botImage()
The current image the bot is using.


turn

public void turn(int new_direction)
The bot turns to face the new passed direction.

Specified by:
turn in interface Informer
Overrides:
turn in class CoreInformer

rest

public void rest()
Description copied from interface: Informer
Bot Action

Specified by:
rest in interface Informer
Overrides:
rest in class CoreInformer

say

public void say(String s)
Description copied from interface: Informer
Bot Action--it says something

Specified by:
say in interface Informer
Overrides:
say in class CoreInformer

inform

public void inform(String s)
Description copied from interface: Informer
A message of something that transpired (for example, used object.)

Specified by:
inform in interface Informer
Overrides:
inform in class CoreInformer

grab

public void grab()
Description copied from interface: Informer
Bot Action

Specified by:
grab in interface Informer
Overrides:
grab in class CoreInformer

feel

public void feel()
Description copied from interface: Informer
Bot Action

Specified by:
feel in interface Informer
Overrides:
feel in class CoreInformer

place

public void place()
Description copied from interface: Informer
Bot Action

Specified by:
place in interface Informer
Overrides:
place in class CoreInformer

endGame

public void endGame(boolean won)
Specified by:
endGame in interface Informer
Overrides:
endGame in class CoreInformer

setRenderSpeed

public void setRenderSpeed(int spd)

setStepSpeed

public void setStepSpeed(int spd)

stopHit

public void stopHit()

goHit

public void goHit()

resetHit

public void resetHit()

stepHit

public void stepHit()

beginSimulation

public void beginSimulation(boolean pause)
This waits for the "Go" button to be hit.

Specified by:
beginSimulation in interface Informer

waitForReset

public void waitForReset()
Wait for the reset button to be hit.

Specified by:
waitForReset in interface Informer
Overrides:
waitForReset in class CoreInformer

tick

protected void tick()
Overrides:
tick in class CoreInformer

resetTick

public void resetTick()
Overrides:
resetTick in class CoreInformer

selectBot

public void selectBot()
Inform user that they must select a bot, and then have them select it.

Specified by:
selectBot in interface Informer

selectBoard

public void selectBoard()
Inform user that they must select a bot, and then have them select it.

Specified by:
selectBoard in interface Informer