|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.columbia.cs.coms4701.agent.observer.GUIEnvironmentObserver<K,P,A,J>
public abstract class GUIEnvironmentObserver<K extends AgentAction,P extends AgentPercept,A extends Agent<K,P>,J extends javax.swing.JPanel>
Provides a GUI display for observing the progress of an Environment.
Subclasses must, at minimum, implement the #generateEnvironmentPanel method, which produces a component that displays a God-like overview of the entire environment in some sensible graphical fashion.
Nested Class Summary | |
---|---|
protected static class |
GUIEnvironmentObserver.PlayingMode
|
Field Summary | |
---|---|
protected int |
delay
|
protected int |
delay_default
|
protected int |
delay_max
|
protected double |
delay_r
|
protected ObserverFrame<K,P,A,J> |
frame
|
protected GUIEnvironmentObserver.PlayingMode |
playingMode
|
protected double |
x_0
|
Constructor Summary | |
---|---|
GUIEnvironmentObserver()
Constructs a new GUIEnvironmentObserver, which can then be attached to a (single!) Environment to track progress. |
Method Summary | |
---|---|
void |
agentAdded(AgentAddedEvent<K,P,A> theEvent)
Fired when an agent is added to an environment. |
void |
agentChoseAction(AgentChoseActionEvent<K,P,A> theEvent)
Fired when an agent in an environment chooses an action (i.e. |
void |
agentReceivedPercepts(AgentReceivedPerceptsEvent<K,P,A> theEvent)
Fired when an agent in an environment receives percepts, i.e. |
protected int |
delayForSetting(int setting)
Given a number between 0 and 100 (inclusive), returns a delay in milliseconds. |
void |
environmentBeganRunning(EnvironmentBeganRunningEvent theEvent)
Fired when an environment has just begun its run() loop. |
void |
environmentObjectAdded(EnvironmentObjectAddedEvent theEvent)
Fired when an EnvironmentObject is added to an environment. |
void |
environmentStoppedRunning(EnvironmentStoppedRunningEvent theEvent)
Fired when an environment is about to stop its run() loop. |
abstract J |
generateEnvironmentPanel()
Generates a new instance of the environment panel for this observer. |
void |
playingStateChanged(ObserverPlayingStateChangedEvent theEvent)
Fired when the user clicks one of the buttons to change the playing state. |
void |
propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
|
void |
stateChanged(javax.swing.event.ChangeEvent changeEvent)
Fired when the user adjusts the slider to set the playing speed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected double delay_r
protected double x_0
protected int delay_max
protected int delay_default
protected ObserverFrame<K extends AgentAction,P extends AgentPercept,A extends Agent<K,P>,J extends javax.swing.JPanel> frame
protected int delay
protected GUIEnvironmentObserver.PlayingMode playingMode
Constructor Detail |
---|
public GUIEnvironmentObserver()
Method Detail |
---|
public void propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
propertyChange
in interface java.beans.PropertyChangeListener
public void environmentBeganRunning(EnvironmentBeganRunningEvent theEvent)
environmentBeganRunning
in interface EnvironmentBeganRunningListener
theEvent
- event specifying the environmentpublic void agentAdded(AgentAddedEvent<K,P,A> theEvent)
agentAdded
in interface AgentAddedListener<K extends AgentAction,P extends AgentPercept,A extends Agent<K,P>>
theEvent
- event specifying the environment and agentpublic void environmentObjectAdded(EnvironmentObjectAddedEvent theEvent)
We should add ourselves as a property-change observer for this object.
environmentObjectAdded
in interface EnvironmentObjectAddedListener
theEvent
- event specifying the environment and the object.public void agentReceivedPercepts(AgentReceivedPerceptsEvent<K,P,A> theEvent)
agentReceivedPercepts
in interface AgentReceivedPerceptsListener<K extends AgentAction,P extends AgentPercept,A extends Agent<K,P>>
theEvent
- event specifying the environment, agent, and set of perceptspublic void agentChoseAction(AgentChoseActionEvent<K,P,A> theEvent)
This step is where the GUI imposes a delay, or pauses.
agentChoseAction
in interface AgentChoseActionListener<K extends AgentAction,P extends AgentPercept,A extends Agent<K,P>>
theEvent
- specifies the environment, agent, and actionpublic void environmentStoppedRunning(EnvironmentStoppedRunningEvent theEvent)
environmentStoppedRunning
in interface EnvironmentStoppedRunningListener
theEvent
- event specifying the environment.public void playingStateChanged(ObserverPlayingStateChangedEvent theEvent)
playingStateChanged
in interface ObserverPlayingStateChangedListener
theEvent
- public void stateChanged(javax.swing.event.ChangeEvent changeEvent)
stateChanged
in interface javax.swing.event.ChangeListener
changeEvent
- public abstract J generateEnvironmentPanel()
protected int delayForSetting(int setting)
The idea here is to allow relatively fine control over the faster speeds (smaller delays), while still allowing the delay to range to large values.
This implementation uses a simple logistic equation to give a nice curve.
setting,
- between 0 and 100 where 0 = fast, 100 = slow
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |