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
FieldsFields inherited from class com.luciad.model.ALcdModel
fModelEventSupportFields inherited from interface com.luciad.model.ILcdModel
FIRE_LATER, FIRE_NOW, NO_EVENT -
Constructor Summary
ConstructorsConstructorDescriptionConstructs 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 TypeMethodDescriptionvoidaddElement(Object aElement, int aFireEventMode) Adds the specified element to this model.booleancanAddElement(Object aElement) Returnstrueif the specified element can be added to this model,falseotherwise.booleancanRemoveElement(Object aElement) Returnstrueif the specified element can be removed from this model,falseotherwise.booleanReturnstrueif the specified element is contained in this model,falseotherwise.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.intReturns the index of the first occurrence of the specified element in the model, or -1 if this model does not contain the element.voidremoveAllElements(int aFireEventMode) Removes all elements from this model.voidremoveElement(Object aElement, int aFireEventMode) Removes the specified element from this model.voidsetAddElementFilter(ILcdFilter aFilter) Sets the filter that is used to control which elements are accepted for addition to this model.voidsetRemoveElementFilter(ILcdFilter aFilter) Sets the filter that is used to control which elements are accepted for removal from this model.intsize()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, setTraceOnMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.luciad.util.ILcdDisposable
closeMethods 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:ILcdIntegerIndexedModelReturns the number of elements in this model.- Specified by:
sizein interfaceILcdIntegerIndexedModel- Returns:
- the number of elements in this model.
-
elementAt
Description copied from interface:ILcdIntegerIndexedModelReturns the element at the specified index.- Specified by:
elementAtin interfaceILcdIntegerIndexedModel- Parameters:
aIndex- an index into thisILcdModel.- Returns:
- the element at the specified index.
-
indexOf
Description copied from interface:ILcdIntegerIndexedModelReturns 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 smallestifor whichthis.elementAt(i).equals(aElement).- Specified by:
indexOfin 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:ILcdModelReturns 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:
addElementin interfaceILcdModel- Overrides:
addElementin classALcdModel- Parameters:
aElement- the element to be added to this model.aFireEventMode- the mode for sending out the model change event. This can beFIRE_LATERorNO_EVENT.- See Also:
-
canAddElement
Returnstrueif the specified element can be added to this model,falseotherwise. If an addition filter is set, this method returnsfilter.accept(aElement), otherwise it always returnstrue.- Specified by:
canAddElementin interfaceILcdModel- Overrides:
canAddElementin classALcdModel- Parameters:
aElement- the element to be tested.- Returns:
trueif the specified element can be added to this model,falseotherwise.
-
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:
removeElementin interfaceILcdModel- Overrides:
removeElementin classALcdModel- Parameters:
aElement- the element to be removed from this model.aFireEventMode- the mode for sending out the model change event. This can beFIRE_LATERorNO_EVENT.- See Also:
-
canRemoveElement
Returnstrueif the specified element can be removed from this model,falseotherwise. If a removal filter is set, this method returnsfilter.accept(aElement), otherwise it always returnstrue.- Specified by:
canRemoveElementin interfaceILcdModel- Overrides:
canRemoveElementin classALcdModel- Parameters:
aElement- the element to be tested.- Returns:
trueif the specified element can be removed from this model,falseotherwise.
-
contains
Returnstrueif the specified element is contained in this model,falseotherwise.- Parameters:
aElement- the element to be tested.- Returns:
trueif the specified element is contained in this model,falseotherwise.
-
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_EVENTif the specified event mode isNO_EVENT,FIRE_LATERotherwise. 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:
removeAllElementsin interfaceILcdModel- Overrides:
removeAllElementsin classALcdModel- Parameters:
aFireEventMode- the mode for sending out the model change event. This can beFIRE_LATERorNO_EVENT.
-
toString
-