pamScrollSystem
Class ScrollerCoupling

java.lang.Object
  extended by pamScrollSystem.ScrollerCoupling

public class ScrollerCoupling
extends java.lang.Object

A class for coupling two or more scrollers.

Coupled scrollers will move together - when one moves, the others move.

Author:
Doug Gillespie

Field Summary
protected  java.lang.String name
           
private  boolean notificationLock
          lock to stop looping of calls to the notifyOthers function.
private  java.util.Vector<AbstractPamScroller> scrollers
           
 
Constructor Summary
ScrollerCoupling(java.lang.String name)
           
 
Method Summary
 void addScroller(AbstractPamScroller aScroller)
          Add a new scroller to the coupling
 int getScrollerCount()
           
 void notifyOthers(AbstractPamScroller scroller)
          Notify other scrollers in the set that a scroller has changed then pass them a reference to the changed scroller so that they can copy information from it.
 boolean removeScroller(AbstractPamScroller aScroller)
          Remove a scroller form a coupling
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

scrollers

private java.util.Vector<AbstractPamScroller> scrollers

notificationLock

private boolean notificationLock
lock to stop looping of calls to the notifyOthers function.

Constructor Detail

ScrollerCoupling

public ScrollerCoupling(java.lang.String name)
Method Detail

addScroller

public void addScroller(AbstractPamScroller aScroller)
Add a new scroller to the coupling

Parameters:
aScroller -

notifyOthers

public void notifyOthers(AbstractPamScroller scroller)
Notify other scrollers in the set that a scroller has changed then pass them a reference to the changed scroller so that they can copy information from it.

This function holds a lock since as soon as another scroller is changed, it's likely to call back to this same function and set up an infinite loop. The lock will exit the function if set to avoid this situation.

Parameters:
scroller - scroller which changes.

removeScroller

public boolean removeScroller(AbstractPamScroller aScroller)
Remove a scroller form a coupling

Parameters:
aScroller -
Returns:
true if the scroller wwas present.

getScrollerCount

public int getScrollerCount()