|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--controller.Controller
This class is the core of the simulator. It initializes the interface components, holds the agents, and controls the sockets for sending and recieving data.
Nested Class Summary | |
(package private) class |
Controller.MessageSender
This class is used for Multicasting a message to all users in wireless range. |
Field Summary | |
private gui.ChartComp |
chart
The chart is the visual map. |
private agent.Agent |
current_agent
The agent that is being moved, or has center of screen. |
private gui.SimulatorFrame |
frame
The main frame which displays the map ChartComp. |
private java.util.Vector |
listeners
Components that want to listen for when information changes in controller. |
private java.util.Vector |
points
The list of all access points in the simulation. |
private gui.tray.TrayDialog |
tray
An interface component for viewing agent stats, etc. |
private java.util.Vector |
users
The list of all users in the simulation. |
Constructor Summary | |
Controller()
This constructor initializes the controller by creating the interface components, so that the user can begin interacting with the simulator. |
Method Summary | |
void |
addAccessPoint(int r)
This method is for adding a new access point into the simulator. |
void |
addControllerListener(controller.ControllerListener listener)
This methods adds a listener to the list of listeners this controller knows about. |
void |
addUser(int r,
int p)
This method is for adding a new user into the simulator. |
agent.Agent |
centerAgent(java.lang.String name)
This method is for centering the given agent on the map. |
void |
changeChart(java.lang.String chartName)
This method changes the current map/chart used in the simulation. |
private double |
diff(java.awt.Point p1,
java.awt.Point p2)
This method returns the pixel distance between two points. |
void |
fireControllerChange()
This method notifies all subscribed listeners that they must refresh themselves. |
gui.ChartComp |
getChartComp()
This method returns the ChartComp which holds the simulation map, and draws all the users. |
agent.Agent |
getCurrentAgent()
This method returns the current agent in focus or being moved around in the simulator map. |
javax.swing.JFrame |
getFrame()
This method returns the main JFrame for the iSIM application. |
java.util.Vector |
getPoints()
This method returns the Vector of all current access points in the simulator. |
java.util.Vector |
getUsers()
This method returns the Vector of all the current users in the simulator. |
void |
incomingMessage(transport.protocol.Message msg)
This method is required by SocketReceiverListener and is called by the SocketReceiver object. |
boolean |
isTrayAlive()
This method simply tests to see if the tray is visible, if not visible then it is assumed to be dead. |
void |
locationChange(agent.User u)
This method is called when a User's location has changed. |
void |
makeTray()
This method creates a new TrayDialog for performing various functions in the simulator, and viewing information. |
void |
removeAccessPoint(agent.AccessPoint u)
This method is for removing a access point from the simulator. |
void |
removeControllerListener(controller.ControllerListener listener)
This method removes a listener from the list of listeners that this controller knows about. |
void |
removeUser(agent.User u)
This method is for removing a user from the simulator. |
void |
reset()
This method is for reseting the data insdie the controller. |
void |
setCurrentAgent(agent.Agent a)
This method sets who the current is. |
void |
setRanges(boolean ranges)
This method sets whether the wireless ranges should be displayed or not. |
void |
updateAgentPosition(agent.Agent u)
This method |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private gui.ChartComp chart
private gui.SimulatorFrame frame
private gui.tray.TrayDialog tray
private agent.Agent current_agent
private java.util.Vector points
private java.util.Vector users
private java.util.Vector listeners
Constructor Detail |
public Controller()
Method Detail |
public void addUser(int r, int p)
r
- The range for the new user.p
- The port for the new user.public void removeUser(agent.User u)
u
- The User object to remove from the users list.public void addAccessPoint(int r)
r
- The range for the new Access Pointpublic void removeAccessPoint(agent.AccessPoint u)
u
- The Access Point object to remove from the points list.public void updateAgentPosition(agent.Agent u)
u
- The agent whose Position needs to be set by this method.public java.util.Vector getUsers()
public java.util.Vector getPoints()
public agent.Agent getCurrentAgent()
public void setCurrentAgent(agent.Agent a)
a
- The Agent to make the current agent.public agent.Agent centerAgent(java.lang.String name)
name
- The name of Agent to find and center on screen.
public void locationChange(agent.User u)
u
- The user who has changed location.public boolean isTrayAlive()
public void makeTray()
public javax.swing.JFrame getFrame()
public gui.ChartComp getChartComp()
public void setRanges(boolean ranges)
ranges
- True to show the wireless range on map, false otherwise.public void changeChart(java.lang.String chartName)
chartName
- The new chart file name.public void reset()
private double diff(java.awt.Point p1, java.awt.Point p2)
p1
- The first point.p2
- The second point.public void incomingMessage(transport.protocol.Message msg)
incomingMessage
in interface SocketReceiverListener
msg
- The incoming Message that the simulator has received.public void addControllerListener(controller.ControllerListener listener)
listener
- public void removeControllerListener(controller.ControllerListener listener)
listener
- public void fireControllerChange()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |