Class TLcdMultilevel2DBoundsIndexedModel
- All Implemented Interfaces:
ILcd2DBoundsIndexedModel
,ILcd2DBoundsInteractable
,ILcdIntegerIndexedModel
,ILcdModel
,ILcdBounded
,ILcdLockDependent
,ILcdDisposable
,Serializable
,AutoCloseable
ILcd2DBoundsIndexedModel
and ILcdIntegerIndexedModel
that can be used to
represent the same data at different levels of detail.
This model contains multiple submodels, each representing (part of) the model's data at different levels of detail. Depending on the required accuracy, this model chooses one or more of the submodels to delegate its queries to.
This model can be used in two different modes:
- non-cumulative: each submodel represents the full dataset on a different level of detail. For each query, only the submodel that matches the required accuracy is used.
- cumulative: each submodel represents a part of the dataset, all submodels together form the full dataset. For each query, all submodels with the required or less accuracy are combined.
A range needs to be specified for each submodel, to map accuracies (expressed in model units) onto levels. An
accuracy is only available for the applyOnInteract
methods. For other methods (elements, elementAt,
indexOf, size
, the default level is used to determine which submodel(s) to query. A default level can be specified
in the constructor or can be set afterwards.
If the selected sub-model is already indexed and the model is used non-cumulative, direct delegation is used for all
ILcdIntegerIndexedModel
methods, otherwise an index for the sub-model(s) is constructed on-the-fly and cached
for future use.
The model is a read-only model. It is thread-safe for accessing its sub-models.
- 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
ConstructorDescriptionTLcdMultilevel2DBoundsIndexedModel
(ILcd2DBoundsIndexedModel[] aSubModels) Constructs a newTLcdMultilevel2DBoundsIndexedModel
, initialized with the specified submodels.TLcdMultilevel2DBoundsIndexedModel
(ILcd2DBoundsIndexedModel[] aSubModels, double[] aRanges) Constructs a newTLcdMultilevel2DBoundsIndexedModel
, initialized with the specified submodels and corresponding accuracy ranges.TLcdMultilevel2DBoundsIndexedModel
(ILcd2DBoundsIndexedModel[] aMultilevelModel, double[] aRange, int aDefaultLevel) Constructs a newTLcdMultilevel2DBoundsIndexedModel
, initialized with the specified submodels, corresponding accuracy ranges and default level. -
Method Summary
Modifier and TypeMethodDescriptionint
applyOnInteract2DBounds
(ILcdBounds aBounds, boolean aStrictInteract, ILcdFunction aFunctionToApply, double aPrecisionX, double aPrecisionY) Applies the specified function to all the model elements of which the 2D bounds overlap with the specified bounds.int
applyOnInteract2DBounds
(ILcdBounds aBounds, boolean aStrictInteract, ILcdFunction aFunctionToApply, double aPrecisionX, double aPrecisionY, double aMinSizeX, double aMinSizeY, boolean aIncludePoints) Applies the specified function to all the elements of which the 2D bounds overlap with the specified bounds.void
dispose()
Disposes of this model and allows it to release any system resources that it is holding.elementAt
(int i) Returns the element at the specified index.elements()
Returns an enumeration over all elements of this model.void
finalize()
Returns theILcdBounds
by which the geometry of thisILcdBounded
object is bounded.int
Returns the default level to be used for methods for which no accuracy is specified (elements(), indexOf(), elementAt(), size()
.Returns the objects that must be locked along with this object.int
Returns the number of accuracy levels for this model.getModel()
Returns the array of submodels representing this model at increasing levels of accuracy.getModelAt
(int aIndex) Returns the submodel at the specified index.Returns theILcdModelDescriptor
providing meta information about this model and its elements.double[]
getRange()
Returns the accuracy ranges in which the submodels should be used.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.boolean
Returnstrue
if this model is to be used in cumulative mode,false
otherwise.boolean
Deprecated.This method has been deprecated.void
setCumulative
(boolean aCumulative) Sets whether this model is to be used in cumulative mode or not.void
setDefaultLevel
(int aDefaultLevel) Sets the default level to be used for methods for which no accuracy is specified (elements(), indexOf(), elementAt(), size()
.void
setModel
(ILcd2DBoundsIndexedModel[] aMultilevelModel) Sets the array of submodels representing this model at increasing levels of accuracy.void
setModelAt
(int aIndex, ILcd2DBoundsIndexedModel aModel) Replaces the submodel at the specified index.void
setRange
(double[] aRange) Sets the accuracy ranges in which the submodels should be used.void
setTraceOn
(boolean aTraceOn) Deprecated.This method has been deprecated.int
size()
Returns the number of elements in this model.Methods inherited from class com.luciad.model.ALcdModel
addElement, addElements, addModelListener, allElementsChanged, allElementsRemoved, canAddElement, canRemoveElement, elementAdded, elementChanged, elementRemoved, elementsAdded, elementsChanged, elementsRemoved, fireCollectedModelChanges, getModelEncoder, getModelMetadata, getModelReference, initializeTransientValues, isClassTraceOn, removeAllElements, removeElement, removeElements, removeModelListener, setClassTraceOn, setModelDescriptor, setModelDisposer, setModelEncoder, setModelMetadataFunction, setModelReference
Methods inherited from class java.lang.Object
clone, equals, 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
addElement, addElements, addModelListener, canAddElement, canRemoveElement, elementChanged, elementsChanged, fireCollectedModelChanges, getModelEncoder, getModelMetadata, getModelReference, removeAllElements, removeElement, removeElements, removeModelListener
-
Constructor Details
-
TLcdMultilevel2DBoundsIndexedModel
Constructs a newTLcdMultilevel2DBoundsIndexedModel
, initialized with the specified submodels. One should set the ranges for the submodels afterwards.The default level is the most detailed one.
- Parameters:
aSubModels
- the array of models that represent this model at increasing levels of accuracy. At least one model should be specified.- See Also:
-
TLcdMultilevel2DBoundsIndexedModel
Constructs a newTLcdMultilevel2DBoundsIndexedModel
, initialized with the specified submodels and corresponding accuracy ranges.The default level is the most detailed one.
- Parameters:
aSubModels
- the array models that represent this model at increasing levels of accuracy. At least one model should be specified.aRanges
- the array containing the accuracy range values. This array should have lengthaSubModels.length + 1
.
-
TLcdMultilevel2DBoundsIndexedModel
public TLcdMultilevel2DBoundsIndexedModel(ILcd2DBoundsIndexedModel[] aMultilevelModel, double[] aRange, int aDefaultLevel) Constructs a newTLcdMultilevel2DBoundsIndexedModel
, initialized with the specified submodels, corresponding accuracy ranges and default level.- Parameters:
aMultilevelModel
- the array models that represent this model at increasing levels of accuracy. At least one model should be specified.aRange
- the array containing the accuracy range values. This array should have lengthaSubModels.length + 1
.aDefaultLevel
- the default level, used for operations that do not have a accuracy specified.
-
-
Method Details
-
setTraceOn
public void setTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for this class instance. Calling this method with eithertrue
orfalse
as argument automatically turns off tracing for all other class instances for whichsetTraceOn
has not been called. If the argument isfalse
then only the informative, warning and error log messages are recorded.- Overrides:
setTraceOn
in classALcdModel
- Parameters:
aTraceOn
- if true then all log messages are recorded for this instance. If false, then only the informative, warning and error log messages are recorded.
-
isTraceOn
public boolean isTraceOn()Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Returnstrue
if tracing is enabled for this class. -
setModel
Sets the array of submodels representing this model at increasing levels of accuracy.- Parameters:
aMultilevelModel
- the array of submodels representing this model at increasing levels of accuracy.- See Also:
-
getModel
Returns the array of submodels representing this model at increasing levels of accuracy.- Returns:
- the array of submodels representing this model at increasing levels of accuracy.
- See Also:
-
setModelAt
Replaces the submodel at the specified index.- Parameters:
aIndex
- the index of the submodel to be replaced.aModel
- the new submodel at the specified index.- Throws:
IndexOutOfBoundsException
- ifaIndex < 0 || aIndex >= getLevelCount()
.- See Also:
-
getModelAt
Returns the submodel at the specified index.- Parameters:
aIndex
- the index of the submodel to be returned.- Returns:
- the submodel at the specified index.
- Throws:
IndexOutOfBoundsException
- ifaIndex < 0 || aIndex >= getLevelCount()
- See Also:
-
getLevelCount
public int getLevelCount()Returns the number of accuracy levels for this model.- Returns:
- the number of accuracy levels for this model.
-
setRange
public void setRange(double[] aRange) Sets the accuracy ranges in which the submodels should be used. The length of this array should be the number of levels plus one.The accuracy values should be expressed in the units of the
ILcdModelReference
of this model. 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 accuracy value passed as argument in the method
applyOnInteract2DBounds
corresponds to the distance, in model units, below which two points are mapped on the same pixel on the screen if used for visualization.- Parameters:
aRange
- the array with the accuracy range values.- See Also:
-
getRange
public double[] getRange()Returns the accuracy ranges in which the submodels should be used.- Returns:
- the accuracy ranges in which the submodels should be used.
- See Also:
-
setCumulative
public void setCumulative(boolean aCumulative) Sets whether this model is to be used in cumulative mode or not.- Parameters:
aCumulative
-boolean
indicating whether this model is to be used in cumulative mode or not. Iffalse
(default value), only one submodel is used for a specified accuracy. Iftrue
, all submodels with the specified or lower accuracy are taken into account for a specified accuracy.- See Also:
-
isCumulative
public boolean isCumulative()Returnstrue
if this model is to be used in cumulative mode,false
otherwise.- Returns:
true
if this model is to be used in cumulative mode,false
otherwise.- See Also:
-
setDefaultLevel
public void setDefaultLevel(int aDefaultLevel) Sets the default level to be used for methods for which no accuracy is specified (elements(), indexOf(), elementAt(), size()
.- Parameters:
aDefaultLevel
- the default level to be used for methods for which no accuracy is specified.- Throws:
IllegalArgumentException
- ifaDefaultLevel < 0 || aDefaultLevel >= getLevelCount()
.- See Also:
-
getDefaultLevel
public int getDefaultLevel()Returns the default level to be used for methods for which no accuracy is specified (elements(), indexOf(), elementAt(), size()
. The default value isgetLevelCount() - 1
(most detailed).- See Also:
-
getDependentObjects
Description copied from interface:ILcdLockDependent
Returns the objects that must be locked along with this object.TLcdLockUtil
first locks all objects returned by this method before locking this object.- Specified by:
getDependentObjects
in interfaceILcdLockDependent
- Returns:
- the objects that must be locked along with this object.
-
getModelDescriptor
Description copied from class:ALcdModel
Returns theILcdModelDescriptor
providing meta information about this model and its elements.- Specified by:
getModelDescriptor
in interfaceILcdModel
- Overrides:
getModelDescriptor
in classALcdModel
- Returns:
- the
ILcdModelDescriptor
of thisILcdModel
. Should not benull
. - See Also:
-
getBounds
Description copied from interface:ILcdBounded
Returns theILcdBounds
by which the geometry of thisILcdBounded
object is bounded.If the geometry does not allow retrieving valid bounds (for example a polyline with 0 points) the return value is unspecified. It is highly recommended to return an
undefined
bounds. You can create undefined bounds using the default constructors ofTLcdLonLatBounds
orTLcdXYBounds
.- Specified by:
getBounds
in interfaceILcdBounded
- Returns:
- the
ILcdBounds
by which the geometry of thisILcdBounded
object is bounded.
-
applyOnInteract2DBounds
public int applyOnInteract2DBounds(ILcdBounds aBounds, boolean aStrictInteract, ILcdFunction aFunctionToApply, double aPrecisionX, double aPrecisionY) Applies the specified function to all the model elements of which the 2D bounds overlap with the specified bounds. By default, the order in which the function is applied on the elements is unspecified and depends on the implementation. The return value of the specified function is used as a stop criterion: the spatial query is interrupted if the function returnsfalse
.The
aPrecisionX
argument is used to determine the submodel(s) to be queried.- Specified by:
applyOnInteract2DBounds
in interfaceILcd2DBoundsIndexedModel
- 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.aFunctionToApply
- the function to apply on each element that overlaps with the given bounds. The return value of the specified function is used as a stop criterion: the spatial query is interrupted if the function returnsfalse
.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.- Returns:
- the number of elements to which the
ILcdFunction
has been applied. - See Also:
-
applyOnInteract2DBounds
public int applyOnInteract2DBounds(ILcdBounds aBounds, boolean aStrictInteract, ILcdFunction aFunctionToApply, double aPrecisionX, double aPrecisionY, double aMinSizeX, double aMinSizeY, boolean aIncludePoints) Applies the specified function to all the elements of which the 2D bounds overlap with the specified bounds. The order in which the function is applied on the elements is unspecified and depends on the implementation. Only elements that have at least the specified minimal size in the x dimension or in the y dimension are considered. This can be useful for quickly eliminating elements that are too small to be visible in a view, for instance. If required, an exception can be made for point elements, which have a size of 0 by 0. They can be forced to be considered, even though they would always be rejected as being too small for any sizes larger than 0. The return value of the specified function is used as a stop criterion: the spatial query will be interrupted as soon as the function returnsfalse
for an element it was applied on.The
aPrecisionX
argument is used to determine the submodel(s) to be queried.- 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.aFunctionToApply
- 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. - See Also:
-
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. -
dispose
public void dispose()Description copied from class:ALcdModel
Disposes of this model and allows it to release any system resources that it is holding. The result of calling any other method (other thanfinalize
) on this model subsequent to a call to this method is undefined.When a model disposer has been provided it is called, otherwise this method does nothing. When overriding this method it is recommended to call
super.dispose()
. -
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:
i
- 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.
-
finalize
public void finalize()
-