de.fhpotsdam.unfolding.events
Class EventDispatcher

java.lang.Object
  extended by de.fhpotsdam.unfolding.events.EventDispatcher

public class EventDispatcher
extends java.lang.Object

The event dispatcher is the core class for handling the event system.

In the simplest case all user input only affects a single UnfoldingMap. For instance, a user clicks and drags the mouse, so that the map gets panned. In this case, the MouseHandler, a MapEventBroadcaster, reacts to the user's mouse-dragging, and creates a PanMapEvent with the respective geo-location to pan to. That event is fired, and send via the EventDispatcher to the only listener, the single map.

In other cases, applications can set up more sophisticated behaviors. For instance, in an overview+detail setting with a large detail map and a small overview map, the small map shall only show an overview but not be interactive itself. For this case, the MouseHandler is created for the large map, but with a scope of both maps. The EventDispatcher is initiated with both maps listening to pan-events. Thus, any panning on the large overview map also affects the small detail map.
See the OverviewAndDetailMapApp and the ComplexMapEventApp in the examples section for this.

Your application then can create EventDispatcher to connect broadcasters and listeners, and customize the event handling in an application.


Field Summary
static org.apache.log4j.Logger log
           
 java.util.Map<java.lang.String,java.util.List<ScopedListeners>> typedScopedListeners
           
 
Constructor Summary
EventDispatcher()
           
 
Method Summary
 void addBroadcaster(MapEventBroadcaster broadcaster)
          Adds broadcaster by setting this EventDispatcher in the MapEventDispatcher.
 void fireMapEvent(MapEvent event)
          Fires a map event.
 void register(java.util.List<MapEventListener> listeners, java.lang.String type, java.lang.String... scopeIds)
          Registers multiple listener for an event type within one or more event scopes.
 void register(MapEventListener listener, java.lang.String type, java.lang.String... scopeIds)
          Registers listener to an event type within one or more event scopes.
 void unregister(MapEventListener listener, java.lang.String type, java.lang.String... scopeIds)
          Removes listener if ScopedListeners exist for scopeIds to unregister.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Logger log

typedScopedListeners

public java.util.Map<java.lang.String,java.util.List<ScopedListeners>> typedScopedListeners
Constructor Detail

EventDispatcher

public EventDispatcher()
Method Detail

fireMapEvent

public void fireMapEvent(MapEvent event)
Fires a map event. Sends it to all listeners

Parameters:
event -

addBroadcaster

public void addBroadcaster(MapEventBroadcaster broadcaster)
Adds broadcaster by setting this EventDispatcher in the MapEventDispatcher. (Convenience method).

Parameters:
broadcaster - The broadcaster to add.

register

public void register(MapEventListener listener,
                     java.lang.String type,
                     java.lang.String... scopeIds)
Registers listener to an event type within one or more event scopes.

Parameters:
listener - The listener to register, e.g. a map.
type - The type of the event, e.g. pan or zoom.
scopeIds - IDs of scopes to register for. If none is provided the scope of the listener is used. Note, that if you provide some scopes the listener's own scope is not added, automatically.

register

public void register(java.util.List<MapEventListener> listeners,
                     java.lang.String type,
                     java.lang.String... scopeIds)
Registers multiple listener for an event type within one or more event scopes.

Parameters:
listeners - The listeners to register, e.g. some maps.
type - The type of the event, e.g. pan or zoom.
scopeIds - IDs of scopes to register for. If none is provided the scope of the listener is used. Note, that if you provide some scopes the listener's own scope is not added, automatically.

unregister

public void unregister(MapEventListener listener,
                       java.lang.String type,
                       java.lang.String... scopeIds)
Removes listener if ScopedListeners exist for scopeIds to unregister.

Parameters:
listener - The listener to unregister, e.g. a maps.
type - The type of the event, e.g. pan or zoom.
scopeIds - IDs of scopes to unregister for.