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.
Constructor and Description |
---|
TLcdLayerTreeNodeSupport(ILcdLayerTreeNode aNode)
Creates a support object for node
aNode . |
Modifier and Type | Method and Description |
---|---|
void |
addHierarchyLayeredListener(ILcdLayeredListener aListener)
Registers the given
ILcdLayeredListener to receive
TLcdLayeredEvent s from all the ILcdLayerTreeNode s contained in the
tree with this node as root node. |
void |
addHierarchyPropertyChangeListener(PropertyChangeListener aListener)
Registers the given
PropertyChangeListener to
receive PropertyChangeEvent s from all the ILcdLayer s contained in the
tree with this node as root node. |
void |
addHierarchySelectionListener(ILcdSelectionListener aListener)
Registers the given
ILcdSelectionListener to
receive TLcdSelectionChangedEvent s from all the ILcdLayer s contained
in the tree with this node as root node. |
boolean |
addLayer(ILcdLayer aNewChildNode)
Adds a new node to the tree as a child of this node.
|
boolean |
addLayer(ILcdLayer aNewChildNode,
int aIndex)
Adds a new node to the tree as a child of this node.
|
void |
addLayeredListener(ILcdLayeredListener aListener)
Registers the given
ILcdLayeredListener to be notified when layers are added, removed or moved. |
boolean |
containsLayer(ILcdLayer aLayer)
Returns whether this
ILcdLayered contains the given layer. |
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.
|
ILcdLayer |
getLayer(int aIndex)
Returns the
ILcdLayer in this ILcdLayered
with index aIndex . |
int |
indexOf(ILcdLayer aLayer)
Returns the index if the given layer is in the list.
|
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.
|
int |
layerCount()
Returns the number of
ILcdLayer objects in this ILcdLayered . |
ILcdLayer |
layerOf(ILcdModel aModel)
Returns the
ILcdLayer of this ILcdLayered that contains the given ILcdModel . |
Enumeration |
layers()
Returns an
Enumeration of all ILcdLayer objects currently
in this ILcdLayered ,
starting from the bottom layer to the top layer. |
Enumeration |
layersBackwards()
Returns an
Enumeration of all ILcdLayer objects currently in this ILcdLayered ,
starting from the top layer to the bottom layer. |
void |
moveLayerAt(int aIndex,
ILcdLayer aLayer)
Moves the given layer (which is already in
ILcdLayered ) to the existing index
aIndex. |
void |
removeAllLayers()
Removes all the
ILcdLayer objects from this ILcdLayered . |
void |
removeHierarchyLayeredListener(ILcdLayeredListener aListener)
Unregisters the given
ILcdLayeredListener from
receiving TLcdLayeredEvent s for the tree with this node as root node. |
void |
removeHierarchyPropertyChangeListener(PropertyChangeListener aListener)
Unregisters the given
PropertyChangeListener from
receiving PropertyChangeEvent s for the tree with this node as root node. |
void |
removeHierarchySelectionListener(ILcdSelectionListener aListener)
Unregisters the given
ILcdSelectionListener
from receiving TLcdSelectionChangedEvent s for the tree with this node as root
node. |
void |
removeLayer(ILcdLayer aLayer)
Removes aLayer from this
ILcdLayered . |
void |
removeLayer(int aIndex)
Removes the node at index
aIndex from this node and sends the appropriate
TLcdLayeredEvent . |
void |
removeLayeredListener(ILcdLayeredListener aListener)
Unregisters the given
ILcdLayeredListener from receiving layered events for
the ILcdLayered . |
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addLayeredListener, getLayers, removeLayeredListener
public TLcdLayerTreeNodeSupport(ILcdLayerTreeNode aNode)
Creates a support object for node aNode
.
aNode
- the node for which a support object is neededpublic 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.
aNewChildNode
- the node which must be added as a childtrue
when the layer was successfully added to this node, false
if the node already contained layer aNewChildNode
IllegalArgumentException
- when the node is already an element of the treepublic 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.
aNewChildNode
- the new childaIndex
- the index in the child list of this node for the new childtrue
when the layer was successfully added to this node, false
if the node already contained layer aNewChildNode
IndexOutOfBoundsException
- when index > #getChildCount
IllegalArgumentException
- when the node is already an element of the treepublic void removeLayer(ILcdLayer aLayer)
ILcdLayered
ILcdLayered
.removeLayer
in interface ILcdLayered
aLayer
- the layer to remove.public void removeLayer(int aIndex)
Removes the node at index aIndex
from this node and sends the appropriate
TLcdLayeredEvent
.
aIndex
- the index of the child node which has to be removedpublic ILcdLayer getLayer(int aIndex) throws IndexOutOfBoundsException
ILcdLayered
ILcdLayer
in this ILcdLayered
with index aIndex
.getLayer
in interface ILcdLayered
aIndex
- the position of the layer to retrieve in the ILcdLayered
.ILcdLayer
in this ILcdLayered
with index aIndex
.ArrayIndexOutOfBoundsException
- if the given index is invalidIndexOutOfBoundsException
public int layerCount()
ILcdLayered
ILcdLayer
objects in this ILcdLayered
.layerCount
in interface ILcdLayered
ILcdLayer
objects in this ILcdLayered
.public Enumeration layers()
ILcdLayered
Enumeration
of all ILcdLayer
objects currently
in this ILcdLayered
,
starting from the bottom layer to the top layer.layers
in interface ILcdLayered
Enumeration
of all ILcdLayer
objects currently
in this ILcdLayered
,
starting from the bottom layer to the top layer.public void moveLayerAt(int aIndex, ILcdLayer aLayer) throws NoSuchElementException, ArrayIndexOutOfBoundsException
ILcdLayered
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.
moveLayerAt
in interface ILcdLayered
aIndex
- the index of the position where to move the layer.aLayer
- the layer to move.NoSuchElementException
- if aLayer
is not in this ILcdLayered
.ArrayIndexOutOfBoundsException
- if aIndex
is not an index of one of
the layers of this ILcdLayered
.public int indexOf(ILcdLayer aLayer) throws NoSuchElementException
ILcdLayered
indexOf
in interface ILcdLayered
aLayer
- the layer whose index to returnaLayer
NoSuchElementException
- if aLayer
is not in the listpublic void addLayeredListener(ILcdLayeredListener aListener)
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.
addLayeredListener
in interface ILcdLayered
aListener
- the listener that from now on will be notified of all changes
to the ILcdLayered
ILcdLayered.removeLayeredListener(com.luciad.view.ILcdLayeredListener)
public void removeLayeredListener(ILcdLayeredListener aListener)
ILcdLayered
ILcdLayeredListener
from receiving layered events for
the ILcdLayered
.removeLayeredListener
in interface ILcdLayered
aListener
- the listener that will no longer be notified of changes
to the ILcdLayered
ILcdLayered.addLayeredListener(ILcdLayeredListener)
public void addHierarchyLayeredListener(ILcdLayeredListener aListener)
Registers the given ILcdLayeredListener
to receive
TLcdLayeredEvent
s from all the ILcdLayerTreeNode
s 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
.
aListener
- the listenerpublic void removeHierarchyLayeredListener(ILcdLayeredListener aListener)
Unregisters the given ILcdLayeredListener
from
receiving TLcdLayeredEvent
s for the tree with this node as root node.
aListener
- the listenerpublic void addHierarchyPropertyChangeListener(PropertyChangeListener aListener)
Registers the given PropertyChangeListener
to
receive PropertyChangeEvent
s from all the ILcdLayer
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 received PropertyChangeEvent
.
aListener
- the listenerpublic void addHierarchySelectionListener(ILcdSelectionListener aListener)
Registers the given ILcdSelectionListener
to
receive TLcdSelectionChangedEvent
s from all the ILcdLayer
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 received TLcdSelectionChangedEvent
.
aListener
- the listenerpublic void removeHierarchySelectionListener(ILcdSelectionListener aListener)
Unregisters the given ILcdSelectionListener
from receiving TLcdSelectionChangedEvent
s for the tree with this node as root
node.
aListener
- the listenerpublic void removeHierarchyPropertyChangeListener(PropertyChangeListener aListener)
Unregisters the given PropertyChangeListener
from
receiving PropertyChangeEvent
s for the tree with this node as root node.
aListener
- the listenerpublic void removeAllLayers()
ILcdLayer
objects from this ILcdLayered
.
An event will be fired for every removed layer.
removeAllLayers
in interface ILcdLayered
public Enumeration layersBackwards()
ILcdLayered
Enumeration
of all ILcdLayer
objects currently in this ILcdLayered
,
starting from the top layer to the bottom layer.layersBackwards
in interface ILcdLayered
Enumeration
of all ILcdLayer
objects currently in this ILcdLayered
,
starting from the top layer to the bottom layer.public ILcdLayer layerOf(ILcdModel aModel) throws NoSuchElementException
ILcdLayered
ILcdLayer
of this ILcdLayered
that contains the given ILcdModel
.layerOf
in interface ILcdLayered
aModel
- the model to check for in this ILcdLayered
.ILcdLayer
of this ILcdLayered
that contains the given ILcdModel
.NoSuchElementException
- if there is no layer containing the given modelpublic boolean containsLayer(ILcdLayer aLayer)
ILcdLayered
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)).containsLayer
in interface ILcdLayered
aLayer
- the layer to check whether it is in this layered.aLayer
is in this ILcdLayered
,
false otherwise.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.
true
when a node should be painted on top of its children,
false
when the node should be painted underneath its child layerssetPaintOnTopOfChildrenHint(boolean)
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.
aPaintOnTopOfChildrenHint
- true
when a node should be painted on top of its
children, false
when the node should be painted
underneath its child layersisPaintOnTopOfChildrenHint()
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.
aInitialLayerIndexProvider
- The new initial layer index provider. May be
null
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.
null
setInitialLayerIndexProvider(ILcdInitialLayerIndexProvider)