public class TLcyCompositeFormatBarFactory extends ALcyFormatBarFactory
A composite implementation of ALcyFormatBarFactory
according to the
composite design pattern.
When creating a new TLcyCompositeFormatBarFactory
using the default
constructor (see TLcyCompositeFormatBarFactory()
), the created instance will
only work on/with the ALcyFormatBarFactorys registered
on this composite instance (see addFormatBarFactory(ALcyFormatBarFactory)
and removeFormatBarFactory(ALcyFormatBarFactory)
).
When creating a new TLcyCompositeFormatBarFactory
using the constructor
specifying an ILcyLucyEnv
instance (see TLcyCompositeFormatBarFactory(com.luciad.lucy.ILcyLucyEnv)
, the created instance will
work on the Lucy back-end services. It will use
all registered ALcyFormatBarFactory instances of the
Lucy back-end, adding and/or removing an ALcyFormatBarFactory
will
add/remove the ALcyFormatBarFactory
as service from Lucy, ... .
Creating an ALcyFormatBar
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.
TLcyCompositeFormatBarFactory factory = new TLcyCompositeFormatBarFactory( aLucyEnv );
if( factory.canCreateFormatBar( aView, aLayer ){
ALcyFormatBar bar = factory.createFormatBar( aView, 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
factory = null;
Constructor and Description |
---|
TLcyCompositeFormatBarFactory()
Default constructor.
|
TLcyCompositeFormatBarFactory(ILcyLucyEnv aLucyEnv)
Construct a
TLcyCompositeFormatBarFactory working on the Lucy back-end |
Modifier and Type | Method and Description |
---|---|
void |
addFormatBarFactory(ALcyFormatBarFactory aFormatBarFactory)
Adds the given
ALcyFormatBarFactory to the list of registered format bar
factories. |
void |
addFormatBarFactory(ALcyFormatBarFactory aFormatBarFactory,
int aPriority)
Adds the given
ALcyFormatBarFactory to the list of registered format bar
factories. |
boolean |
canCreateFormatBar(ILcdView aView,
ILcdLayer aLayer)
Returns
true if a ALcyFormatBar can be created for the given
parameters, false otherwise. |
ALcyFormatBar |
createFormatBar(ILcdView aView,
ILcdLayer aLayer)
Creates an
ALcyFormatBar for the given parameters. |
ALcyFormatBarFactory |
getFormatBarFactory(int aIndex)
Returns the
ALcyFormatBarFactory at index aIndex . |
int |
getFormatBarFactoryCount()
Returns the number of registered
ALcyFormatBarFactory instances. |
void |
removeFormatBarFactory(ALcyFormatBarFactory aFormatBarFactory)
Removes the given
ALcyFormatBarFactory from the list of registered format bar
factories. |
public TLcyCompositeFormatBarFactory()
Default constructor.
The created instance will only work on the ALcyFormatBarFactory
instances
registered to it. If you want to use all registered ALcyFormatBarFactory
instances
of the Lucy back-end, use TLcyCompositeFormatBarFactory(com.luciad.lucy.ILcyLucyEnv)
instead.
public TLcyCompositeFormatBarFactory(ILcyLucyEnv aLucyEnv)
Construct a TLcyCompositeFormatBarFactory
working on the Lucy back-end
It will use all ALcyFormatBarFactory
instances registered to the back-end, and
adding and/or removing ALcyFormatBarFactory
s to/from this
TLcyCompositeFormatBarFactory
will respectively add/remove it as service from the
back-end.
If you want to create a TLcyCompositeFormatBarFactory
which does not use the
back-end, use TLcyCompositeFormatBarFactory()
instead.
aLucyEnv
- The Lucy back-end.TLcyCompositeFormatBarFactory()
,
ILcyLucyEnv.addService(Object, int)
,
ILcyLucyEnv.removeService(Object)
public void addFormatBarFactory(ALcyFormatBarFactory aFormatBarFactory)
Adds the given ALcyFormatBarFactory
to the list of registered format bar
factories.
Equivalent of calling
addFormatBarFactory( aFormatBarFactory, ILcyLucyEnv.PRIORITY_DEFAULT );
aFormatBarFactory
- The format bar factory. Must not be null
removeFormatBarFactory(ALcyFormatBarFactory)
public void addFormatBarFactory(ALcyFormatBarFactory aFormatBarFactory, int aPriority)
Adds the given ALcyFormatBarFactory
to the list of registered format bar
factories.
If the constructor specifying an ILcyLucyEnv
is used, the
ALcyFormatBarFactory
will be registered as a service on the Lucy back-end (see
ILcyLucyEnv.addService(Object, int)
). When calling ILcyLucyEnv.getServices(Class)
afterwards, aFormatBarFactory
will
only be included in the returned list when the requested class was
ALcyFormatBarFactory.class
.
Note: if you want to remove the registered ALcyFormatBarFactory
afterwards,
use removeFormatBarFactory(ALcyFormatBarFactory)
and not ILcyLucyEnv.removeService(Object)
.
aFormatBarFactory
- The format bar factory. Must not be null
aPriority
- The priority for the instance. Lower values mean higher priorities. Services
with higher priority appear earlier in the list of results. Common values are
ILcyLucyEnv.PRIORITY_DEFAULT
and ILcyLucyEnv.PRIORITY_FALLBACK
removeFormatBarFactory(ALcyFormatBarFactory)
public void removeFormatBarFactory(ALcyFormatBarFactory aFormatBarFactory)
Removes the given ALcyFormatBarFactory
from the list of registered format bar
factories. Nothing will happen if the given provider was never added before.
If the constructor specifying an ILcyLucyEnv
is used, the
ALcyFormatBarFactory
will be removed as service from the Lucy back-end
(see ILcyLucyEnv.removeService(Object)
).
Note: it is only possible to remove ALcyFormatBarFactory
instances
which were registered using the addFormatBarFactory(ALcyFormatBarFactory)
method.
aFormatBarFactory
- The format bar factory. Must not be null
addFormatBarFactory(ALcyFormatBarFactory)
public boolean canCreateFormatBar(ILcdView aView, ILcdLayer aLayer)
ALcyFormatBarFactory
true
if a ALcyFormatBar
can be created for the given
parameters, false
otherwise.canCreateFormatBar
in class ALcyFormatBarFactory
aView
- The view to create the bar for. Cannot be null
.aLayer
- The layer to create this bar for. Can be null
. It is null if
a bar needs to be created before any layer of the format is available.true
if a ALcyFormatBar
can be created for the given
parameters, false
otherwise.public ALcyFormatBar createFormatBar(ILcdView aView, ILcdLayer aLayer)
ALcyFormatBarFactory
Creates an ALcyFormatBar
for the given parameters.
This method does not need to set the given layer to the created ALcyFormatBar
,
that is the responsibility of the user of this method.
createFormatBar
in class ALcyFormatBarFactory
aView
- The view to create the bar for. Cannot be null
.aLayer
- The layer to create this bar for. Can be null
. It is null if
a bar needs to be created before any layer of the format is available.ALcyFormatBar
.public int getFormatBarFactoryCount()
Returns the number of registered ALcyFormatBarFactory
instances.
ALcyFormatBarFactory
instances.public ALcyFormatBarFactory getFormatBarFactory(int aIndex)
Returns the ALcyFormatBarFactory
at index aIndex
.
aIndex
- The index: 0 <= aIndex < getFormatBarFactoryCount()
ALcyFormatBarFactory
at index aIndex
.