public class TLcyCompositeGXYLayerEncoder extends TLcyGenericComposite<TLcyGXYLayerEncoderHolder> implements ILcdGXYLayerEncoder
Composite implementation (see composite design pattern) of ILcdGXYLayerEncoder
. It
keeps a list of associated ILcdGXYLayerEncoder
s. When it is asked to encode a layer,
it loops over its associated ILcdGXYLayerEncoder
s to find a suitable
ILcdGXYLayerEncoder
. That ILcdGXYLayerEncoder
is asked to encode the
layer.
When creating a new TLcyCompositeGXYLayerEncoder
using the default constructor (see
TLcyCompositeGXYLayerEncoder()
, the created instance will only work on/with the ILcdGXYLayerEncoders registered on this composite instance (see addGXYLayerEncoder(com.luciad.view.gxy.ILcdGXYLayerEncoder, com.luciad.lucy.model.ALcyFileTypeDescriptor)
and removeGXYLayerEncoder(com.luciad.view.gxy.ILcdGXYLayerEncoder)
.
When creating a new TLcyCompositeGXYLayerEncoder
using the constructor specifying an
ILcyLucyEnv
instance (see TLcyCompositeGXYLayerEncoder(com.luciad.lucy.ILcyLucyEnv)
,
the created instance will work on the Lucy back-end services. It will use all registered ILcdGXYLayerEncoder instances of the Lucy back-end, adding and/or removing an
ILcdGXYLayerEncoder
will add/remove the ILcdGXYLayerEncoder
as service from Lucy, ... .
Decoding an ILcdGXYLayer
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
TLcyCompositeGXYLayerEncoder encoder = new TLcyCompositeGXYLayerEncoder( aLucyEnv );
if ( encoder.canEncodeGXYLayer( aGXYLayer, aDestinationName ) ){
try{
encoder.encodeGXYLayer( aGXYLayer, aDestinationName )
} catch ( IOException aIOException ){
//IOException during encoding
}
}
//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
encoder = null;
Note: the ILcdGXYLayerEncoder
s are not directly registered as service to
Lucy, but wrapped with a holder object.
This holder object allows to register the ILcdGXYLayerEncoder
with some extra
information like e.g. an ALcyFileTypeDescriptor
. Using a back-end based
TLcyCompositeGXYLayerEncoder
will only use the registered TLcyGXYLayerEncoderHolder
objects, and not for example an
ILcdGXYLayerEncoder
which was directly (=not wrapped) registered as a service .
TLcyGXYLayerEncoderHolder
PRIORITY_DEFAULT, PRIORITY_FALLBACK
Constructor and Description |
---|
TLcyCompositeGXYLayerEncoder()
Default constructor.
|
TLcyCompositeGXYLayerEncoder(ILcyLucyEnv aLucyEnv)
Construct a
TLcyCompositeGXYLayerEncoder working on the Lucy back-end. |
Modifier and Type | Method and Description |
---|---|
void |
addGXYLayerEncoder(ILcdGXYLayerEncoder aGXYLayerEncoder,
ALcyFileTypeDescriptor aFileTypeDescriptor)
Adds the given
ILcdGXYLayerEncoder to the list of associated
ILcdGXYLayerEncoder s. |
boolean |
canEncodeGXYLayer(ILcdGXYLayer aGXYLayer,
String aDestinationName)
Loops over its list of associated
ILcdGXYLayerEncoder s to find a suitable
ILcdGXYLayerEncoder . |
void |
encodeGXYLayer(ILcdGXYLayer aGXYLayer,
String aDestinationName)
Loops over its list of associated
ILcdGXYLayerEncoder s to find a suitable
ILcdGXYLayerEncoder . |
String |
getDisplayName()
Returns the display name of this encoder.
|
ALcyFileTypeDescriptor |
getFileTypeDescriptor(int aIndex)
Returns the layer encoder file type descriptor at the given index.
|
ILcdGXYLayerEncoder |
getGXYLayerEncoder(int aIndex)
Returns the
ILcdGXYLayerEncoder at the given index. |
int |
getGXYLayerEncoderCount()
Returns the number of associated
ILcdGXYLayerEncoder s. |
void |
removeGXYLayerEncoder(ILcdGXYLayerEncoder aGXYLayerEncoder)
Removes the given
ILcdGXYLayerEncoder from the list of associated
ILcdGXYLayerEncoder s. |
void |
setDisplayName(String aDisplayName)
Sets the display name of this encoder.
|
add, add, getList, getPriority, iterator, remove
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public TLcyCompositeGXYLayerEncoder()
Default constructor. No ILcdGXYLayerEncoder
s are associated.
The created instance will only work on the ILcdGXYLayerEncoder
instances
registered to it. If you want to use all registered ILcdGXYLayerEncoder
instances
of the Lucy back-end, use TLcyCompositeGXYLayerEncoder(com.luciad.lucy.ILcyLucyEnv)
instead.
public TLcyCompositeGXYLayerEncoder(ILcyLucyEnv aLucyEnv)
Construct a TLcyCompositeGXYLayerEncoder
working on the Lucy back-end.
It will use all ILcdGXYLayerEncoder
instances registered to the back-end, and
adding and/or removing ILcdGXYLayerEncoder
s to/from this
TLcyCompositeGXYLayerEncoder
will respectively add/remove it as service from the
back-end.
If you want to create a TLcyCompositeGXYLayerEncoder
which does not use the
back-end, use TLcyCompositeGXYLayerEncoder()
instead.
aLucyEnv
- The Lucy back-end.TLcyCompositeGXYLayerEncoder()
,
ILcyLucyEnv.addService(Object, int)
,
ILcyLucyEnv.removeService(Object)
public void addGXYLayerEncoder(ILcdGXYLayerEncoder aGXYLayerEncoder, ALcyFileTypeDescriptor aFileTypeDescriptor)
Adds the given ILcdGXYLayerEncoder
to the list of associated
ILcdGXYLayerEncoder
s.
If the constructor specifying an ILcyLucyEnv
is used, the
ALcyFileTypeDescriptor
and its associated ILcdGXYLayerEncoder
will be
registered on the Lucy back-end (see ILcyLucyEnv.addService(Object,
int)
by using an TLcyGXYLayerEncoderHolder
. When calling ILcyLucyEnv.getServices(Class)
afterwards, the holder objects will only be
returned when the requested class was TLcyGXYLayerEncoderHolder.class
.
Note: if you want to remove the registered ALcyFileTypeDescriptor
and its
associated ILcdGXYLayerEncoder
, use removeGXYLayerEncoder(com.luciad.view.gxy.ILcdGXYLayerEncoder)
and not ILcyLucyEnv.removeService(Object)
.
aGXYLayerEncoder
- The ILcdGXYLayerEncoder
to addaFileTypeDescriptor
- The file type descriptor describing which files this encoder can
handle.removeGXYLayerEncoder(com.luciad.view.gxy.ILcdGXYLayerEncoder)
public void removeGXYLayerEncoder(ILcdGXYLayerEncoder aGXYLayerEncoder)
Removes the given ILcdGXYLayerEncoder
from the list of associated
ILcdGXYLayerEncoder
s. Has no effect if the given ILcdGXYLayerEncoder
was never added.
If the constructor specifying an ILcyLucyEnv
is used, the
TLcyGXYLayerEncoderHolder
object containing the ILcdGXYLayerEncoder
aGXYLayerEncoder
will be removed as service from the Lucy back-end (see ILcyLucyEnv.removeService(Object)
).
Note: it is only possible to remove TLcyGXYLayerEncoderHolder
instances
which were registered using the addGXYLayerEncoder(com.luciad.view.gxy.ILcdGXYLayerEncoder,
com.luciad.lucy.model.ALcyFileTypeDescriptor)
method.
aGXYLayerEncoder
- The ILcdGXYLayerEncoder
to remove.addGXYLayerEncoder(com.luciad.view.gxy.ILcdGXYLayerEncoder, com.luciad.lucy.model.ALcyFileTypeDescriptor)
public int getGXYLayerEncoderCount()
ILcdGXYLayerEncoder
s.ILcdGXYLayerEncoder
s.getGXYLayerEncoder(int)
public ILcdGXYLayerEncoder getGXYLayerEncoder(int aIndex)
ILcdGXYLayerEncoder
at the given index.aIndex
- The index to retrieve the ILcdGXYLayerEncoder
at. 0 <= index
< getGXYLayerEncoderCount()ILcdGXYLayerEncoder
at the given index.getGXYLayerEncoderCount()
public ALcyFileTypeDescriptor getFileTypeDescriptor(int aIndex)
aIndex
- The index to retrieve the layer encoder file type descriptor for.getGXYLayerEncoderCount()
public String getDisplayName()
ILcdGXYLayerEncoder
getDisplayName
in interface ILcdGXYLayerEncoder
public void setDisplayName(String aDisplayName)
aDisplayName
- The new display name.getDisplayName()
public boolean canEncodeGXYLayer(ILcdGXYLayer aGXYLayer, String aDestinationName)
ILcdGXYLayerEncoder
s to find a suitable
ILcdGXYLayerEncoder
. Suitable means that when canExport is invoked, it does not
throw an exception and it returns true. If returns true if such a suitable
ILcdGXYLayerEncoder
could be found, false otherwise.canEncodeGXYLayer
in interface ILcdGXYLayerEncoder
aGXYLayer
- The layer to export.aDestinationName
- The destination name to export to.ILcdGXYLayerEncoder
could be found, false
otherwise.ILcdGXYLayerEncoder.encodeGXYLayer(com.luciad.view.gxy.ILcdGXYLayer, java.lang.String)
public void encodeGXYLayer(ILcdGXYLayer aGXYLayer, String aDestinationName) throws IOException
ILcdGXYLayerEncoder
s to find a suitable
ILcdGXYLayerEncoder
. Suitable means that canExport returns true. It delegates the
export to the first suitable ILcdGXYLayerEncoder
that was found.encodeGXYLayer
in interface ILcdGXYLayerEncoder
aGXYLayer
- The layer to export.aDestinationName
- The destination name to export to.IOException
- In case of io failure.ILcdGXYLayerEncoder.canEncodeGXYLayer(com.luciad.view.gxy.ILcdGXYLayer, java.lang.String)