Class TLcyCompositeBalloonContentProvider
- All Implemented Interfaces:
ILcdBalloonContentProvider
,Iterable<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, ... .
-
Field Summary
Fields inherited from class com.luciad.lucy.util.TLcyGenericComposite
PRIORITY_DEFAULT, PRIORITY_FALLBACK
-
Constructor Summary
ConstructorDescriptionDefault constructor.Construct aTLcyCompositeBalloonContentProvider
working on the Lucy back-end -
Method Summary
Modifier and TypeMethodDescriptionvoid
addBalloonContentProvider
(ILcdBalloonContentProvider aBalloonContentProvider) Adds the givenILcdBalloonContentProvider
to this composite balloon content provider.boolean
canGetContent
(ALcdBalloonDescriptor aBalloonDescriptor) Checks if it is possible to return aJComponent
that should be used as the content.getBalloonContentProvider
(int aIndex) Returns theILcdBalloonContentProvider
at the given index.int
Returns the number of currently registered balloon content providers.getContent
(ALcdBalloonDescriptor aBalloonDescriptor) Returns the balloon contents of an object.void
removeBalloonContentProvider
(ILcdBalloonContentProvider aBalloonContentProvider) Removes the givenILcdBalloonContentProvider
from this composite layer factory.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
-
TLcyCompositeBalloonContentProvider
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 registeredILcdBalloonContentProvider
instances of the Lucy back-end, useTLcyCompositeBalloonContentProvider(com.luciad.lucy.ILcyLucyEnv)
instead.- See Also:
-
TLcyCompositeBalloonContentProvider
Construct a
TLcyCompositeBalloonContentProvider
working on the Lucy back-endIt will use all
ILcdBalloonContentProvider
instances registered to the back-end, and adding and/or removingILcdBalloonContentProvider
s to/from thisILcdBalloonContentProvider
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, useTLcyCompositeBalloonContentProvider()
instead.- Parameters:
aLucyEnv
- The Lucy back-end.- See Also:
-
-
Method Details
-
canGetContent
Description copied from interface:ILcdBalloonContentProvider
Checks if it is possible to return aJComponent
that should be used as the content. The implementation of this method should be consistent with the implementation ofILcdBalloonContentProvider.getContent(ALcdBalloonDescriptor)
, i.e. when this method returnsfalse
,ILcdBalloonContentProvider.getContent(ALcdBalloonDescriptor)
should returnnull
and vice versa.- Specified by:
canGetContent
in interfaceILcdBalloonContentProvider
- Parameters:
aBalloonDescriptor
- An object describing a balloon.- Returns:
- true if a content
JComponent
can be returned for the givenALcdBalloonDescriptor
and false otherwise.
-
getContent
Description copied from interface:ILcdBalloonContentProvider
Returns the balloon contents of an object. It is allowed to call this method without first callingILcdBalloonContentProvider.canGetContent(ALcdBalloonDescriptor)
. Both implementations should be consistent though, i.e. whenILcdBalloonContentProvider.canGetContent(ALcdBalloonDescriptor)
returnsfalse
, this method should returnnull
and vice versa.- Specified by:
getContent
in interfaceILcdBalloonContentProvider
- Parameters:
aBalloonDescriptor
- An object describing a balloon.- Returns:
- a
JComponent
that should be used as the content of a balloon, ornull
when this provider cannot provide contents for the givenALcdBalloonDescriptor
.
-
addBalloonContentProvider
Adds the given
ILcdBalloonContentProvider
to this composite balloon content provider. TheILcdBalloonContentProvider
should only create balloon contents for objects it knows about.If the constructor specifying an
ILcyLucyEnv
is used, theILcdBalloonContentProvider
will be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
). When callingILcyLucyEnv.getServices(Class)
afterwards,aBalloonContentProvider
will only be included in the returned list when the requested class wasILcdBalloonContentProvider.class
.
Note: if you want to remove the registeredILcdBalloonContentProvider
afterwards, useremoveBalloonContentProvider(com.luciad.view.swing.ILcdBalloonContentProvider)
and notILcyLucyEnv.removeService(Object)
.- Parameters:
aBalloonContentProvider
- the balloon content provider- See Also:
-
removeBalloonContentProvider
Removes the given
ILcdBalloonContentProvider
from this composite layer factory. If the givenILcdBalloonContentProvider
was never added before, nothing happens.If the constructor specifying an
ILcyLucyEnv
is used, theILcdBalloonContentProvider
will be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)
).
Note: it is only possible to removeILcdBalloonContentProvider
instances which were registered using theaddBalloonContentProvider(com.luciad.view.swing.ILcdBalloonContentProvider)
method.- Parameters:
aBalloonContentProvider
- AILcdBalloonContentProvider
to remove.- See Also:
-
getBalloonContentProviderCount
public int getBalloonContentProviderCount()Returns the number of currently registered balloon content providers.
- Returns:
- The number of associated
ILcdBalloonContentProvider
s.
-
getBalloonContentProvider
Returns the
ILcdBalloonContentProvider
at the given index.- Parameters:
aIndex
- the index of theILcdBalloonContentProvider
to return.- Returns:
- The associated
ILcdBalloonContentProvider
at the given index.
-