Class TLcyCompositeGXYLayerDecoder
- All Implemented Interfaces:
ILcdGXYLayerDecoder,Iterable<TLcyGXYLayerDecoderHolder>
Composite implementation (see composite design pattern) of ILcdGXYLayerDecoder. It
keeps a list of associated ILcdGXYLayerDecoders. When it is asked to create a layer,
it loops over its associated ILcdGXYLayerDecoders to find a suitable
ILcdGXYLayerDecoder. That ILcdGXYLayerDecoder is asked to create a
layer.
When creating a new TLcyCompositeGXYLayerDecoder using the default constructor (see
TLcyCompositeGXYLayerDecoder(), the created instance will only work on/with the ILcdGXYLayerDecoders registered on this composite instance (see addGXYLayerDecoder(com.luciad.view.gxy.ILcdGXYLayerDecoder, com.luciad.lucy.model.ALcyFileTypeDescriptor) and removeGXYLayerDecoder(com.luciad.view.gxy.ILcdGXYLayerDecoder).
When creating a new TLcyCompositeGXYLayerDecoder using the constructor specifying an
ILcyLucyEnv instance (see TLcyCompositeGXYLayerDecoder(com.luciad.lucy.ILcyLucyEnv),
the created instance will work on the Lucy back-end services. It will use all registered ILcdGXYLayerDecoder instances of the Lucy back-end, adding and/or removing an
ILcdGXYLayerDecoder will add/remove the ILcdGXYLayerDecoder 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
TLcyCompositeGXYLayerDecoder decoder = new TLcyCompositeGXYLayerDecoder( aLucyEnv );
if ( decoder.canDecodeGXYLayer( aModel, aSourceName ) ){
try{
ILcdGXYLayer layer = decoder.decodeGXYLayer( aModel, aSourceName );
} catch ( IOException aIOException ){
//IOException during decoding
}
}
//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
decoder = null;
Note: the ILcdGXYLayerDecoders are not directly registered as service to
Lucy, but wrapped with a holder object.
This holder object allows to register the ILcdGXYLayerDecoder with some extra
information like e.g. an ALcyFileTypeDescriptor. Using a back-end based
TLcyCompositeGXYLayerDecoder will only use the registered TLcyGXYLayerDecoderHolder objects, and not for example an
ILcdGXYLayerDecoder 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.TLcyCompositeGXYLayerDecoder(ILcyLucyEnv aLucyEnv) Construct aTLcyCompositeGXYLayerDecoderworking on the Lucy back-end. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGXYLayerDecoder(ILcdGXYLayerDecoder aGXYLayerDecoder, ALcyFileTypeDescriptor aFileTypeDescriptor) Adds the givenILcdGXYLayerDecoderto the list of associatedILcdGXYLayerDecoders.booleancanDecodeGXYLayer(ILcdModel aModel, String aSourceName) Loops over its list of associatedILcdGXYLayerDecoders to find a suitableILcdGXYLayerDecoder.decodeGXYLayer(ILcdModel aModel, String aSourceName) Loops over its associated list ofILcdGXYLayerDecoders to find a suitableILcdGXYLayerDecoder.Returns the display name of this encoder.getFileTypeDescriptor(int aIndex) Retrieves the layer decoder file type descriptor at the given index.getGXYLayerDecoder(int aIndex) Returns theILcdGXYLayerDecoderat the given index.intReturns the number ofILcdGXYLayerDecoders.voidremoveGXYLayerDecoder(ILcdGXYLayerDecoder aGXYLayerDecoder) Removes the givenILcdGXYLayerDecoderfrom the list of associatedILcdGXYLayerDecoders.voidsetDisplayName(String aDisplayName) Sets the display name of this decoder.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
-
TLcyCompositeGXYLayerDecoder
public TLcyCompositeGXYLayerDecoder()Default constructor. No
ILcdGXYLayerDecoders are associated.The created instance will only work on the
ILcdGXYLayerDecoderinstances registered to it. If you want to use all registeredILcdGXYLayerDecoderinstances of the Lucy back-end, useTLcyCompositeGXYLayerDecoder(com.luciad.lucy.ILcyLucyEnv)instead. -
TLcyCompositeGXYLayerDecoder
Construct a
TLcyCompositeGXYLayerDecoderworking on the Lucy back-end.It will use all
ILcdGXYLayerDecoderinstances registered to the back-end, and adding and/or removingILcdGXYLayerDecoders to/from thisTLcyCompositeGXYLayerDecoderwill respectively add/remove it as service from the back-end.If you want to create a
TLcyCompositeGXYLayerDecoderwhich does not use the back-end, useTLcyCompositeGXYLayerDecoder()instead.- Parameters:
aLucyEnv- The Lucy back-end.- See Also:
-
-
Method Details
-
addGXYLayerDecoder
public void addGXYLayerDecoder(ILcdGXYLayerDecoder aGXYLayerDecoder, ALcyFileTypeDescriptor aFileTypeDescriptor) Adds the given
ILcdGXYLayerDecoderto the list of associatedILcdGXYLayerDecoders.If the constructor specifying an
ILcyLucyEnvis used, theALcyFileTypeDescriptorand its associatedILcdGXYLayerDecoderwill be registered on the Lucy back-end (seeILcyLucyEnv.addService(Object, int)by using anTLcyGXYLayerDecoderHolder. When callingILcyLucyEnv.getServices(Class)afterwards, the holder objects will only be returned when the requested class wasTLcyGXYLayerDecoderHolder.class.
Note: if you want to remove the registeredALcyFileTypeDescriptorand its associatedILcdGXYLayerDecoder, useremoveGXYLayerDecoder(com.luciad.view.gxy.ILcdGXYLayerDecoder)and notILcyLucyEnv.removeService(Object).- Parameters:
aGXYLayerDecoder- TheILcdGXYLayerDecoderto addaFileTypeDescriptor- The file type descriptor describing which files this decoder can handle.- See Also:
-
removeGXYLayerDecoder
Removes the given
ILcdGXYLayerDecoderfrom the list of associatedILcdGXYLayerDecoders. Has no effect if the givenILcdGXYLayerDecoderwas never added. The correspondingALcyFileTypeDescriptoris also removed.If the constructor specifying an
ILcyLucyEnvis used, theTLcyGXYLayerDecoderHolderobject containing theILcdGXYLayerDecoderaGXYLayerDecoderwill be removed as service from the Lucy back-end (seeILcyLucyEnv.removeService(Object)).
Note: it is only possible to removeTLcyGXYLayerDecoderHolderinstances which were registered using theaddGXYLayerDecoder(com.luciad.view.gxy.ILcdGXYLayerDecoder, com.luciad.lucy.model.ALcyFileTypeDescriptor)method.- Parameters:
aGXYLayerDecoder- TheILcdGXYLayerDecoderto remove.- See Also:
-
getGXYLayerDecoderCount
public int getGXYLayerDecoderCount()Returns the number ofILcdGXYLayerDecoders.- Returns:
- the number of
ILcdGXYLayerDecoders. - See Also:
-
getGXYLayerDecoder
Returns theILcdGXYLayerDecoderat the given index.- Parameters:
aIndex- The index to retrieve theILcdGXYLayerDecoderat. 0 <= aIndex <getGXYLayerDecoderCount()- Returns:
- the
ILcdGXYLayerDecoderat the given index. - See Also:
-
getFileTypeDescriptor
Retrieves the layer decoder file type descriptor at the given index. This descriptor is null if the decoder was added with null as a descriptor.- Parameters:
aIndex- The index to retrieve the layer decoder file type descriptor for.- Returns:
- the layer decoder file type descriptor at the given index.
- See Also:
-
getDisplayName
Description copied from interface:ILcdGXYLayerDecoderReturns the display name of this encoder.- Specified by:
getDisplayNamein interfaceILcdGXYLayerDecoder- Returns:
- the display name of this encoder.
-
setDisplayName
Sets the display name of this decoder.- Parameters:
aDisplayName- The new display name.- See Also:
-
canDecodeGXYLayer
Loops over its list of associatedILcdGXYLayerDecoders to find a suitableILcdGXYLayerDecoder. Suitable means that canDecodeSource returns true. This method returns true if it can find such a suitableILcdGXYLayerDecoder, false otherwise.- Specified by:
canDecodeGXYLayerin interfaceILcdGXYLayerDecoder- Parameters:
aModel- The model for the decoded layer.aSourceName- The name of the source to decode.- Returns:
- True if a suitable
ILcdGXYLayerDecodercould be found, false otherwise. - See Also:
-
decodeGXYLayer
Loops over its associated list ofILcdGXYLayerDecoders to find a suitableILcdGXYLayerDecoder. Suitable means that canDecodeGXYLayer returns true.The first suitable
ILcdGXYLayerDecoderis used to decode the given source.- Specified by:
decodeGXYLayerin interfaceILcdGXYLayerDecoder- Parameters:
aModel- The model for the decoded layer.aSourceName- The name of the source to decode.- Returns:
- The layer decoded by the first suitable
ILcdGXYLayerDecoder, or null if no suitable decoder could be found or if the user aborted the operation. - Throws:
IOException- In case of io failure.- See Also:
-