Class TLcyCompositeAsynchronousPaintHintProvider
- All Implemented Interfaces:
ILcyAsynchronousPaintHintProvider,ILcdGXYAsynchronousPaintHintProvider,Iterable<ILcyAsynchronousPaintHintProvider>
Composite (see composite design pattern) implementation of ILcyAsynchronousPaintHintProvider.
It keeps a list of associated ILcyAsynchronousPaintHintProviders. When it needs to
provide an asynchronous paint hint, it will delegate to the first suitable paint hint provider.
When creating a new TLcyCompositeAsynchronousPaintHintProvider using the default
constructor (see TLcyCompositeAsynchronousPaintHintProvider()), the created instance will
only work on/with the ILcyAsynchronousPaintHintProviders registered
on this composite instance (see addAsynchronousPaintHintProvider(ILcyAsynchronousPaintHintProvider)
and removeAsynchronousPaintHintProvider(ILcyAsynchronousPaintHintProvider)).
When creating a new TLcyCompositeAsynchronousPaintHintProvider using the constructor
specifying an ILcyLucyEnv instance (see TLcyCompositeAsynchronousPaintHintProvider(com.luciad.lucy.ILcyLucyEnv), the created instance will
work on the Lucy back-end services. It will use
all registered ILcyAsynchronousPaintHintProvider instances of the
Lucy back-end, adding and/or removing an ILcyAsynchronousPaintHintProvider will
add/remove the ILcyAsynchronousPaintHintProvider as service from Lucy, ... .
Retrieving the paint hint 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.
TLcyCompositeAsynchronousPaintHintProvider provider = new TLcyCompositeAsynchronousPaintHintProvider( aLucyEnv );
TLcyAsynchronousPaintHint paintHint = provider.getAsynchronousPaintHint( 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;
-
Field Summary
Fields inherited from class com.luciad.lucy.util.TLcyGenericComposite
PRIORITY_DEFAULT, PRIORITY_FALLBACK -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Construct aTLcyCompositeAsynchronousPaintHintProviderworking on the Lucy back-end -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAsynchronousPaintHintProvider(ILcyAsynchronousPaintHintProvider aPaintHintProvider) Adds the givenILcyAsynchronousPaintHintProviderto the list of associated providers.getAsynchronousPaintHint(ILcdLayer aLayer) Loops over all its associatedILcyAsynchronousPaintHintProviders to find the first suitable provider.getAsynchronousPaintHintProvider(int aIndex) Returns the layer type provider at the given index.intReturns the number of associated paint hint providers.Returns theTLcdGXYAsynchronousPaintHintcorresponding to the layeraLayer.voidremoveAsynchronousPaintHintProvider(ILcyAsynchronousPaintHintProvider aGXYLayerTypeProvider) Removes the givenILcyAsynchronousPaintHintProviderfrom the list of associated 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
-
TLcyCompositeAsynchronousPaintHintProvider
public TLcyCompositeAsynchronousPaintHintProvider()Default constructor. No
ILcyAsynchronousPaintHintProviders are associated.The created instance will only work on the
ILcyAsynchronousPaintHintProviderinstances registered to it. If you want to use all registeredILcyAsynchronousPaintHintProviderinstances of the Lucy back-end, useTLcyCompositeAsynchronousPaintHintProvider(com.luciad.lucy.ILcyLucyEnv)instead.- See Also:
-
TLcyCompositeAsynchronousPaintHintProvider
Construct a
TLcyCompositeAsynchronousPaintHintProviderworking on the Lucy back-endIt will use all
ILcyAsynchronousPaintHintProviderinstances registered to the back-end, and adding and/or removingILcyAsynchronousPaintHintProviders to/from thisTLcyCompositeAsynchronousPaintHintProviderwill respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeAsynchronousPaintHintProviderwhich does not use the back-end, useTLcyCompositeAsynchronousPaintHintProvider()instead.- Parameters:
aLucyEnv- The Lucy back-end.- See Also:
-
-
Method Details
-
addAsynchronousPaintHintProvider
Adds the given
ILcyAsynchronousPaintHintProviderto the list of associated providers.If the constructor specifying an
ILcyLucyEnvis used, theILcyAsynchronousPaintHintProviderwill be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)). When callingILcyLucyEnv.getServices(Class)afterwards,aPaintHintProviderwill only be included in the returned list when the requested class wasILcyAsynchronousPaintHintProvider.class.
Note: if you want to remove the registeredILcyAsynchronousPaintHintProviderafterwards, useremoveAsynchronousPaintHintProvider(ILcyAsynchronousPaintHintProvider)and notILcyLucyEnv.removeService(Object).- Parameters:
aPaintHintProvider- The provider to add.- See Also:
-
removeAsynchronousPaintHintProvider
public void removeAsynchronousPaintHintProvider(ILcyAsynchronousPaintHintProvider aGXYLayerTypeProvider) Removes the given
ILcyAsynchronousPaintHintProviderfrom the list of associated providers. If the given provider was never added, nothing will happen.If the constructor specifying an
ILcyLucyEnvis used, theILcyAsynchronousPaintHintProviderwill be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)).
Note: it is only possible to removeILcyAsynchronousPaintHintProviderinstances which were registered using theaddAsynchronousPaintHintProvider(ILcyAsynchronousPaintHintProvider)method.- Parameters:
aGXYLayerTypeProvider- The provider to remove.- See Also:
-
getAsynchronousPaintHintProviderCount
public int getAsynchronousPaintHintProviderCount()Returns the number of associated paint hint providers.- Returns:
- the number of associated paint hint providers.
- See Also:
-
getAsynchronousPaintHintProvider
Returns the layer type provider at the given index.- Parameters:
aIndex- The index of the provider to retrieve. 0 <= aIndex <getAsynchronousPaintHintProviderCount()- Returns:
- the layer type provider at the given index.
- See Also:
-
getAsynchronousPaintHint
Loops over all its associatedILcyAsynchronousPaintHintProviders to find the first suitable provider. Suitable means it does not return null.- Specified by:
getAsynchronousPaintHintin interfaceILcyAsynchronousPaintHintProvider- Parameters:
aLayer- The layer to provide the layer type of.- Returns:
- The asynchronous paint hint returned by the first suitable provider, or null if no such provider could be found.
- See Also:
-
getPaintHint
Description copied from interface:ILcdGXYAsynchronousPaintHintProviderReturns the
TLcdGXYAsynchronousPaintHintcorresponding to the layeraLayer.Depending on the returned
TLcdGXYAsynchronousPaintHintinstances, it might be useful for implementations of this class to use a caching mechanism. This is however left to the implementation.- Specified by:
getPaintHintin interfaceILcdGXYAsynchronousPaintHintProvider- Parameters:
aLayer- The layer to retrieve the paint hint for.- Returns:
- the paint hint
-