Class TLcdTreeLayeredSupport
- All Implemented Interfaces:
ILcdLayered,ILcdTreeLayered,ILcdTreeLayeredSupport,Serializable
- Direct Known Subclasses:
TLcdIndependentOrderTreeLayeredSupport
This is a utility class that can be used to make a class that implements
ILcdTreeLayered.
The order of the layers in the flat list representation is derived from the order in which the
layers appear in the hierarchical layer structure. As a consequence, moving a layer to a certain
index is not always possible since the hierarchical structure must allow such a move (see also
moveLayerAt(int, ILcdLayer)). This also means that adjusting the layer order in the
hierarchical structure will influence the layer order in the flat list.
- Since:
- 9.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTLcdTreeLayeredSupport(ILcdLayered aLayeredToSupport, ILcdLayerTreeNode aRootNode) Constructs a newTLcdTreeLayeredSupportfor a tree with root nodeaRootNode.TLcdTreeLayeredSupport(ILcdLayerTreeNode aRootNode) Constructs a newTLcdTreeLayeredSupportfor a tree with root nodeaRootNode. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLayeredListener(ILcdLayeredListener aLayeredListener) Registers the givenILcdLayeredListenerto be notified when layers are added, removed or moved in the flat list.booleancontainsLayer(ILcdLayer aLayer) Returns whether the flat list representation of the hierarchical layer structure contains the given layer.getLayer(int aIndex) Returns theILcdLayerwith indexaIndexin the flat list representation of the hierarchical layer structure.Returns theILcdLayeredfor which this support is created.Returns the root node of the tree structure.intReturns the index of the given layeraLayerin the flat list representation of the hierarchical structure.intReturns the number of layers in the flat list representation of the hierarchical layer structure.Returns theILcdLayerof the flat list that contains the givenILcdModel.layers()Returns anEnumerationof all theILcdLayers currently in the flat list representation of the hierarchical layer structure, starting from the bottom layer to the top layer.Returns anEnumerationof all theILcdLayers currently in the flat list representation of the hierarchical layer structure, starting from the top layer to the bottom layer.voidmoveLayerAt(int aIndex, ILcdLayer aLayer) Tries to move the layeraLayerto indexaIndex, without affecting the tree structure, in a best effort approach.voidRemove all the layers from the hierarchical layer structure and the flat list representation.voidremoveLayer(ILcdLayer aLayer) Removes a layer from both the hierarchical layer structure and the flat list representation.voidremoveLayeredListener(ILcdLayeredListener aLayeredListener) Unregisters the givenILcdLayeredListenerfrom receiving layered events for the flat list.voidsetLayeredToSupport(ILcdLayered aLayeredToSupport) Sets theILcdLayeredfor which this support is created.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.view.ILcdLayered
addLayeredListener, getLayers, removeLayeredListener
-
Constructor Details
-
TLcdTreeLayeredSupport
Constructs a new
TLcdTreeLayeredSupportfor a tree with root nodeaRootNode.- Parameters:
aLayeredToSupport- theILcdLayeredthat will delegate to this supportaRootNode- the root node of the hierarchical layer structure
-
TLcdTreeLayeredSupport
Constructs a new
TLcdTreeLayeredSupportfor a tree with root nodeaRootNode.Before using an instance of this class,
setLayeredToSupport(ILcdLayered)must be called.- Parameters:
aRootNode- the root node of the hierarchical layer structure
-
-
Method Details
-
setLayeredToSupport
Sets the
ILcdLayeredfor which this support is created. This method may only be called once, and this call should happen before using this class. When using the constructor which takes anILcdLayeredas a parameter, calling this method is not necessary since this is already done by the constructor.- Specified by:
setLayeredToSupportin interfaceILcdTreeLayeredSupport- Parameters:
aLayeredToSupport- the ILcdLayered that will delegate to this support
-
getRootNode
Description copied from interface:ILcdTreeLayeredReturns the root node of the tree structure.
- Specified by:
getRootNodein interfaceILcdTreeLayered- Returns:
- the root node of the tree structure
-
addLayeredListener
Description copied from interface:ILcdTreeLayeredRegisters the givenILcdLayeredListenerto be notified when layers are added, removed or moved in the flat list.- Specified by:
addLayeredListenerin interfaceILcdLayered- Specified by:
addLayeredListenerin interfaceILcdTreeLayered- Parameters:
aLayeredListener- the listener that from now on will be notified of all changes to the flat list.- See Also:
-
removeLayeredListener
Description copied from interface:ILcdTreeLayeredUnregisters the givenILcdLayeredListenerfrom receiving layered events for the flat list.- Specified by:
removeLayeredListenerin interfaceILcdLayered- Specified by:
removeLayeredListenerin interfaceILcdTreeLayered- Parameters:
aLayeredListener- the listener that will no longer be notified of changes in the flat list.- See Also:
-
layerCount
public int layerCount()Description copied from interface:ILcdTreeLayeredReturns the number of layers in the flat list representation of the hierarchical layer structure. This does not include the root node.
- Specified by:
layerCountin interfaceILcdLayered- Specified by:
layerCountin interfaceILcdTreeLayered- Returns:
- the number of layers in the flat list. Does not include the root node.
-
layers
Description copied from interface:ILcdTreeLayeredReturns an
Enumerationof all theILcdLayers currently in the flat list representation of the hierarchical layer structure, starting from the bottom layer to the top layer. This does not include the root node.- Specified by:
layersin interfaceILcdLayered- Specified by:
layersin interfaceILcdTreeLayered- Returns:
- an
Enumerationof all theILcdLayers currently in the flat list, starting from the bottom layer to the top layer. Does not include the root node.
-
layersBackwards
Description copied from interface:ILcdTreeLayeredReturns an
Enumerationof all theILcdLayers currently in the flat list representation of the hierarchical layer structure, starting from the top layer to the bottom layer. This does not include the root node.- Specified by:
layersBackwardsin interfaceILcdLayered- Specified by:
layersBackwardsin interfaceILcdTreeLayered- Returns:
- an
Enumerationof all theILcdLayers currently in the flat list, starting from the top layer to the bottom layer. Does not include the root node.
-
getLayer
Description copied from interface:ILcdTreeLayeredReturns the
ILcdLayerwith indexaIndexin the flat list representation of the hierarchical layer structure.- Specified by:
getLayerin interfaceILcdLayered- Specified by:
getLayerin interfaceILcdTreeLayered- Parameters:
aIndex- the position of the layer to retrieve in the flat list representation.- Returns:
- the
ILcdLayerwith indexaIndexin the flat list representation - Throws:
ArrayIndexOutOfBoundsException- if the given index is invalid
-
layerOf
Description copied from interface:ILcdTreeLayeredReturns theILcdLayerof the flat list that contains the givenILcdModel.- Specified by:
layerOfin interfaceILcdLayered- Specified by:
layerOfin interfaceILcdTreeLayered- Parameters:
aModel- the model to check for in the flat list- Returns:
- the
ILcdLayerof the flat list that contains the givenILcdModel. - Throws:
NoSuchElementException- if there is no layer containing the given model
-
indexOf
Description copied from interface:ILcdTreeLayeredReturns the index of the given layer
aLayerin the flat list representation of the hierarchical structure.- Specified by:
indexOfin interfaceILcdLayered- Specified by:
indexOfin interfaceILcdTreeLayered- Parameters:
aLayer- the layer whose index to return- Returns:
- the index of
aLayerin the flat list representation - Throws:
NoSuchElementException- ifaLayeris not in the flat list
-
moveLayerAt
public void moveLayerAt(int aIndex, ILcdLayer aLayer) throws NoSuchElementException, ArrayIndexOutOfBoundsException Tries to move the layer
aLayerto indexaIndex, without affecting the tree structure, in a best effort approach. This best effort approach can be seen as follows:- First the layer at index
aIndexis searched. - Then the first common ancestor of layer
aLayerand the layer at indexaIndexis searched - Once the first common ancestor is found, the subtree containing
aLayeris moved to the position of the subtree containing the layer at indexaIndexin the child list of the common ancestor
This also means that after calling this method the index of the layer
aLayercan be different from the requested indexaIndex.- Specified by:
moveLayerAtin interfaceILcdLayered- Parameters:
aIndex- the desired index for the layeraLayeraLayer- the layer to move.- Throws:
NoSuchElementException- ifaLayeris not in thisILcdLayered.ArrayIndexOutOfBoundsException- ifaIndexis not an index of one of the layers of thisILcdLayered.
- First the layer at index
-
removeLayer
Description copied from interface:ILcdTreeLayeredRemoves a layer from both the hierarchical layer structure and the flat list representation. When removing an
ILcdLayerTreeNodeall of its children will also be removed. An event will then be generated for every layer that has been removed (one for the node and one for each of its child layers).It is not possible to remove the root node
- Specified by:
removeLayerin interfaceILcdLayered- Specified by:
removeLayerin interfaceILcdTreeLayered- Parameters:
aLayer- the layer to remove. If the layer is not in the flat list, this method has no effect.
-
removeAllLayers
public void removeAllLayers()Description copied from interface:ILcdTreeLayeredRemove all the layers from the hierarchical layer structure and the flat list representation. An event will be fired for every layer that has been removed. This will not remove the root node.
- Specified by:
removeAllLayersin interfaceILcdLayered- Specified by:
removeAllLayersin interfaceILcdTreeLayered
-
containsLayer
Description copied from interface:ILcdTreeLayeredReturns whether the flat list representation of the hierarchical layer structure contains the given layer. More formally, returns
trueif and only if the flat list representation contains at least one layerlsuch that (aLayer==null ? l==null : aLayer.equals(l)).Calling this method with the root node will return
false, since the root node is not a part of the flat list representation.- Specified by:
containsLayerin interfaceILcdLayered- Specified by:
containsLayerin interfaceILcdTreeLayered- Parameters:
aLayer- the layer to check whether it is in the flat list representation- Returns:
truewhen the flat list representation contains the given layer,falseotherwise
-
getLayeredToSupport
Description copied from interface:ILcdTreeLayeredSupportReturns the
ILcdLayeredfor which this support is created.- Specified by:
getLayeredToSupportin interfaceILcdTreeLayeredSupport- Returns:
- the
ILcdLayeredfor which this support is created.
-