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
ConstructorsConstructorDescriptionDefault constructor.TLcyCompositeLayerStyleProvider(ILcyLucyEnv aLucyEnv) Construct aTLcyCompositeLayerStyleProviderworking on the Lucy back-end -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLayerStyleProvider(ILcyLayerStyleProvider aLayerStyleProvider) Adds the givenILcyLayerStyleProviderto the list of registered layer style providers.voidapplyStyle(ILcyLayerStyle aLayerStyle, ILcdLayer aLayerSFCT) Applies the given style to the given layer.booleancanApplyStyle(ILcyLayerStyle aLayerStyle, ILcdLayer aLayerSFCT) Returns true if the provider can apply the given style to the given layer.booleancanGetStyle(ILcdLayer aLayer) Returns true if the provider can return the given layer's style.getLayerStyleProvider(int aIndex) Returns theILcyLayerStyleProviderat indexaIndex.intReturns the number of registeredILcyLayerStyleProviderinstances.Returns the layer style of the given layer.voidremoveLayerStyleProvider(ILcyLayerStyleProvider aLayerStyleProvider) Removes the givenILcyLayerStyleProviderfrom the list of registered layer style providers.Methods inherited from class com.luciad.lucy.util.TLcyGenericComposite
add, add, getList, getPriority, iterator, removeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TLcyCompositeLayerStyleProvider
public TLcyCompositeLayerStyleProvider()Default constructor.
The created instance will only work on the
ILcyLayerStyleProviderinstances registered to it. If you want to use all registeredILcyLayerStyleProviderinstances of the Lucy back-end, useTLcyCompositeLayerStyleProvider(com.luciad.lucy.ILcyLucyEnv)instead.- See Also:
-
TLcyCompositeLayerStyleProvider
Construct a
TLcyCompositeLayerStyleProviderworking on the Lucy back-endIt will use all
ILcyLayerStyleProviderinstances registered to the back-end, and adding and/or removingILcyLayerStyleProviders to/from thisTLcyCompositeLayerStyleProviderwill respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeLayerStyleProviderwhich does not use the back-end, useTLcyCompositeLayerStyleProvider()instead.- Parameters:
aLucyEnv- The Lucy back-end.- See Also:
-
-
Method Details
-
addLayerStyleProvider
Adds the given
ILcyLayerStyleProviderto the list of registered layer style providers.If the constructor specifying an
ILcyLucyEnvis used, theILcyLayerStyleProviderwill be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)). When callingILcyLucyEnv.getServices(Class)afterwards,aLayerStyleProviderwill only be included in the returned list when the requested class wasILcyLayerStyleProvider.class.
Note: if you want to remove the registeredILcyLayerStyleProviderafterwards, useremoveLayerStyleProvider(ILcyLayerStyleProvider)and notILcyLucyEnv.removeService(Object).- Parameters:
aLayerStyleProvider- The layer style provider to add. Must not benull.- See Also:
-
removeLayerStyleProvider
Removes the given
ILcyLayerStyleProviderfrom the list of registered layer style providers. Nothing will happen if the given provider was never added before.If the constructor specifying an
ILcyLucyEnvis used, theILcyLayerStyleProviderwill be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)).
Note: it is only possible to removeILcyLayerStyleProviderinstances 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:ILcyLayerStyleProviderReturns the layer style of the given layer. As a result, modifying this style after it has been retrieved updates the layer style.
When this
ILcyLayerStyleProvideris unable to retrieve the layer's style,nullshould be returned.- Specified by:
getStylein interfaceILcyLayerStyleProvider- Parameters:
aLayer- The layer to get the style from.- Returns:
- The style.
-
canGetStyle
Description copied from interface:ILcyLayerStyleProviderReturns true if the provider can return the given layer's style.- Specified by:
canGetStylein 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:ILcyLayerStyleProviderApplies 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:
applyStylein interfaceILcyLayerStyleProvider- Parameters:
aLayerStyle- The style to apply.aLayerSFCT- The layer to update.
-
canApplyStyle
Description copied from interface:ILcyLayerStyleProviderReturns true if the provider can apply the given style to the given layer.- Specified by:
canApplyStylein 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 registeredILcyLayerStyleProviderinstances.- Returns:
- the number of registered
ILcyLayerStyleProviderinstances.
-
getLayerStyleProvider
Returns theILcyLayerStyleProviderat indexaIndex.- Parameters:
aIndex- The index: 0 <= aIndex <getLayerStyleProviderCount()- Returns:
- the
ILcyLayerStyleProviderat indexaIndex.
-