public abstract class SwingViewer extends Watcher
observe
method is already defined and is
intended to be called by scheduler agents to trigger the rendering. This class could be thus extended to reuse the
rendering call mechanism which is defined in here.AbstractAgent.ReturnCode, AbstractAgent.State
Constructor and Description |
---|
SwingViewer()
Creates a new agent with a default panel for rendering purposes
|
Modifier and Type | Method and Description |
---|---|
JMenu |
getDisplayMenu()
Returns a menu which could be used in any viewer GUI.
|
JComponent |
getDisplayPane() |
JFrame |
getFrame()
By default, get the default frame provided by MaDKit in
setupFrame(AgentFrame) and set using
setupFrame(AgentFrame) . |
Action |
getSynchroPaintingAction() |
JToolBar |
getToolBar()
Returns the viewer's toolbar.
|
boolean |
isRendering() |
boolean |
isSynchronousPainting()
Tells if the rendering should be done synchronously or asynchronously with respect to simulation steps.
|
protected void |
observe()
Intended to be invoked by a scheduler's activator for triggering the rendering.
|
protected abstract void |
render(Graphics g)
Override this method to do the rendering in the agent's panel.
|
void |
setDisplayPane(JComponent displayPane)
Could be used to define a customized panel instead of the default pane
|
void |
setRendering(boolean activated)
Enable or disable the rendering activity
|
void |
setRenderingInterval(int interval)
Set the number of states between display updates.
|
void |
setSynchronousPainting(boolean synchronousPainting)
Set the rendering mode to synchronous or asynchronous.
|
void |
setupFrame(AgentFrame frame)
Provides a default implementation that assigns the default panel to the default frame
|
activate, addProbe, allProbes, getProbes, removeAllProbes, removeProbe, toString
broadcastMessage, broadcastMessageWithRole, bucketModeCreateGroup, bucketModeRequestRole, checkAgentAddress, compareTo, createGroup, createGroup, createGroup, createGroupIfAbsent, createGroupIfAbsent, createGroupIfAbsent, createGUIOnStartUp, destroyCommunity, destroyGroup, destroyRole, end, executeThisAgent, executeThisAgent, executeThisAgent, getAgentAddressIn, getAgentsWithRole, getAgentsWithRole, getAgentWithRole, getDistantAgentWithRole, getExistingCommunities, getExistingGroups, getExistingRoles, getKernelAddress, getLastReceivedMessage, getLastReceivedMessage, getLogger, getMadkitConfig, getMadkitProperty, getMadkitProperty, getMyGroups, getMyRoles, getName, getNetworkID, getOrganizationSnapShot, getReplyTo, getServerInfo, getSimpleNetworkID, getState, hasGUI, hashCode, hasRole, isAlive, isCommunity, isGroup, isKernelOnline, isMadkitPropertyTrue, isMessageBoxEmpty, isRole, killAgent, killAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgent, launchAgentBucket, launchAgentBucket, launchAgentBucket, launchAgentBucket, launchNode, launchXmlAgents, leaveGroup, leaveRole, nextMessage, nextMessage, nextMessages, proceedEnumMessage, purgeMailbox, receiveMessage, reload, requestRole, requestRole, sendMessage, sendMessage, sendMessageWithRole, sendMessageWithRole, sendReply, sendReplyWithRole, setLogLevel, setMadkitProperty, setMadkitProperty, setName
public SwingViewer()
public boolean isRendering()
true
if the rendering activity is activated.public void setRendering(boolean activated)
public JComponent getDisplayPane()
public void setDisplayPane(JComponent displayPane)
displayPane
- the displayPane to setprotected void observe()
isSynchronousPainting()
.protected abstract void render(Graphics g)
observe
method is triggered by a Schedulerg
- public boolean isSynchronousPainting()
public void setSynchronousPainting(boolean synchronousPainting)
synchronousPainting
- the synchronousPainting mode to setpublic void setupFrame(AgentFrame frame)
setupFrame
in class AbstractAgent
frame
- the default frame which has been created by MaDKit for this
agent.AbstractAgent.setupFrame(AgentFrame)
public JMenu getDisplayMenu()
public JFrame getFrame()
setupFrame(AgentFrame)
and set using
setupFrame(AgentFrame)
. It can be any JFrame
if setupFrame(AgentFrame)
has been overridden.public Action getSynchroPaintingAction()
public void setRenderingInterval(int interval)
interval
- an int > 0public JToolBar getToolBar()
Fabien Michel, Olivier Gutknecht, Jacques Ferber - July 18 2017