Class TLcdVectorModel

java.lang.Object
com.luciad.model.ALcdModel
com.luciad.model.TLcdVectorModel
All Implemented Interfaces:
ILcdIntegerIndexedModel, ILcdModel, ILcdDisposable, Serializable, AutoCloseable
Direct Known Subclasses:
TLcdModelTreeNode

public class TLcdVectorModel extends ALcdModel implements ILcdIntegerIndexedModel
Default implementation of ILcdIntegerIndexedModel. This model stores its elements in a linear index, allowing fast integer-index-based queries.

Since only a linear index is maintained, addition of elements is fast and memory consumption is very low. There are no constraints on the elements that can be added to this model.

Users may consider using this model if one or more of the following conditions are met:

  • no spatial queries are involved,
  • (one or more of) the elements do not implement ILcdBounded.
The package documentation provides a detailed overview of all model implementations that are available in this package, and their usage.
See Also:
  • Field Details

    • fVector

      protected Vector fVector
      The vector to contain the models elements.
  • Constructor Details

    • TLcdVectorModel

      public TLcdVectorModel()
      Constructs a new, empty TLcdVectorModel, initialized with a default TLcdModelDescriptor.
    • TLcdVectorModel

      public TLcdVectorModel(ILcdModelReference aModelReference)
      Constructs a new, empty TLcdVectorModel, initialized with the specified model reference and a default TLcdModelDescriptor.
      Parameters:
      aModelReference - the model reference describing the coordinate system used in this model.
    • TLcdVectorModel

      public TLcdVectorModel(ILcdModelReference aModelReference, ILcdModelDescriptor aModelDescriptor)
      Constructs a new, empty TLcdVectorModel, initialized with the specified model reference and model descriptor.
      Parameters:
      aModelReference - the model reference describing the coordinate system used in this model.
      aModelDescriptor - the model descriptor providing meta information about this model.
  • Method Details

    • setAddElementFilter

      public void setAddElementFilter(ILcdFilter aFilter)
      Sets the filter that is used to control which elements are accepted for addition to this model. This filter is used by the canAddElement(Object) method, to decide whether an element can be added to this model or not. By default, no filter is set.
      Parameters:
      aFilter - the filter to be used to control which elements are accepted for addition to this model.
      See Also:
    • getAddElementFilter

      public ILcdFilter getAddElementFilter()
      Returns the filter that is used to control which elements are accepted for addition to this model.
      Returns:
      the filter that is used to control which elements are accepted for addition to this model.
      See Also:
    • setRemoveElementFilter

      public void setRemoveElementFilter(ILcdFilter aFilter)
      Sets the filter that is used to control which elements are accepted for removal from this model. This filter is used by the canRemoveElement(Object) method, to decide whether an element can be removed from this model or not. By default, no filter is set.
      Parameters:
      aFilter - the filter to be used to control which elements are accepted for removal from this model.
      See Also:
    • getRemoveElementFilter

      public ILcdFilter getRemoveElementFilter()
      Returns the filter that is used to control which elements are accepted for removal from this model.
      Returns:
      the filter that is used to control which elements are accepted for removal from this model.
      See Also:
    • size

      public int size()
      Description copied from interface: ILcdIntegerIndexedModel
      Returns the number of elements in this model.
      Specified by:
      size in interface ILcdIntegerIndexedModel
      Returns:
      the number of elements in this model.
    • elementAt

      public Object elementAt(int aIndex)
      Description copied from interface: ILcdIntegerIndexedModel
      Returns the element at the specified index.
      Specified by:
      elementAt in interface ILcdIntegerIndexedModel
      Parameters:
      aIndex - an index into this ILcdModel.
      Returns:
      the element at the specified index.
    • indexOf

      public int indexOf(Object aObject)
      Description copied from interface: ILcdIntegerIndexedModel
      Returns the index of the first occurrence of the specified element in the model, or -1 if this model does not contain the element. More formally: returns the smallest i for which this.elementAt(i).equals(aElement).
      Specified by:
      indexOf in interface ILcdIntegerIndexedModel
      Parameters:
      aObject - the element to search for.
      Returns:
      the index of the first occurrence of the specified element in model vector, or -1 if this model does not contain the element.
    • elements

      public Enumeration elements()
      Description copied from interface: ILcdModel
      Returns an enumeration over all elements of this model. The order in which the elements are enumerated is unspecified by default.
      Specified by:
      elements in interface ILcdModel
      Returns:
      an enumeration over all elements of this model.
    • addElement

      public void addElement(Object aElement, int aFireEventMode)
      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.

      This implementation always throws an UnsupportedOperationException.

      This implementation calls ALcdModel.elementAdded(Object, int) after the element has been added, to sent a model change event to this model's listeners.

      Specified by:
      addElement in interface ILcdModel
      Overrides:
      addElement in class ALcdModel
      Parameters:
      aElement - the element to be added to this model.
      aFireEventMode - the mode for sending out the model change event. This can be FIRE_LATER or NO_EVENT.
      See Also:
    • canAddElement

      public boolean canAddElement(Object aElement)
      Returns true if the specified element can be added to this model, false otherwise. If an addition filter is set, this method returns filter.accept(aElement), otherwise it always returns true.
      Specified by:
      canAddElement in interface ILcdModel
      Overrides:
      canAddElement in class ALcdModel
      Parameters:
      aElement - the element to be tested.
      Returns:
      true if the specified element can be added to this model, false otherwise.
    • removeElement

      public void removeElement(Object aElement, int aFireEventMode)
      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.

      This implementation always throws an UnsupportedOperationException.

      This implementation calls ALcdModel.elementRemoved(Object, int) after the element has been removed, to sent a model change event to this model's listeners.

      Specified by:
      removeElement in interface ILcdModel
      Overrides:
      removeElement in class ALcdModel
      Parameters:
      aElement - the element to be removed from this model.
      aFireEventMode - the mode for sending out the model change event. This can be FIRE_LATER or NO_EVENT.
      See Also:
    • canRemoveElement

      public boolean canRemoveElement(Object aElement)
      Returns true if the specified element can be removed from this model, false otherwise. If a removal filter is set, this method returns filter.accept(aElement), otherwise it always returns true.
      Specified by:
      canRemoveElement in interface ILcdModel
      Overrides:
      canRemoveElement in class ALcdModel
      Parameters:
      aElement - the element to be tested.
      Returns:
      true if the specified element can be removed from this model, false otherwise.
    • contains

      public boolean contains(Object aElement)
      Returns true if the specified element is contained in this model, false otherwise.
      Parameters:
      aElement - the element to be tested.
      Returns:
      true if the specified element is contained in this model, false otherwise.
    • removeAllElements

      public void removeAllElements(int aFireEventMode)
      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.

      This implementation iterates over all elements in the model, and calls removeElement(Object, int) for each element to be removed, using event mode NO_EVENT if the specified event mode is NO_EVENT, FIRE_LATER otherwise. If the specified event mode is FIRE_NOW, fireCollectedModelChanges() is called afterwards.

      This implementation calls ALcdModel.allElementsRemoved(int) after the elements have been removed, to sent a model change event to this model's listeners.

      Specified by:
      removeAllElements in interface ILcdModel
      Overrides:
      removeAllElements in class ALcdModel
      Parameters:
      aFireEventMode - the mode for sending out the model change event. This can be FIRE_LATER or NO_EVENT.
    • toString

      public String toString()
      Overrides:
      toString in class Object