info.gridworld.gui
Class GUIController<T>

java.lang.Object
  extended by info.gridworld.gui.GUIController<T>

public class GUIController<T>
extends java.lang.Object

The GUIController controls the behavior in a WorldFrame.
This code is not tested on the AP CS A and AB exams. It contains GUI implementation details that are not intended to be understood by AP CS students.


Field Summary
static int FIXED_STEPS
           
static int INDEFINITE
           
static int PROMPT_STEPS
           
 
Constructor Summary
GUIController(WorldFrame<T> parent, GridPanel disp, DisplayMap displayMap, java.util.ResourceBundle res)
          Creates a new controller tied to the specified display and gui frame.
 
Method Summary
 javax.swing.JComponent controlPanel()
          Returns the panel containing the controls.
 void deleteLocation()
          Edits the contents of the current location, by displaying the constructor or method menu.
 void editLocation()
          Edits the contents of the current location, by displaying the constructor or method menu.
 boolean isRunning()
           
 void run()
          Starts a timer to repeatedly carry out steps at the speed currently indicated by the speed slider up Depending on the run option, it will either carry out steps for some fixed number or indefinitely until stopped.
 void step()
          Advances the world one step.
 void stop()
          Stops any existing timer currently carrying out steps.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INDEFINITE

public static final int INDEFINITE
See Also:
Constant Field Values

FIXED_STEPS

public static final int FIXED_STEPS
See Also:
Constant Field Values

PROMPT_STEPS

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

GUIController

public GUIController(WorldFrame<T> parent,
                     GridPanel disp,
                     DisplayMap displayMap,
                     java.util.ResourceBundle res)
Creates a new controller tied to the specified display and gui frame.

Parameters:
parent - the frame for the world window
disp - the panel that displays the grid
displayMap - the map for occupant displays
res - the resource bundle for message display
Method Detail

step

public void step()
Advances the world one step.


run

public void run()
Starts a timer to repeatedly carry out steps at the speed currently indicated by the speed slider up Depending on the run option, it will either carry out steps for some fixed number or indefinitely until stopped.


stop

public void stop()
Stops any existing timer currently carrying out steps.


isRunning

public boolean isRunning()

controlPanel

public javax.swing.JComponent controlPanel()
Returns the panel containing the controls.

Returns:
the control panel

editLocation

public void editLocation()
Edits the contents of the current location, by displaying the constructor or method menu.


deleteLocation

public void deleteLocation()
Edits the contents of the current location, by displaying the constructor or method menu.