Class TLcyCompositeGXYLayerFactory
- All Implemented Interfaces:
ILcdGXYLayerFactory
,Iterable<ILcdGXYLayerFactory>
Composite implementation (see composite design pattern) of ILcdGXYLayerFactory
. It
keeps a list of associated ILcdGXYLayerFactory
s: one can add and remove other
ILcdGXYLayerFactory
s to this ILcdGXYLayerFactory
. When it is asked to
create a layer, it loops over its associated ILcdGXYLayerFactory
s to find the first
one that returns a valid layer (means createGXYLayer does not return null). That layer will then be
returned.
When creating a new TLcyCompositeGXYLayerFactory
using the default
constructor (see TLcyCompositeGXYLayerFactory()
), the created instance will
only work on/with the ILcdGXYLayerFactorys registered
on this composite instance (see addGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory)
and removeGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory)
).
When creating a new TLcyCompositeGXYLayerFactory
using the constructor
specifying an ILcyLucyEnv
instance (see TLcyCompositeGXYLayerFactory(com.luciad.lucy.ILcyLucyEnv)
, the created instance will
work on the Lucy back-end services. It will use
all registered ILcdGXYLayerFactory instances of the
Lucy back-end, adding and/or removing an ILcdGXYLayerFactory
will
add/remove the ILcdGXYLayerFactory
as service from Lucy, ... .
Creating an ILcdGXYLayer
for an ILcdModel
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.
TLcyCompositeGXYLayerFactory factory = new TLcyCompositeGXYLayerFactory( aLucyEnv );
ILcdGXYLayer layer = factory.createGXYLayer( aModel );
//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
factory = null;
-
Field Summary
Fields inherited from class com.luciad.lucy.util.TLcyGenericComposite
PRIORITY_DEFAULT, PRIORITY_FALLBACK
-
Constructor Summary
ConstructorDescriptionDefault constructor.TLcyCompositeGXYLayerFactory
(ILcyLucyEnv aLucyEnv) Construct aTLcyCompositeGXYLayerFactory
working on the Lucy back-end -
Method Summary
Modifier and TypeMethodDescriptionvoid
addGXYLayerFactory
(ILcdGXYLayerFactory aGXYLayerFactory) Adds the givenILcdGXYLayerFactory
to this composite layer factory.createGXYLayer
(ILcdModel aModel) Implementation of ILcdGXYLayerFactory.createGXYLayer.getGXYLayerFactory
(int aIndex) Returns theILcdGXYLayerFactory
at the given index.int
Returns the number of currently registered layer factories.void
removeGXYLayerFactory
(ILcdGXYLayerFactory aGXYLayerFactory) Removes the givenILcdGXYLayerFactory
from this composite layer factory.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
-
TLcyCompositeGXYLayerFactory
public TLcyCompositeGXYLayerFactory()Default constructor. No
ILcdGXYLayerFactory
s are associated.The created instance will only work on the
ILcdGXYLayerFactory
instances registered to it. If you want to use all registeredILcdGXYLayerFactory
instances of the Lucy back-end, useTLcyCompositeGXYLayerFactory(com.luciad.lucy.ILcyLucyEnv)
instead.- See Also:
-
TLcyCompositeGXYLayerFactory
Construct a
TLcyCompositeGXYLayerFactory
working on the Lucy back-endIt will use all
ILcdGXYLayerFactory
instances registered to the back-end, and adding and/or removingILcdGXYLayerFactory
s to/from thisTLcyCompositeGXYLayerFactory
will respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeGXYLayerFactory
which does not use the back-end, useTLcyCompositeGXYLayerFactory()
instead.- Parameters:
aLucyEnv
- The Lucy back-end.- See Also:
-
-
Method Details
-
addGXYLayerFactory
Adds the given
ILcdGXYLayerFactory
to this composite layer factory. TheILcdGXYLayerFactory
should only createILcdGXYLayer
's forILcdModel
's it knows about. It should not simply create aILcdGXYLayer
for everyILcdModel
it gets passed in itscreateGXYLayer
, but instead verify if the givenILcdModel
is supported, e.g. by testing theILcdModelDescriptor
of theILcdModel
. If theILcdModel
passed in thecreateGXYLayer
method is not supported, it should return null as specified in theILcdGXYLayerFactory
interface.If the constructor specifying an
ILcyLucyEnv
is used, theILcdGXYLayerFactory
will be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
). When callingILcyLucyEnv.getServices(Class)
afterwards,aGXYLayerFactory
will only be included in the returned list when the requested class wasILcdGXYLayerFactory.class
.
Note: if you want to remove the registeredILcdGXYLayerFactory
afterwards, useremoveGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory)
and notILcyLucyEnv.removeService(Object)
.- Parameters:
aGXYLayerFactory
- The layer factory to add.- See Also:
-
removeGXYLayerFactory
Removes the given
ILcdGXYLayerFactory
from this composite layer factory. If the given layer factory was never added before, nothing happens.If the constructor specifying an
ILcyLucyEnv
is used, theILcdGXYLayerFactory
will be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)
).
Note: it is only possible to removeILcdGXYLayerFactory
instances which were registered using theaddGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory)
method.- Parameters:
aGXYLayerFactory
- The layer factory to remove.- See Also:
-
getGXYLayerFactoryCount
public int getGXYLayerFactoryCount()Returns the number of currently registered layer factories.
- Returns:
- The number of associated
ILcdGXYLayerFactory
s.
-
getGXYLayerFactory
Returns the
ILcdGXYLayerFactory
at the given index.- Returns:
- The associated
ILcdGXYLayerFactory
at the given index.
-
createGXYLayer
Implementation of ILcdGXYLayerFactory.createGXYLayer. Loops over all associatedILcdGXYLayerFactory
s to find the first suitable layer factory. A layer factory is considered suitable when the invocation of its createGXYLayer method does not return null.- Specified by:
createGXYLayer
in interfaceILcdGXYLayerFactory
- Parameters:
aModel
- The model to create a layer for.- Returns:
- The created layer, or null if no suitable layer factory could be found.
- See Also:
-