public class TLcyCompositeHyperlinkListener extends TLcyGenericComposite<HyperlinkListener> implements 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, ... .
PRIORITY_DEFAULT, PRIORITY_FALLBACK
Constructor and Description |
---|
TLcyCompositeHyperlinkListener()
Default constructor.
|
TLcyCompositeHyperlinkListener(ILcyLucyEnv aLucyEnv)
Construct a
TLcyCompositeHyperlinkListener working on the Lucy back-end |
Modifier and Type | Method and Description |
---|---|
void |
addHyperlinkListener(HyperlinkListener aHyperlinkListener)
Adds the given
HyperlinkListener to this composite hyperlink listener. |
HyperlinkListener |
getHyperlinkListener(int aIndex)
Returns the
HyperlinkListener at the given index. |
int |
getHyperlinkListenerCount()
Returns the number of currently registered hyperlink listeners.
|
void |
hyperlinkUpdate(HyperlinkEvent aHyperlinkEvent)
Implementation of HyperlinkListener.hyperlinkUpdate.
|
void |
removeHyperlinkListener(HyperlinkListener aHyperlinkListener)
Removes the given
HyperlinkListener from this composite hyperlink listener. |
add, add, getList, getPriority, iterator, remove
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
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 registered HyperlinkListener
instances of the Lucy back-end, use TLcyCompositeHyperlinkListener(com.luciad.lucy.ILcyLucyEnv)
instead.
public TLcyCompositeHyperlinkListener(ILcyLucyEnv aLucyEnv)
Construct a TLcyCompositeHyperlinkListener
working on the Lucy back-end
It will use all HyperlinkListener
instances registered to the back-end, and
adding and/or removing HyperlinkListener
s to/from this
HyperlinkListener
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, use TLcyCompositeHyperlinkListener()
instead.
aLucyEnv
- The Lucy back-end.TLcyCompositeHyperlinkListener()
,
ILcyLucyEnv.addService(Object, int)
,
ILcyLucyEnv.removeService(Object)
public void addHyperlinkListener(HyperlinkListener aHyperlinkListener)
Adds the given HyperlinkListener
to this composite hyperlink listener. The registered
HyperlinkListener
will be notified of every HyperlinkEvent
that is
dispatched to the TLcyCompositeHyperlinkListener
If the constructor specifying an ILcyLucyEnv
is used, the
HyperlinkListener
will be registered as a service on the Lucy back-end
(see ILcyLucyEnv.addService(Object, int)
). When calling ILcyLucyEnv.getServices(Class)
afterwards, aHyperlinkListener
will only be included in the returned list when the requested class was
HyperlinkListener.class
.
Note: if you want to remove the registered HyperlinkListener
afterwards, use removeHyperlinkListener(javax.swing.event.HyperlinkListener)
and not
ILcyLucyEnv.removeService(Object)
.
aHyperlinkListener
- A HyperlinkListener
that should be registered.removeHyperlinkListener(HyperlinkListener)
public void removeHyperlinkListener(HyperlinkListener aHyperlinkListener)
Removes the given HyperlinkListener
from this composite hyperlink listener. If the
given HyperlinkListener
was never added before, nothing happens.
If the constructor specifying an ILcyLucyEnv
is used, the
HyperlinkListener
will be removed as service from the Lucy back-end
(see ILcyLucyEnv.removeService(Object)
).
Note: it is only possible to remove HyperlinkListener
instances
which were registered using the addHyperlinkListener(javax.swing.event.HyperlinkListener)
method.
aHyperlinkListener
- A HyperlinkListener
to remove.(HyperlinkListener)
public int getHyperlinkListenerCount()
Returns the number of currently registered hyperlink listeners.
HyperlinkListener
s.public HyperlinkListener getHyperlinkListener(int aIndex)
Returns the HyperlinkListener
at the given index.
aIndex
- the index of the HyperlinkListener
to return.HyperlinkListener
at the given index.public void hyperlinkUpdate(HyperlinkEvent aHyperlinkEvent)
HyperlinkListeners
s and dispatches the event to each of them.hyperlinkUpdate
in interface HyperlinkListener
aHyperlinkEvent
- A HyperlinkEvent
.