public class TLcyCompositeGXYLayerFactory extends TLcyGenericComposite<ILcdGXYLayerFactory> implements 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;
PRIORITY_DEFAULT, PRIORITY_FALLBACK
Constructor and Description |
---|
TLcyCompositeGXYLayerFactory()
Default constructor.
|
TLcyCompositeGXYLayerFactory(ILcyLucyEnv aLucyEnv)
Construct a
TLcyCompositeGXYLayerFactory working on the Lucy back-end |
Modifier and Type | Method and Description |
---|---|
void |
addGXYLayerFactory(ILcdGXYLayerFactory aGXYLayerFactory)
Adds the given
ILcdGXYLayerFactory to this composite layer factory. |
ILcdGXYLayer |
createGXYLayer(ILcdModel aModel)
Implementation of ILcdGXYLayerFactory.createGXYLayer.
|
ILcdGXYLayerFactory |
getGXYLayerFactory(int aIndex)
Returns the
ILcdGXYLayerFactory at the given index. |
int |
getGXYLayerFactoryCount()
Returns the number of currently registered layer factories.
|
void |
removeGXYLayerFactory(ILcdGXYLayerFactory aGXYLayerFactory)
Removes the given
ILcdGXYLayerFactory from this composite layer factory. |
add, add, getList, getPriority, iterator, remove
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
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 registered ILcdGXYLayerFactory
instances of the Lucy back-end, use TLcyCompositeGXYLayerFactory(com.luciad.lucy.ILcyLucyEnv)
instead.
public TLcyCompositeGXYLayerFactory(ILcyLucyEnv aLucyEnv)
Construct a TLcyCompositeGXYLayerFactory
working on the Lucy back-end
It will use all ILcdGXYLayerFactory
instances registered to the back-end, and
adding and/or removing ILcdGXYLayerFactory
s to/from this
TLcyCompositeGXYLayerFactory
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, use TLcyCompositeGXYLayerFactory()
instead.
aLucyEnv
- The Lucy back-end.TLcyCompositeGXYLayerFactory()
,
ILcyLucyEnv.addService(Object, int)
,
ILcyLucyEnv.removeService(Object)
public void addGXYLayerFactory(ILcdGXYLayerFactory aGXYLayerFactory)
Adds the given ILcdGXYLayerFactory
to this composite layer factory. The
ILcdGXYLayerFactory
should only create ILcdGXYLayer
's for
ILcdModel
's it knows about. It should not simply create a
ILcdGXYLayer
for every ILcdModel
it gets passed in its
createGXYLayer
, but instead verify if the given ILcdModel
is
supported, e.g. by testing the ILcdModelDescriptor
of the ILcdModel
.
If the ILcdModel
passed in the createGXYLayer
method is not
supported, it should return null as specified in the ILcdGXYLayerFactory
interface.
If the constructor specifying an ILcyLucyEnv
is used, the
ILcdGXYLayerFactory
will be registered as a service on the Lucy back-end
(see ILcyLucyEnv.addService(Object, int)
). When calling ILcyLucyEnv.getServices(Class)
afterwards, aGXYLayerFactory
will only be included in the returned list when the requested class was
ILcdGXYLayerFactory.class
.
Note: if you want to remove the registered ILcdGXYLayerFactory
afterwards, use removeGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory)
and not
ILcyLucyEnv.removeService(Object)
.
aGXYLayerFactory
- The layer factory to add.removeGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory)
public void removeGXYLayerFactory(ILcdGXYLayerFactory aGXYLayerFactory)
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, the
ILcdGXYLayerFactory
will be removed as service from the Lucy back-end
(see ILcyLucyEnv.removeService(Object)
).
Note: it is only possible to remove ILcdGXYLayerFactory
instances
which were registered using the addGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory)
method.
aGXYLayerFactory
- The layer factory to remove.addGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory)
public int getGXYLayerFactoryCount()
Returns the number of currently registered layer factories.
ILcdGXYLayerFactory
s.public ILcdGXYLayerFactory getGXYLayerFactory(int aIndex)
Returns the ILcdGXYLayerFactory
at the given index.
ILcdGXYLayerFactory
at the given index.public ILcdGXYLayer createGXYLayer(ILcdModel aModel)
ILcdGXYLayerFactory
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.createGXYLayer
in interface ILcdGXYLayerFactory
aModel
- The model to create a layer for.TLcdGXYViewJPanel.setGXYLayerFactory(com.luciad.view.gxy.ILcdGXYLayerFactory)