Class TLcdMultilevelGridCoordinateModel
java.lang.Object
com.luciad.model.ALcdModel
com.luciad.view.map.multilevelgrid.TLcdMultilevelGridCoordinateModel
- All Implemented Interfaces:
ILcd2DBoundsIndexedModel
,ILcd2DBoundsInteractable
,ILcdModel
,ILcdBounded
,ILcdDisposable
,Serializable
,AutoCloseable
public class TLcdMultilevelGridCoordinateModel
extends ALcdModel
implements ILcd2DBoundsIndexedModel
An
ILcd2DBoundsIndexedModel
implementation to contain ILcdMultilevelGridCoordinate
objects.
The internal structure of the model takes into account the structure of the ILcdMultilevelGrid
with
regard to which the multilevel grid coordinates are defined.
This ILcdModel
implementation is not thread safe.
- Since:
- 7.0
- 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
ConstructorDescriptionTLcdMultilevelGridCoordinateModel
(ILcdMultilevelGrid aMultilevelGrid, ILcdModelReference aModelReference) Constructs a multilevel model to containILcdMultilevelCoordinate
which are defined with regard to the multilevel grid passed, which is based on the model reference passed. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addElement
(Object aObject, int aFireEventMode) Adds aILcdMultilevelCoordinate
object to the model.void
allElementsChanged
(int aFireEventMode) Updates the structure for all elements and notifies the listeners that all elements in this model have changed.int
applyOnInteract2DBounds
(ILcdBounds aBounds, boolean aStrictInteract, ILcdFunction aFunction, double aPrecisionX, double aPrecisionY) Applies a given function to all elements in this model that interact with the given model bounds.int
applyOnInteract2DBounds
(ILcdBounds aBounds, boolean aStrictInteract, ILcdFunction aFunction, double aPrecisionX, double aPrecisionY, double aMinSizeX, double aMinSizeY, boolean aIncludePoints) Calls applyOnInteract2DBounds without the 3 last parameters.boolean
canAddElement
(Object aObject) OnlyILcdMultilevelCoordinate
implementations can be added to this model.boolean
canRemoveElement
(Object aObject) Always returns true.void
elementChanged
(Object aObject, int aFireEventMode) Updates the internal structure to the change of the object passed and notifies the model listeners.elements()
Returns all elements contained in this model, in no specific order.void
elementsAtSFCT
(ILcdMultilevelGridCoordinate aMultilevelGridCoordinate, Vector aCollectedObjectsVector) Puts all the model elements which are in the model at the location of the multilevel coordinate passed.void
elementsChanged
(Vector aVector, int aFireEventMode) Updates the internal structure to the changes of the objects passed and notifies the model listeners.Returns the bounds of the grid on which this model is based.Returns the grid on which this model is based.void
removeAllElements
(int aFireEventMode) Clears the internal structure of the model and notifies the listeners that all elements have been removed.void
removeElement
(Object aObject, int aFireEventMode) Removes an object from the model and notifies the model listeners that the object was removed from the model.Methods inherited from class com.luciad.model.ALcdModel
addElements, addModelListener, allElementsRemoved, dispose, elementAdded, elementRemoved, elementsAdded, 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, toString, wait, wait, wait
Methods inherited from interface com.luciad.model.ILcd2DBoundsIndexedModel
query
Methods inherited from interface com.luciad.util.ILcdDisposable
close
Methods inherited from interface com.luciad.model.ILcdModel
addElements, addModelListener, dispose, fireCollectedModelChanges, getModelDescriptor, getModelEncoder, getModelMetadata, getModelReference, removeElements, removeModelListener
-
Constructor Details
-
TLcdMultilevelGridCoordinateModel
public TLcdMultilevelGridCoordinateModel(ILcdMultilevelGrid aMultilevelGrid, ILcdModelReference aModelReference) Constructs a multilevel model to containILcdMultilevelCoordinate
which are defined with regard to the multilevel grid passed, which is based on the model reference passed.- Parameters:
aMultilevelGrid
- the multilevel grid with regard to which theILcdMultilevelCoordinate
objects in the model should be interpreted. The multilevel grid cannot be null.aModelReference
- the model reference on which the grid is based. This may be null, but it should be set usingALcdModel.setModelReference(com.luciad.model.ILcdModelReference)
before this model is used anywhere.
-
-
Method Details
-
getMultilevelGrid
Returns the grid on which this model is based. Elements in this model should have valid coordinates with regard to this grid. The number of specified levels should be less than or equal to that of the grid and the coordinate on every axis and every level should be smaller than or equal to the number of divisions of the grid at that level and axis.- Returns:
- the grid on which this model is based.
-
canAddElement
OnlyILcdMultilevelCoordinate
implementations can be added to this model. This method also checks whether the coordinates comply to the grid on which this model is based.- Specified by:
canAddElement
in interfaceILcdModel
- Overrides:
canAddElement
in classALcdModel
- Parameters:
aObject
- the object to check.- Returns:
- true if the object passed implements
ILcdMultilevelCoordinate
, false otherwise.
-
elementsAtSFCT
public void elementsAtSFCT(ILcdMultilevelGridCoordinate aMultilevelGridCoordinate, Vector aCollectedObjectsVector) Puts all the model elements which are in the model at the location of the multilevel coordinate passed. Only elements which are at exactly the same level are returned, not elements at higher or lower levels.- Parameters:
aMultilevelGridCoordinate
- the location of the elements to look for, expressed as a multilevel coordinate.aCollectedObjectsVector
- the vector to put the elements in.
-
canRemoveElement
Always returns true. All objects may be removed from the model, there is no check whether the object is actually in the model.- Specified by:
canRemoveElement
in interfaceILcdModel
- Overrides:
canRemoveElement
in classALcdModel
- Parameters:
aObject
- not take into account.- Returns:
- always true.
-
removeElement
Removes an object from the model and notifies the model listeners that the object was removed from the model.- Specified by:
removeElement
in interfaceILcdModel
- Overrides:
removeElement
in classALcdModel
- Parameters:
aObject
- the object to remove from the grid. If the object was not part of the model, the model will not be adapted.aFireEventMode
- indicates when or whether the listeners should be notified that an object was removed from the model. It should be one of ILcdFireEventMode.FIRE_LATER, ILcdFireEventMode.NO_EVENT, or ILcdFireEventMode.FIRE_NOW.- See Also:
-
removeAllElements
public void removeAllElements(int aFireEventMode) Clears the internal structure of the model and notifies the listeners that all elements have been removed.- Specified by:
removeAllElements
in interfaceILcdModel
- Overrides:
removeAllElements
in classALcdModel
- Parameters:
aFireEventMode
- indicates when or whether the listeners should be notified that all objects were removed from the model. It should be one of ILcdFireEventMode.FIRE_LATER, ILcdFireEventMode.NO_EVENT, or ILcdFireEventMode.FIRE_NOW.
-
addElement
Adds aILcdMultilevelCoordinate
object to the model. If the object is not anILcdMultilevelGridCoordinate
object, it will not be added to the model.- Specified by:
addElement
in interfaceILcdModel
- Overrides:
addElement
in classALcdModel
- Parameters:
aObject
- anILcdMultilevelCoordinate
to be added to the model. The coordinate should be valid with regard to the multilevel grid with which this model is constructed.aFireEventMode
- indicates when or whether the listeners should be notified that an object was added to the model. It should be one of ILcdFireEventMode.FIRE_LATER, ILcdFireEventMode.NO_EVENT, or ILcdFireEventMode.FIRE_NOW.- See Also:
-
applyOnInteract2DBounds
public int applyOnInteract2DBounds(ILcdBounds aBounds, boolean aStrictInteract, ILcdFunction aFunction, double aPrecisionX, double aPrecisionY) Applies a given function to all elements in this model that interact with the given model bounds.- Specified by:
applyOnInteract2DBounds
in interfaceILcd2DBoundsIndexedModel
- Parameters:
aBounds
- all grid elements interacting with this model bounds will be passed to the function passed.aStrictInteract
- if set to false the model is checked at the highest level, precision is not taken into account. All objects of elements at the highest level that overlap with the bounds and all objects of all their children are passed to the function.aFunction
- the function to apply to all objects in the model which are found to interact with the given bounds. A return value false acts as a stop condition.aPrecisionX
- only taken into account when strict interaction is wanted, otherwise all objects contained in the top level grid elements that interact with the bounds and their children are passed to the function.aPrecisionY
- only taken into account when strict interaction is wanted, otherwise all objects contained in the top level grid elements that interact with the bounds and their children are passed to the function.- Returns:
- the number of objects passed to the function.
-
applyOnInteract2DBounds
public int applyOnInteract2DBounds(ILcdBounds aBounds, boolean aStrictInteract, ILcdFunction aFunction, double aPrecisionX, double aPrecisionY, double aMinSizeX, double aMinSizeY, boolean aIncludePoints) Calls applyOnInteract2DBounds without the 3 last parameters.- Specified by:
applyOnInteract2DBounds
in interfaceILcd2DBoundsIndexedModel
- Specified by:
applyOnInteract2DBounds
in interfaceILcd2DBoundsInteractable
- Parameters:
aBounds
- the rectangle to test overlap with.aStrictInteract
- iffalse
, the spatial search may return more elements than the ones strictly overlapping; iftrue
, the search only returns the elements that are overlapping. The latter mode is more precise, but it may be slower.aFunction
- the function to apply on each element that overlaps with the given bounds.aPrecisionX
- the precision required in the x dimension, expressed in model units. For example, for a cartesian grid system expressed in meters, the values should be expressed in meters as well, for a geodetic coordinate system the accuracy values should be expressed in degrees.The precision is useful in combination with multi-leveled data (multiple representations of the same object, but with varying accuracy), so that the most appropriate accuracy level can be used. 0 means best possible accuracy, but it might trigger lazy-loaded implementations to load lots of data.
aPrecisionY
- the precision required in the y dimension, expressed in model units.aMinSizeX
- the minimal element size in the x dimension (as inILcdBounds.getWidth()
), expressed in model units. Elements that are smaller than this size will be skipped. This may, for example, be useful when improving the efficiency of painting elements by skipping elements that are smaller than some threshold (e.g. one pixel, converted to model units).aMinSizeY
- the minimal element size in the y dimension (as inILcdBounds.getHeight()
), expressed in model units.aIncludePoints
- iftrue
, zero-sized elements (points) are considered as well, even though they might be smaller than the minimum size.- Returns:
- the number of elements to which the
ILcdFunction
has been applied.
-
getBounds
Returns the bounds of the grid on which this model is based.- Specified by:
getBounds
in interfaceILcdBounded
- Returns:
- the bounds of the grid on which this model is based.
- See Also:
-
elements
Returns all elements contained in this model, in no specific order. -
elementChanged
Updates the internal structure to the change of the object passed and notifies the model listeners.- Specified by:
elementChanged
in interfaceILcdModel
- Overrides:
elementChanged
in classALcdModel
- Parameters:
aObject
- the object that has changed. Note that an object that is not in the model will not influence the model.aFireEventMode
- indicates when or whether the listeners should be notified that an element in the model has changed. It should be one of ILcdFireEventMode.FIRE_LATER, ILcdFireEventMode.NO_EVENT, or ILcdFireEventMode.FIRE_NOW.
-
elementsChanged
Updates the internal structure to the changes of the objects passed and notifies the model listeners.- Specified by:
elementsChanged
in interfaceILcdModel
- Overrides:
elementsChanged
in classALcdModel
- Parameters:
aVector
- contains all elements that have changed.aFireEventMode
- indicates when or whether the listeners should be notified that an elements in the model has changed. It should be one of ILcdFireEventMode.FIRE_LATER, ILcdFireEventMode.NO_EVENT, or ILcdFireEventMode.FIRE_NOW.
-
allElementsChanged
public void allElementsChanged(int aFireEventMode) Updates the structure for all elements and notifies the listeners that all elements in this model have changed. This method callselementsChanged(java.util.Vector, int)
with all objects in the model. If not all objects have changed, callelementsChanged
with the objects that have changed to avoid unnecessary checks of the models structure.- Overrides:
allElementsChanged
in classALcdModel
- Parameters:
aFireEventMode
- indicates when or whether the listeners should be notified that all elements in the model have changed. It should be one of ILcdFireEventMode.FIRE_LATER, ILcdFireEventMode.NO_EVENT, or ILcdFireEventMode.FIRE_NOW.
-