Class TLcyCompositeGXYLayerEncoder
- All Implemented Interfaces:
ILcdGXYLayerEncoder,Iterable<TLcyGXYLayerEncoderHolder>
Composite implementation (see composite design pattern) of ILcdGXYLayerEncoder. It
keeps a list of associated ILcdGXYLayerEncoders. When it is asked to encode a layer,
it loops over its associated ILcdGXYLayerEncoders 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 ILcdGXYLayerEncoders 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
ConstructorsConstructorDescriptionDefault constructor.TLcyCompositeGXYLayerEncoder(ILcyLucyEnv aLucyEnv) Construct aTLcyCompositeGXYLayerEncoderworking on the Lucy back-end. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGXYLayerEncoder(ILcdGXYLayerEncoder aGXYLayerEncoder, ALcyFileTypeDescriptor aFileTypeDescriptor) Adds the givenILcdGXYLayerEncoderto the list of associatedILcdGXYLayerEncoders.booleancanEncodeGXYLayer(ILcdGXYLayer aGXYLayer, String aDestinationName) Loops over its list of associatedILcdGXYLayerEncoders to find a suitableILcdGXYLayerEncoder.voidencodeGXYLayer(ILcdGXYLayer aGXYLayer, String aDestinationName) Loops over its list of associatedILcdGXYLayerEncoders 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 theILcdGXYLayerEncoderat the given index.intReturns the number of associatedILcdGXYLayerEncoders.voidremoveGXYLayerEncoder(ILcdGXYLayerEncoder aGXYLayerEncoder) Removes the givenILcdGXYLayerEncoderfrom the list of associatedILcdGXYLayerEncoders.voidsetDisplayName(String aDisplayName) Sets the display name of this encoder.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
-
TLcyCompositeGXYLayerEncoder
public TLcyCompositeGXYLayerEncoder()Default constructor. No
ILcdGXYLayerEncoders are associated.The created instance will only work on the
ILcdGXYLayerEncoderinstances registered to it. If you want to use all registeredILcdGXYLayerEncoderinstances of the Lucy back-end, useTLcyCompositeGXYLayerEncoder(com.luciad.lucy.ILcyLucyEnv)instead.- See Also:
-
TLcyCompositeGXYLayerEncoder
Construct a
TLcyCompositeGXYLayerEncoderworking on the Lucy back-end.It will use all
ILcdGXYLayerEncoderinstances registered to the back-end, and adding and/or removingILcdGXYLayerEncoders to/from thisTLcyCompositeGXYLayerEncoderwill respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeGXYLayerEncoderwhich 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
ILcdGXYLayerEncoderto the list of associatedILcdGXYLayerEncoders.If the constructor specifying an
ILcyLucyEnvis used, theALcyFileTypeDescriptorand its associatedILcdGXYLayerEncoderwill 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 registeredALcyFileTypeDescriptorand its associatedILcdGXYLayerEncoder, useremoveGXYLayerEncoder(com.luciad.view.gxy.ILcdGXYLayerEncoder)and notILcyLucyEnv.removeService(Object).- Parameters:
aGXYLayerEncoder- TheILcdGXYLayerEncoderto addaFileTypeDescriptor- The file type descriptor describing which files this encoder can handle.- See Also:
-
removeGXYLayerEncoder
Removes the given
ILcdGXYLayerEncoderfrom the list of associatedILcdGXYLayerEncoders. Has no effect if the givenILcdGXYLayerEncoderwas never added.If the constructor specifying an
ILcyLucyEnvis used, theTLcyGXYLayerEncoderHolderobject containing theILcdGXYLayerEncoderaGXYLayerEncoderwill be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)).
Note: it is only possible to removeTLcyGXYLayerEncoderHolderinstances which were registered using theaddGXYLayerEncoder(com.luciad.view.gxy.ILcdGXYLayerEncoder, com.luciad.lucy.model.ALcyFileTypeDescriptor)method.- Parameters:
aGXYLayerEncoder- TheILcdGXYLayerEncoderto remove.- See Also:
-
getGXYLayerEncoderCount
public int getGXYLayerEncoderCount()Returns the number of associatedILcdGXYLayerEncoders.- Returns:
- the number of associated
ILcdGXYLayerEncoders. - See Also:
-
getGXYLayerEncoder
Returns theILcdGXYLayerEncoderat the given index.- Parameters:
aIndex- The index to retrieve theILcdGXYLayerEncoderat. 0 <= index < getGXYLayerEncoderCount()- Returns:
- the
ILcdGXYLayerEncoderat 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:ILcdGXYLayerEncoderReturns the display name of this encoder.- Specified by:
getDisplayNamein 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 associatedILcdGXYLayerEncoders 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 suitableILcdGXYLayerEncodercould be found, false otherwise.- Specified by:
canEncodeGXYLayerin interfaceILcdGXYLayerEncoder- Parameters:
aGXYLayer- The layer to export.aDestinationName- The destination name to export to.- Returns:
- True if such a suitable
ILcdGXYLayerEncodercould be found, false otherwise. - See Also:
-
encodeGXYLayer
Loops over its list of associatedILcdGXYLayerEncoders to find a suitableILcdGXYLayerEncoder. Suitable means that canExport returns true. It delegates the export to the first suitableILcdGXYLayerEncoderthat was found.- Specified by:
encodeGXYLayerin interfaceILcdGXYLayerEncoder- Parameters:
aGXYLayer- The layer to export.aDestinationName- The destination name to export to.- Throws:
IOException- In case of io failure.- See Also:
-