This sections reviews the handling of events in the INTViewer platform, including how to send and receive events. We also review the major types of event supported.
The utility class com.interactive.intviewerapi.events.EventBroadcaster implements a singleton that keeps track of all the listeners that have been registered for event notification. It also has a send method which can be used to post an event.
When you customize INTViewer, you create your own components that "listen" to specific event types. By customizing your listener component (as opposed to customizing your event handler), you make sure that all components have a common set of events to react to. For example, the RectangularEvent event is common to all components that react to a completed rubberband selection. You could have several panels in your INTViewer application displaying various information about that rectangular selection.
To draw shapes on a 2D layer, or if you need to detect that the mouse was clicked in a 2D layer, go to 2D Layer Event Handlers. Synchronization settings are discussed in the Synchronization section.
Below is a list of the main types of events supported by INTViewer:
Other less used events are:
INTViewer EventBroadcaster utility class provides a simple static method to post an event:
EventBroadcaster.getInstance().send(myEvent);
where myEvent must be a subclass of java.util.EventObject.
Typically, a simple static method can be used to subscribe to events:
EventBroadcaster.getInstance().subscribe(MyEvent.class, this, true); // true means weak subscription
In this example, we assume that "this" is a IEventSubscriber, meaning that a "onEvent" method is implemented:
public void onEvent(MyEvent event)
To explicitely unsubscribe, use the unsubscribe method. Example:
EventBroadcaster.getInstance().unsubscribe(MyEvent.class, this)