Class TLcyCompositeGXYLayerTypeProvider
- All Implemented Interfaces:
ILcyGXYLayerType
,ILcyGXYLayerTypeProvider
,Iterable<ILcyGXYLayerTypeProvider>
Composite (see composite design pattern) implementation of ILcyGXYLayerTypeProvider
.
It keeps a list of associated ILcyGXYLayerTypeProvider
s. When it needs to provide a
layer type, it will delegate to the first suitable layer type provider.
When creating a new TLcyCompositeGXYLayerTypeProvider
using the default
constructor (see TLcyCompositeGXYLayerTypeProvider()
), the created instance will
only work on/with the ILcyGXYLayerTypeProviders registered
on this composite instance (see addGXYLayerTypeProvider(ILcyGXYLayerTypeProvider)
and removeGXYLayerTypeProvider(ILcyGXYLayerTypeProvider)
).
When creating a new TLcyCompositeGXYLayerTypeProvider
using the constructor
specifying an ILcyLucyEnv
instance (see TLcyCompositeGXYLayerTypeProvider(com.luciad.lucy.ILcyLucyEnv)
, the created instance will
work on the Lucy back-end services. It will use
all registered ILcyGXYLayerTypeProvider instances of the
Lucy back-end, adding and/or removing an ILcyGXYLayerTypeProvider
will
add/remove the ILcyGXYLayerTypeProvider
as service from Lucy, ... .
Retrieving the layer type for an ILcdGXYLayer
using the back-end based implementation
can be done by creating a new instance of this class:
//Create a new instance whenever you need it.
TLcyCompositeGXYLayerTypeProvider provider = new TLcyCompositeGXYLayerTypeProvider( aLucyEnv );
int layerType = provider.getGXYLayerType( aGXYLayer );
//There is no need to keep a reference to the composite instance, you can create a new one
//the next time you would need it
provider = null;
-
Field Summary
Fields inherited from class com.luciad.lucy.util.TLcyGenericComposite
PRIORITY_DEFAULT, PRIORITY_FALLBACK
Fields inherited from interface com.luciad.lucy.map.ILcyGXYLayerType
BACKGROUND, EDITABLE, REALTIME, UNKNOWN
-
Constructor Summary
ConstructorDescriptionDefault constructor.TLcyCompositeGXYLayerTypeProvider
(ILcyLucyEnv aLucyEnv) Construct aTLcyCompositeGXYLayerTypeProvider
working on the Lucy back-end -
Method Summary
Modifier and TypeMethodDescriptionvoid
addGXYLayerTypeProvider
(ILcyGXYLayerTypeProvider aGXYLayerTypeProvider) Adds the givenILcyGXYLayerTypeProvider
to the list of associated providers.int
getGXYLayerType
(ILcdGXYLayer aGXYLayer) Loops over all its associatedILcyGXYLayerTypeProvider
s to find the first suitable provider.getGXYLayerTypeProvider
(int aIndex) Returns the layer type provider at the given index.int
Returns the number of associated layer type providers.void
removeGXYLayerTypeProvider
(ILcyGXYLayerTypeProvider aGXYLayerTypeProvider) Removes the givenILcyGXYLayerTypeProvider
from the list of associated providers.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
-
TLcyCompositeGXYLayerTypeProvider
public TLcyCompositeGXYLayerTypeProvider()Default constructor. No
ILcyGXYLayerTypeProvider
s are associated.The created instance will only work on the
ILcyGXYLayerTypeProvider
instances registered to it. If you want to use all registeredILcyGXYLayerTypeProvider
instances of the Lucy back-end, useTLcyCompositeGXYLayerTypeProvider(com.luciad.lucy.ILcyLucyEnv)
instead. -
TLcyCompositeGXYLayerTypeProvider
Construct a
TLcyCompositeGXYLayerTypeProvider
working on the Lucy back-endIt will use all
ILcyGXYLayerTypeProvider
instances registered to the back-end, and adding and/or removingILcyGXYLayerTypeProvider
s to/from thisTLcyCompositeGXYLayerTypeProvider
will respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeGXYLayerTypeProvider
which does not use the back-end, useTLcyCompositeGXYLayerTypeProvider()
instead.- Parameters:
aLucyEnv
- The Lucy back-end.- See Also:
-
-
Method Details
-
addGXYLayerTypeProvider
Adds the given
ILcyGXYLayerTypeProvider
to the list of associated providers.If the constructor specifying an
ILcyLucyEnv
is used, theILcyGXYLayerTypeProvider
will be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
). When callingILcyLucyEnv.getServices(Class)
afterwards,aGXYLayerTypeProvider
will only be included in the returned list when the requested class wasILcyGXYLayerTypeProvider.class
.
Note: if you want to remove the registeredILcyGXYLayerTypeProvider
afterwards, useremoveGXYLayerTypeProvider(ILcyGXYLayerTypeProvider)
and notILcyLucyEnv.removeService(Object)
.- Parameters:
aGXYLayerTypeProvider
- The provider to add.- See Also:
-
removeGXYLayerTypeProvider
Removes the given
ILcyGXYLayerTypeProvider
from the list of associated providers. If the given provider was never added, nothing will happen.If the constructor specifying an
ILcyLucyEnv
is used, theILcyGXYLayerTypeProvider
will be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)
).
Note: it is only possible to removeILcyGXYLayerTypeProvider
instances which were registered using theaddGXYLayerTypeProvider(ILcyGXYLayerTypeProvider)
method.- Parameters:
aGXYLayerTypeProvider
- The provider to remove.- See Also:
-
getGXYLayerTypeProviderCount
public int getGXYLayerTypeProviderCount()Returns the number of associated layer type providers.- Returns:
- the number of associated layer type providers.
- See Also:
-
getGXYLayerTypeProvider
Returns the layer type provider at the given index.- Parameters:
aIndex
- The index of the provider to retrieve. 0 <= aIndex <getGXYLayerTypeProviderCount()
- Returns:
- the layer type provider at the given index.
- See Also:
-
getGXYLayerType
Loops over all its associatedILcyGXYLayerTypeProvider
s to find the first suitable provider. Suitable means it does not return ILcyGXYLayerType.UNKNOWN. Providing the layer type is delegated to the first suitable provider.- Specified by:
getGXYLayerType
in interfaceILcyGXYLayerTypeProvider
- Parameters:
aGXYLayer
- The layer to provide the layer type of.- Returns:
- The layer type returned by the first suitable provider, or ILcyGXYLayerType.UNKNOWN if no such provider could be found.
- See Also:
-