com.bbn.openmap.event
Class LayerSupport

java.lang.Object
  extended by java.util.concurrent.CopyOnWriteArrayList<E>
      extended by com.bbn.openmap.event.ListenerSupport<LayerListener>
          extended by com.bbn.openmap.event.LayerSupport
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<LayerListener>, java.util.Collection<LayerListener>, java.util.List<LayerListener>, java.util.RandomAccess

public class LayerSupport
extends ListenerSupport<LayerListener>

This is a utility class that can be used by beans that need support for handling LayerListeners and firing LayerEvents. You can use an instance of this class as a member field of your bean and delegate work to it.

See Also:
Serialized Form

Nested Class Summary
protected  class LayerSupport.SetLayerRunnable
          A reusable Runnable used by a thread to notify listeners when layers are turned on/off or shuffled.
 
Field Summary
protected  java.util.Vector<LayerSupport.SetLayerRunnable> events
          Event information stack.
protected  boolean synchronous
           
protected  java.lang.Thread t
          Used to see if another Thread object needs to be created.
 
Fields inherited from class com.bbn.openmap.event.ListenerSupport
source
 
Constructor Summary
LayerSupport(java.lang.Object sourceBean)
          Construct a LayerSupport.
 
Method Summary
 void fireLayer(int type, Layer[] layers)
          Send a layer event to all registered listeners.
 boolean isSynchronous()
           
 LayerSupport.SetLayerRunnable popLayerEvent()
          Return the first event on the stack, may be null if there is nothing to do.
 void pushLayerEvent(int layerEventType, Layer[] layers)
          Pushed the information onto a Vector stack to get executed by a separate thread.
 void setSynchronous(boolean synchronous)
           
 
Methods inherited from class com.bbn.openmap.event.ListenerSupport
add, add, addAll, clear, getSource, iterator, listIterator, remove, remove, set, setSource, size
 
Methods inherited from class java.util.concurrent.CopyOnWriteArrayList
addAll, addAllAbsent, addIfAbsent, clone, contains, containsAll, equals, get, hashCode, indexOf, indexOf, isEmpty, lastIndexOf, lastIndexOf, listIterator, removeAll, retainAll, subList, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

synchronous

protected boolean synchronous

t

protected java.lang.Thread t
Used to see if another Thread object needs to be created.


events

protected java.util.Vector<LayerSupport.SetLayerRunnable> events
Event information stack.

Constructor Detail

LayerSupport

public LayerSupport(java.lang.Object sourceBean)
Construct a LayerSupport.

Parameters:
sourceBean - The bean to be given as the source for any events.
Method Detail

fireLayer

public void fireLayer(int type,
                      Layer[] layers)
Send a layer event to all registered listeners.

Parameters:
type - the event type: one of ADD, REMOVE, REPLACE
layers - the list of layers
See Also:
LayerEvent

pushLayerEvent

public void pushLayerEvent(int layerEventType,
                           Layer[] layers)
Pushed the information onto a Vector stack to get executed by a separate thread. Any thread launched is held on to, and if that thread is is null or not active, a new thread is kicked off. The dying thread checks the Vector stack and fires another event if it can.

Parameters:
layerEventType -
layers -

popLayerEvent

public LayerSupport.SetLayerRunnable popLayerEvent()
Return the first event on the stack, may be null if there is nothing to do.


isSynchronous

public boolean isSynchronous()

setSynchronous

public void setSynchronous(boolean synchronous)


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details