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
ConstructorsConstructorDescriptionCreates a support object for nodeaNode. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHierarchyLayeredListener(ILcdLayeredListener aListener) Registers the givenILcdLayeredListenerto receiveTLcdLayeredEvents from all theILcdLayerTreeNodes contained in the tree with this node as root node.voidRegisters the givenPropertyChangeListenerto receivePropertyChangeEvents from all theILcdLayers contained in the tree with this node as root node.voidRegisters the givenILcdSelectionListenerto receiveTLcdSelectionChangedEvents from all theILcdLayers contained in the tree with this node as root node.booleanAdds a new node to the tree as a child of this node.booleanAdds a new node to the tree as a child of this node.voidaddLayeredListener(ILcdLayeredListener aListener) Registers the givenILcdLayeredListenerto be notified when layers are added, removed or moved.booleancontainsLayer(ILcdLayer aLayer) Returns whether thisILcdLayeredcontains 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 theILcdLayerin thisILcdLayeredwith indexaIndex.intReturns the index if the given layer is in the list.booleanReturns whether a node should be painted on top of its children when the node is added to a view, or beneath its child layers.intReturns the number ofILcdLayerobjects in thisILcdLayered.Returns theILcdLayerof thisILcdLayeredthat contains the givenILcdModel.layers()Returns anEnumerationof allILcdLayerobjects currently in thisILcdLayered, starting from the bottom layer to the top layer.Returns anEnumerationof allILcdLayerobjects currently in thisILcdLayered, starting from the top layer to the bottom layer.voidmoveLayerAt(int aIndex, ILcdLayer aLayer) Moves the given layer (which is already inILcdLayered) to the existing index aIndex.voidRemoves all theILcdLayerobjects from thisILcdLayered.voidUnregisters the givenILcdLayeredListenerfrom receivingTLcdLayeredEvents for the tree with this node as root node.voidUnregisters the givenPropertyChangeListenerfrom receivingPropertyChangeEvents for the tree with this node as root node.voidUnregisters the givenILcdSelectionListenerfrom receivingTLcdSelectionChangedEvents for the tree with this node as root node.voidremoveLayer(int aIndex) Removes the node at indexaIndexfrom this node and sends the appropriateTLcdLayeredEvent.voidremoveLayer(ILcdLayer aLayer) Removes aLayer from thisILcdLayered.voidremoveLayeredListener(ILcdLayeredListener aListener) Unregisters the givenILcdLayeredListenerfrom receiving layered events for theILcdLayered.voidsetInitialLayerIndexProvider(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.voidsetPaintOnTopOfChildrenHint(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, waitMethods 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
aNewChildNodemust not already be an element of the tree. This method should also generate aTLcdLayeredEventto warn its listeners that a node has been added.In order to determine the index at which
aNewChildNodeis 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:
truewhen the layer was successfully added to this node,falseif 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
aIndexin the child list of this node. Notice that in order to avoid loops in the treeaNewChildNodemust not already be an element of the tree. This method should also generate aTLcdLayeredEventto 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:
truewhen the layer was successfully added to this node,falseif the node already contained layeraNewChildNode- Throws:
IndexOutOfBoundsException- whenindex > #getChildCountIllegalArgumentException- when the node is already an element of the tree
-
removeLayer
Description copied from interface:ILcdLayeredRemoves aLayer from thisILcdLayered.- Specified by:
removeLayerin interfaceILcdLayered- Parameters:
aLayer- the layer to remove.
-
removeLayer
public void removeLayer(int aIndex) Removes the node at index
aIndexfrom this node and sends the appropriateTLcdLayeredEvent.- Parameters:
aIndex- the index of the child node which has to be removed
-
getLayer
Description copied from interface:ILcdLayeredReturns theILcdLayerin thisILcdLayeredwith indexaIndex.- Specified by:
getLayerin interfaceILcdLayered- Parameters:
aIndex- the position of the layer to retrieve in theILcdLayered.- Returns:
- the
ILcdLayerin thisILcdLayeredwith indexaIndex. - Throws:
IndexOutOfBoundsException
-
layerCount
public int layerCount()Description copied from interface:ILcdLayeredReturns the number ofILcdLayerobjects in thisILcdLayered.- Specified by:
layerCountin interfaceILcdLayered- Returns:
- the number of
ILcdLayerobjects in thisILcdLayered.
-
layers
Description copied from interface:ILcdLayeredReturns anEnumerationof allILcdLayerobjects currently in thisILcdLayered, starting from the bottom layer to the top layer.- Specified by:
layersin interfaceILcdLayered- Returns:
- an
Enumerationof allILcdLayerobjects 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:ILcdLayeredMoves 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
aLayerbefore the move. If previousIndex < aIndex, then the index of allILcdLayerobjects in from previousIndex + 1 to aIndex is decremented with 1. If previousIndex > aIndex, then the index of allILcdLayerobjects in from aIndex to previousIndex -1 is incremented with 1.- Specified by:
moveLayerAtin interfaceILcdLayered- Parameters:
aIndex- the index of the position where to move the layer.aLayer- the layer to move.- Throws:
NoSuchElementException- ifaLayeris not in thisILcdLayered.ArrayIndexOutOfBoundsException- ifaIndexis not an index of one of the layers of thisILcdLayered.
-
indexOf
Description copied from interface:ILcdLayeredReturns the index if the given layer is in the list.- Specified by:
indexOfin interfaceILcdLayered- Parameters:
aLayer- the layer whose index to return- Returns:
- the index of
aLayer - Throws:
NoSuchElementException- ifaLayeris not in the list
-
addLayeredListener
Description copied from interface:ILcdLayeredRegisters the given
ILcdLayeredListenerto 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
ALcdWeakLayeredListenerinstance as layered listener.- Specified by:
addLayeredListenerin interfaceILcdLayered- Parameters:
aListener- the listener that from now on will be notified of all changes to theILcdLayered- See Also:
-
removeLayeredListener
Description copied from interface:ILcdLayeredUnregisters the givenILcdLayeredListenerfrom receiving layered events for theILcdLayered.- Specified by:
removeLayeredListenerin interfaceILcdLayered- Parameters:
aListener- the listener that will no longer be notified of changes to theILcdLayered- See Also:
-
addHierarchyLayeredListener
Registers the given
ILcdLayeredListenerto receiveTLcdLayeredEvents from all theILcdLayerTreeNodes contained in the tree with this node as root node.The source
ILcdLayeredof the event can be retrieved by callingTLcdLayeredEvent.getLayered()on the receivedTLcdLayeredEvent.- Parameters:
aListener- the listener
-
removeHierarchyLayeredListener
Unregisters the given
ILcdLayeredListenerfrom receivingTLcdLayeredEvents for the tree with this node as root node.- Parameters:
aListener- the listener
-
addHierarchyPropertyChangeListener
Registers the given
PropertyChangeListenerto receivePropertyChangeEvents from all theILcdLayers 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
ILcdSelectionListenerto receiveTLcdSelectionChangedEvents from all theILcdLayers 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
ILcdSelectionListenerfrom receivingTLcdSelectionChangedEvents for the tree with this node as root node.- Parameters:
aListener- the listener
-
removeHierarchyPropertyChangeListener
Unregisters the given
PropertyChangeListenerfrom receivingPropertyChangeEvents for the tree with this node as root node.- Parameters:
aListener- the listener
-
removeAllLayers
public void removeAllLayers()Removes all theILcdLayerobjects from thisILcdLayered.An event will be fired for every removed layer.
- Specified by:
removeAllLayersin interfaceILcdLayered
-
layersBackwards
Description copied from interface:ILcdLayeredReturns anEnumerationof allILcdLayerobjects currently in thisILcdLayered, starting from the top layer to the bottom layer.- Specified by:
layersBackwardsin interfaceILcdLayered- Returns:
- an
Enumerationof allILcdLayerobjects currently in thisILcdLayered, starting from the top layer to the bottom layer.
-
layerOf
Description copied from interface:ILcdLayeredReturns theILcdLayerof thisILcdLayeredthat contains the givenILcdModel.- Specified by:
layerOfin interfaceILcdLayered- Parameters:
aModel- the model to check for in thisILcdLayered.- Returns:
- the
ILcdLayerof thisILcdLayeredthat contains the givenILcdModel. - Throws:
NoSuchElementException- if there is no layer containing the given model
-
containsLayer
Description copied from interface:ILcdLayeredReturns whether thisILcdLayeredcontains the given layer. More formally, returnstrueif and only if theILcdLayeredcontains at least one layerlsuch that (aLayer==null ? l==null : aLayer.equals(l)).- Specified by:
containsLayerin interfaceILcdLayered- Parameters:
aLayer- the layer to check whether it is in this layered.- Returns:
- true if
aLayeris 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:
truewhen a node should be painted on top of its children,falsewhen 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 theILcdLayerTreeNodefor which this support class is created to fire thePropertyChangeEventif needed.- Parameters:
aPaintOnTopOfChildrenHint-truewhen a node should be painted on top of its children,falsewhen 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 theILcdLayerTreeNodefor which this support class is created to fire thePropertyChangeEventif 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:
-