public class TLcyCompositeBalloonContentProvider extends TLcyGenericComposite<ILcdBalloonContentProvider> implements ILcdBalloonContentProvider
Composite implementation (see composite design pattern) of ILcdBalloonContentProvider
. It
keeps a list of associated ILcdBalloonContentProvider
s: one can add and remove other
ILcdBalloonContentProvider
s to this ILcdBalloonContentProvider
. When a HyperlinkEvent
is fired, it loops over its associated ILcdBalloonContentProvider
s and notifies all of them.
It is up to the registered ILcdBalloonContentProvider
s to determine whether or not the fired
HyperlinkEvent
is relevant.
When creating a new TLcyCompositeBalloonContentProvider
using the default
constructor (see TLcyCompositeBalloonContentProvider()
), the created instance will
only work on/with the ILcdBalloonContentProviders registered
on this composite instance (see addBalloonContentProvider(com.luciad.view.swing.ILcdBalloonContentProvider)
and removeBalloonContentProvider(ILcdBalloonContentProvider)
).
When creating a new TLcyCompositeBalloonContentProvider
using the constructor
specifying an ILcyLucyEnv
instance (see TLcyCompositeBalloonContentProvider(com.luciad.lucy.ILcyLucyEnv)
, the created instance will
work on the Lucy back-end services. It will use
all registered ILcdBalloonContentProvider instances of the
Lucy back-end, adding and/or removing an ILcdBalloonContentProvider
will
add/remove the ILcdBalloonContentProvider
as service from Lucy, ... .
PRIORITY_DEFAULT, PRIORITY_FALLBACK
Constructor and Description |
---|
TLcyCompositeBalloonContentProvider()
Default constructor.
|
TLcyCompositeBalloonContentProvider(ILcyLucyEnv aLucyEnv)
Construct a
TLcyCompositeBalloonContentProvider working on the Lucy back-end |
Modifier and Type | Method and Description |
---|---|
void |
addBalloonContentProvider(ILcdBalloonContentProvider aBalloonContentProvider)
Adds the given
ILcdBalloonContentProvider to this composite balloon content provider. |
boolean |
canGetContent(ALcdBalloonDescriptor aBalloonDescriptor)
Checks if it is possible to return a
JComponent that should be used as the content. |
ILcdBalloonContentProvider |
getBalloonContentProvider(int aIndex)
Returns the
ILcdBalloonContentProvider at the given index. |
int |
getBalloonContentProviderCount()
Returns the number of currently registered balloon content providers.
|
JComponent |
getContent(ALcdBalloonDescriptor aBalloonDescriptor)
Returns the balloon contents of an object.
|
void |
removeBalloonContentProvider(ILcdBalloonContentProvider aBalloonContentProvider)
Removes the given
ILcdBalloonContentProvider from this composite layer factory. |
add, add, getList, getPriority, iterator, remove
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public TLcyCompositeBalloonContentProvider()
Default constructor. No ILcdBalloonContentProvider
s are associated.
The created instance will only work on the ILcdBalloonContentProvider
instances registered to it. If you want to use all registered ILcdBalloonContentProvider
instances of the Lucy back-end, use TLcyCompositeBalloonContentProvider(com.luciad.lucy.ILcyLucyEnv)
instead.
public TLcyCompositeBalloonContentProvider(ILcyLucyEnv aLucyEnv)
Construct a TLcyCompositeBalloonContentProvider
working on the Lucy back-end
It will use all ILcdBalloonContentProvider
instances registered to the back-end, and
adding and/or removing ILcdBalloonContentProvider
s to/from this
ILcdBalloonContentProvider
will respectively add/remove it as service from the
back-end.
If you want to create a TLcyCompositeBalloonContentProvider
which does not use the
back-end, use TLcyCompositeBalloonContentProvider()
instead.
aLucyEnv
- The Lucy back-end.TLcyCompositeBalloonContentProvider()
,
ILcyLucyEnv.addService(Object, int)
,
ILcyLucyEnv.removeService(Object)
public boolean canGetContent(ALcdBalloonDescriptor aBalloonDescriptor)
ILcdBalloonContentProvider
JComponent
that should be used as the content.
The implementation of this method should be consistent with the implementation of
ILcdBalloonContentProvider.getContent(ALcdBalloonDescriptor)
, i.e. when this method returns false
,
ILcdBalloonContentProvider.getContent(ALcdBalloonDescriptor)
should return
null
and vice versa.canGetContent
in interface ILcdBalloonContentProvider
aBalloonDescriptor
- An object describing a balloon.JComponent
can be returned for the given
ALcdBalloonDescriptor
and false otherwise.public JComponent getContent(ALcdBalloonDescriptor aBalloonDescriptor)
ILcdBalloonContentProvider
ILcdBalloonContentProvider.canGetContent(ALcdBalloonDescriptor)
. Both implementations should be
consistent though, i.e. when ILcdBalloonContentProvider.canGetContent(ALcdBalloonDescriptor)
returns
false
, this method should return null
and vice versa.getContent
in interface ILcdBalloonContentProvider
aBalloonDescriptor
- An object describing a balloon.JComponent
that should be used as the content of a balloon, or
null
when this provider cannot provide contents for the given
ALcdBalloonDescriptor
.public void addBalloonContentProvider(ILcdBalloonContentProvider aBalloonContentProvider)
Adds the given ILcdBalloonContentProvider
to this composite balloon content provider. The
ILcdBalloonContentProvider
should only create balloon contents for objects it knows about.
If the constructor specifying an ILcyLucyEnv
is used, the
ILcdBalloonContentProvider
will be registered as a service on the Lucy back-end
(see ILcyLucyEnv.addService(Object, int)
). When calling ILcyLucyEnv.getServices(Class)
afterwards, aBalloonContentProvider
will only be included in the returned list when the requested class was
ILcdBalloonContentProvider.class
.
Note: if you want to remove the registered ILcdBalloonContentProvider
afterwards, use removeBalloonContentProvider(com.luciad.view.swing.ILcdBalloonContentProvider)
and not
ILcyLucyEnv.removeService(Object)
.
aBalloonContentProvider
- the balloon content providerremoveBalloonContentProvider(ILcdBalloonContentProvider)
public void removeBalloonContentProvider(ILcdBalloonContentProvider aBalloonContentProvider)
Removes the given ILcdBalloonContentProvider
from this composite layer factory. If the
given ILcdBalloonContentProvider
was never added before, nothing happens.
If the constructor specifying an ILcyLucyEnv
is used, the
ILcdBalloonContentProvider
will be removed as service from the Lucy back-end
(see ILcyLucyEnv.removeService(Object)
).
Note: it is only possible to remove ILcdBalloonContentProvider
instances
which were registered using the addBalloonContentProvider(com.luciad.view.swing.ILcdBalloonContentProvider)
method.
aBalloonContentProvider
- A ILcdBalloonContentProvider
to remove.(ILcdBalloonContentProvider)
public int getBalloonContentProviderCount()
Returns the number of currently registered balloon content providers.
ILcdBalloonContentProvider
s.public ILcdBalloonContentProvider getBalloonContentProvider(int aIndex)
Returns the ILcdBalloonContentProvider
at the given index.
aIndex
- the index of the ILcdBalloonContentProvider
to return.ILcdBalloonContentProvider
at the given index.