public interface ILcdTreeLayered extends ILcdLayered
An extension of ILcdLayered
, to access a flat list of layers as
a hierarchical structure. The hierarchical structure can be accessed directly
by calling getRootNode()
. This is illustrated in the figure below.
The figure shows that the ILcdTreeLayered
exposes a
root node for the hierarchical layer structure through the
getRootNode()
method.
At the same time, ILcdTreeLayered
is linked to all the layers of the
hierarchical structure, and provides a flat list
representation of this hierarchical layer structure. The root node is not
included in the flat list representation.
All the operations, defined in the ILcdLayered
interface, can now be performed on the hierarchical structure.
Adding and/or removing layers from the hierarchical structure will also remove them from the flat list representation, and vice versa.
Two support classes allow for an easy concrete
implementation of this interface in GXY views:
TLcdTreeLayeredSupport
and
TLcdIndependentOrderTreeLayeredSupport
. TLcdTreeLayeredSupport
is the default. It derives the flat list from the hierarchical layer structure, and keeps them
both synchronized. Moving a layer in the hierarchical structure will move the
layer in the flat list representation and vice versa. The
TLcdIndependentOrderTreeLayeredSupport
allows having an
independent layer order in the flat list representation and in the
hierarchical structure.
The following assumptions are made:
The class TLcdLayerTree
is available to
visualise the hierarchical layer structure.
ILcdTreeLayeredSupport
Modifier and Type | Method and Description |
---|---|
void |
addLayeredListener(ILcdLayeredListener aLayeredListener)
Registers the given
ILcdLayeredListener to be notified when layers are added,
removed or moved in the flat list. |
boolean |
containsLayer(ILcdLayer aLayer)
Returns whether the flat list representation of the hierarchical layer structure contains
the given layer.
|
ILcdLayer |
getLayer(int aIndex)
Returns the
ILcdLayer with index aIndex in the flat list
representation of the hierarchical layer structure. |
ILcdLayerTreeNode |
getRootNode()
Returns the root node of the tree structure.
|
int |
indexOf(ILcdLayer aLayer)
Returns the index of the given layer
aLayer in the flat list representation of
the hierarchical structure. |
int |
layerCount()
Returns the number of layers in the flat list representation of the hierarchical layer
structure.
|
ILcdLayer |
layerOf(ILcdModel aModel)
Returns the
ILcdLayer of the flat list that contains the given
ILcdModel . |
Enumeration |
layers()
Returns an
Enumeration of all the ILcdLayer s currently in the flat
list representation of the hierarchical layer structure, starting from the bottom layer to the
top layer. |
Enumeration |
layersBackwards()
Returns an
Enumeration of all the ILcdLayer s currently in the flat
list representation of the hierarchical layer structure, starting from the top layer to the
bottom layer. |
void |
removeAllLayers()
Remove all the layers from the hierarchical layer structure and the flat list
representation.
|
void |
removeLayer(ILcdLayer aLayer)
Removes a layer from both the hierarchical layer structure and the flat list representation.
|
void |
removeLayeredListener(ILcdLayeredListener aLayeredListener)
Unregisters the given
ILcdLayeredListener from receiving layered events for the
flat list. |
addLayeredListener, getLayers, moveLayerAt, removeLayeredListener
ILcdLayerTreeNode getRootNode()
Returns the root node of the tree structure.
int layerCount()
Returns the number of layers in the flat list representation of the hierarchical layer structure. This does not include the root node.
layerCount
in interface ILcdLayered
Enumeration layers()
Returns an Enumeration
of all the ILcdLayer
s 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.
layers
in interface ILcdLayered
Enumeration
of all the ILcdLayer
s currently in the flat
list, starting from the bottom layer to the top layer. Does not include the root node.Enumeration layersBackwards()
Returns an Enumeration
of all the ILcdLayer
s 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.
layersBackwards
in interface ILcdLayered
Enumeration
of all the ILcdLayer
s currently in the flat
list, starting from the top layer to the bottom layer. Does not include the root node.ILcdLayer getLayer(int aIndex) throws ArrayIndexOutOfBoundsException
Returns the ILcdLayer
with index aIndex
in the flat list
representation of the hierarchical layer structure.
getLayer
in interface ILcdLayered
aIndex
- the position of the layer to retrieve in the flat list representation.ILcdLayer
with index aIndex
in the flat list
representationArrayIndexOutOfBoundsException
- if the given index is invalidint indexOf(ILcdLayer aLayer) throws NoSuchElementException
Returns the index of the given layer aLayer
in the flat list representation of
the hierarchical structure.
indexOf
in interface ILcdLayered
aLayer
- the layer whose index to returnaLayer
in the flat list representationNoSuchElementException
- if aLayer
is not in the flat listvoid removeLayer(ILcdLayer aLayer)
Removes a layer from both the hierarchical layer structure and the flat list representation.
When removing an ILcdLayerTreeNode
all 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
removeLayer
in interface ILcdLayered
aLayer
- the layer to remove. If the layer is not in the flat list, this method has no effect.boolean containsLayer(ILcdLayer aLayer)
Returns whether the flat list representation of the hierarchical layer structure contains
the given layer. More formally, returns true
if and only if the flat list
representation contains at least one layer l
such 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.
containsLayer
in interface ILcdLayered
aLayer
- the layer to check whether it is in the flat list representationtrue
when the flat list representation contains the given layer,
false
otherwisevoid removeAllLayers()
Remove 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.
removeAllLayers
in interface ILcdLayered
void addLayeredListener(ILcdLayeredListener aLayeredListener)
ILcdLayeredListener
to be notified when layers are added,
removed or moved in the flat list.addLayeredListener
in interface ILcdLayered
aLayeredListener
- the listener that from now on will be notified of all changes to the
flat list.removeLayeredListener(com.luciad.view.ILcdLayeredListener)
void removeLayeredListener(ILcdLayeredListener aLayeredListener)
ILcdLayeredListener
from receiving layered events for the
flat list.removeLayeredListener
in interface ILcdLayered
aLayeredListener
- the listener that will no longer be notified of changes in the flat
list.addLayeredListener(com.luciad.view.ILcdLayeredListener)
ILcdLayer layerOf(ILcdModel aModel) throws NoSuchElementException
ILcdLayer
of the flat list that contains the given
ILcdModel
.layerOf
in interface ILcdLayered
aModel
- the model to check for in the flat listILcdLayer
of the flat list that contains the given
ILcdModel
.NoSuchElementException
- if there is no layer containing the given model