Interface ILcdModelTreeNode
- All Superinterfaces:
AutoCloseable,EventListener,ILcdDisposable,ILcdModel,ILcdModelContainer,ILcdModelProducerListener,Serializable
- All Known Implementing Classes:
TLcd2DBoundsIndexedModelTreeNode,TLcdGML2AbstractFeatureCollection,TLcdGML31AbstractFeatureCollection,TLcdGML31DynamicFeatureCollection,TLcdGML31FeatureCollection,TLcdGML31Model,TLcdGML32AbstractFeatureCollection,TLcdGML32FeatureCollection,TLcdGML32Model,TLcdKML22AbstractContainer,TLcdKML22Document,TLcdKML22DynamicModel,TLcdKML22Folder,TLcdKML22Kml,TLcdKML22NetworkLink,TLcdModelTreeNode
An ILcdModelTreeNode is an ILcdModel which can
also have child models. This allows to create a hierarchical model structure.

This interface extends ILcdModelContainer since it
is a container for its child models. Therefore, all methods inherited from
ILcdModelContainer only apply on the child models. An example is modelCount() which will return the number of child models of this model node. This does not
include the node itself.
It also extends ILcdModel since every model node is a model
itself. Therefore, all methods inherited from ILcdModel only apply on the node, and
not on its child models. For example calling addElement(Object, int) will add the
element only to this model node, and not to all its child models.
The difference with a TLcdModelList is that the model
list is a composite model where an ILcdModelTreeNode is a model itself, which can
have child models. As a consequence, all the methods inherited from ILcdModel will
only perform on the node and not on its children. For example calling ILcdModel.elements() on a node will return all the elements in the node, while calling it on a
model list will return all the elements of all the sub models of the model list.
There are no restrictions on the model reference of the child models, unlike in a TLcdModelList.
It is possible to attach listeners which will be notified of changes in the whole hierarchical
structure (see addHierarchyModelContainerListener(ILcdModelContainerListener) and addHierarchyModelListener(ILcdModelListener)) or which will only be notified of changes in the
node (see addModelListener(ILcdModelListener) and addModelContainerListener(ILcdModelContainerListener)).
A model node can contain data itself, but it can also be used as a container for models and
contain no useful data itself. Such a node is empty, and should return true for
isEmpty().
- Since:
- 9.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.model.ILcdModel
ILcdModel.Query -
Field Summary
Fields inherited from interface com.luciad.model.ILcdModel
FIRE_LATER, FIRE_NOW, NO_EVENT -
Method Summary
Modifier and TypeMethodDescriptionvoidaddElement(Object aElement, int aEventMode) Adds the specified element to this model.voidaddElements(Vector aElements, int aEventMode) Adds all of the elements in the specified vector to this model.voidaddHierarchyModelContainerListener(ILcdModelContainerListener aModelContainerListener) Registers the givenILcdModelContainerListenerto receiveTLcdModelContainerEvents from all theILcdModelTreeNodes contained in the tree with this node as root node.voidaddHierarchyModelListener(ILcdModelListener aModelListener) Registers the givenILcdModelListenerto receiveTLcdModelChangedEvents from all theILcdModels contained in the tree with this node as root node.booleanAdds theILcdModel aModelas a child model to thisILcdModelTreeNode.voidaddModelContainerListener(ILcdModelContainerListener aModelContainerListener) Adds anILcdModelContainerListenerto thisILcdModelContainer.voidaddModelListener(ILcdModelListener aModelListener) Registers the specified model listener to receive notifications of model changes on this model.booleancanAddElement(Object aElement) Returnstrueif the specified element can be added to this model,falseotherwise.booleancanRemoveElement(Object aElement) Returnstrueif the specified element can be removed from this model,falseotherwise.voiddispose()Disposes of this model and allows it to release any system resources that it is holding.voidelementChanged(Object aElement, int aEventMode) Notifies this model that the specified element has changed.elements()Returns an enumeration over all elements of this model.voidelementsChanged(Vector aElements, int aEventMode) Notifies this model that the elements in the specified vector have changed.voidNotifies all listeners that are registered on this model of all the changes that have been collected between the previous notification and now.getModel(int aIndex) Returns the child model at the given index.Returns theILcdModelDescriptorproviding meta information about this model and its elements.Returns, if available, a model encoder that is capable of encoding this model, (encoder.canEncode(this)),nullotherwise.Returns theILcdModelReferencedescribing how the geometry of the elements contained in this model should be interpreted.booleanisEmpty()Returnstruewhen the model node is only used as a container for other models, and contains no useful data itself,falseotherwise.intReturns the number of child models of this model node.models()Returns anEnumerationof the child models of thisILcdModelTreeNode.voidremoveAllElements(int aEventMode) Removes all elements from this model.voidremoveElement(Object aElement, int aEventMode) Removes the specified element from this model.voidremoveElements(Vector aElements, int aEventMode) Removes all of the elements in the specified vector from this model.voidremoveHierarchyModelContainerListener(ILcdModelContainerListener aModelContainerListener) Unregisters the givenILcdModelContainerListenerfrom receivingTLcdModelContainerEvents for the tree with this node as root node.voidremoveHierarchyModelListener(ILcdModelListener aModelListener) Unregisters the givenILcdModelListenerfrom receivingTLcdModelChangedEvents for the tree with this node as root node.booleanremoveModel(ILcdModel aModel) Removes the child modelaModelfrom thisILcdModelTreeNode.voidremoveModelContainerListener(ILcdModelContainerListener aModelContainerListener) Removes anILcdModelContainerListenerfrom thisILcdModelContainer.voidremoveModelListener(ILcdModelListener aModelListener) Unregisters the specified model listener so that it no longer receives notifications of model changes on this model.Methods inherited from interface com.luciad.util.ILcdDisposable
closeMethods inherited from interface com.luciad.model.ILcdModel
getModelMetadata, queryMethods inherited from interface com.luciad.model.ILcdModelContainer
getModelsMethods inherited from interface com.luciad.model.ILcdModelProducerListener
modelProduced
-
Method Details
-
addHierarchyModelContainerListener
Registers the given
ILcdModelContainerListenerto receiveTLcdModelContainerEvents from all theILcdModelTreeNodes contained in the tree with this node as root node. If the listener should only receive events originating from this model node, it should be adedd as a regular model listener (seeaddModelContainerListener(ILcdModelContainerListener)).The source
ILcdModelContainerof the event can be retrieved by callingTLcdModelContainerEvent.getModelContainer()on the receivedTLcdModelContainerEvent.- Parameters:
aModelContainerListener- the listener- See Also:
-
removeHierarchyModelContainerListener
Unregisters the given
ILcdModelContainerListenerfrom receivingTLcdModelContainerEvents for the tree with this node as root node.- Parameters:
aModelContainerListener- the listener- See Also:
-
addHierarchyModelListener
Registers the given
ILcdModelListenerto receiveTLcdModelChangedEvents from all theILcdModels contained in the tree with this node as root node. If the listener should only receive events originating from this model node, it should be added as a regular model listener (seeaddModelListener(ILcdModelListener)).The source
ILcdModelof the event can be retrieved by callingTLcdModelChangedEvent.getModel()on the receivedTLcdModelChangedEvent.- Parameters:
aModelListener- the listener- See Also:
-
removeHierarchyModelListener
Unregisters the given
ILcdModelListenerfrom receivingTLcdModelChangedEvents for the tree with this node as root node.- Parameters:
aModelListener- the listener- See Also:
-
getModelReference
ILcdModelReference getModelReference()Returns theILcdModelReferencedescribing how the geometry of the elements contained in this model should be interpreted.This model reference is independent of the model reference(s) of the child models of this node.
- Specified by:
getModelReferencein interfaceILcdModel- Returns:
- the
ILcdModelReferenceof thisILcdModel.
-
getModelDescriptor
ILcdModelDescriptor getModelDescriptor()Returns theILcdModelDescriptorproviding meta information about this model and its elements.This model descriptor is independent of the model descriptor(s) of the child models of this node.
- Specified by:
getModelDescriptorin interfaceILcdModel- Returns:
- the
ILcdModelDescriptorof thisILcdModel. Should not benull.
-
elements
Enumeration elements()Returns an enumeration over all elements of this model. The order in which the elements are enumerated is unspecified by default.The elements of the child model(s) are not included in this enumeration.
-
addElement
Adds the specified element to this model.Models that support this operation may place limitations on what elements may be added to this model. For example, implementations that are based on a spatial indexing structure will require that elements implement
ILcdBounded.When adding an element, the user should make sure that
canAddElement(aElement)holds, and that the element's geometry is expressed in the same model reference as this model. It is generally undefined what happens if an invalid element is added.Implementations of this interface should clearly specify in their documentation any restrictions on what elements may be added. Although it is unspecified what happens if the preconditions are not met, implementations are encouraged to throw meaningful exceptions (for example,
NullPointerException, IllegalArgumentException, ClassCastException, UnsupportedOperationException), whenever possible.The element will only be added to this model node and not to any of the child model(s).
- Specified by:
addElementin interfaceILcdModel- Parameters:
aElement- the element to be added to this model.aEventMode- the mode for sending out the model change event. This can beFIRE_LATERorNO_EVENT.- See Also:
-
canAddElement
Returnstrueif the specified element can be added to this model,falseotherwise.Note that this method generally does not validate whether the specified element is expressed in the same model reference as this model. It is the responsibility of the user of this model to make sure this precondition is fulfilled when an element is added to this model.
This method only checks this model node and not any of the child models.
- Specified by:
canAddElementin interfaceILcdModel- Parameters:
aElement- the element to be verified.- Returns:
trueif the specified element can be added to this model,falseotherwise.
-
addElements
Adds all of the elements in the specified vector to this model. Models that support this operation may place limitations on what elements may be added to this model. For example, implementations that are based on a spatial indexing structure will require that elements implementILcdBounded. Implementations of this interface should clearly specify in their documentation any restrictions on what elements may be added.The behavior of this operation is undefined if the specified vector is modified while the operation is in progress.
The specified elements will be added to this model in the order they are specified in the vector. If an element cannot be added, this method will return at the first failure. Succeeding elements won't be added.
Although it is unspecified what happens if the preconditions are not met, implementations are encouraged to throw meaningful exceptions (for example,
NullPointerException, IllegalArgumentException, ClassCastException, UnsupportedOperationException), whenever possible.The elements will only be added to this model node and not to any of the child model(s).
- Specified by:
addElementsin interfaceILcdModel- Parameters:
aElements- the vector of elements to be added to this model.aEventMode- the mode for sending the model change events This can beFIRE_LATERorNO_EVENT.- See Also:
-
removeElement
Removes the specified element from this model. If the specified element is not contained in this model, this method has no effect.Although it is unspecified what happens if the preconditions are not met, implementations are encouraged to throw meaningful exceptions (for example,
NullPointerException, IllegalArgumentException, ClassCastException, UnsupportedOperationException), whenever possible.The element will not be removed from the child model(s).
- Specified by:
removeElementin interfaceILcdModel- Parameters:
aElement- the element to be removed from this model.aEventMode- the mode for sending out the model change event. This can beFIRE_LATERorNO_EVENT.- See Also:
-
canRemoveElement
Returnstrueif the specified element can be removed from this model,falseotherwise. Note that this method generally does not check whether the specified element is actually contained in this model.This method will only check this model node and not any of the child models.
- Specified by:
canRemoveElementin interfaceILcdModel- Parameters:
aElement- the element to be verified.- Returns:
trueif the specified element can be removed from this model,falseotherwise.
-
removeElements
Removes all of the elements in the specified vector from this model. If one of the elements in the specified vector is not contained in this model, this element will be ignored.The behavior of this operation is undefined if the specified vector is modified while the operation is in progress.
The specified elements will be removed from this model in the order they are specified in the vector. If an element cannot be removed, this method will return at the first failure. Succeeding elements won't be removed.
Although it is unspecified what happens if the preconditions are not met, implementations are encouraged to throw meaningful exceptions (for example,
NullPointerException, IllegalArgumentException, ClassCastException, UnsupportedOperationException), whenever possible.The elements will not be removed from the child model(s).
- Specified by:
removeElementsin interfaceILcdModel- Parameters:
aElements- the vector of elements to be removed from this model.aEventMode- the mode for sending out the model change event. This can beFIRE_LATERorNO_EVENT.- See Also:
-
removeAllElements
void removeAllElements(int aEventMode) Removes all elements from this model.If an element cannot be removed, this method will return at the first failure. Succeeding elements won't be removed.
Although it is unspecified what happens if the preconditions are not met, implementations are encouraged to throw meaningful exceptions (for example,
NullPointerException, IllegalArgumentException, ClassCastException, UnsupportedOperationException), whenever possible.It will not remove any elements from any of the child models.
- Specified by:
removeAllElementsin interfaceILcdModel- Parameters:
aEventMode- the mode for sending out the model change event. This can beFIRE_LATERorNO_EVENT.
-
elementChanged
Notifies this model that the specified element has changed.When an element in one the child models has changed, this method must be called on that child model and not on this node.
- Specified by:
elementChangedin interfaceILcdModel- Parameters:
aElement- the element that has changed.aEventMode- the mode for sending out the model change event. This can beFIRE_LATERorNO_EVENT.
-
elementsChanged
Notifies this model that the elements in the specified vector have changed.When elements of one of the child models have changed, this method must be called on that child model and not on this node.
- Specified by:
elementsChangedin interfaceILcdModel- Parameters:
aElements- the vector of elements that have changed.aEventMode- the mode for sending out the model change event. This can beFIRE_LATERorNO_EVENT.
-
fireCollectedModelChanges
void fireCollectedModelChanges()Notifies all listeners that are registered on this model of all the changes that have been collected between the previous notification and now.Notice that both the hierarchical as the regular registered model listeners will be notified.
Only the changes in this model node will be fired, not the changes in any of the child models.
- Specified by:
fireCollectedModelChangesin interfaceILcdModel- See Also:
-
addModelListener
Registers the specified model listener to receive notifications of model changes on this model.
Model changes are sent out when an element has been added, removed or changed. Model changes can be sent out individually, grouped or silently applied without notifications, depending on the
ILcdFireEventModethat was specified with the change.In case you need to register a listener which keeps a reference to an object with a shorter life-time than this model, you can use a
ALcdWeakModelListenerinstance as model listener.The model listener will not receive any notifications of model changes in any of the child models. If the listener should also receive notifications about changes in the child models, it should be registered as a hierarchy listener (see
addHierarchyModelListener(ILcdModelListener)).- Specified by:
addModelListenerin interfaceILcdModel- Parameters:
aModelListener- theILcdModelListenerto register on this model.- See Also:
-
removeModelListener
Unregisters the specified model listener so that it no longer receives notifications of model changes on this model.It is not possible to unregister hierarchy model listeners with this method. Use
removeHierarchyModelListener(ILcdModelListener)for this purpose.- Specified by:
removeModelListenerin interfaceILcdModel- Parameters:
aModelListener- theILcdModelListenerto remove.- See Also:
-
getModelEncoder
ILcdModelEncoder getModelEncoder()Returns, if available, a model encoder that is capable of encoding this model, (encoder.canEncode(this)),nullotherwise.It is implementation-dependant whether this encoder considers the child models or not.
- Specified by:
getModelEncoderin interfaceILcdModel- Returns:
- a model encoder that is capable of encoding this model if available,
nullotherwise.
-
modelCount
int modelCount()Returns the number of child models of this model node.
- Specified by:
modelCountin interfaceILcdModelContainer- Returns:
- the number of child models of this model node.
-
addModel
Adds the
ILcdModel aModelas a child model to thisILcdModelTreeNode.- Specified by:
addModelin interfaceILcdModelContainer- Parameters:
aModel- the model to be added.- Returns:
trueif this collection of models changed as a result of the call
-
removeModel
Removes the child model
aModelfrom thisILcdModelTreeNode.- Specified by:
removeModelin interfaceILcdModelContainer- Parameters:
aModel- the model to be removed.- Returns:
trueif a model was removed as a result of this call
-
getModel
Returns the child model at the given index.
- Specified by:
getModelin interfaceILcdModelContainer- Parameters:
aIndex- a valid index in thisILcdModelTreeNode- Returns:
- the child model at the given index.
-
models
Enumeration models()Returns an
Enumerationof the child models of thisILcdModelTreeNode.- Specified by:
modelsin interfaceILcdModelContainer- Returns:
- an
Enumerationof the child models of thisILcdModelTreeNode.
-
addModelContainerListener
Adds anILcdModelContainerListenerto thisILcdModelContainer.It will only receive notifications of changes in this
.ILcdModelTreeNodeand not of any changes in the state of the child model node(s). If this is required, the listener must be registered as a hierarchy listener (seeaddHierarchyModelContainerListener(ILcdModelContainerListener)).- Specified by:
addModelContainerListenerin interfaceILcdModelContainer- Parameters:
aModelContainerListener- the listener to be added.- See Also:
-
removeModelContainerListener
Removes anILcdModelContainerListenerfrom thisILcdModelContainer.It is not possible to remove a hierarchy model container listener. Use
removeHierarchyModelContainerListener(ILcdModelContainerListener)for this purpose.- Specified by:
removeModelContainerListenerin interfaceILcdModelContainer- Parameters:
aModelContainerListener- the listener to be removed.- See Also:
-
dispose
void dispose()Disposes of this model and allows it to release any system resources that it is holding. The result of calling any other method (other thanfinalize) on this model subsequent to a call to this method is undefined.Calling this method will not dispose any of the child models, or alter the hierarchical structure. If the child models should also be disposed, this method should be called on those models.
- Specified by:
disposein interfaceILcdDisposable- Specified by:
disposein interfaceILcdModel
-
isEmpty
boolean isEmpty()Returns
truewhen the model node is only used as a container for other models, and contains no useful data itself,falseotherwise.- Returns:
truewhen the model node contains no useful data,falseotherwise
-