public interface ILcdModelTreeNode extends ILcdModel, ILcdModelContainer
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()
.
ILcdModel.Query
FIRE_LATER, FIRE_NOW, NO_EVENT
Modifier and Type | Method and Description |
---|---|
void |
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 given
ILcdModelContainerListener to receive TLcdModelContainerEvent s from all the
ILcdModelTreeNode s contained in the tree with this node as root node. |
void |
addHierarchyModelListener(ILcdModelListener aModelListener)
Registers the given
ILcdModelListener to receive
TLcdModelChangedEvent s from all the ILcdModel s contained in the tree
with this node as root node. |
boolean |
addModel(ILcdModel aModel)
Adds the
ILcdModel aModel as a child model to this
ILcdModelTreeNode . |
void |
addModelContainerListener(ILcdModelContainerListener aModelContainerListener)
Adds an
ILcdModelContainerListener to this ILcdModelContainer . |
void |
addModelListener(ILcdModelListener aModelListener)
Registers the specified model listener to receive notifications of model changes on this model.
|
boolean |
canAddElement(Object aElement)
Returns
true if the specified element can be added to this model, false otherwise. |
boolean |
canRemoveElement(Object aElement)
Returns
true 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.
|
Enumeration |
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 |
fireCollectedModelChanges()
Notifies all listeners that are registered on this model of all the changes that have been collected between the
previous notification and now.
|
ILcdModel |
getModel(int aIndex)
Returns the child model at the given index.
|
ILcdModelDescriptor |
getModelDescriptor()
Returns the
ILcdModelDescriptor providing meta information about this model and
its elements. |
ILcdModelEncoder |
getModelEncoder()
Returns, if available, a model encoder that is capable of encoding this model,
(
encoder.canEncode(this) ), null otherwise. |
ILcdModelReference |
getModelReference()
Returns the
ILcdModelReference describing how the geometry of the elements contained in this
model should be interpreted. |
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. |
int |
modelCount()
Returns the number of child models of this model node.
|
Enumeration |
models()
Returns an
Enumeration of the child models of this
ILcdModelTreeNode . |
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 given
ILcdModelContainerListener from receiving TLcdModelContainerEvent s for the tree
with this node as root node. |
void |
removeHierarchyModelListener(ILcdModelListener aModelListener)
Unregisters the given
ILcdModelListener from
receiving TLcdModelChangedEvent s for the tree with this node as root node. |
boolean |
removeModel(ILcdModel aModel)
Removes the child model
aModel from this ILcdModelTreeNode . |
void |
removeModelContainerListener(ILcdModelContainerListener aModelContainerListener)
Removes an
ILcdModelContainerListener from this ILcdModelContainer . |
void |
removeModelListener(ILcdModelListener aModelListener)
Unregisters the specified model listener so that it no longer receives notifications of model changes on this model.
|
all, filter, getModelMetadata, query
close
getModels
modelProduced
void addHierarchyModelContainerListener(ILcdModelContainerListener aModelContainerListener)
Registers the given ILcdModelContainerListener
to receive TLcdModelContainerEvent
s from all the
ILcdModelTreeNode
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 (see addModelContainerListener(ILcdModelContainerListener)
).
The source ILcdModelContainer
of the event can be retrieved by calling TLcdModelContainerEvent.getModelContainer()
on the received TLcdModelContainerEvent
.
aModelContainerListener
- the listenerremoveHierarchyModelContainerListener(ILcdModelContainerListener)
void removeHierarchyModelContainerListener(ILcdModelContainerListener aModelContainerListener)
Unregisters the given ILcdModelContainerListener
from receiving TLcdModelContainerEvent
s for the tree
with this node as root node.
aModelContainerListener
- the listeneraddHierarchyModelContainerListener(ILcdModelContainerListener)
void addHierarchyModelListener(ILcdModelListener aModelListener)
Registers the given ILcdModelListener
to receive
TLcdModelChangedEvent
s from all the ILcdModel
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 (see addModelListener(ILcdModelListener)
).
The source ILcdModel
of the event can be retrieved by calling TLcdModelChangedEvent.getModel()
on the received TLcdModelChangedEvent
.
aModelListener
- the listenerremoveHierarchyModelListener(ILcdModelListener)
void removeHierarchyModelListener(ILcdModelListener aModelListener)
Unregisters the given ILcdModelListener
from
receiving TLcdModelChangedEvent
s for the tree with this node as root node.
aModelListener
- the listeneraddHierarchyModelListener(ILcdModelListener)
ILcdModelReference getModelReference()
ILcdModelReference
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.
getModelReference
in interface ILcdModel
ILcdModelReference
of this ILcdModel
.ILcdModelDescriptor getModelDescriptor()
ILcdModelDescriptor
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.
getModelDescriptor
in interface ILcdModel
ILcdModelDescriptor
of this ILcdModel
. Should not be null
.Enumeration elements()
The elements of the child model(s) are not included in this enumeration.
void addElement(Object aElement, int aEventMode)
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).
addElement
in interface ILcdModel
aElement
- the element to be added to this model.aEventMode
- the mode for sending out the model change event. This can be FIRE_LATER
or NO_EVENT
.ILcdModel.canAddElement(Object)
boolean canAddElement(Object aElement)
true
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.
canAddElement
in interface ILcdModel
aElement
- the element to be verified.true
if the specified element can be added to this model, false
otherwise.void addElements(Vector aElements, int aEventMode)
ILcdBounded
. 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).
addElements
in interface ILcdModel
aElements
- the vector of elements to be added to this model.aEventMode
- the mode for sending the model change events This can be FIRE_LATER
or NO_EVENT
.ILcdModel.canAddElement(Object)
void removeElement(Object aElement, int aEventMode)
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).
removeElement
in interface ILcdModel
aElement
- the element to be removed from this model.aEventMode
- the mode for sending out the model change event. This can be FIRE_LATER
or NO_EVENT
.ILcdModel.canRemoveElement(Object)
boolean canRemoveElement(Object aElement)
true
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.
canRemoveElement
in interface ILcdModel
aElement
- the element to be verified.true
if the specified element can be removed from this model, false
otherwise.void removeElements(Vector aElements, int aEventMode)
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).
removeElements
in interface ILcdModel
aElements
- the vector of elements to be removed from this model.aEventMode
- the mode for sending out the model change event. This can be FIRE_LATER
or NO_EVENT
.ILcdModel.canRemoveElement(Object)
void removeAllElements(int aEventMode)
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.
removeAllElements
in interface ILcdModel
aEventMode
- the mode for sending out the model change event. This can be FIRE_LATER
or NO_EVENT
.void elementChanged(Object aElement, int aEventMode)
When an element in one the child models has changed, this method must be called on that child model and not on this node.
elementChanged
in interface ILcdModel
aElement
- the element that has changed.aEventMode
- the mode for sending out the model change event. This can be FIRE_LATER
or NO_EVENT
.void elementsChanged(Vector aElements, int aEventMode)
When elements of one of the child models have changed, this method must be called on that child model and not on this node.
elementsChanged
in interface ILcdModel
aElements
- the vector of elements that have changed.aEventMode
- the mode for sending out the model change event. This can be FIRE_LATER
or NO_EVENT
.void fireCollectedModelChanges()
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.
fireCollectedModelChanges
in interface ILcdModel
ILcdModelListener.modelChanged(TLcdModelChangedEvent)
void addModelListener(ILcdModelListener aModelListener)
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)
).
addModelListener
in interface ILcdModel
aModelListener
- the ILcdModelListener
to register on this model.ILcdModel.removeModelListener(com.luciad.model.ILcdModelListener)
,
ILcdModelListener
void removeModelListener(ILcdModelListener aModelListener)
It is not possible to unregister hierarchy model listeners with this method. Use removeHierarchyModelListener(ILcdModelListener)
for this purpose.
removeModelListener
in interface ILcdModel
aModelListener
- the ILcdModelListener
to remove.ILcdModel.addModelListener(com.luciad.model.ILcdModelListener)
,
ILcdModelListener
ILcdModelEncoder getModelEncoder()
encoder.canEncode(this)
), null
otherwise.
It is implementation-dependant whether this encoder considers the child models or not.
getModelEncoder
in interface ILcdModel
null
otherwise.int modelCount()
Returns the number of child models of this model node.
modelCount
in interface ILcdModelContainer
boolean addModel(ILcdModel aModel)
Adds the ILcdModel aModel
as a child model to this
ILcdModelTreeNode
.
addModel
in interface ILcdModelContainer
aModel
- the model to be added.true
if this collection of models changed as a result of the callboolean removeModel(ILcdModel aModel)
Removes the child model aModel
from this ILcdModelTreeNode
.
removeModel
in interface ILcdModelContainer
aModel
- the model to be removed.true
if a model was removed as a result of this callILcdModel getModel(int aIndex)
Returns the child model at the given index.
getModel
in interface ILcdModelContainer
aIndex
- a valid index in this ILcdModelTreeNode
Enumeration models()
Returns an Enumeration
of the child models of this
ILcdModelTreeNode
.
models
in interface ILcdModelContainer
Enumeration
of the child models of this ILcdModelTreeNode
.void addModelContainerListener(ILcdModelContainerListener aModelContainerListener)
ILcdModelContainerListener
to this ILcdModelContainer
.
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 (see addHierarchyModelContainerListener(ILcdModelContainerListener)
).
addModelContainerListener
in interface ILcdModelContainer
aModelContainerListener
- the listener to be added.ILcdModelContainer.removeModelContainerListener(com.luciad.model.ILcdModelContainerListener)
void removeModelContainerListener(ILcdModelContainerListener aModelContainerListener)
ILcdModelContainerListener
from this ILcdModelContainer
.
It is not possible to remove a hierarchy model container listener. Use removeHierarchyModelContainerListener(ILcdModelContainerListener)
for this purpose.
removeModelContainerListener
in interface ILcdModelContainer
aModelContainerListener
- the listener to be removed.ILcdModelContainer.addModelContainerListener(com.luciad.model.ILcdModelContainerListener)
void dispose()
finalize
) 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.
dispose
in interface ILcdDisposable
dispose
in interface ILcdModel
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.
true
when the model node contains no useful data, false
otherwise