Class TLcyDataFormatManager
ILcdModelDecoder:getCompositeModelDecoder()ILcdModelEncoder:getCompositeModelEncoder()ALcyDataSourceHandler:getCompositeDataSourceHandler()ILcdGXYLayerFactory:getCompositeGXYLayerFactory()ILcyGXYLayerTypeProvider:getCompositeGXYLayerTypeProvider()ILcyAsynchronousPaintHintProvider:getCompositeAsynchronousPaintHintProvider()ILcyModelContentTypeProvider:getCompositeModelContentTypeProvider()ILcdGXYLayerDecoder:getCompositeGXYLayerDecoder()ILcdGXYLayerEncoder:getCompositeGXYLayerEncoder()ILcdModelReferenceDecoder:getCompositeModelReferenceDecoder()
TLcyDataFormatManager is that it allows
to programmatically handle data sources, for example opening data files. This can be done
using handleDataSources(ILcdDataSource[], ILcyGenericMapComponent, Component).
Consult the "Loading data in Lucy" chapter in the Lucy developer guide for more information about how this class can be used for data loading, and for some examples.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass that represents the logic to choose aILcdModelDecoderorALcyDataSourceHandlerout of a list of candidates.static classClass that represents the logic to choose one or multipleILcyGenericMapComponent(s) out of a list of candidates. -
Constructor Summary
ConstructorsConstructorDescriptionTLcyDataFormatManager(ILcyLucyEnv aLucyEnv) Create a new data format manager -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDataSourceListener(ILcyDataSourceListener aDataSourceListener) Adds the givenILcyDataSourceListener.Deprecated.Deprecated.Usenew TLcyCompositeDataSourceHandler(aLucyEnv)instead.Returns theTLcyCompositeFileTypeDescriptorthat represents the list of associatedALcyFileTypeDescriptors.Deprecated.Usenew TLcyCompositeGXYLayerDecoder(aLucyEnv)instead.Deprecated.Usenew TLcyCompositeGXYLayerEncoder(aLucyEnv)instead.Deprecated.Usenew TLcyCompositeGXYLayerFactory(aLucyEnv)instead.Deprecated.Usenew TLcyCompositeGXYLayerTypeProvider(aLucyEnv)instead.Deprecated.Usenew TLcyCompositeModelContentTypeProvider(aLucyEnv)instead.Deprecated.Usenew TLcyCompositeModelDecoder(aLucyEnv)instead.Deprecated.Usenew TLcyCompositeModelEncoder(aLucyEnv)instead.Deprecated.Usenew TLcyCompositeModelReferenceDecoder(aLucyEnv)instead.Returns theALcyHandlerChooserthat is currently used.Returns the one and onlyILcdLogListenerto which end-user messages will be passed when handling data.Returns theALcyMapComponentChooserthat is currently used.voidhandleDataSources(ILcdDataSource[] aDataSources, ILcyGenericMapComponent<? extends ILcdView, ? extends ILcdLayer> aMapComponent, ILcdModelDecoder[] aModelDecoders, Component aParentComponent) Opens the data represented byaDataSourcesonaMapComponentby using all theILcdModelDecoders inaModelDecoders.voidhandleDataSources(ILcdDataSource[] aDataSources, ILcyGenericMapComponent<? extends ILcdView, ? extends ILcdLayer> aMapComponent, Component aParentComponent) Opens the data represented byaDataSourcesonaMapComponentby using all theILcdModelDecoders that are registered on the Lucy back-end.voidhandleDataSources(String[] aDataSources, ILcyGenericMapComponent<? extends ILcdView, ? extends ILcdLayer> aMapComponent, ALcyFileTypeDescriptor aSelectedFileTypeDescriptor, Component aParentComponent) Opens the data represented byaDataSourcesonaMapComponentby using all theILcdModelDecoders andALcyDataSourceHandlers that are registered on the Lucy back-end.voidhandleDataSources(String[] aDataSources, ILcyGenericMapComponent<? extends ILcdView, ? extends ILcdLayer> aMapComponent, ILcdModelDecoder[] aModelDecoders, ALcyFileTypeDescriptor[] aModelDecoderFileTypeDescriptors, ALcyDataSourceHandler[] aDataSourceHandlers, ALcyFileTypeDescriptor[] aDataSourceHandlerFileTypeDescriptors, ALcyFileTypeDescriptor aSelectedFileTypeDescriptor, Component aParentComponent) Opens the data represented byaDataSourcesonaMapComponentby using theILcdModelDecoders inaModelDecodersand theALcyDataSourceHandlers inaDataSourceHandlers.voidremoveDataSourceListener(ILcyDataSourceListener aDataSourceListener) Removes the givenILcyDataSourceListener.voidsetHandlerChooser(TLcyDataFormatManager.ALcyHandlerChooser aHandlerChooser) TheALcyHandlerChooseris responsible for deciding whichILcdModelDecoderorALcyDataSourceHandleris used when a data source (aStringorILcdDataSource) is passed to thisTLcyDataFormatManager.voidsetLogListener(ILcdLogListener aLogListener) Sets the one and onlyILcdLogListenerto which end-user messages will be passed when handling data.voidsetMapComponentChooser(TLcyDataFormatManager.ALcyMapComponentChooser aMapComponentChooser) TheALcyMapComponentChooseris responsible for deciding on whichILcyGenericMapComponent(s) a data source (aStringorILcdDataSource) should be opened when handling data sources.
-
Constructor Details
-
TLcyDataFormatManager
Create a new data format manager
Note: normally this constructor should never be used. Use the
TLcyDataFormatManageravailable on the Lucy back-end instead by callingILcyLucyEnv#getDataFormatManager().- Parameters:
aLucyEnv- the Lucy backend
-
-
Method Details
-
handleDataSources
public void handleDataSources(String[] aDataSources, ILcyGenericMapComponent<? extends ILcdView, ? extends ILcdLayer> aMapComponent, ALcyFileTypeDescriptor aSelectedFileTypeDescriptor, Component aParentComponent) Opens the data represented by
aDataSourcesonaMapComponentby using all theILcdModelDecoders andALcyDataSourceHandlers that are registered on the Lucy back-end.When data can not be opened on
aMapComponent, the map component chooser will be asked for other map(s) on which theTLcyDataFormatManagerre-tries opening the data.- Parameters:
aDataSources- The data sources to open.aMapComponent- The map component to which the data will be added if possible.aSelectedFileTypeDescriptor- The selected file type descriptor, can be used if there is ambiguity (multiple decoders can read a file). Usenullfor default behavior.aParentComponent- A parent component, used to display message dialogs.- See Also:
-
handleDataSources
public void handleDataSources(ILcdDataSource[] aDataSources, ILcyGenericMapComponent<? extends ILcdView, ? extends ILcdLayer> aMapComponent, Component aParentComponent) Opens the data represented by
aDataSourcesonaMapComponentby using all theILcdModelDecoders that are registered on the Lucy back-end.When data can not be opened on
aMapComponent, the map component chooser will be asked for other map(s) on which theTLcyDataFormatManagerre-tries opening the data.- Parameters:
aDataSources- The data sources to open.aMapComponent- The map component to which the data will be added if possible.aParentComponent- A parent component, used to display message dialogs.- See Also:
-
handleDataSources
public void handleDataSources(String[] aDataSources, ILcyGenericMapComponent<? extends ILcdView, ? extends ILcdLayer> aMapComponent, ILcdModelDecoder[] aModelDecoders, ALcyFileTypeDescriptor[] aModelDecoderFileTypeDescriptors, ALcyDataSourceHandler[] aDataSourceHandlers, ALcyFileTypeDescriptor[] aDataSourceHandlerFileTypeDescriptors, ALcyFileTypeDescriptor aSelectedFileTypeDescriptor, Component aParentComponent) Opens the data represented by
aDataSourcesonaMapComponentby using theILcdModelDecoders inaModelDecodersand theALcyDataSourceHandlers inaDataSourceHandlers.Before handling starts, and after handling has finished, all
ILcyDataSourceListeners are informed. Such a listener can be added usingaddDataSourceListener.Choosing which
ILcdModelDecoderorALcyDataSourceHandlerto use for a particular data source and a particular map component is left to aALcyHandlerChooser. That handler can be replaced usingsetHandlerChooser.If errors occur while handling the data sources, messages will be send to
getLogListener(). It is up to that listener to inform the end user of these messages.When the data cannot be opened on
aMapComponentit will be re-tried on other available maps. The maps on which opening the data is re-tried are determined by theALcyMapComponentChooser. This chooser can be replaced usingsetMapComponentChooser.Note that the data sources are handled on the calling thread. As this is probably a task that may take some time, it is advised to call this method from a worker thread.
- Parameters:
aDataSources- The data sources to open.aMapComponent- The map component to which the data will be added if possible.aModelDecoders- A list ofILcdModelDecoders to use when handling the data sources.aModelDecoderFileTypeDescriptors- The file type descriptors corresponding to aModelDecoders. Isnulliff aModelDecoders isnull. Array must have equal length as aModelDecoders. It can contain null values for thoseILcdModelDecoders that don't work with files.aDataSourceHandlers- A list ofALcyDataSourceHandlers to use when handling the data sources.aDataSourceHandlerFileTypeDescriptors- The file type descriptors corresponding to aDataSourceHandlers. Isnulliff aDataSourceHandlers isnull. Array must have equal length as aDataSourceHandlers. It can contain null values for thoseALcyDataSourceHandlers that don't work with files.aSelectedFileTypeDescriptor- The selected file type descriptor, can be used if there is ambiguity (multiple decoders can read a file). Usenullfor default behavior.aParentComponent- A parent component, used to display message dialogs.
-
handleDataSources
public void handleDataSources(ILcdDataSource[] aDataSources, ILcyGenericMapComponent<? extends ILcdView, ? extends ILcdLayer> aMapComponent, ILcdModelDecoder[] aModelDecoders, Component aParentComponent) Opens the data represented by
aDataSourcesonaMapComponentby using all theILcdModelDecoders inaModelDecoders.Before handling starts, and after handling has finished, all
ILcyDataSourceListeners are informed. Such a listener can be added usingaddDataSourceListener(ILcyDataSourceListener).Choosing which
ILcdModelDecoderto use for a particular data source and a particular map component is left to aALcyHandlerChooser. That chooser can be replaced usingsetHandlerChooser.If errors occur while handling the data sources, messages will be send to
getLogListener(). It is up to that listener to inform the end user of these messages.When the data cannot be opened on
aMapComponentit will be re-tried on other available maps. The maps on which opening the data is re-tried are determined by theALcyMapComponentChooser. This chooser can be replaced usingsetMapComponentChooser.Note that the data sources are handled on the calling thread. As this is probably a task that may take some time, it is advised to call this method from a worker thread.
- Parameters:
aDataSources- The data sources to open.aMapComponent- The map component to which the data will be added if possible.aModelDecoders- A list ofILcdModelDecoders to use when handling the data sources.aParentComponent- A parent component, used to display message dialogs.
-
addDataSourceListener
Adds the givenILcyDataSourceListener. The listener will be notified when datasources are handled usinghandleDataSources(ILcdDataSource[], ILcyGenericMapComponent, Component).- Parameters:
aDataSourceListener- The listener to add.- See Also:
-
removeDataSourceListener
Removes the givenILcyDataSourceListener.- Parameters:
aDataSourceListener- The listener to remove.- See Also:
-
getLogListener
Returns the one and only
ILcdLogListenerto which end-user messages will be passed when handling data.- Returns:
- The log listener.
- See Also:
-
setLogListener
Sets the one and only
ILcdLogListenerto which end-user messages will be passed when handling data.The listener could for example pop up a message dialog if a message is received, or it could collect all messages and display one dialog when handling the data sources has finished (
addDataSourceListenercan be useful in that context).- Parameters:
aLogListener- The log listener. Should not benull- See Also:
-
getCompositeModelDecoder
Deprecated.Usenew TLcyCompositeModelDecoder(aLucyEnv)instead. The Lucy API offers composite implementations of all interfaces which can be registered on the services. Those composite implementations will use those registered instances when the constructor with the Lucy back-end as parameter is used. See the javadoc ofILcyLucyEnv.addService(Object, int)and the Lucy developer guide for more information.Returns the
TLcyCompositeModelDecoderthat represents the list of associatedILcdModelDecoders. It can also be directly used as aILcdModelDecoderitself.Adding
ILcdModelDecoders to this list allows an add-on to provide Lucy with its ownILcdModelDecoders, offering a wider set of supported data formats.When a
ILcdModelDecoderis registered, a matchingILcdGXYLayerFactory,ILcyModelContentTypeProviderandILcyGXYLayerTypeProvidermight need to be registered as well. Please refer togetCompositeGXYLayerFactory(),getCompositeGXYLayerTypeProvider()andgetCompositeModelContentTypeProvider()for more details.Note: the returned composite instance works on the
Lucy services.- Returns:
- The
TLcyCompositeModelDecoder.
-
getCompositeModelEncoder
Deprecated.Usenew TLcyCompositeModelEncoder(aLucyEnv)instead. The Lucy API offers composite implementations of all interfaces which can be registered on the services. Those composite implementations will use those registered instances when the constructor with the Lucy back-end as parameter is used. See the javadoc ofILcyLucyEnv.addService(Object, int)and the Lucy developer guide for more information.Returns the
TLcyCompositeModelEncoderthat represents the list of associatedILcdModelEncoders. It can also be directly used as aILcdModelEncoderitself.Adding
ILcdModelEncoders to this list allows an add-on to provide Lucy with its ownILcdModelEncoders, allowing to export to more data formats.Note: the returned composite instance works on the
Lucy services.- Returns:
- The
TLcyCompositeModelEncoder.
-
getCompositeDataSourceHandler
Deprecated.Usenew TLcyCompositeDataSourceHandler(aLucyEnv)instead. The Lucy API offers composite implementations of all interfaces which can be registered on the services. Those composite implementations will use those registered instances when the constructor with the Lucy back-end as parameter is used. See the javadoc ofILcyLucyEnv.addService(Object, int)and the Lucy developer guide for more information.Returns the
TLcyCompositeDataSourceHandlerthat represents the list of associatedALcyDataSourceHandlers. It can also be directly used as aALcyDataSourceHandleritself.Adding
ALcyDataSourceHandlers to this list allows an add-on to provide Lucy with its ownALcyDataSourceHandlers, offering a wider set of supported data formats.Note: the returned composite instance works on the
Lucy services.- Returns:
- The
TLcyCompositeDataSourceHandler.
-
getCompositeGXYLayerFactory
Deprecated.Usenew TLcyCompositeGXYLayerFactory(aLucyEnv)instead. The Lucy API offers composite implementations of all interfaces which can be registered on the services. Those composite implementations will use those registered instances when the constructor with the Lucy back-end as parameter is used. See the javadoc ofILcyLucyEnv.addService(Object, int)and the Lucy developer guide for more information.Returns the
TLcyCompositeGXYLayerFactorythat represents the list of associatedILcdGXYLayerFactorys. It can also be directly used as aILcdGXYLayerFactoryitself.ILcdGXYLayerFactorys that are added to this composite should only createILcdGXYLayers forILcdModel's they know about. It should not simply create aILcdGXYLayerfor everyILcdModelit gets passed in itscreateGXYLayer, but instead verify if the givenILcdModelis supported, e.g. by testing theILcdModelDescriptorof theILcdModel. If theILcdModelpassed in thecreateGXYLayermethod is not supported, it should returnnull.When a
ILcdGXYLayerFactoryis registered, a matchingILcyGXYLayerTypeProvidermight need to be registered as well. Please refer togetCompositeGXYLayerTypeProvider()for more details.Note: the returned composite instance works on the
Lucy services.- Returns:
- The
TLcyCompositeGXYLayerFactory.
-
getCompositeGXYLayerTypeProvider
Deprecated.Usenew TLcyCompositeGXYLayerTypeProvider(aLucyEnv)instead. The Lucy API offers composite implementations of all interfaces which can be registered on the services. Those composite implementations will use those registered instances when the constructor with the Lucy back-end as parameter is used. See the javadoc ofILcyLucyEnv.addService(Object, int)and the Lucy developer guide for more information.Returns the
TLcyCompositeGXYLayerTypeProviderthat represents the list of associatedILcyGXYLayerTypeProviders. It can also be directly used as aILcyGXYLayerTypeProvideritself.Adding
ILcyGXYLayerTypeProviders to this list allows an add-on to provide Lucy with its own layer type providers.Note: the returned composite instance works on the
Lucy services.- Returns:
- The
TLcyCompositeGXYLayerTypeProvider.
-
getCompositeModelContentTypeProvider
Deprecated.Usenew TLcyCompositeModelContentTypeProvider(aLucyEnv)instead. The Lucy API offers composite implementations of all interfaces which can be registered on the services. Those composite implementations will use those registered instances when the constructor with the Lucy back-end as parameter is used. See the javadoc ofILcyLucyEnv.addService(Object, int)and the Lucy developer guide for more information.Returns the
TLcyCompositeModelContentTypeProviderthat represents the list of associatedILcyModelContentTypeProviders. It can also be directly used as aILcyModelContentTypeProvideritself.Adding
ILcyModelContentTypeProviders to this list allows an add-on to provide Lucy with its ownILcyModelContentTypeProviders.Note: the returned composite instance works on the
Lucy services.- Returns:
- The
TLcyCompositeModelContentTypeProvider. - See Also:
-
getCompositeAsynchronousPaintHintProvider
@Deprecated public TLcyCompositeAsynchronousPaintHintProvider getCompositeAsynchronousPaintHintProvider()Deprecated.Usenew TLcyCompositeAsynchronousPaintHintProvider(aLucyEnv)instead. The Lucy API offers composite implementations of all interfaces which can be registered on the services. Those composite implementations will use those registered instances when the constructor with the Lucy back-end as parameter is used. See the javadoc ofILcyLucyEnv.addService(Object, int)and the Lucy developer guide for more information.Returns the
TLcyCompositeAsynchronousPaintHintProviderthat represents the list of associatedILcyAsynchronousPaintHintProviders. It can also be directly used as aILcyAsynchronousPaintHintProvideritself.Adding
ILcyAsynchronousPaintHintProviders to this list allows an add-on to provide Lucy with its ownILcyAsynchronousPaintHintProviders.Note: the returned composite instance works on the
Lucy services.- Returns:
- The
TLcyCompositeAsynchronousPaintHintProvider.
-
getCompositeGXYLayerDecoder
Deprecated.Usenew TLcyCompositeGXYLayerDecoder(aLucyEnv)instead. The Lucy API offers composite implementations of all interfaces which can be registered on the services. Those composite implementations will use those registered instances when the constructor with the Lucy back-end as parameter is used. See the javadoc ofILcyLucyEnv.addService(Object, int)and the Lucy developer guide for more information.Returns the
TLcyCompositeGXYLayerDecoderthat represents the list of associatedILcdGXYLayerDecoders. It can also be directly used as aILcdGXYLayerDecoderitself.Adding
ILcdGXYLayerDecoders to this list allows an add-on to provide Lucy with its ownILcdGXYLayerDecoders.Note: the returned composite instance works on the
Lucy services.- Returns:
- The
TLcyCompositeGXYLayerDecoder.
-
getCompositeGXYLayerEncoder
Deprecated.Usenew TLcyCompositeGXYLayerEncoder(aLucyEnv)instead. The Lucy API offers composite implementations of all interfaces which can be registered on the services. Those composite implementations will use those registered instances when the constructor with the Lucy back-end as parameter is used. See the javadoc ofILcyLucyEnv.addService(Object, int)and the Lucy developer guide for more information.Returns the
TLcyCompositeGXYLayerEncoderthat represents the list of associatedILcdGXYLayerEncoders. It can also be directly used as aILcdGXYLayerEncoderitself.Adding
ILcdGXYLayerEncoders to this list allows an add-on to provide Lucy with its ownILcdGXYLayerEncoders.Note: the returned composite instance works on the
Lucy services.- Returns:
- The
TLcyCompositeGXYLayerEncoder.
-
getCompositeModelReferenceDecoder
Deprecated.Usenew TLcyCompositeModelReferenceDecoder(aLucyEnv)instead. The Lucy API offers composite implementations of all interfaces which can be registered on the services. Those composite implementations will use those registered instances when the constructor with the Lucy back-end as parameter is used. See the javadoc ofILcyLucyEnv.addService(Object, int)and the Lucy developer guide for more information.Returns the
TLcyCompositeModelReferenceDecoderthat represents the list of associatedILcdModelReferenceDecoders. It can also be directly used as aILcdModelReferenceDecoderitself.Adding
ILcdModelReferenceDecoders to this list allows an add-on to provide Lucy with its ownILcdModelReferenceDecoders.Note: the returned composite instance works on the
Lucy services.- Returns:
- The
TLcyCompositeModelReferenceDecoder.
-
getCompositeFileTypeDescriptorGroup
Returns theTLcyCompositeFileTypeDescriptorthat represents the list of associatedALcyFileTypeDescriptors. It can also be directly used as aALcyFileTypeDescriptoritself. AddingALcyFileTypeDescriptors to this list allows an add-on to provide Lucy with its ownALcyFileTypeDescriptorgroups. Such a group could be (though not mandatory) aTLcyCompositeFileTypeDescriptoritself. It could for example represent "All known vector files", composed of several otherALcyFileTypeDescriptors.- Returns:
- The
TLcyCompositeModelReferenceDecoder.
-
getHandlerChooser
Returns theALcyHandlerChooserthat is currently used.- Returns:
- the
ALcyHandlerChooserthat is currently used. - See Also:
-
setHandlerChooser
The
ALcyHandlerChooseris responsible for deciding whichILcdModelDecoderorALcyDataSourceHandleris used when a data source (aStringorILcdDataSource) is passed to thisTLcyDataFormatManager.- Parameters:
aHandlerChooser- The handler chooser.
-
setMapComponentChooser
public void setMapComponentChooser(TLcyDataFormatManager.ALcyMapComponentChooser aMapComponentChooser) The
ALcyMapComponentChooseris responsible for deciding on whichILcyGenericMapComponent(s) a data source (aStringorILcdDataSource) should be opened when handling data sources.- Parameters:
aMapComponentChooser- The map component chooser.
-
getMapComponentChooser
Returns theALcyMapComponentChooserthat is currently used.- Returns:
- the
ALcyMapComponentChooserthat is currently used. - See Also:
-
new TLcyCompositeAsynchronousPaintHintProvider(aLucyEnv)instead.