EVENT - public abstract class EventReact<EVENT extends IWorldEvent> extends Object
IWorldEvent for you and calls react(IWorldEvent)
method automatically.
If you need to react only once to the event, use EventReactOnce.
Use enable() and disable() to enable react / disable react. The reaction is enabled
as default.
WARNING:Use as anonymous class, but save it as a field of your class! Note, that we're using weak-references to listeners and if you do not save pointer to the object, it will be gc()ed!
| Modifier and Type | Field and Description |
|---|---|
protected Class<EVENT> |
reactEventClass |
protected IWorldEventListener<EVENT> |
reactListener |
protected IWorldView |
reactWorldView |
| Constructor and Description |
|---|
EventReact(Class<EVENT> eventClass,
IWorldView worldView) |
| Modifier and Type | Method and Description |
|---|---|
void |
disable()
Disables the reaction.
|
void |
enable()
Enables the reaction.
|
protected void |
postReact(EVENT event)
post-
react(IWorldEvent) hook allowing you to do additional work after the react method. |
protected void |
preReact(EVENT event)
pre-
react(IWorldEvent) hook allowing you to do additional work before the react method. |
protected abstract void |
react(EVENT event)
React upon event notification.
|
protected IWorldEventListener<EVENT extends IWorldEvent> reactListener
protected IWorldView reactWorldView
protected Class<EVENT extends IWorldEvent> reactEventClass
public EventReact(Class<EVENT> eventClass, IWorldView worldView)
public void disable()
public void enable()
protected void preReact(EVENT event)
react(IWorldEvent) hook allowing you to do additional work before the react method.event - protected abstract void react(EVENT event)
event - protected void postReact(EVENT event)
react(IWorldEvent) hook allowing you to do additional work after the react method.event - Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.