Class TLcyCompositeGXYLayerFactory
- All Implemented Interfaces:
ILcdGXYLayerFactory,Iterable<ILcdGXYLayerFactory>
Composite implementation (see composite design pattern) of ILcdGXYLayerFactory. It
keeps a list of associated ILcdGXYLayerFactorys: one can add and remove other
ILcdGXYLayerFactorys to this ILcdGXYLayerFactory. When it is asked to
create a layer, it loops over its associated ILcdGXYLayerFactorys 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
ConstructorsConstructorDescriptionDefault constructor.TLcyCompositeGXYLayerFactory(ILcyLucyEnv aLucyEnv) Construct aTLcyCompositeGXYLayerFactoryworking on the Lucy back-end -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGXYLayerFactory(ILcdGXYLayerFactory aGXYLayerFactory) Adds the givenILcdGXYLayerFactoryto this composite layer factory.createGXYLayer(ILcdModel aModel) Implementation of ILcdGXYLayerFactory.createGXYLayer.getGXYLayerFactory(int aIndex) Returns theILcdGXYLayerFactoryat the given index.intReturns the number of currently registered layer factories.voidremoveGXYLayerFactory(ILcdGXYLayerFactory aGXYLayerFactory) Removes the givenILcdGXYLayerFactoryfrom this composite layer factory.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
-
TLcyCompositeGXYLayerFactory
public TLcyCompositeGXYLayerFactory()Default constructor. No
ILcdGXYLayerFactorys are associated.The created instance will only work on the
ILcdGXYLayerFactoryinstances registered to it. If you want to use all registeredILcdGXYLayerFactoryinstances of the Lucy back-end, useTLcyCompositeGXYLayerFactory(com.luciad.lucy.ILcyLucyEnv)instead.- See Also:
-
TLcyCompositeGXYLayerFactory
Construct a
TLcyCompositeGXYLayerFactoryworking on the Lucy back-endIt will use all
ILcdGXYLayerFactoryinstances registered to the back-end, and adding and/or removingILcdGXYLayerFactorys to/from thisTLcyCompositeGXYLayerFactorywill respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeGXYLayerFactorywhich does not use the back-end, useTLcyCompositeGXYLayerFactory()instead.- Parameters:
aLucyEnv- The Lucy back-end.- See Also:
-
-
Method Details
-
addGXYLayerFactory
Adds the given
ILcdGXYLayerFactoryto this composite layer factory. TheILcdGXYLayerFactoryshould only createILcdGXYLayer's forILcdModel's it knows about. It should not simply create aILcdGXYLayerfor everyILcdModelit gets passed in itscreateGXYLayer, but instead verify if the givenILcdModelis supported, e.g. by testing theILcdModelDescriptorof theILcdModel. If theILcdModelpassed in thecreateGXYLayermethod is not supported, it should return null as specified in theILcdGXYLayerFactoryinterface.If the constructor specifying an
ILcyLucyEnvis used, theILcdGXYLayerFactorywill be registered as a service on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)). When callingILcyLucyEnv.getServices(Class)afterwards,aGXYLayerFactorywill only be included in the returned list when the requested class wasILcdGXYLayerFactory.class.
Note: if you want to remove the registeredILcdGXYLayerFactoryafterwards, useremoveGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory)and notILcyLucyEnv.removeService(Object).- Parameters:
aGXYLayerFactory- The layer factory to add.- See Also:
-
removeGXYLayerFactory
Removes the given
ILcdGXYLayerFactoryfrom this composite layer factory. If the given layer factory was never added before, nothing happens.If the constructor specifying an
ILcyLucyEnvis used, theILcdGXYLayerFactorywill be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)).
Note: it is only possible to removeILcdGXYLayerFactoryinstances 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
ILcdGXYLayerFactorys.
-
getGXYLayerFactory
Returns the
ILcdGXYLayerFactoryat the given index.- Returns:
- The associated
ILcdGXYLayerFactoryat the given index.
-
createGXYLayer
Implementation of ILcdGXYLayerFactory.createGXYLayer. Loops over all associatedILcdGXYLayerFactorys 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:
createGXYLayerin 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:
-