public class TLcyDataTransferManager extends Object
This manager is a central container for ALcyLayerSelectionTransferHandler
objects
by using a TLcyCompositeLayerSelectionTransferHandler
. The
registered ALcyLayerSelectionTransferHandler
objects are responsible for converting
model objects from one representation to another. This allows Lucy to provide, for instance,
copy/paste functionality.
Consult the javadoc of TLcyCompositeLayerSelectionTransferHandler
for more information about adding and/or removing ALcyLayerSelectionTransferHandler
s,
either directly to the TLcyCompositeLayerSelectionTransferHandler
or by using the
Lucy back-end services.
Obtaining, adding and/or removing ALcyLayerSelectionTransferHandler
instances can
either be achieved by using the corresponding methods in this class, or by using the
corresponding methods provided in TLcyCompositeLayerSelectionTransferHandler
.
When using the back-end based TLcyDataTransferManager
, obtaining, adding and/or
removing ALcyLayerSelectionTransferHandler
instances can be achieved on any back-end
based TLcyCompositeLayerSelectionTransferHandler
, e.g. there is no need to go through this
TLcyDataTransferManager
. This is illustrated in the code snippets below, which
are equivalent:
Obtaining, adding and/or removing an ALcyLayerSelectionTransferHandler
through a
back-end based TLcyDataTransferManager
:
//Create a new instance whenever you need it
TLcyDataTransferManager manager = new TLcyDataTransferManager( aLucyEnv );
//add a handler
manager.addLayerSelectionTransferHandler( aLayerSelectionTransferHandler );
//remove a handler
manager.removeLayerSelectionTransferHandler( anotherLayerSelectionTransferHandler );
//obtain a handler
ALcyLayerSelectionTransferHandler handler =
manager.getLayerSelectionTransferHandler( manager.getLayerSelectionTransferHandlerCount() -1 );
//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
manager = null;
Obtaining, adding and/or removing an ALcyLayerSelectionTransferHandler
through a
back-end based TLcyCompositeLayerSelectionTransferHandler
:
//Create a new instance whenever you need it
TLcyCompositeLayerSelectionTransferHandler composite = new TLcyCompositeLayerSelectionTransferHandler( aLucyEnv );
//add a handler
composite.addLayerSelectionTransferHandler( aLayerSelectionTransferHandler );
//remove a handler
composite.removeLayerSelectionTransferHandler( anotherLayerSelectionTransferHandler );
//obtain a handler
ALcyLayerSelectionTransferHandler handler =
composite.getLayerSelectionTransferHandler( composite.getLayerSelectionTransferHandlerCount() -1 );
//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
manager = null;
Obtaining, adding and/or removing an ALcyLayerSelectionTransferHandler
directly from/on the
back-end:
//Suppose we have a reference to the back-end
ILcyLucyEnv backEnd;
//add a handler
backEnd.addService( aLayerSelectionTransferHandler );
//remove a handler
backEnd.removeService( anotherLayerSelectionTransferHandler );
//obtain a handler
List<ALcyLayerSelectionTransferHandler> handlers =
backEnd.getServices( ALcyLayerSelectionTransferHandler.class );
ALcyLayerSelectionTransferHandler handler = handlers.get( handlers.size() -1 );
Note: when ALcyLayerSelectionTransferHandler implementations added to this
manager or to the TLcyCompositeLayerSelectionTransferHandler
can export to a custom DataFlavor
, the transfer data associated with this
DataFlavor
should be an ILcyLayerSubsetList
.
Modifier and Type | Field and Description |
---|---|
static DataFlavor |
TRANSFERABLES_LIST
This data flavor gives you access to the complete transferables representing the data.
|
Constructor and Description |
---|
TLcyDataTransferManager()
Default constructor.
|
TLcyDataTransferManager(ILcyLucyEnv aLucyEnv)
Construct a
TLcyDataTransferManager working on the Lucy back-end. |
Modifier and Type | Method and Description |
---|---|
void |
addLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler)
Adds
aLayerSelectionTransferHandler to the TLcyCompositeLayerSelectionTransferHandler . |
TLcyCompositeLayerSelectionTransferHandler |
getCompositeLayerSelectionTransferHandler()
Returns the
TLcyCompositeLayerSelectionTransferHandler used for this
TLcyDataTransferManager . |
ALcyLayerSelectionTransferHandler |
getLayerSelectionTransferHandler(int aIndex)
Returns the
ALcyLayerSelectionTransferHandler at location aIndex
in the TLcyCompositeLayerSelectionTransferHandler . |
int |
getLayerSelectionTransferHandlerCount()
Returns the number of
ALcyLayerSelectionTransferHandler objects the
TLcyCompositeLayerSelectionTransferHandler contains. |
void |
removeLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler)
Removes
aLayerSelectionTransferHandler from the TLcyCompositeLayerSelectionTransferHandler . |
public static final DataFlavor TRANSFERABLES_LIST
This data flavor gives you access to the complete transferables representing the data. You
can consult this data when you need more information about the data represented by other
flavors. For instance, when the Transferable
on the clipboard supports the TLcyMapDataFlavor.GENERAL_SHAPE_FLAVOR
as well as this flavor, you can
consult the data from this flavor to see if not each transferable separately contains more
detailed data.
The representation class of this DataFlavor is a java.util.List
. All elements
in this list are guaranteed to be Transferable
instances. These transferables are
the original transferables as they were generated by the ALcyLayerSelectionTransferHandler
.
Note that one should never rely on the properties of this constant (e.g.
TRANSFERABLES_LIST.getMimeType()
), as they might change in a future version of
Lucy. Instead one should always compare directly with this constant.
public TLcyDataTransferManager()
Default constructor.
The created instance will use a TLcyCompositeLayerSelectionTransferHandler which will only work the
ALcyLayerSelectionTransferHandler
instances registered to it. If you want to use
all registered ALcyLayerSelectionTransferHandler
instances of the Lucy back-end,
use TLcyDataTransferManager(com.luciad.lucy.ILcyLucyEnv)
instead.
public TLcyDataTransferManager(ILcyLucyEnv aLucyEnv)
Construct a TLcyDataTransferManager
working on the Lucy back-end.
The created instance will use a TLcyCompositeLayerSelectionTransferHandler which will use all ALcyLayerSelectionTransferHandler
instances registered to the back-end, and adding and/or removing
ALcyLayerSelectionTransferHandler
instances to/from the
TLcyCompositeLayerSelectionTransferHandler
will respectively add/remove it as
service from the back-end.
If you want to create a TLcyDataTransferManager
which does not use the
back-end, use TLcyDataTransferManager()
instead.
aLucyEnv
- The Lucy back-endTLcyDataTransferManager(com.luciad.lucy.ILcyLucyEnv)
,
TLcyCompositeLayerSelectionTransferHandler.TLcyCompositeLayerSelectionTransferHandler(com.luciad.lucy.ILcyLucyEnv)
public void addLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler)
Adds aLayerSelectionTransferHandler
to the TLcyCompositeLayerSelectionTransferHandler
.
Note: when aLayerSelectionTransferHandler
exports to a custom
DataFlavor
, ie. a DataFlavor
defined by yourself, the transfer data
associated with this DataFlavor
should be a ILcyLayerSubsetList
.
aLayerSelectionTransferHandler
- The handler to add to the list.TLcyCompositeLayerSelectionTransferHandler.addLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler)
,
getCompositeLayerSelectionTransferHandler()
public int getLayerSelectionTransferHandlerCount()
Returns the number of ALcyLayerSelectionTransferHandler
objects the
TLcyCompositeLayerSelectionTransferHandler
contains.
getCompositeLayerSelectionTransferHandler()
public ALcyLayerSelectionTransferHandler getLayerSelectionTransferHandler(int aIndex)
Returns the ALcyLayerSelectionTransferHandler
at location aIndex
in the TLcyCompositeLayerSelectionTransferHandler
.
aIndex
- The position of the ALcyLayerSelectionTransferHandler
you want to
retrieve.getCompositeLayerSelectionTransferHandler()
public void removeLayerSelectionTransferHandler(ALcyLayerSelectionTransferHandler aLayerSelectionTransferHandler)
Removes aLayerSelectionTransferHandler
from the TLcyCompositeLayerSelectionTransferHandler
.
aLayerSelectionTransferHandler
- The ALcyLayerSelectionTransferHandler
to
remove.getCompositeLayerSelectionTransferHandler()
public TLcyCompositeLayerSelectionTransferHandler getCompositeLayerSelectionTransferHandler()
Returns the TLcyCompositeLayerSelectionTransferHandler
used for this
TLcyDataTransferManager
.
If the constructor specifying an ILcyLucyEnv
is used, the
TLcyCompositeLayerSelectionTransferHandler
will be based on all
ALcyLayerSelectionTransferHandler
instances registered to the Lucy back-end.
ALcyLayerSelectionTransferHandler
.TLcyCompositeLayerSelectionTransferHandler