Class TLcyCompositeAsynchronousPaintHintProvider
- All Implemented Interfaces:
ILcyAsynchronousPaintHintProvider
,ILcdGXYAsynchronousPaintHintProvider
,Iterable<ILcyAsynchronousPaintHintProvider>
Composite (see composite design pattern) implementation of ILcyAsynchronousPaintHintProvider
.
It keeps a list of associated ILcyAsynchronousPaintHintProvider
s. 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
ConstructorDescriptionDefault constructor.Construct aTLcyCompositeAsynchronousPaintHintProvider
working on the Lucy back-end -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAsynchronousPaintHintProvider
(ILcyAsynchronousPaintHintProvider aPaintHintProvider) Adds the givenILcyAsynchronousPaintHintProvider
to the list of associated providers.getAsynchronousPaintHint
(ILcdLayer aLayer) Loops over all its associatedILcyAsynchronousPaintHintProvider
s to find the first suitable provider.getAsynchronousPaintHintProvider
(int aIndex) Returns the layer type provider at the given index.int
Returns the number of associated paint hint providers.Returns theTLcdGXYAsynchronousPaintHint
corresponding to the layeraLayer
.void
removeAsynchronousPaintHintProvider
(ILcyAsynchronousPaintHintProvider aGXYLayerTypeProvider) Removes the givenILcyAsynchronousPaintHintProvider
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
-
TLcyCompositeAsynchronousPaintHintProvider
public TLcyCompositeAsynchronousPaintHintProvider()Default constructor. No
ILcyAsynchronousPaintHintProvider
s are associated.The created instance will only work on the
ILcyAsynchronousPaintHintProvider
instances registered to it. If you want to use all registeredILcyAsynchronousPaintHintProvider
instances of the Lucy back-end, useTLcyCompositeAsynchronousPaintHintProvider(com.luciad.lucy.ILcyLucyEnv)
instead.- See Also:
-
TLcyCompositeAsynchronousPaintHintProvider
Construct a
TLcyCompositeAsynchronousPaintHintProvider
working on the Lucy back-endIt will use all
ILcyAsynchronousPaintHintProvider
instances registered to the back-end, and adding and/or removingILcyAsynchronousPaintHintProvider
s to/from thisTLcyCompositeAsynchronousPaintHintProvider
will respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeAsynchronousPaintHintProvider
which does not use the back-end, useTLcyCompositeAsynchronousPaintHintProvider()
instead.- Parameters:
aLucyEnv
- The Lucy back-end.- See Also:
-
-
Method Details
-
addAsynchronousPaintHintProvider
Adds the given
ILcyAsynchronousPaintHintProvider
to the list of associated providers.If the constructor specifying an
ILcyLucyEnv
is used, theILcyAsynchronousPaintHintProvider
will be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
). When callingILcyLucyEnv.getServices(Class)
afterwards,aPaintHintProvider
will only be included in the returned list when the requested class wasILcyAsynchronousPaintHintProvider.class
.
Note: if you want to remove the registeredILcyAsynchronousPaintHintProvider
afterwards, useremoveAsynchronousPaintHintProvider(ILcyAsynchronousPaintHintProvider)
and notILcyLucyEnv.removeService(Object)
.- Parameters:
aPaintHintProvider
- The provider to add.- See Also:
-
removeAsynchronousPaintHintProvider
public void removeAsynchronousPaintHintProvider(ILcyAsynchronousPaintHintProvider aGXYLayerTypeProvider) Removes the given
ILcyAsynchronousPaintHintProvider
from the list of associated providers. If the given provider was never added, nothing will happen.If the constructor specifying an
ILcyLucyEnv
is used, theILcyAsynchronousPaintHintProvider
will be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)
).
Note: it is only possible to removeILcyAsynchronousPaintHintProvider
instances 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 associatedILcyAsynchronousPaintHintProvider
s to find the first suitable provider. Suitable means it does not return null.- Specified by:
getAsynchronousPaintHint
in 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:ILcdGXYAsynchronousPaintHintProvider
Returns the
TLcdGXYAsynchronousPaintHint
corresponding to the layeraLayer
.Depending on the returned
TLcdGXYAsynchronousPaintHint
instances, it might be useful for implementations of this class to use a caching mechanism. This is however left to the implementation.- Specified by:
getPaintHint
in interfaceILcdGXYAsynchronousPaintHintProvider
- Parameters:
aLayer
- The layer to retrieve the paint hint for.- Returns:
- the paint hint
-