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

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.

ILcdModelTreeNode class diagram

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
  • Method Details

    • addHierarchyModelContainerListener

      void addHierarchyModelContainerListener(ILcdModelContainerListener aModelContainerListener)

      Registers the given ILcdModelContainerListener to receive TLcdModelContainerEvents from all the ILcdModelTreeNodes 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.

      Parameters:
      aModelContainerListener - the listener
      See Also:
    • removeHierarchyModelContainerListener

      void removeHierarchyModelContainerListener(ILcdModelContainerListener aModelContainerListener)

      Unregisters the given ILcdModelContainerListener from receiving TLcdModelContainerEvents for the tree with this node as root node.

      Parameters:
      aModelContainerListener - the listener
      See Also:
    • addHierarchyModelListener

      void addHierarchyModelListener(ILcdModelListener aModelListener)

      Registers the given ILcdModelListener to receive TLcdModelChangedEvents from all the ILcdModels 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.

      Parameters:
      aModelListener - the listener
      See Also:
    • removeHierarchyModelListener

      void removeHierarchyModelListener(ILcdModelListener aModelListener)

      Unregisters the given ILcdModelListener from receiving TLcdModelChangedEvents for the tree with this node as root node.

      Parameters:
      aModelListener - the listener
      See Also:
    • getModelReference

      ILcdModelReference getModelReference()
      Returns the 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.

      Specified by:
      getModelReference in interface ILcdModel
      Returns:
      the ILcdModelReference of this ILcdModel.
    • getModelDescriptor

      ILcdModelDescriptor getModelDescriptor()
      Returns the 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.

      Specified by:
      getModelDescriptor in interface ILcdModel
      Returns:
      the ILcdModelDescriptor of this ILcdModel. Should not be null.
    • 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.

      Specified by:
      elements in interface ILcdModel
      Returns:
      an enumeration over all elements of this model. The elements of the child model(s) are not included in this enumeration.
    • addElement

      void addElement(Object aElement, int aEventMode)
      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 interface ILcdModel
      Parameters:
      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.
      See Also:
    • canAddElement

      boolean canAddElement(Object aElement)
      Returns 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.

      Specified by:
      canAddElement in interface ILcdModel
      Parameters:
      aElement - the element to be verified.
      Returns:
      true if the specified element can be added to this model, false otherwise.
    • addElements

      void addElements(Vector aElements, int aEventMode)
      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 implement 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).

      Specified by:
      addElements in interface ILcdModel
      Parameters:
      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.
      See Also:
    • removeElement

      void removeElement(Object aElement, int aEventMode)
      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 interface ILcdModel
      Parameters:
      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.
      See Also:
    • canRemoveElement

      boolean canRemoveElement(Object aElement)
      Returns 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.

      Specified by:
      canRemoveElement in interface ILcdModel
      Parameters:
      aElement - the element to be verified.
      Returns:
      true if the specified element can be removed from this model, false otherwise.
    • removeElements

      void removeElements(Vector aElements, int aEventMode)
      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 interface ILcdModel
      Parameters:
      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.
      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 interface ILcdModel
      Parameters:
      aEventMode - the mode for sending out the model change event. This can be FIRE_LATER or NO_EVENT.
    • elementChanged

      void elementChanged(Object aElement, int aEventMode)
      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 interface ILcdModel
      Parameters:
      aElement - the element that has changed.
      aEventMode - the mode for sending out the model change event. This can be FIRE_LATER or NO_EVENT.
    • elementsChanged

      void elementsChanged(Vector aElements, int aEventMode)
      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 interface ILcdModel
      Parameters:
      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.
    • 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 interface ILcdModel
      See Also:
    • addModelListener

      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)).

      Specified by:
      addModelListener in interface ILcdModel
      Parameters:
      aModelListener - the ILcdModelListener to register on this model.
      See Also:
    • removeModelListener

      void removeModelListener(ILcdModelListener aModelListener)
      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 interface ILcdModel
      Parameters:
      aModelListener - the ILcdModelListener 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 interface ILcdModel
      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 interface ILcdModelContainer
      Returns:
      the number of child models of this model node.
    • addModel

      boolean addModel(ILcdModel aModel)

      Adds the ILcdModel aModel as a child model to this ILcdModelTreeNode.

      Specified by:
      addModel in interface ILcdModelContainer
      Parameters:
      aModel - the model to be added.
      Returns:
      true if this collection of models changed as a result of the call
    • removeModel

      boolean removeModel(ILcdModel aModel)

      Removes the child model aModel from this ILcdModelTreeNode.

      Specified by:
      removeModel in interface ILcdModelContainer
      Parameters:
      aModel - the model to be removed.
      Returns:
      true if a model was removed as a result of this call
    • getModel

      ILcdModel getModel(int aIndex)

      Returns the child model at the given index.

      Specified by:
      getModel in interface ILcdModelContainer
      Parameters:
      aIndex - a valid index in this ILcdModelTreeNode
      Returns:
      the child model at the given index.
    • models

      Enumeration models()

      Returns an Enumeration of the child models of this ILcdModelTreeNode.

      Specified by:
      models in interface ILcdModelContainer
      Returns:
      an Enumeration of the child models of this ILcdModelTreeNode.
    • addModelContainerListener

      void addModelContainerListener(ILcdModelContainerListener aModelContainerListener)
      Adds an 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)).

      .
      Specified by:
      addModelContainerListener in interface ILcdModelContainer
      Parameters:
      aModelContainerListener - the listener to be added.
      See Also:
    • removeModelContainerListener

      void removeModelContainerListener(ILcdModelContainerListener aModelContainerListener)
      Removes an ILcdModelContainerListener from this ILcdModelContainer.

      It is not possible to remove a hierarchy model container listener. Use removeHierarchyModelContainerListener(ILcdModelContainerListener) for this purpose.

      Specified by:
      removeModelContainerListener in interface ILcdModelContainer
      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 than 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.

      Specified by:
      dispose in interface ILcdDisposable
      Specified by:
      dispose in interface ILcdModel
    • 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