Class TLcyCompositeHyperlinkListener
- All Implemented Interfaces:
Iterable<HyperlinkListener>,EventListener,HyperlinkListener
Composite implementation (see composite design pattern) of HyperlinkListener. It
keeps a list of associated HyperlinkListeners: one can add and remove other
HyperlinkListeners to this HyperlinkListener. When a HyperlinkEvent
is fired, it loops over its associated HyperlinkListeners and notifies all of them.
It is up to the registered HyperlinkListeners to determine whether or not the fired
HyperlinkEvent is relevant.
When creating a new TLcyCompositeHyperlinkListener using the default
constructor (see TLcyCompositeHyperlinkListener()), the created instance will
only work on/with the HyperlinkListeners registered
on this composite instance (see addHyperlinkListener(HyperlinkListener)
and removeHyperlinkListener(HyperlinkListener)).
When creating a new TLcyCompositeHyperlinkListener using the constructor
specifying an ILcyLucyEnv instance (see TLcyCompositeHyperlinkListener(com.luciad.lucy.ILcyLucyEnv), the created instance will
work on the Lucy back-end services. It will use
all registered HyperlinkListener instances of the
Lucy back-end, adding and/or removing an HyperlinkListener will
add/remove the HyperlinkListener as service from Lucy, ... .
- Since:
- 10.0
-
Field Summary
Fields inherited from class com.luciad.lucy.util.TLcyGenericComposite
PRIORITY_DEFAULT, PRIORITY_FALLBACK -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.TLcyCompositeHyperlinkListener(ILcyLucyEnv aLucyEnv) Construct aTLcyCompositeHyperlinkListenerworking on the Lucy back-end -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHyperlinkListener(HyperlinkListener aHyperlinkListener) Adds the givenHyperlinkListenerto this composite hyperlink listener.getHyperlinkListener(int aIndex) Returns theHyperlinkListenerat the given index.intReturns the number of currently registered hyperlink listeners.voidhyperlinkUpdate(HyperlinkEvent aHyperlinkEvent) Implementation of HyperlinkListener.hyperlinkUpdate.voidremoveHyperlinkListener(HyperlinkListener aHyperlinkListener) Removes the givenHyperlinkListenerfrom this composite hyperlink listener.Methods inherited from class com.luciad.lucy.util.TLcyGenericComposite
add, add, getList, getPriority, iterator, removeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TLcyCompositeHyperlinkListener
public TLcyCompositeHyperlinkListener()Default constructor. No
HyperlinkListeners are associated.The created instance will only work on the
HyperlinkListenerinstances registered to it. If you want to use all registeredHyperlinkListenerinstances of the Lucy back-end, useTLcyCompositeHyperlinkListener(com.luciad.lucy.ILcyLucyEnv)instead.- See Also:
-
TLcyCompositeHyperlinkListener
Construct a
TLcyCompositeHyperlinkListenerworking on the Lucy back-endIt will use all
HyperlinkListenerinstances registered to the back-end, and adding and/or removingHyperlinkListeners to/from thisHyperlinkListenerwill respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeHyperlinkListenerwhich does not use the back-end, useTLcyCompositeHyperlinkListener()instead.- Parameters:
aLucyEnv- The Lucy back-end.- See Also:
-
-
Method Details
-
addHyperlinkListener
Adds the given
HyperlinkListenerto this composite hyperlink listener. The registeredHyperlinkListenerwill be notified of everyHyperlinkEventthat is dispatched to theTLcyCompositeHyperlinkListenerIf the constructor specifying an
ILcyLucyEnvis used, theHyperlinkListenerwill be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)). When callingILcyLucyEnv.getServices(Class)afterwards,aHyperlinkListenerwill only be included in the returned list when the requested class wasHyperlinkListener.class.
Note: if you want to remove the registeredHyperlinkListenerafterwards, useremoveHyperlinkListener(javax.swing.event.HyperlinkListener)and notILcyLucyEnv.removeService(Object).- Parameters:
aHyperlinkListener- AHyperlinkListenerthat should be registered.- See Also:
-
removeHyperlinkListener
Removes the given
HyperlinkListenerfrom this composite hyperlink listener. If the givenHyperlinkListenerwas never added before, nothing happens.If the constructor specifying an
ILcyLucyEnvis used, theHyperlinkListenerwill be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)).
Note: it is only possible to removeHyperlinkListenerinstances which were registered using theaddHyperlinkListener(javax.swing.event.HyperlinkListener)method.- Parameters:
aHyperlinkListener- AHyperlinkListenerto remove.- See Also:
-
getHyperlinkListenerCount
public int getHyperlinkListenerCount()Returns the number of currently registered hyperlink listeners.
- Returns:
- The number of associated
HyperlinkListeners.
-
getHyperlinkListener
Returns the
HyperlinkListenerat the given index.- Parameters:
aIndex- the index of theHyperlinkListenerto return.- Returns:
- The associated
HyperlinkListenerat the given index.
-
hyperlinkUpdate
Implementation of HyperlinkListener.hyperlinkUpdate. Loops over all associatedHyperlinkListenerss and dispatches the event to each of them.- Specified by:
hyperlinkUpdatein interfaceHyperlinkListener- Parameters:
aHyperlinkEvent- AHyperlinkEvent.
-