jade.gui
Class GuiAgent
java.lang.Object
|
+--jade.core.Agent
|
+--jade.gui.GuiAgent
- Direct Known Subclasses:
- df
- public abstract class GuiAgent
- extends Agent
When a program instantiates a GUI, the Java programming language
starts a new thread, different from the Agent thread.
The Agent thread generally is active because it has its tasks to perform
and also the GUI thread is active, in respect to the Agent thread, because
its behaviour depends on the user actions (e.g. pressing a button, using
the nemu bar,...) and not only on the agent task.
Therefore, an appropriate mechanism is needed to manage the interaction
between these two active threads.
It is not a good practice allowing one thread to just call the method of
another thread because of the difference in the thread space.
What should be done, instead is one thread requesting the other to execute a
method, each thread in its one execution space.
Since its common to have an agent with a GUI, this class is for this purpose.
This class extends the jade.core.Agent
class: at the start-up
it instantiate ad ad-hoc behaviour that manages a queue of
jade.gui.GuiEvent
,event objects that can be received by other threads.
A thread (in particular a GUI)to notify an event to an Agent should create
a new Object of type jade.gui.GuiEvent
and pass it as a parameter
to the call of the method postGuiEvent
of the
jade.gui.GuiAgent
object. Notice that an object of type
GuiEvent
has two mandatory attributes and an optional
list of parameters that can be added to the event object.
After the method postGuiEvent
is called,the agent reacts
by waking up all its active behaviours, and in particular the one that causes
the Agent thread to execute the method onGuiEvent
.
- Version:
- $Date: 2003/03/04 11:48:08 $ $Revision: 2.3 $
- Author:
- Giovanni Caire - CSELT S.p.A.
- See Also:
Agent
,
GuiEvent
, Serialized Form
Fields inherited from class jade.core.Agent |
AP_ACTIVE,
AP_DELETED,
AP_IDLE,
AP_INITIATED,
AP_MAX,
AP_MIN,
AP_SUSPENDED,
AP_TRANSIT,
AP_WAITING,
currentBehaviour,
currentMessage,
D_ACTIVE,
D_MAX,
D_MIN,
D_RETIRED,
D_SUSPENDED,
D_UNKNOWN |
Methods inherited from class jade.core.Agent |
addBehaviour,
afterClone,
afterMove,
beforeClone,
beforeMove,
blockingReceive,
blockingReceive,
blockingReceive,
blockingReceive,
doActivate,
doClone,
doDelete,
doMove,
doStart,
doSuspend,
doTimeOut,
doWait,
doWait,
doWake,
extractPassword,
extractUsername,
getAID,
getAMS,
getArguments,
getAuthority,
getCertificateFolder,
getContainerController,
getContentManager,
getCurQueueSize,
getDefaultDF,
getHap,
getLocalName,
getName,
getO2AObject,
getPrincipal,
getProperty,
getQueueSize,
getState,
here,
notifyChangeBehaviourState,
notifyRestarted,
postMessage,
putBack,
putO2AObject,
read,
read,
receive,
receive,
removeBehaviour,
restartLater,
restore,
run,
send,
setArguments,
setEnabledO2ACommunication,
setOwnership,
setPrincipal,
setQueueSize,
setup,
takeDown,
waitUntilStarted,
write |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
GuiAgent
public GuiAgent()
postGuiEvent
public void postGuiEvent(GuiEvent e)
onGuiEvent
protected abstract void onGuiEvent(GuiEvent ev)