Class TLcyCompositeLayerStyleProvider
- All Implemented Interfaces:
ILcyLayerStyleProvider
,Iterable<ILcyLayerStyleProvider>
A composite implementation of ILcyModelContentTypeProvider
according to the
composite design pattern.
When creating a new TLcyCompositeLayerStyleProvider
using the default
constructor (see TLcyCompositeLayerStyleProvider()
), the created instance will
only work on/with the ILcyLayerStyleProviders registered
on this composite instance (see addLayerStyleProvider(ILcyLayerStyleProvider)
and removeLayerStyleProvider(ILcyLayerStyleProvider)
).
When creating a new TLcyCompositeLayerStyleProvider
using the constructor
specifying an ILcyLucyEnv
instance (see TLcyCompositeLayerStyleProvider(com.luciad.lucy.ILcyLucyEnv)
, the created instance will
work on the Lucy back-end services. It will use
all registered ILcyLayerStyleProvider instances of the
Lucy back-end, adding and/or removing an ILcyLayerStyleProvider
will
add/remove the ILcyLayerStyleProvider
as service from Lucy, ... .
Retrieving the style for an ILcdLayer
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.
TLcyCompositeLayerStyleProvider provider = new TLcyCompositeLayerStyleProvider( aLucyEnv );
if( provider.canGetStyle( aLayer ) ){
ILcyLayerStyle layerStyle = provider.getStyle( aLayer );
}
//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;
- Since:
- 10.0
-
Field Summary
Fields inherited from class com.luciad.lucy.util.TLcyGenericComposite
PRIORITY_DEFAULT, PRIORITY_FALLBACK
-
Constructor Summary
ConstructorDescriptionDefault constructor.TLcyCompositeLayerStyleProvider
(ILcyLucyEnv aLucyEnv) Construct aTLcyCompositeLayerStyleProvider
working on the Lucy back-end -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLayerStyleProvider
(ILcyLayerStyleProvider aLayerStyleProvider) Adds the givenILcyLayerStyleProvider
to the list of registered layer style providers.void
applyStyle
(ILcyLayerStyle aLayerStyle, ILcdLayer aLayerSFCT) Applies the given style to the given layer.boolean
canApplyStyle
(ILcyLayerStyle aLayerStyle, ILcdLayer aLayerSFCT) Returns true if the provider can apply the given style to the given layer.boolean
canGetStyle
(ILcdLayer aLayer) Returns true if the provider can return the given layer's style.getLayerStyleProvider
(int aIndex) Returns theILcyLayerStyleProvider
at indexaIndex
.int
Returns the number of registeredILcyLayerStyleProvider
instances.Returns the layer style of the given layer.void
removeLayerStyleProvider
(ILcyLayerStyleProvider aLayerStyleProvider) Removes the givenILcyLayerStyleProvider
from the list of registered layer style 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
-
TLcyCompositeLayerStyleProvider
public TLcyCompositeLayerStyleProvider()Default constructor.
The created instance will only work on the
ILcyLayerStyleProvider
instances registered to it. If you want to use all registeredILcyLayerStyleProvider
instances of the Lucy back-end, useTLcyCompositeLayerStyleProvider(com.luciad.lucy.ILcyLucyEnv)
instead.- See Also:
-
TLcyCompositeLayerStyleProvider
Construct a
TLcyCompositeLayerStyleProvider
working on the Lucy back-endIt will use all
ILcyLayerStyleProvider
instances registered to the back-end, and adding and/or removingILcyLayerStyleProvider
s to/from thisTLcyCompositeLayerStyleProvider
will respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeLayerStyleProvider
which does not use the back-end, useTLcyCompositeLayerStyleProvider()
instead.- Parameters:
aLucyEnv
- The Lucy back-end.- See Also:
-
-
Method Details
-
addLayerStyleProvider
Adds the given
ILcyLayerStyleProvider
to the list of registered layer style providers.If the constructor specifying an
ILcyLucyEnv
is used, theILcyLayerStyleProvider
will be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
). When callingILcyLucyEnv.getServices(Class)
afterwards,aLayerStyleProvider
will only be included in the returned list when the requested class wasILcyLayerStyleProvider.class
.
Note: if you want to remove the registeredILcyLayerStyleProvider
afterwards, useremoveLayerStyleProvider(ILcyLayerStyleProvider)
and notILcyLucyEnv.removeService(Object)
.- Parameters:
aLayerStyleProvider
- The layer style provider to add. Must not benull
.- See Also:
-
removeLayerStyleProvider
Removes the given
ILcyLayerStyleProvider
from the list of registered layer style providers. Nothing will happen if the given provider was never added before.If the constructor specifying an
ILcyLucyEnv
is used, theILcyLayerStyleProvider
will be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)
).
Note: it is only possible to removeILcyLayerStyleProvider
instances which were registered using theaddLayerStyleProvider(ILcyLayerStyleProvider)
method.- Parameters:
aLayerStyleProvider
- The layer style provider to remove. Must not benull
- See Also:
-
getStyle
Description copied from interface:ILcyLayerStyleProvider
Returns the layer style of the given layer. As a result, modifying this style after it has been retrieved updates the layer style.
When this
ILcyLayerStyleProvider
is unable to retrieve the layer's style,null
should be returned.- Specified by:
getStyle
in interfaceILcyLayerStyleProvider
- Parameters:
aLayer
- The layer to get the style from.- Returns:
- The style.
-
canGetStyle
Description copied from interface:ILcyLayerStyleProvider
Returns true if the provider can return the given layer's style.- Specified by:
canGetStyle
in interfaceILcyLayerStyleProvider
- Parameters:
aLayer
- the layer to get the style from- Returns:
- true if the provider can return the given layer's style, false otherwise.
- See Also:
-
applyStyle
Description copied from interface:ILcyLayerStyleProvider
Applies the given style to the given layer. As a result, the layer is modified to match the given style. Modifying the style object after it has been applied has no effect.- Specified by:
applyStyle
in interfaceILcyLayerStyleProvider
- Parameters:
aLayerStyle
- The style to apply.aLayerSFCT
- The layer to update.
-
canApplyStyle
Description copied from interface:ILcyLayerStyleProvider
Returns true if the provider can apply the given style to the given layer.- Specified by:
canApplyStyle
in interfaceILcyLayerStyleProvider
- Parameters:
aLayerStyle
- The style to apply.aLayerSFCT
- The layer to update.- Returns:
- true if the provider can apply the given style to the given layer, false otherwise
- See Also:
-
getLayerStyleProviderCount
public int getLayerStyleProviderCount()Returns the number of registeredILcyLayerStyleProvider
instances.- Returns:
- the number of registered
ILcyLayerStyleProvider
instances.
-
getLayerStyleProvider
Returns theILcyLayerStyleProvider
at indexaIndex
.- Parameters:
aIndex
- The index: 0 <= aIndex <getLayerStyleProviderCount()
- Returns:
- the
ILcyLayerStyleProvider
at indexaIndex
.
-