Class TLcdVectorModel
- All Implemented Interfaces:
ILcdIntegerIndexedModel
,ILcdModel
,ILcdDisposable
,Serializable
,AutoCloseable
- Direct Known Subclasses:
TLcdModelTreeNode
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.
package documentation
provides a detailed overview of all model
implementations that are available in this package, and their usage.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.model.ILcdModel
ILcdModel.Query
-
Field Summary
Fields inherited from class com.luciad.model.ALcdModel
fModelEventSupport
Fields inherited from interface com.luciad.model.ILcdModel
FIRE_LATER, FIRE_NOW, NO_EVENT
-
Constructor Summary
ConstructorDescriptionConstructs a new, emptyTLcdVectorModel
, initialized with a defaultTLcdModelDescriptor
.TLcdVectorModel
(ILcdModelReference aModelReference) Constructs a new, emptyTLcdVectorModel
, initialized with the specified model reference and a defaultTLcdModelDescriptor
.TLcdVectorModel
(ILcdModelReference aModelReference, ILcdModelDescriptor aModelDescriptor) Constructs a new, emptyTLcdVectorModel
, initialized with the specified model reference and model descriptor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addElement
(Object aElement, int aFireEventMode) Adds the specified element to 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.boolean
Returnstrue
if the specified element is contained in this model,false
otherwise.elementAt
(int aIndex) Returns the element at the specified index.elements()
Returns an enumeration over all elements of this model.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 removal from this model.int
Returns the index of the first occurrence of the specified element in the model, or -1 if this model does not contain the element.void
removeAllElements
(int aFireEventMode) Removes all elements from this model.void
removeElement
(Object aElement, int aFireEventMode) Removes the specified element from this model.void
setAddElementFilter
(ILcdFilter aFilter) Sets the filter that is used to control which elements are accepted for addition to this model.void
setRemoveElementFilter
(ILcdFilter aFilter) Sets the filter that is used to control which elements are accepted for removal from this model.int
size()
Returns the number of elements in this model.toString()
Methods inherited from class com.luciad.model.ALcdModel
addElements, addModelListener, allElementsChanged, allElementsRemoved, dispose, elementAdded, elementChanged, elementRemoved, elementsAdded, elementsChanged, elementsRemoved, fireCollectedModelChanges, getModelDescriptor, getModelEncoder, getModelMetadata, getModelReference, initializeTransientValues, isClassTraceOn, isTraceOn, removeElements, removeModelListener, setClassTraceOn, setModelDescriptor, setModelDisposer, setModelEncoder, setModelMetadataFunction, setModelReference, setTraceOn
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.luciad.util.ILcdDisposable
close
Methods inherited from interface com.luciad.model.ILcdModel
addElements, addModelListener, dispose, elementChanged, elementsChanged, fireCollectedModelChanges, getModelDescriptor, getModelEncoder, getModelMetadata, getModelReference, query, removeElements, removeModelListener
-
Field Details
-
fVector
The vector to contain the models elements.
-
-
Constructor Details
-
TLcdVectorModel
public TLcdVectorModel()Constructs a new, emptyTLcdVectorModel
, initialized with a defaultTLcdModelDescriptor
. -
TLcdVectorModel
Constructs a new, emptyTLcdVectorModel
, initialized with the specified model reference and a defaultTLcdModelDescriptor
.- Parameters:
aModelReference
- the model reference describing the coordinate system used in this model.
-
TLcdVectorModel
Constructs a new, emptyTLcdVectorModel
, 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
Sets the filter that is used to control which elements are accepted for addition to this model. This filter is used by thecanAddElement(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
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
Sets the filter that is used to control which elements are accepted for removal from this model. This filter is used by thecanRemoveElement(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
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 interfaceILcdIntegerIndexedModel
- Returns:
- the number of elements in this model.
-
elementAt
Description copied from interface:ILcdIntegerIndexedModel
Returns the element at the specified index.- Specified by:
elementAt
in interfaceILcdIntegerIndexedModel
- Parameters:
aIndex
- an index into thisILcdModel
.- Returns:
- the element at the specified index.
-
indexOf
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 smallesti
for whichthis.elementAt(i).equals(aElement)
.- Specified by:
indexOf
in interfaceILcdIntegerIndexedModel
- 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
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. -
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.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 interfaceILcdModel
- Overrides:
addElement
in classALcdModel
- Parameters:
aElement
- the element to be added to this model.aFireEventMode
- 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. If an addition filter is set, this method returnsfilter.accept(aElement)
, otherwise it always returnstrue
.- Specified by:
canAddElement
in interfaceILcdModel
- Overrides:
canAddElement
in classALcdModel
- Parameters:
aElement
- the element to be tested.- Returns:
true
if the specified element can be added to this model,false
otherwise.
-
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.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 interfaceILcdModel
- Overrides:
removeElement
in classALcdModel
- Parameters:
aElement
- the element to be removed from this model.aFireEventMode
- 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. If a removal filter is set, this method returnsfilter.accept(aElement)
, otherwise it always returnstrue
.- Specified by:
canRemoveElement
in interfaceILcdModel
- Overrides:
canRemoveElement
in classALcdModel
- Parameters:
aElement
- the element to be tested.- Returns:
true
if the specified element can be removed from this model,false
otherwise.
-
contains
Returnstrue
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 modeNO_EVENT
if the specified event mode isNO_EVENT
,FIRE_LATER
otherwise. If the specified event mode isFIRE_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 interfaceILcdModel
- Overrides:
removeAllElements
in classALcdModel
- Parameters:
aFireEventMode
- the mode for sending out the model change event. This can beFIRE_LATER
orNO_EVENT
.
-
toString
-