edu.ksu.cis.macr.simulator.display
Class SimDisplay

java.lang.Object
  extended by edu.ksu.cis.macr.simulator.display.SimDisplay
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class SimDisplay
extends java.lang.Object
implements java.awt.event.ActionListener


Field Summary
private  javax.swing.JList agentList
           
private  java.util.HashMap<java.lang.Integer,edu.ksu.cis.macr.simulator.remote.DisplayData> agents
          Stores states of each agent/object in the simulator
private  boolean auto1
           
 boolean auto2
           
private  javax.swing.JButton autoButton
           
 java.awt.Color background
           
private  java.util.HashMap<java.lang.String,java.awt.Color> colors
          Mapping of COlors to object names
private  java.io.BufferedReader config
          IO reader for the display configuration file
private  javax.swing.JButton downSleepButton
           
private  edu.ksu.cis.macr.simulator.environment.Environment environ
          Reference to Evironment object.
private  java.util.HashSet<java.lang.String> forbid
          Culled from the config File.
private  boolean go
           
private  javax.swing.JButton goButton
           
private  GPanel gpanel
           
private  java.util.HashMap<java.lang.String,java.lang.String> icons
          Culled from the config file.
private  java.util.HashSet<java.lang.String> list
          Culled from the config File.
private  javax.swing.DefaultListModel listModel
          List model for the agent list.
private  int listnum
           
private  javax.swing.JFrame menu
          Menu display frame.
private  java.util.HashMap<java.lang.Integer,edu.ksu.cis.macr.simulator.remote.DisplayData> newAgents
          Stores the data from the changelist.
private  java.lang.String oldSelected
           
private  javax.swing.JPanel pane
           
private  int pHeight
           
private  int pWidth
           
private  javax.swing.JScrollPane scrollPane
          Holds the agent list in the menu display.
private  javax.swing.JButton setSleepButton
           
private  javax.swing.JButton showButton
           
private  javax.swing.JButton snapButton
           
private  javax.swing.JLabel statusBar
           
private  java.lang.String Title
           
private  javax.swing.JButton unZoomButton
           
private  javax.swing.JButton upSleepButton
           
 
Constructor Summary
SimDisplay(edu.ksu.cis.macr.simulator.environment.Environment environ, java.lang.String filename)
          Constructor for Display.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          actionPerformed(ActionEvent event) Action listener for all button on menu display.
private  void autoUpdate(int wait)
          starts autoUpdate timer thread.
private  void displayData(int x)
          Displays dialog containing info on agent.
private  void downSleep()
          decreases environment sleeptime by one
private  int findSelected(java.lang.String sel)
          returns unique id number of selected object chosen from the agentlist
 java.util.HashMap<java.lang.Integer,edu.ksu.cis.macr.simulator.remote.DisplayData> getAgents()
          Returns all display data to be displayed
private  java.awt.Color getColor(java.lang.String color)
          maps ascii color name to Color object use lower case letters for each name dark gray is default .
 void getData()
          Obtains changelist from the environment Stores info and updates both the list and GDisplay
private  void pause()
          Pauses the Simulator
private  void setConfig(java.lang.String filename)
          Reads config file and builds data structures.
private  void setSleep()
          sets environment sleeptime value received from user via an Input Dialog
private  void unpause()
          unpauses the simulator
private  void updateList()
          Intelligently adds agents to the agent list.
private  void upSleep()
          increases environment sleeptime by one
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

agents

private java.util.HashMap<java.lang.Integer,edu.ksu.cis.macr.simulator.remote.DisplayData> agents
Stores states of each agent/object in the simulator


newAgents

private java.util.HashMap<java.lang.Integer,edu.ksu.cis.macr.simulator.remote.DisplayData> newAgents
Stores the data from the changelist. Data is eventually merged in the agents HashMap.


environ

private edu.ksu.cis.macr.simulator.environment.Environment environ
Reference to Evironment object. Necessary to start and stop simulation


config

private java.io.BufferedReader config
IO reader for the display configuration file


menu

private javax.swing.JFrame menu
Menu display frame. Has executive control of all display capabilities.


snapButton

private javax.swing.JButton snapButton

goButton

private javax.swing.JButton goButton

showButton

private javax.swing.JButton showButton

autoButton

private javax.swing.JButton autoButton

unZoomButton

private javax.swing.JButton unZoomButton

downSleepButton

private javax.swing.JButton downSleepButton

upSleepButton

private javax.swing.JButton upSleepButton

setSleepButton

private javax.swing.JButton setSleepButton

statusBar

private javax.swing.JLabel statusBar

Title

private java.lang.String Title

scrollPane

private javax.swing.JScrollPane scrollPane
Holds the agent list in the menu display.


icons

private java.util.HashMap<java.lang.String,java.lang.String> icons
Culled from the config file. Map of object names to icons. Given to GDisplay


forbid

private java.util.HashSet<java.lang.String> forbid
Culled from the config File. Set of object names to be supressed in the display


list

private java.util.HashSet<java.lang.String> list
Culled from the config File. Set of Object names to be displayed in the agent list. This is seperate from the list of objects to be displayed in the GDisplay.


colors

private java.util.HashMap<java.lang.String,java.awt.Color> colors
Mapping of COlors to object names


agentList

private javax.swing.JList agentList

pane

private javax.swing.JPanel pane

gpanel

private GPanel gpanel

listModel

private javax.swing.DefaultListModel listModel
List model for the agent list. Data structure has a data listener attached. Every time data within the list changes, the display list refreshes.


go

private boolean go

auto1

private boolean auto1

auto2

public boolean auto2

listnum

private int listnum

pWidth

private int pWidth

pHeight

private int pHeight

oldSelected

private java.lang.String oldSelected

background

public java.awt.Color background
Constructor Detail

SimDisplay

public SimDisplay(edu.ksu.cis.macr.simulator.environment.Environment environ,
                  java.lang.String filename)
Constructor for Display. Builds menu diplay and calls constructor for GDisplay Tells environment when to start simulation

Parameters:
environ - Simulator Environment reference
filename - name and path of display configuration file.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
actionPerformed(ActionEvent event) Action listener for all button on menu display. Necessary for implementation of ActionPeformed Interface

Specified by:
actionPerformed in interface java.awt.event.ActionListener

setConfig

private void setConfig(java.lang.String filename)
Reads config file and builds data structures.

Parameters:
filename - : name of configuration file (with path if necessary)

autoUpdate

private void autoUpdate(int wait)
starts autoUpdate timer thread.

Parameters:
wait - sleep time in milliseconds

getData

public void getData()
Obtains changelist from the environment Stores info and updates both the list and GDisplay


updateList

private void updateList()
Intelligently adds agents to the agent list. No duplicates.


findSelected

private int findSelected(java.lang.String sel)
returns unique id number of selected object chosen from the agentlist

Parameters:
sel - name of object in agentlist.

displayData

private void displayData(int x)
Displays dialog containing info on agent. (Coordinates & fields). Current implmentation just takes all the info and builds a string buffer. That string buffer is then displayed in the dialog.

Parameters:
x - id number of agent

getAgents

public java.util.HashMap<java.lang.Integer,edu.ksu.cis.macr.simulator.remote.DisplayData> getAgents()
Returns all display data to be displayed


getColor

private java.awt.Color getColor(java.lang.String color)
maps ascii color name to Color object use lower case letters for each name dark gray is default .

Returns:
Color:

downSleep

private void downSleep()
decreases environment sleeptime by one


upSleep

private void upSleep()
increases environment sleeptime by one


setSleep

private void setSleep()
sets environment sleeptime value received from user via an Input Dialog


pause

private void pause()
Pauses the Simulator


unpause

private void unpause()
unpauses the simulator