Class TLcyCompositeHyperlinkListener
- All Implemented Interfaces:
Iterable<HyperlinkListener>
,EventListener
,HyperlinkListener
Composite implementation (see composite design pattern) of HyperlinkListener
. It
keeps a list of associated HyperlinkListener
s: one can add and remove other
HyperlinkListener
s to this HyperlinkListener
. When a HyperlinkEvent
is fired, it loops over its associated HyperlinkListener
s and notifies all of them.
It is up to the registered HyperlinkListener
s 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
ConstructorDescriptionDefault constructor.TLcyCompositeHyperlinkListener
(ILcyLucyEnv aLucyEnv) Construct aTLcyCompositeHyperlinkListener
working on the Lucy back-end -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHyperlinkListener
(HyperlinkListener aHyperlinkListener) Adds the givenHyperlinkListener
to this composite hyperlink listener.getHyperlinkListener
(int aIndex) Returns theHyperlinkListener
at the given index.int
Returns the number of currently registered hyperlink listeners.void
hyperlinkUpdate
(HyperlinkEvent aHyperlinkEvent) Implementation of HyperlinkListener.hyperlinkUpdate.void
removeHyperlinkListener
(HyperlinkListener aHyperlinkListener) Removes the givenHyperlinkListener
from this composite hyperlink listener.Methods inherited from class com.luciad.lucy.util.TLcyGenericComposite
add, add, getList, getPriority, iterator, remove
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TLcyCompositeHyperlinkListener
public TLcyCompositeHyperlinkListener()Default constructor. No
HyperlinkListener
s are associated.The created instance will only work on the
HyperlinkListener
instances registered to it. If you want to use all registeredHyperlinkListener
instances of the Lucy back-end, useTLcyCompositeHyperlinkListener(com.luciad.lucy.ILcyLucyEnv)
instead.- See Also:
-
TLcyCompositeHyperlinkListener
Construct a
TLcyCompositeHyperlinkListener
working on the Lucy back-endIt will use all
HyperlinkListener
instances registered to the back-end, and adding and/or removingHyperlinkListener
s to/from thisHyperlinkListener
will respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeHyperlinkListener
which does not use the back-end, useTLcyCompositeHyperlinkListener()
instead.- Parameters:
aLucyEnv
- The Lucy back-end.- See Also:
-
-
Method Details
-
addHyperlinkListener
Adds the given
HyperlinkListener
to this composite hyperlink listener. The registeredHyperlinkListener
will be notified of everyHyperlinkEvent
that is dispatched to theTLcyCompositeHyperlinkListener
If the constructor specifying an
ILcyLucyEnv
is used, theHyperlinkListener
will be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
). When callingILcyLucyEnv.getServices(Class)
afterwards,aHyperlinkListener
will only be included in the returned list when the requested class wasHyperlinkListener.class
.
Note: if you want to remove the registeredHyperlinkListener
afterwards, useremoveHyperlinkListener(javax.swing.event.HyperlinkListener)
and notILcyLucyEnv.removeService(Object)
.- Parameters:
aHyperlinkListener
- AHyperlinkListener
that should be registered.- See Also:
-
removeHyperlinkListener
Removes the given
HyperlinkListener
from this composite hyperlink listener. If the givenHyperlinkListener
was never added before, nothing happens.If the constructor specifying an
ILcyLucyEnv
is used, theHyperlinkListener
will be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)
).
Note: it is only possible to removeHyperlinkListener
instances which were registered using theaddHyperlinkListener(javax.swing.event.HyperlinkListener)
method.- Parameters:
aHyperlinkListener
- AHyperlinkListener
to remove.- See Also:
-
getHyperlinkListenerCount
public int getHyperlinkListenerCount()Returns the number of currently registered hyperlink listeners.
- Returns:
- The number of associated
HyperlinkListener
s.
-
getHyperlinkListener
Returns the
HyperlinkListener
at the given index.- Parameters:
aIndex
- the index of theHyperlinkListener
to return.- Returns:
- The associated
HyperlinkListener
at the given index.
-
hyperlinkUpdate
Implementation of HyperlinkListener.hyperlinkUpdate. Loops over all associatedHyperlinkListeners
s and dispatches the event to each of them.- Specified by:
hyperlinkUpdate
in interfaceHyperlinkListener
- Parameters:
aHyperlinkEvent
- AHyperlinkEvent
.
-