Class TLcyCompositeGXYLayerEncoder
- All Implemented Interfaces:
ILcdGXYLayerEncoder
,Iterable<TLcyGXYLayerEncoderHolder>
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 .
- See Also:
-
Field Summary
Fields inherited from class com.luciad.lucy.util.TLcyGenericComposite
PRIORITY_DEFAULT, PRIORITY_FALLBACK
-
Constructor Summary
ConstructorDescriptionDefault constructor.TLcyCompositeGXYLayerEncoder
(ILcyLucyEnv aLucyEnv) Construct aTLcyCompositeGXYLayerEncoder
working on the Lucy back-end. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addGXYLayerEncoder
(ILcdGXYLayerEncoder aGXYLayerEncoder, ALcyFileTypeDescriptor aFileTypeDescriptor) Adds the givenILcdGXYLayerEncoder
to the list of associatedILcdGXYLayerEncoder
s.boolean
canEncodeGXYLayer
(ILcdGXYLayer aGXYLayer, String aDestinationName) Loops over its list of associatedILcdGXYLayerEncoder
s to find a suitableILcdGXYLayerEncoder
.void
encodeGXYLayer
(ILcdGXYLayer aGXYLayer, String aDestinationName) Loops over its list of associatedILcdGXYLayerEncoder
s to find a suitableILcdGXYLayerEncoder
.Returns the display name of this encoder.getFileTypeDescriptor
(int aIndex) Returns the layer encoder file type descriptor at the given index.getGXYLayerEncoder
(int aIndex) Returns theILcdGXYLayerEncoder
at the given index.int
Returns the number of associatedILcdGXYLayerEncoder
s.void
removeGXYLayerEncoder
(ILcdGXYLayerEncoder aGXYLayerEncoder) Removes the givenILcdGXYLayerEncoder
from the list of associatedILcdGXYLayerEncoder
s.void
setDisplayName
(String aDisplayName) Sets the display name of this encoder.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
-
TLcyCompositeGXYLayerEncoder
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 registeredILcdGXYLayerEncoder
instances of the Lucy back-end, useTLcyCompositeGXYLayerEncoder(com.luciad.lucy.ILcyLucyEnv)
instead.- See Also:
-
TLcyCompositeGXYLayerEncoder
Construct a
TLcyCompositeGXYLayerEncoder
working on the Lucy back-end.It will use all
ILcdGXYLayerEncoder
instances registered to the back-end, and adding and/or removingILcdGXYLayerEncoder
s to/from thisTLcyCompositeGXYLayerEncoder
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, useTLcyCompositeGXYLayerEncoder()
instead.- Parameters:
aLucyEnv
- The Lucy back-end.- See Also:
-
-
Method Details
-
addGXYLayerEncoder
public void addGXYLayerEncoder(ILcdGXYLayerEncoder aGXYLayerEncoder, ALcyFileTypeDescriptor aFileTypeDescriptor) Adds the given
ILcdGXYLayerEncoder
to the list of associatedILcdGXYLayerEncoder
s.If the constructor specifying an
ILcyLucyEnv
is used, theALcyFileTypeDescriptor
and its associatedILcdGXYLayerEncoder
will be registered on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)
by using anTLcyGXYLayerEncoderHolder
. When callingILcyLucyEnv.getServices(Class)
afterwards, the holder objects will only be returned when the requested class wasTLcyGXYLayerEncoderHolder.class
.
Note: if you want to remove the registeredALcyFileTypeDescriptor
and its associatedILcdGXYLayerEncoder
, useremoveGXYLayerEncoder(com.luciad.view.gxy.ILcdGXYLayerEncoder)
and notILcyLucyEnv.removeService(Object)
.- Parameters:
aGXYLayerEncoder
- TheILcdGXYLayerEncoder
to addaFileTypeDescriptor
- The file type descriptor describing which files this encoder can handle.- See Also:
-
removeGXYLayerEncoder
Removes the given
ILcdGXYLayerEncoder
from the list of associatedILcdGXYLayerEncoder
s. Has no effect if the givenILcdGXYLayerEncoder
was never added.If the constructor specifying an
ILcyLucyEnv
is used, theTLcyGXYLayerEncoderHolder
object containing theILcdGXYLayerEncoder
aGXYLayerEncoder
will be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)
).
Note: it is only possible to removeTLcyGXYLayerEncoderHolder
instances which were registered using theaddGXYLayerEncoder(com.luciad.view.gxy.ILcdGXYLayerEncoder, com.luciad.lucy.model.ALcyFileTypeDescriptor)
method.- Parameters:
aGXYLayerEncoder
- TheILcdGXYLayerEncoder
to remove.- See Also:
-
getGXYLayerEncoderCount
public int getGXYLayerEncoderCount()Returns the number of associatedILcdGXYLayerEncoder
s.- Returns:
- the number of associated
ILcdGXYLayerEncoder
s. - See Also:
-
getGXYLayerEncoder
Returns theILcdGXYLayerEncoder
at the given index.- Parameters:
aIndex
- The index to retrieve theILcdGXYLayerEncoder
at. 0 <= index < getGXYLayerEncoderCount()- Returns:
- the
ILcdGXYLayerEncoder
at the given index. - See Also:
-
getFileTypeDescriptor
Returns the layer encoder file type descriptor at the given index. This descriptor is null if the encoder was added with null as a descriptor.- Parameters:
aIndex
- The index to retrieve the layer encoder file type descriptor for.- Returns:
- the layer encoder file type descriptor at the given index.
- See Also:
-
getDisplayName
Description copied from interface:ILcdGXYLayerEncoder
Returns the display name of this encoder.- Specified by:
getDisplayName
in interfaceILcdGXYLayerEncoder
- Returns:
- the display name of this encoder.
-
setDisplayName
Sets the display name of this encoder.- Parameters:
aDisplayName
- The new display name.- See Also:
-
canEncodeGXYLayer
Loops over its list of associatedILcdGXYLayerEncoder
s to find a suitableILcdGXYLayerEncoder
. Suitable means that when canExport is invoked, it does not throw an exception and it returns true. If returns true if such a suitableILcdGXYLayerEncoder
could be found, false otherwise.- Specified by:
canEncodeGXYLayer
in interfaceILcdGXYLayerEncoder
- Parameters:
aGXYLayer
- The layer to export.aDestinationName
- The destination name to export to.- Returns:
- True if such a suitable
ILcdGXYLayerEncoder
could be found, false otherwise. - See Also:
-
encodeGXYLayer
Loops over its list of associatedILcdGXYLayerEncoder
s to find a suitableILcdGXYLayerEncoder
. Suitable means that canExport returns true. It delegates the export to the first suitableILcdGXYLayerEncoder
that was found.- Specified by:
encodeGXYLayer
in interfaceILcdGXYLayerEncoder
- Parameters:
aGXYLayer
- The layer to export.aDestinationName
- The destination name to export to.- Throws:
IOException
- In case of io failure.- See Also:
-