T - The subclass of WorldModel that this viewer understands.public abstract class AbstractViewer<T extends WorldModel<? extends Entity>> extends AbstractComponent<T> implements Viewer
| Modifier and Type | Field and Description |
|---|---|
protected int |
viewerID
The ID of this viewer.
|
config, connection, model, random| Modifier | Constructor and Description |
|---|---|
protected |
AbstractViewer()
Create a new AbstractViewer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
connect(Connection connection,
RequestIDGenerator generator,
Config config)
Connect this component to the kernel.
|
int |
getViewerID()
Get this viewer's ID.
|
protected void |
handleTimestep(KVTimestep timestep)
Handle a KVTimestep object from the server.
|
void |
postConnect(Connection c,
int id,
java.util.Collection<Entity> entities,
Config kernelConfig)
Notification that this viewer has been connected to the kernel.
|
protected void |
processMessage(Message msg)
Process an incoming message.
|
createWorldModel, getName, getPreferredLogContext, getPreferredNDC, getPreferredRegistry, initialise, postConnect, postConnect, processImmediately, send, shutdownclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetName, getPreferredLogContext, getPreferredRegistry, initialise, shutdownpublic final int getViewerID()
public void postConnect(Connection c, int id, java.util.Collection<Entity> entities, Config kernelConfig)
ViewerpostConnect in interface Viewerc - The connection to the kernel.id - The ID of this viewer.entities - The set of Entities the kernel sent to this viewer on connection.kernelConfig - The Config the kernel send to this agent on connection.public void connect(Connection connection, RequestIDGenerator generator, Config config) throws ConnectionException, ComponentConnectionException, java.lang.InterruptedException
Componentconnect in interface Componentconnection - The Connection to use.generator - The RequestIDGenerator to use.config - The system configuration.ConnectionException - If there is a problem communicating with the kernel.ComponentConnectionException - If the connection fails.java.lang.InterruptedException - If the thread is interrupted before the connection attempt completes.protected void handleTimestep(KVTimestep timestep)
timestep - The KVTimestep object.protected void processMessage(Message msg)
AbstractComponentprocessMessage in class AbstractComponent<T extends WorldModel<? extends Entity>>msg - The incoming message.