Class TLcdTreeLayeredSupport

java.lang.Object
com.luciad.view.TLcdTreeLayeredSupport
All Implemented Interfaces:
ILcdLayered, ILcdTreeLayered, ILcdTreeLayeredSupport, Serializable
Direct Known Subclasses:
TLcdIndependentOrderTreeLayeredSupport

public class TLcdTreeLayeredSupport extends Object implements ILcdTreeLayeredSupport

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 Details

    • TLcdTreeLayeredSupport

      public TLcdTreeLayeredSupport(ILcdLayered aLayeredToSupport, ILcdLayerTreeNode aRootNode)

      Constructs a new TLcdTreeLayeredSupport for a tree with root node aRootNode.

      Parameters:
      aLayeredToSupport - the ILcdLayered that will delegate to this support
      aRootNode - the root node of the hierarchical layer structure
    • TLcdTreeLayeredSupport

      public TLcdTreeLayeredSupport(ILcdLayerTreeNode aRootNode)

      Constructs a new TLcdTreeLayeredSupport for a tree with root node aRootNode.

      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

      public void setLayeredToSupport(ILcdLayered aLayeredToSupport)

      Sets the ILcdLayered for 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 an ILcdLayered as a parameter, calling this method is not necessary since this is already done by the constructor.

      Specified by:
      setLayeredToSupport in interface ILcdTreeLayeredSupport
      Parameters:
      aLayeredToSupport - the ILcdLayered that will delegate to this support
    • getRootNode

      public ILcdLayerTreeNode getRootNode()
      Description copied from interface: ILcdTreeLayered

      Returns the root node of the tree structure.

      Specified by:
      getRootNode in interface ILcdTreeLayered
      Returns:
      the root node of the tree structure
    • addLayeredListener

      public void addLayeredListener(ILcdLayeredListener aLayeredListener)
      Description copied from interface: ILcdTreeLayered
      Registers the given ILcdLayeredListener to be notified when layers are added, removed or moved in the flat list.
      Specified by:
      addLayeredListener in interface ILcdLayered
      Specified by:
      addLayeredListener in interface ILcdTreeLayered
      Parameters:
      aLayeredListener - the listener that from now on will be notified of all changes to the flat list.
      See Also:
    • removeLayeredListener

      public void removeLayeredListener(ILcdLayeredListener aLayeredListener)
      Description copied from interface: ILcdTreeLayered
      Unregisters the given ILcdLayeredListener from receiving layered events for the flat list.
      Specified by:
      removeLayeredListener in interface ILcdLayered
      Specified by:
      removeLayeredListener in interface ILcdTreeLayered
      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: ILcdTreeLayered

      Returns the number of layers in the flat list representation of the hierarchical layer structure. This does not include the root node.

      Specified by:
      layerCount in interface ILcdLayered
      Specified by:
      layerCount in interface ILcdTreeLayered
      Returns:
      the number of layers in the flat list. Does not include the root node.
    • layers

      public Enumeration layers()
      Description copied from interface: ILcdTreeLayered

      Returns an Enumeration of all the ILcdLayers 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:
      layers in interface ILcdLayered
      Specified by:
      layers in interface ILcdTreeLayered
      Returns:
      an Enumeration of all the ILcdLayers currently in the flat list, starting from the bottom layer to the top layer. Does not include the root node.
    • layersBackwards

      public Enumeration layersBackwards()
      Description copied from interface: ILcdTreeLayered

      Returns an Enumeration of all the ILcdLayers 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:
      layersBackwards in interface ILcdLayered
      Specified by:
      layersBackwards in interface ILcdTreeLayered
      Returns:
      an Enumeration of all the ILcdLayers currently in the flat list, starting from the top layer to the bottom layer. Does not include the root node.
    • getLayer

      public ILcdLayer getLayer(int aIndex) throws ArrayIndexOutOfBoundsException
      Description copied from interface: ILcdTreeLayered

      Returns the ILcdLayer with index aIndex in the flat list representation of the hierarchical layer structure.

      Specified by:
      getLayer in interface ILcdLayered
      Specified by:
      getLayer in interface ILcdTreeLayered
      Parameters:
      aIndex - the position of the layer to retrieve in the flat list representation.
      Returns:
      the ILcdLayer with index aIndex in the flat list representation
      Throws:
      ArrayIndexOutOfBoundsException - if the given index is invalid
    • layerOf

      public ILcdLayer layerOf(ILcdModel aModel) throws NoSuchElementException
      Description copied from interface: ILcdTreeLayered
      Returns the ILcdLayer of the flat list that contains the given ILcdModel.
      Specified by:
      layerOf in interface ILcdLayered
      Specified by:
      layerOf in interface ILcdTreeLayered
      Parameters:
      aModel - the model to check for in the flat list
      Returns:
      the ILcdLayer of the flat list that contains the given ILcdModel.
      Throws:
      NoSuchElementException - if there is no layer containing the given model
    • indexOf

      public int indexOf(ILcdLayer aLayer) throws NoSuchElementException
      Description copied from interface: ILcdTreeLayered

      Returns the index of the given layer aLayer in the flat list representation of the hierarchical structure.

      Specified by:
      indexOf in interface ILcdLayered
      Specified by:
      indexOf in interface ILcdTreeLayered
      Parameters:
      aLayer - the layer whose index to return
      Returns:
      the index of aLayer in the flat list representation
      Throws:
      NoSuchElementException - if aLayer is not in the flat list
    • moveLayerAt

      public void moveLayerAt(int aIndex, ILcdLayer aLayer) throws NoSuchElementException, ArrayIndexOutOfBoundsException

      Tries to move the layer aLayer to index aIndex, without affecting the tree structure, in a best effort approach. This best effort approach can be seen as follows:

      1. First the layer at index aIndex is searched.
      2. Then the first common ancestor of layer aLayer and the layer at index aIndex is searched
      3. Once the first common ancestor is found, the subtree containing aLayer is moved to the position of the subtree containing the layer at index aIndex in the child list of the common ancestor

      This also means that after calling this method the index of the layer aLayer can be different from the requested index aIndex.

      Specified by:
      moveLayerAt in interface ILcdLayered
      Parameters:
      aIndex - the desired index for the layer aLayer
      aLayer - the layer to move.
      Throws:
      NoSuchElementException - if aLayer is not in this ILcdLayered.
      ArrayIndexOutOfBoundsException - if aIndex is not an index of one of the layers of this ILcdLayered.
    • removeLayer

      public void removeLayer(ILcdLayer aLayer)
      Description copied from interface: ILcdTreeLayered

      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

      Specified by:
      removeLayer in interface ILcdLayered
      Specified by:
      removeLayer in interface ILcdTreeLayered
      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: ILcdTreeLayered

      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.

      Specified by:
      removeAllLayers in interface ILcdLayered
      Specified by:
      removeAllLayers in interface ILcdTreeLayered
    • containsLayer

      public boolean containsLayer(ILcdLayer aLayer)
      Description copied from interface: ILcdTreeLayered

      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.

      Specified by:
      containsLayer in interface ILcdLayered
      Specified by:
      containsLayer in interface ILcdTreeLayered
      Parameters:
      aLayer - the layer to check whether it is in the flat list representation
      Returns:
      true when the flat list representation contains the given layer, false otherwise
    • getLayeredToSupport

      public ILcdLayered getLayeredToSupport()
      Description copied from interface: ILcdTreeLayeredSupport

      Returns the ILcdLayered for which this support is created.

      Specified by:
      getLayeredToSupport in interface ILcdTreeLayeredSupport
      Returns:
      the ILcdLayered for which this support is created.