public class TLcdIndependentOrderTreeLayeredSupport extends TLcdTreeLayeredSupport
A utility class that can be used to create a class that implements
ILcdTreeLayered
. The major difference with the class
TLcdTreeLayeredSupport
is that the order of the layers in this
ILcdTreeLayered
is independent of the order in the hierarchical structure on which
this ILcdTreeLayered
is based.
As a consequence, the move operation (moveLayerAt(int, ILcdLayer)
performs the move
only on the flat list representation and not on the hierarchical structure. If you want to move a
node/layer in the hierarchical structure, it is necessary to access this structure directly
(TLcdTreeLayeredSupport.getRootNode()
) and perform the move on the node structure. Notice that this operation
will not affect the order in the flat list representation.
TLcdTreeLayeredSupport
,
Serialized FormConstructor and Description |
---|
TLcdIndependentOrderTreeLayeredSupport(ILcdLayered aLayeredToSupport,
ILcdLayerTreeNode aRootNode)
Constructs a new
TLcdIndependentOrderTreeLayeredSupport for a tree with root
node aRootNode . |
TLcdIndependentOrderTreeLayeredSupport(ILcdLayerTreeNode aRootNode)
Constructs a new
TLcdIndependentOrderTreeLayeredSupport for a tree with root
node aRootNode . |
Modifier and Type | Method and Description |
---|---|
int |
getLayerAddingIndex(ILcdLayer aLayer)
This method provides a hook allowing to alter the index at which the layer
aLayer
will be inserted in the flat list representation. |
void |
moveLayerAt(int aIndex,
ILcdLayer aLayer)
Move the layer
aLayer to the index aIndex |
addLayeredListener, containsLayer, getLayer, getLayeredToSupport, getRootNode, indexOf, layerCount, layerOf, layers, layersBackwards, removeAllLayers, removeLayer, removeLayeredListener, setLayeredToSupport
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addLayeredListener, getLayers, removeLayeredListener
public TLcdIndependentOrderTreeLayeredSupport(ILcdLayered aLayeredToSupport, ILcdLayerTreeNode aRootNode)
Constructs a new TLcdIndependentOrderTreeLayeredSupport
for a tree with root
node aRootNode
.
aLayeredToSupport
- the ILcdLayered
that will delegate to this supportaRootNode
- the root node of the hierarchical layer structurepublic TLcdIndependentOrderTreeLayeredSupport(ILcdLayerTreeNode aRootNode)
Constructs a new TLcdIndependentOrderTreeLayeredSupport
for a tree with root
node aRootNode
.
Before using an instance of this class, TLcdTreeLayeredSupport.setLayeredToSupport(ILcdLayered)
must be
called.
aRootNode
- the root node of the hierarchical layer structurepublic int getLayerAddingIndex(ILcdLayer aLayer)
This method provides a hook allowing to alter the index at which the layer aLayer
will be inserted in the flat list representation. However, it is up to the synchronization
listener to use this method when adding layers to the flat list structure (see createSynchronizationListener(TLcdLayeredSupport)
).
The default implementation of createSynchronizationListener(TLcdLayeredSupport)
uses this method. If you only want to change the index when layers are added, it is sufficient
to override this method without overriding createSynchronizationListener(TLcdLayeredSupport).
aLayer
- the layeraLayer
will be inserted in the flat list.
Return -1 when the layer should be added at the end of the flat list.createSynchronizationListener(TLcdLayeredSupport)
public void moveLayerAt(int aIndex, ILcdLayer aLayer) throws NoSuchElementException, ArrayIndexOutOfBoundsException
Move the layer aLayer
to the index aIndex
This move operation will only perform the move on the flat list and not on the node structure. This will allow the order in the flat list to be completely independent of the order in hierarchical structure. Hence, the order in the flat list will not always map on a tree structure.
Moving a node with this method will only move the node in the flat list, and not the children of the node. They remain at their position in the flat list. If you want to move the node and its children, this method must be called multiple times (one time for the node, and one time for each child) with the correct indices.
moveLayerAt
in interface ILcdLayered
moveLayerAt
in class TLcdTreeLayeredSupport
aIndex
- the index to move the layer toaLayer
- the layer which must be movedNoSuchElementException
- if aLayer
is not in this ILcdLayered
.ArrayIndexOutOfBoundsException
- if aIndex
is not an index of one of the
layers of this ILcdLayered
.