Class TLcdLayerTreeNodeSupport
- All Implemented Interfaces:
ILcdLayered
,Serializable
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 Summary
ConstructorDescriptionCreates a support object for nodeaNode
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHierarchyLayeredListener
(ILcdLayeredListener aListener) Registers the givenILcdLayeredListener
to receiveTLcdLayeredEvent
s from all theILcdLayerTreeNode
s contained in the tree with this node as root node.void
Registers the givenPropertyChangeListener
to receivePropertyChangeEvent
s from all theILcdLayer
s contained in the tree with this node as root node.void
Registers the givenILcdSelectionListener
to receiveTLcdSelectionChangedEvent
s from all theILcdLayer
s contained in the tree with this node as root node.boolean
Adds a new node to the tree as a child of this node.boolean
Adds a new node to the tree as a child of this node.void
addLayeredListener
(ILcdLayeredListener aListener) Registers the givenILcdLayeredListener
to be notified when layers are added, removed or moved.boolean
containsLayer
(ILcdLayer aLayer) Returns whether thisILcdLayered
contains the given layer.Returns the initial layer index provider, which can be used to determine the best index when a layer is added without specifying an index.getLayer
(int aIndex) Returns theILcdLayer
in thisILcdLayered
with indexaIndex
.int
Returns the index if the given layer is in the list.boolean
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.int
Returns the number ofILcdLayer
objects in thisILcdLayered
.Returns theILcdLayer
of thisILcdLayered
that contains the givenILcdModel
.layers()
Returns anEnumeration
of allILcdLayer
objects currently in thisILcdLayered
, starting from the bottom layer to the top layer.Returns anEnumeration
of allILcdLayer
objects currently in thisILcdLayered
, starting from the top layer to the bottom layer.void
moveLayerAt
(int aIndex, ILcdLayer aLayer) Moves the given layer (which is already inILcdLayered
) to the existing index aIndex.void
Removes all theILcdLayer
objects from thisILcdLayered
.void
Unregisters the givenILcdLayeredListener
from receivingTLcdLayeredEvent
s for the tree with this node as root node.void
Unregisters the givenPropertyChangeListener
from receivingPropertyChangeEvent
s for the tree with this node as root node.void
Unregisters the givenILcdSelectionListener
from receivingTLcdSelectionChangedEvent
s for the tree with this node as root node.void
removeLayer
(int aIndex) Removes the node at indexaIndex
from this node and sends the appropriateTLcdLayeredEvent
.void
removeLayer
(ILcdLayer aLayer) Removes aLayer from thisILcdLayered
.void
removeLayeredListener
(ILcdLayeredListener aListener) Unregisters the givenILcdLayeredListener
from receiving layered events for theILcdLayered
.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.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.view.ILcdLayered
addLayeredListener, getLayers, removeLayeredListener
-
Constructor Details
-
TLcdLayerTreeNodeSupport
Creates a support object for node
aNode
.- Parameters:
aNode
- the node for which a support object is needed
-
-
Method Details
-
addLayer
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 aTLcdLayeredEvent
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 layeraNewChildNode
- 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 treeaNewChildNode
must not already be an element of the tree. This method should also generate aTLcdLayeredEvent
to warn its listeners that a node has been added.- Parameters:
aNewChildNode
- the new childaIndex
- 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 layeraNewChildNode
- Throws:
IndexOutOfBoundsException
- whenindex > #getChildCount
IllegalArgumentException
- when the node is already an element of the tree
-
removeLayer
Description copied from interface:ILcdLayered
Removes aLayer from thisILcdLayered
.- Specified by:
removeLayer
in interfaceILcdLayered
- Parameters:
aLayer
- the layer to remove.
-
removeLayer
public void removeLayer(int aIndex) Removes the node at index
aIndex
from this node and sends the appropriateTLcdLayeredEvent
.- Parameters:
aIndex
- the index of the child node which has to be removed
-
getLayer
Description copied from interface:ILcdLayered
Returns theILcdLayer
in thisILcdLayered
with indexaIndex
.- Specified by:
getLayer
in interfaceILcdLayered
- Parameters:
aIndex
- the position of the layer to retrieve in theILcdLayered
.- Returns:
- the
ILcdLayer
in thisILcdLayered
with indexaIndex
. - Throws:
IndexOutOfBoundsException
-
layerCount
public int layerCount()Description copied from interface:ILcdLayered
Returns the number ofILcdLayer
objects in thisILcdLayered
.- Specified by:
layerCount
in interfaceILcdLayered
- Returns:
- the number of
ILcdLayer
objects in thisILcdLayered
.
-
layers
Description copied from interface:ILcdLayered
Returns anEnumeration
of allILcdLayer
objects currently in thisILcdLayered
, starting from the bottom layer to the top layer.- Specified by:
layers
in interfaceILcdLayered
- Returns:
- an
Enumeration
of allILcdLayer
objects currently in thisILcdLayered
, 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 inILcdLayered
) 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 allILcdLayer
objects in from previousIndex + 1 to aIndex is decremented with 1. If previousIndex > aIndex, then the index of allILcdLayer
objects in from aIndex to previousIndex -1 is incremented with 1.- Specified by:
moveLayerAt
in interfaceILcdLayered
- Parameters:
aIndex
- the index of the position where to move the layer.aLayer
- the layer to move.- Throws:
NoSuchElementException
- ifaLayer
is not in thisILcdLayered
.ArrayIndexOutOfBoundsException
- ifaIndex
is not an index of one of the layers of thisILcdLayered
.
-
indexOf
Description copied from interface:ILcdLayered
Returns the index if the given layer is in the list.- Specified by:
indexOf
in interfaceILcdLayered
- Parameters:
aLayer
- the layer whose index to return- Returns:
- the index of
aLayer
- Throws:
NoSuchElementException
- ifaLayer
is not in the list
-
addLayeredListener
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 interfaceILcdLayered
- Parameters:
aListener
- the listener that from now on will be notified of all changes to theILcdLayered
- See Also:
-
removeLayeredListener
Description copied from interface:ILcdLayered
Unregisters the givenILcdLayeredListener
from receiving layered events for theILcdLayered
.- Specified by:
removeLayeredListener
in interfaceILcdLayered
- Parameters:
aListener
- the listener that will no longer be notified of changes to theILcdLayered
- See Also:
-
addHierarchyLayeredListener
Registers the given
ILcdLayeredListener
to receiveTLcdLayeredEvent
s from all theILcdLayerTreeNode
s contained in the tree with this node as root node.The source
ILcdLayered
of the event can be retrieved by callingTLcdLayeredEvent.getLayered()
on the receivedTLcdLayeredEvent
.- Parameters:
aListener
- the listener
-
removeHierarchyLayeredListener
Unregisters the given
ILcdLayeredListener
from receivingTLcdLayeredEvent
s for the tree with this node as root node.- Parameters:
aListener
- the listener
-
addHierarchyPropertyChangeListener
Registers the given
PropertyChangeListener
to receivePropertyChangeEvent
s from all theILcdLayer
s 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 receivedPropertyChangeEvent
.- Parameters:
aListener
- the listener
-
addHierarchySelectionListener
Registers the given
ILcdSelectionListener
to receiveTLcdSelectionChangedEvent
s from all theILcdLayer
s 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 receivedTLcdSelectionChangedEvent
.- Parameters:
aListener
- the listener
-
removeHierarchySelectionListener
Unregisters the given
ILcdSelectionListener
from receivingTLcdSelectionChangedEvent
s for the tree with this node as root node.- Parameters:
aListener
- the listener
-
removeHierarchyPropertyChangeListener
Unregisters the given
PropertyChangeListener
from receivingPropertyChangeEvent
s for the tree with this node as root node.- Parameters:
aListener
- the listener
-
removeAllLayers
public void removeAllLayers()Removes all theILcdLayer
objects from thisILcdLayered
.An event will be fired for every removed layer.
- Specified by:
removeAllLayers
in interfaceILcdLayered
-
layersBackwards
Description copied from interface:ILcdLayered
Returns anEnumeration
of allILcdLayer
objects currently in thisILcdLayered
, starting from the top layer to the bottom layer.- Specified by:
layersBackwards
in interfaceILcdLayered
- Returns:
- an
Enumeration
of allILcdLayer
objects currently in thisILcdLayered
, starting from the top layer to the bottom layer.
-
layerOf
Description copied from interface:ILcdLayered
Returns theILcdLayer
of thisILcdLayered
that contains the givenILcdModel
.- Specified by:
layerOf
in interfaceILcdLayered
- Parameters:
aModel
- the model to check for in thisILcdLayered
.- Returns:
- the
ILcdLayer
of thisILcdLayered
that contains the givenILcdModel
. - Throws:
NoSuchElementException
- if there is no layer containing the given model
-
containsLayer
Description copied from interface:ILcdLayered
Returns whether thisILcdLayered
contains the given layer. More formally, returnstrue
if and only if theILcdLayered
contains at least one layerl
such that (aLayer==null ? l==null : aLayer.equals(l)).- Specified by:
containsLayer
in interfaceILcdLayered
- Parameters:
aLayer
- the layer to check whether it is in this layered.- Returns:
- true if
aLayer
is in thisILcdLayered
, 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 theILcdLayerTreeNode
for which this support class is created to fire thePropertyChangeEvent
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
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 theILcdLayerTreeNode
for which this support class is created to fire thePropertyChangeEvent
if needed.- Parameters:
aInitialLayerIndexProvider
- The new initial layer index provider. May benull
- See Also:
-
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:
-