Class TLcdLayerTreeNodeSupport

java.lang.Object
com.luciad.view.TLcdLayerTreeNodeSupport
All Implemented Interfaces:
ILcdLayered, Serializable

public class TLcdLayerTreeNodeSupport extends Object implements ILcdLayered

This is a utility class that can be used to create an ILcdLayerTreeNode implementation. This utility class provides support for all the methods in ILcdLayerTreeNode which are not inherited from ILcdLayer.

As a consequence, this class is ideal for creating ILcdLayerTreeNode implementations based on an existing ILcdLayer implementation. All those ILcdLayerTreeNode methods can then be delegated to an instance of this class.

Since:
9.0
See Also:
  • Constructor Details

    • TLcdLayerTreeNodeSupport

      public TLcdLayerTreeNodeSupport(ILcdLayerTreeNode aNode)

      Creates a support object for node aNode.

      Parameters:
      aNode - the node for which a support object is needed
  • Method Details

    • addLayer

      public boolean addLayer(ILcdLayer aNewChildNode) throws IllegalArgumentException

      Adds a new node to the tree as a child of this node. Notice that in order to avoid loops in the tree aNewChildNode must not already be an element of the tree. This method should also generate a TLcdLayeredEvent to warn its listeners that a node has been added.

      In order to determine the index at which aNewChildNode is inserted the initial layer index provider is used. When no such provider is set, the layer is added as the last child layer.

      Parameters:
      aNewChildNode - the node which must be added as a child
      Returns:
      true when the layer was successfully added to this node, false if the node already contained layer aNewChildNode
      Throws:
      IllegalArgumentException - when the node is already an element of the tree
    • addLayer

      public boolean addLayer(ILcdLayer aNewChildNode, int aIndex) throws IndexOutOfBoundsException, IllegalArgumentException

      Adds a new node to the tree as a child of this node. The child will be inserted at index aIndex in the child list of this node. Notice that in order to avoid loops in the tree aNewChildNode must not already be an element of the tree. This method should also generate a TLcdLayeredEvent to warn its listeners that a node has been added.

      Parameters:
      aNewChildNode - the new child
      aIndex - the index in the child list of this node for the new child
      Returns:
      true when the layer was successfully added to this node, false if the node already contained layer aNewChildNode
      Throws:
      IndexOutOfBoundsException - when index > #getChildCount
      IllegalArgumentException - when the node is already an element of the tree
    • removeLayer

      public void removeLayer(ILcdLayer aLayer)
      Description copied from interface: ILcdLayered
      Removes aLayer from this ILcdLayered.
      Specified by:
      removeLayer in interface ILcdLayered
      Parameters:
      aLayer - the layer to remove.
    • removeLayer

      public void removeLayer(int aIndex)

      Removes the node at index aIndex from this node and sends the appropriate TLcdLayeredEvent.

      Parameters:
      aIndex - the index of the child node which has to be removed
    • getLayer

      public ILcdLayer getLayer(int aIndex) throws IndexOutOfBoundsException
      Description copied from interface: ILcdLayered
      Returns the ILcdLayer in this ILcdLayered with index aIndex.
      Specified by:
      getLayer in interface ILcdLayered
      Parameters:
      aIndex - the position of the layer to retrieve in the ILcdLayered.
      Returns:
      the ILcdLayer in this ILcdLayered with index aIndex.
      Throws:
      IndexOutOfBoundsException
    • layerCount

      public int layerCount()
      Description copied from interface: ILcdLayered
      Returns the number of ILcdLayer objects in this ILcdLayered.
      Specified by:
      layerCount in interface ILcdLayered
      Returns:
      the number of ILcdLayer objects in this ILcdLayered.
    • layers

      public Enumeration layers()
      Description copied from interface: ILcdLayered
      Returns an Enumeration of all ILcdLayer objects currently in this ILcdLayered, starting from the bottom layer to the top layer.
      Specified by:
      layers in interface ILcdLayered
      Returns:
      an Enumeration of all ILcdLayer objects currently in this ILcdLayered, starting from the bottom layer to the top layer.
    • moveLayerAt

      public void moveLayerAt(int aIndex, ILcdLayer aLayer) throws NoSuchElementException, ArrayIndexOutOfBoundsException
      Description copied from interface: ILcdLayered
      Moves the given layer (which is already in ILcdLayered) to the existing index aIndex. When a layer is moved down, all layers in between the previous and future position of the given layer (including the layer at index aIndex) are moved one position up. When a layer is moved up, all layers in between the previous and future position of the given layer (including the layer at index aIndex) are moved one position down.

      More formally, let previousIndex be the index of aLayer before the move. If previousIndex < aIndex, then the index of all ILcdLayer objects in from previousIndex + 1 to aIndex is decremented with 1. If previousIndex > aIndex, then the index of all ILcdLayer objects in from aIndex to previousIndex -1 is incremented with 1.

      Specified by:
      moveLayerAt in interface ILcdLayered
      Parameters:
      aIndex - the index of the position where to move the layer.
      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.
    • indexOf

      public int indexOf(ILcdLayer aLayer) throws NoSuchElementException
      Description copied from interface: ILcdLayered
      Returns the index if the given layer is in the list.
      Specified by:
      indexOf in interface ILcdLayered
      Parameters:
      aLayer - the layer whose index to return
      Returns:
      the index of aLayer
      Throws:
      NoSuchElementException - if aLayer is not in the list
    • addLayeredListener

      public void addLayeredListener(ILcdLayeredListener aListener)
      Description copied from interface: ILcdLayered

      Registers the given ILcdLayeredListener to be notified when layers are added, removed or moved.

      In case you need to register a listener which keeps a reference to an object with a shorter life-time than this layered, you can use a ALcdWeakLayeredListener instance as layered listener.

      Specified by:
      addLayeredListener in interface ILcdLayered
      Parameters:
      aListener - the listener that from now on will be notified of all changes to the ILcdLayered
      See Also:
    • removeLayeredListener

      public void removeLayeredListener(ILcdLayeredListener aListener)
      Description copied from interface: ILcdLayered
      Unregisters the given ILcdLayeredListener from receiving layered events for the ILcdLayered.
      Specified by:
      removeLayeredListener in interface ILcdLayered
      Parameters:
      aListener - the listener that will no longer be notified of changes to the ILcdLayered
      See Also:
    • addHierarchyLayeredListener

      public void addHierarchyLayeredListener(ILcdLayeredListener aListener)

      Registers the given ILcdLayeredListener to receive TLcdLayeredEvents from all the ILcdLayerTreeNodes contained in the tree with this node as root node.

      The source ILcdLayered of the event can be retrieved by calling TLcdLayeredEvent.getLayered() on the received TLcdLayeredEvent.

      Parameters:
      aListener - the listener
    • removeHierarchyLayeredListener

      public void removeHierarchyLayeredListener(ILcdLayeredListener aListener)

      Unregisters the given ILcdLayeredListener from receiving TLcdLayeredEvents for the tree with this node as root node.

      Parameters:
      aListener - the listener
    • addHierarchyPropertyChangeListener

      public void addHierarchyPropertyChangeListener(PropertyChangeListener aListener)

      Registers the given PropertyChangeListener to receive PropertyChangeEvents from all the ILcdLayers contained in the tree with this node as root node.

      The source layer of the event can be retrieved by calling EventObject.getSource() on the received PropertyChangeEvent.

      Parameters:
      aListener - the listener
    • addHierarchySelectionListener

      public void addHierarchySelectionListener(ILcdSelectionListener aListener)

      Registers the given ILcdSelectionListener to receive TLcdSelectionChangedEvents from all the ILcdLayers contained in the tree with this node as root node.

      The source layer of the event can be retrieved by calling TLcdSelectionChangedEvent.getSelection() on the received TLcdSelectionChangedEvent.

      Parameters:
      aListener - the listener
    • removeHierarchySelectionListener

      public void removeHierarchySelectionListener(ILcdSelectionListener aListener)

      Unregisters the given ILcdSelectionListener from receiving TLcdSelectionChangedEvents for the tree with this node as root node.

      Parameters:
      aListener - the listener
    • removeHierarchyPropertyChangeListener

      public void removeHierarchyPropertyChangeListener(PropertyChangeListener aListener)

      Unregisters the given PropertyChangeListener from receiving PropertyChangeEvents for the tree with this node as root node.

      Parameters:
      aListener - the listener
    • removeAllLayers

      public void removeAllLayers()
      Removes all the ILcdLayer objects from this ILcdLayered.

      An event will be fired for every removed layer.

      Specified by:
      removeAllLayers in interface ILcdLayered
    • layersBackwards

      public Enumeration layersBackwards()
      Description copied from interface: ILcdLayered
      Returns an Enumeration of all ILcdLayer objects currently in this ILcdLayered, starting from the top layer to the bottom layer.
      Specified by:
      layersBackwards in interface ILcdLayered
      Returns:
      an Enumeration of all ILcdLayer objects currently in this ILcdLayered, starting from the top layer to the bottom layer.
    • layerOf

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

      public boolean containsLayer(ILcdLayer aLayer)
      Description copied from interface: ILcdLayered
      Returns whether this ILcdLayered contains the given layer. More formally, returns true if and only if the ILcdLayered contains at least one layer l such that (aLayer==null ? l==null : aLayer.equals(l)).
      Specified by:
      containsLayer in interface ILcdLayered
      Parameters:
      aLayer - the layer to check whether it is in this layered.
      Returns:
      true if aLayer is in this ILcdLayered, false otherwise.
    • isPaintOnTopOfChildrenHint

      public boolean isPaintOnTopOfChildrenHint()

      Returns whether a node should be painted on top of its children when the node is added to a view, or beneath its child layers.

      Returns:
      true when a node should be painted on top of its children, false when the node should be painted underneath its child layers
      See Also:
    • setPaintOnTopOfChildrenHint

      public void setPaintOnTopOfChildrenHint(boolean aPaintOnTopOfChildrenHint)

      Sets whether a node should be painted on top of its children when the node is added to a view, or beneath its child layers. Notice that this is only a hint, hence the paint order of the node and its children is not guaranteed.

      This property must be set before the node is added to the view. Otherwise it will have no effect. Changing it afterwards will have no effect, unless the node is removed and readded to the view.

      The default behavior is to paint nodes underneath the child layers.

      This method does not fires a PropertyChangeEvent. It is up to the ILcdLayerTreeNode for which this support class is created to fire the PropertyChangeEvent if needed.

      Parameters:
      aPaintOnTopOfChildrenHint - true when a node should be painted on top of its children, false when the node should be painted underneath its child layers
      See Also:
    • setInitialLayerIndexProvider

      public void setInitialLayerIndexProvider(ILcdInitialLayerIndexProvider aInitialLayerIndexProvider)

      Sets an initial layer index provider, which can be used to determine the best index when a layer is added without specifying an index.

      This method does not fires a PropertyChangeEvent. It is up to the ILcdLayerTreeNode for which this support class is created to fire the PropertyChangeEvent if needed.

      Parameters:
      aInitialLayerIndexProvider - The new initial layer index provider. May be null
      See Also:
    • getInitialLayerIndexProvider

      public ILcdInitialLayerIndexProvider getInitialLayerIndexProvider()

      Returns the initial layer index provider, which can be used to determine the best index when a layer is added without specifying an index.

      The support class will use this provider when the addLayer(ILcdLayer) method is called.

      Returns:
      the initial layer index provider. Can be null
      See Also: