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
logger
Constructor and Description |
---|
SwingViewer()
Creates a new agent with a default panel
for rendering purposes
|
Modifier and Type | Method and Description |
---|---|
javax.swing.JMenu |
getDisplayMenu()
Returns a menu which could be used in any GUI.
|
javax.swing.JComponent |
getDisplayPane() |
javax.swing.JFrame |
getFrame()
By default, get the default frame provided by MaDKit in
setupFrame(JFrame) and
set using setupFrame(JFrame) . |
javax.swing.Action |
getSynchroPaintingAction() |
javax.swing.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(java.awt.Graphics g)
Override this method to do the rendering in the agent's panel.
|
void |
setDisplayPane(javax.swing.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(javax.swing.JFrame 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, 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 javax.swing.JComponent getDisplayPane()
public void setDisplayPane(javax.swing.JComponent displayPane)
displayPane
- the displayPane to setprotected void observe()
isSynchronousPainting()
.protected abstract void render(java.awt.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(javax.swing.JFrame frame)
setupFrame
in class AbstractAgent
frame
- the default frame which has been created by MaDKit for this
agent.AbstractAgent.setupFrame(javax.swing.JFrame)
public javax.swing.JMenu getDisplayMenu()
public javax.swing.JFrame getFrame()
setupFrame(JFrame)
and
set using setupFrame(JFrame)
.
It can be anything else if setupFrame(JFrame)
is overridden.public javax.swing.Action getSynchroPaintingAction()
public void setRenderingInterval(int interval)
interval
- an int > 0public javax.swing.JToolBar getToolBar()
Fabien Michel, Olivier Gutknecht, Jacques Ferber - November 18 2014