public class TLcdMultilevel2DBoundsIndexedModel extends ALcdModel implements ILcd2DBoundsIndexedModel, ILcdIntegerIndexedModel, ILcdLockDependent
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:
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.
ILcdModel.Query
fModelEventSupport
FIRE_LATER, FIRE_NOW, NO_EVENT
Constructor and Description |
---|
TLcdMultilevel2DBoundsIndexedModel(ILcd2DBoundsIndexedModel[] aSubModels)
Constructs a new
TLcdMultilevel2DBoundsIndexedModel , initialized with the specified submodels. |
TLcdMultilevel2DBoundsIndexedModel(ILcd2DBoundsIndexedModel[] aSubModels,
double[] aRanges)
Constructs a new
TLcdMultilevel2DBoundsIndexedModel , initialized with the specified submodels and
corresponding accuracy ranges. |
TLcdMultilevel2DBoundsIndexedModel(ILcd2DBoundsIndexedModel[] aMultilevelModel,
double[] aRange,
int aDefaultLevel)
Constructs a new
TLcdMultilevel2DBoundsIndexedModel , initialized with the specified submodels,
corresponding accuracy ranges and default level. |
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
Object |
elementAt(int i)
Returns the element at the specified index.
|
Enumeration |
elements()
Returns an enumeration over all elements of this model.
|
void |
finalize() |
ILcdBounds |
getBounds()
Returns the
ILcdBounds by which the geometry of this ILcdBounded object
is bounded. |
int |
getDefaultLevel()
Returns the default level to be used for methods for which no accuracy is specified (
elements(), indexOf(),
elementAt(), size() . |
List<Object> |
getDependentObjects()
Returns the objects that must be locked along with this object.
|
int |
getLevelCount()
Returns the number of accuracy levels for this model.
|
ILcd2DBoundsIndexedModel[] |
getModel()
Returns the array of submodels representing this model at increasing levels of accuracy.
|
ILcd2DBoundsIndexedModel |
getModelAt(int aIndex)
Returns the submodel at the specified index.
|
ILcdModelDescriptor |
getModelDescriptor()
Returns the
ILcdModelDescriptor providing meta information about this model and
its elements. |
double[] |
getRange()
Returns the accuracy ranges in which the submodels should be used.
|
int |
indexOf(Object aObject)
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 |
isCumulative()
Returns
true if this model is to be used in cumulative mode, false otherwise. |
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
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. It is recommended to use the
standard Java logging framework directly.
|
int |
size()
Returns the number of elements in this model.
|
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
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
query
addElement, addElements, addModelListener, all, canAddElement, canRemoveElement, elementChanged, elementsChanged, filter, fireCollectedModelChanges, getModelEncoder, getModelMetadata, getModelReference, removeAllElements, removeElement, removeElements, removeModelListener
close
public TLcdMultilevel2DBoundsIndexedModel(ILcd2DBoundsIndexedModel[] aSubModels)
TLcdMultilevel2DBoundsIndexedModel
, initialized with the specified submodels.
One should set the ranges for the submodels afterwards.
The default level is the most detailed one.
aSubModels
- the array of models that represent this model at increasing levels of accuracy.
At least one model should be specified.setRange(double[])
public TLcdMultilevel2DBoundsIndexedModel(ILcd2DBoundsIndexedModel[] aSubModels, double[] aRanges)
TLcdMultilevel2DBoundsIndexedModel
, initialized with the specified submodels and
corresponding accuracy ranges.
The default level is the most detailed one.
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 length
aSubModels.length + 1
.public TLcdMultilevel2DBoundsIndexedModel(ILcd2DBoundsIndexedModel[] aMultilevelModel, double[] aRange, int aDefaultLevel)
TLcdMultilevel2DBoundsIndexedModel
, initialized with the specified submodels,
corresponding accuracy ranges and default level.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 length
aSubModels.length + 1
.aDefaultLevel
- the default level, used for operations that do not have a accuracy specified.public void setTraceOn(boolean aTraceOn)
true
or false
as argument automatically turns
off tracing for all other class instances for which
setTraceOn
has not been called.
If the argument is false
then only the informative, warning
and error log messages are recorded.setTraceOn
in class ALcdModel
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.public boolean isTraceOn()
true
if tracing is enabled for this class.public void setModel(ILcd2DBoundsIndexedModel[] aMultilevelModel)
aMultilevelModel
- the array of submodels representing this model at increasing levels of accuracy.getModel()
public ILcd2DBoundsIndexedModel[] getModel()
setModel(ILcd2DBoundsIndexedModel[])
public void setModelAt(int aIndex, ILcd2DBoundsIndexedModel aModel)
aIndex
- the index of the submodel to be replaced.aModel
- the new submodel at the specified index.IndexOutOfBoundsException
- if aIndex < 0 || aIndex >= getLevelCount()
.getModelAt(int)
public ILcd2DBoundsIndexedModel getModelAt(int aIndex) throws IndexOutOfBoundsException
aIndex
- the index of the submodel to be returned.IndexOutOfBoundsException
- if aIndex < 0 || aIndex >= getLevelCount()
setModelAt(int, ILcd2DBoundsIndexedModel)
public int getLevelCount()
public void setRange(double[] aRange)
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.
aRange
- the array with the accuracy range values.getRange()
,
applyOnInteract2DBounds(ILcdBounds, boolean, ILcdFunction, double, double, double, double, boolean)
public double[] getRange()
setRange(double[])
public void setCumulative(boolean aCumulative)
aCumulative
- boolean
indicating whether this model is to be used in cumulative mode or not.
If false
(default value), only one submodel is used for a specified accuracy.
If true
, all submodels with the specified or lower accuracy are taken into account for
a specified accuracy.isCumulative()
public boolean isCumulative()
true
if this model is to be used in cumulative mode, false
otherwise.true
if this model is to be used in cumulative mode, false
otherwise.setCumulative(boolean)
public void setDefaultLevel(int aDefaultLevel)
elements(), indexOf(),
elementAt(), size()
.aDefaultLevel
- the default level to be used for methods for which no accuracy is specified.IllegalArgumentException
- if aDefaultLevel < 0 || aDefaultLevel >= getLevelCount()
.getDefaultLevel()
public int getDefaultLevel()
elements(), indexOf(),
elementAt(), size()
. The default value is getLevelCount() - 1
(most detailed).setDefaultLevel(int)
public List<Object> getDependentObjects()
ILcdLockDependent
TLcdLockUtil
first locks all objects
returned by this method before locking this object.getDependentObjects
in interface ILcdLockDependent
public ILcdModelDescriptor getModelDescriptor()
ALcdModel
ILcdModelDescriptor
providing meta information about this model and
its elements.getModelDescriptor
in interface ILcdModel
getModelDescriptor
in class ALcdModel
ILcdModelDescriptor
of this ILcdModel
. Should not be null
.ALcdModel.setModelDescriptor(ILcdModelDescriptor)
public ILcdBounds getBounds()
ILcdBounded
ILcdBounds
by which the geometry of this ILcdBounded
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
of TLcdLonLatBounds
or TLcdXYBounds
.
getBounds
in interface ILcdBounded
ILcdBounds
by which the geometry of this ILcdBounded
object
is bounded.public int applyOnInteract2DBounds(ILcdBounds aBounds, boolean aStrictInteract, ILcdFunction aFunctionToApply, double aPrecisionX, double aPrecisionY)
false
.
The aPrecisionX
argument is used to determine the submodel(s) to be queried.
applyOnInteract2DBounds
in interface ILcd2DBoundsIndexedModel
aBounds
- the rectangle to test overlap with.aStrictInteract
- if false
, the spatial search may return more elements than the ones strictly
overlapping; if true
, 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 returns false
.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.ILcdFunction
has been applied.setRange(double[])
public int applyOnInteract2DBounds(ILcdBounds aBounds, boolean aStrictInteract, ILcdFunction aFunctionToApply, double aPrecisionX, double aPrecisionY, double aMinSizeX, double aMinSizeY, boolean aIncludePoints)
false
for an element it was applied on.
The aPrecisionX
argument is used to determine the submodel(s) to be queried.
applyOnInteract2DBounds
in interface ILcd2DBoundsIndexedModel
applyOnInteract2DBounds
in interface ILcd2DBoundsInteractable
aBounds
- the rectangle to test overlap with.aStrictInteract
- if false
, the spatial search may return more elements than the ones strictly
overlapping; if true
, 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 in
ILcdBounds.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 in
ILcdBounds.getHeight()
), expressed in model units.aIncludePoints
- if true
, zero-sized elements (points) are considered as well, even though they
might be smaller than the minimum size.ILcdFunction
has been applied.setRange(double[])
public Enumeration elements()
ILcdModel
public void dispose()
ALcdModel
finalize
) 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()
.
dispose
in interface ILcdModel
dispose
in interface ILcdDisposable
dispose
in class ALcdModel
ALcdModel.setModelDisposer(Consumer)
public int size()
ILcdIntegerIndexedModel
size
in interface ILcdIntegerIndexedModel
public Object elementAt(int i)
ILcdIntegerIndexedModel
elementAt
in interface ILcdIntegerIndexedModel
i
- an index into this ILcdModel
.public int indexOf(Object aObject)
ILcdIntegerIndexedModel
i
for which this.elementAt(i).equals(aElement)
.indexOf
in interface ILcdIntegerIndexedModel
aObject
- the element to search for.