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.
Their is also no restriction on the model reference of the child models, as it is the case on
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 TypeMethodDescriptionvoid
addElement
(Object aElement, int aEventMode) Adds the specified element to this model.void
addElements
(Vector aElements, int aEventMode) Adds all of the elements in the specified vector to this model.void
addHierarchyModelContainerListener
(ILcdModelContainerListener aModelContainerListener) Registers the givenILcdModelContainerListener
to receiveTLcdModelContainerEvent
s from all theILcdModelTreeNode
s contained in the tree with this node as root node.void
addHierarchyModelListener
(ILcdModelListener aModelListener) Registers the givenILcdModelListener
to receiveTLcdModelChangedEvent
s from all theILcdModel
s contained in the tree with this node as root node.boolean
Adds theILcdModel aModel
as a child model to thisILcdModelTreeNode
.void
addModelContainerListener
(ILcdModelContainerListener aModelContainerListener) Adds anILcdModelContainerListener
to thisILcdModelContainer
.void
addModelListener
(ILcdModelListener aModelListener) Registers the specified model listener to receive notifications of model changes on this model.boolean
canAddElement
(Object aElement) Returnstrue
if the specified element can be added to this model,false
otherwise.boolean
canRemoveElement
(Object aElement) Returnstrue
if the specified element can be removed from this model,false
otherwise.void
dispose()
Disposes of this model and allows it to release any system resources that it is holding.void
elementChanged
(Object aElement, int aEventMode) Notifies this model that the specified element has changed.elements()
Returns an enumeration over all elements of this model.void
elementsChanged
(Vector aElements, int aEventMode) Notifies this model that the elements in the specified vector have changed.void
Notifies 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 theILcdModelDescriptor
providing meta information about this model and its elements.Returns, if available, a model encoder that is capable of encoding this model, (encoder.canEncode(this)
),null
otherwise.Returns theILcdModelReference
describing how the geometry of the elements contained in this model should be interpreted.boolean
isEmpty()
Returnstrue
when the model node is only used as a container for other models, and contains no useful data itself,false
otherwise.int
Returns the number of child models of this model node.models()
Returns anEnumeration
of the child models of thisILcdModelTreeNode
.void
removeAllElements
(int aEventMode) Removes all elements from this model.void
removeElement
(Object aElement, int aEventMode) Removes the specified element from this model.void
removeElements
(Vector aElements, int aEventMode) Removes all of the elements in the specified vector from this model.void
removeHierarchyModelContainerListener
(ILcdModelContainerListener aModelContainerListener) Unregisters the givenILcdModelContainerListener
from receivingTLcdModelContainerEvent
s for the tree with this node as root node.void
removeHierarchyModelListener
(ILcdModelListener aModelListener) Unregisters the givenILcdModelListener
from receivingTLcdModelChangedEvent
s for the tree with this node as root node.boolean
removeModel
(ILcdModel aModel) Removes the child modelaModel
from thisILcdModelTreeNode
.void
removeModelContainerListener
(ILcdModelContainerListener aModelContainerListener) Removes anILcdModelContainerListener
from thisILcdModelContainer
.void
removeModelListener
(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
close
Methods inherited from interface com.luciad.model.ILcdModel
getModelMetadata, query
Methods inherited from interface com.luciad.model.ILcdModelContainer
getModels
Methods inherited from interface com.luciad.model.ILcdModelProducerListener
modelProduced
-
Method Details
-
addHierarchyModelContainerListener
Registers the given
ILcdModelContainerListener
to receiveTLcdModelContainerEvent
s from all theILcdModelTreeNode
s 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
ILcdModelContainer
of the event can be retrieved by callingTLcdModelContainerEvent.getModelContainer()
on the receivedTLcdModelContainerEvent
.- Parameters:
aModelContainerListener
- the listener- See Also:
-
removeHierarchyModelContainerListener
Unregisters the given
ILcdModelContainerListener
from receivingTLcdModelContainerEvent
s for the tree with this node as root node.- Parameters:
aModelContainerListener
- the listener- See Also:
-
addHierarchyModelListener
Registers the given
ILcdModelListener
to receiveTLcdModelChangedEvent
s from all theILcdModel
s 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
ILcdModel
of the event can be retrieved by callingTLcdModelChangedEvent.getModel()
on the receivedTLcdModelChangedEvent
.- Parameters:
aModelListener
- the listener- See Also:
-
removeHierarchyModelListener
Unregisters the given
ILcdModelListener
from receivingTLcdModelChangedEvent
s for the tree with this node as root node.- Parameters:
aModelListener
- the listener- See Also:
-
getModelReference
ILcdModelReference getModelReference()Returns theILcdModelReference
describing 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:
getModelReference
in interfaceILcdModel
- Returns:
- the
ILcdModelReference
of thisILcdModel
.
-
getModelDescriptor
ILcdModelDescriptor getModelDescriptor()Returns theILcdModelDescriptor
providing 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:
getModelDescriptor
in interfaceILcdModel
- Returns:
- the
ILcdModelDescriptor
of 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:
addElement
in interfaceILcdModel
- Parameters:
aElement
- the element to be added to this model.aEventMode
- the mode for sending out the model change event. This can beFIRE_LATER
orNO_EVENT
.- See Also:
-
canAddElement
Returnstrue
if the specified element can be added to this model,false
otherwise.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:
canAddElement
in interfaceILcdModel
- Parameters:
aElement
- the element to be verified.- Returns:
true
if the specified element can be added to this model,false
otherwise.
-
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:
addElements
in 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_LATER
orNO_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:
removeElement
in interfaceILcdModel
- Parameters:
aElement
- the element to be removed from this model.aEventMode
- the mode for sending out the model change event. This can beFIRE_LATER
orNO_EVENT
.- See Also:
-
canRemoveElement
Returnstrue
if the specified element can be removed from this model,false
otherwise. 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:
canRemoveElement
in interfaceILcdModel
- Parameters:
aElement
- the element to be verified.- Returns:
true
if the specified element can be removed from this model,false
otherwise.
-
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:
removeElements
in 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_LATER
orNO_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:
removeAllElements
in interfaceILcdModel
- Parameters:
aEventMode
- the mode for sending out the model change event. This can beFIRE_LATER
orNO_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:
elementChanged
in interfaceILcdModel
- Parameters:
aElement
- the element that has changed.aEventMode
- the mode for sending out the model change event. This can beFIRE_LATER
orNO_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:
elementsChanged
in interfaceILcdModel
- Parameters:
aElements
- the vector of elements that have changed.aEventMode
- the mode for sending out the model change event. This can beFIRE_LATER
orNO_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:
fireCollectedModelChanges
in 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
ILcdFireEventMode
that 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
ALcdWeakModelListener
instance 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:
addModelListener
in interfaceILcdModel
- Parameters:
aModelListener
- theILcdModelListener
to 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:
removeModelListener
in interfaceILcdModel
- Parameters:
aModelListener
- theILcdModelListener
to remove.- See Also:
-
getModelEncoder
ILcdModelEncoder getModelEncoder()Returns, if available, a model encoder that is capable of encoding this model, (encoder.canEncode(this)
),null
otherwise.It is implementation-dependant whether this encoder considers the child models or not.
- Specified by:
getModelEncoder
in interfaceILcdModel
- Returns:
- a model encoder that is capable of encoding this model if available,
null
otherwise.
-
modelCount
int modelCount()Returns the number of child models of this model node.
- Specified by:
modelCount
in interfaceILcdModelContainer
- Returns:
- the number of child models of this model node.
-
addModel
Adds the
ILcdModel aModel
as a child model to thisILcdModelTreeNode
.- Specified by:
addModel
in interfaceILcdModelContainer
- Parameters:
aModel
- the model to be added.- Returns:
true
if this collection of models changed as a result of the call
-
removeModel
Removes the child model
aModel
from thisILcdModelTreeNode
.- Specified by:
removeModel
in interfaceILcdModelContainer
- Parameters:
aModel
- the model to be removed.- Returns:
true
if a model was removed as a result of this call
-
getModel
Returns the child model at the given index.
- Specified by:
getModel
in interfaceILcdModelContainer
- Parameters:
aIndex
- a valid index in thisILcdModelTreeNode
- Returns:
- the child model at the given index.
-
models
Enumeration models()Returns an
Enumeration
of the child models of thisILcdModelTreeNode
.- Specified by:
models
in interfaceILcdModelContainer
- Returns:
- an
Enumeration
of the child models of thisILcdModelTreeNode
.
-
addModelContainerListener
Adds anILcdModelContainerListener
to thisILcdModelContainer
.It will only receive notifications of changes in this
.ILcdModelTreeNode
and 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:
addModelContainerListener
in interfaceILcdModelContainer
- Parameters:
aModelContainerListener
- the listener to be added.- See Also:
-
removeModelContainerListener
Removes anILcdModelContainerListener
from thisILcdModelContainer
.It is not possible to remove a hierarchy model container listener. Use
removeHierarchyModelContainerListener(ILcdModelContainerListener)
for this purpose.- Specified by:
removeModelContainerListener
in 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:
dispose
in interfaceILcdDisposable
- Specified by:
dispose
in interfaceILcdModel
-
isEmpty
boolean isEmpty()Returns
true
when the model node is only used as a container for other models, and contains no useful data itself,false
otherwise.- Returns:
true
when the model node contains no useful data,false
otherwise
-