Class TLcdMultilevel2DBoundsIndexedModel

java.lang.Object
com.luciad.model.ALcdModel
com.luciad.model.TLcdMultilevel2DBoundsIndexedModel
All Implemented Interfaces:
ILcd2DBoundsIndexedModel, ILcd2DBoundsInteractable, ILcdIntegerIndexedModel, ILcdModel, ILcdBounded, ILcdLockDependent, ILcdDisposable, Serializable, AutoCloseable

public class TLcdMultilevel2DBoundsIndexedModel extends ALcdModel implements ILcd2DBoundsIndexedModel, ILcdIntegerIndexedModel, ILcdLockDependent
An implementation of 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:
  • Constructor Details

    • TLcdMultilevel2DBoundsIndexedModel

      public TLcdMultilevel2DBoundsIndexedModel(ILcd2DBoundsIndexedModel[] aSubModels)
      Constructs a new TLcdMultilevel2DBoundsIndexedModel, 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

      public TLcdMultilevel2DBoundsIndexedModel(ILcd2DBoundsIndexedModel[] aSubModels, double[] aRanges)
      Constructs a new TLcdMultilevel2DBoundsIndexedModel, 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 length aSubModels.length + 1.
    • TLcdMultilevel2DBoundsIndexedModel

      public TLcdMultilevel2DBoundsIndexedModel(ILcd2DBoundsIndexedModel[] aMultilevelModel, double[] aRange, int aDefaultLevel)
      Constructs a new TLcdMultilevel2DBoundsIndexedModel, 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 length aSubModels.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 either 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.
      Overrides:
      setTraceOn in class ALcdModel
      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.
      Returns true if tracing is enabled for this class.
      Overrides:
      isTraceOn in class ALcdModel
      Returns:
      true if tracing is enabled for this class, false otherwise.
    • setModel

      public void setModel(ILcd2DBoundsIndexedModel[] aMultilevelModel)
      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

      public ILcd2DBoundsIndexedModel[] 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

      public void setModelAt(int aIndex, ILcd2DBoundsIndexedModel aModel)
      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 - if aIndex < 0 || aIndex >= getLevelCount().
      See Also:
    • getModelAt

      public ILcd2DBoundsIndexedModel getModelAt(int aIndex) throws IndexOutOfBoundsException
      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 - if aIndex < 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. 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.
      See Also:
    • isCumulative

      public boolean isCumulative()
      Returns true 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 - if aDefaultLevel < 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 is getLevelCount() - 1 (most detailed).
      See Also:
    • getDependentObjects

      public List<Object> getDependentObjects()
      Description copied from interface: ILcdLockDependent
      Returns the objects that must be locked along with this object. TLcdLockUtilfirst locks all objects returned by this method before locking this object.
      Specified by:
      getDependentObjects in interface ILcdLockDependent
      Returns:
      the objects that must be locked along with this object.
    • getModelDescriptor

      public ILcdModelDescriptor getModelDescriptor()
      Description copied from class: ALcdModel
      Returns the ILcdModelDescriptor providing meta information about this model and its elements.
      Specified by:
      getModelDescriptor in interface ILcdModel
      Overrides:
      getModelDescriptor in class ALcdModel
      Returns:
      the ILcdModelDescriptor of this ILcdModel. Should not be null.
      See Also:
    • getBounds

      public ILcdBounds getBounds()
      Description copied from interface: ILcdBounded
      Returns the 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.

      Specified by:
      getBounds in interface ILcdBounded
      Returns:
      the ILcdBounds by which the geometry of this ILcdBounded 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 returns false.

      The aPrecisionX argument is used to determine the submodel(s) to be queried.

      Specified by:
      applyOnInteract2DBounds in interface ILcd2DBoundsIndexedModel
      Parameters:
      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.
      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 returns false for an element it was applied on.

      The aPrecisionX argument is used to determine the submodel(s) to be queried.

      Specified by:
      applyOnInteract2DBounds in interface ILcd2DBoundsIndexedModel
      Specified by:
      applyOnInteract2DBounds in interface ILcd2DBoundsInteractable
      Parameters:
      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.
      Returns:
      the number of elements to which the ILcdFunction has been applied.
      See Also:
    • elements

      public Enumeration 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.
      Specified by:
      elements in interface ILcdModel
      Returns:
      an enumeration over all elements of this model.
    • 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 than 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().

      Specified by:
      dispose in interface ILcdDisposable
      Specified by:
      dispose in interface ILcdModel
      Overrides:
      dispose in class ALcdModel
      See Also:
    • size

      public int size()
      Description copied from interface: ILcdIntegerIndexedModel
      Returns the number of elements in this model.
      Specified by:
      size in interface ILcdIntegerIndexedModel
      Returns:
      the number of elements in this model.
    • elementAt

      public Object elementAt(int i)
      Description copied from interface: ILcdIntegerIndexedModel
      Returns the element at the specified index.
      Specified by:
      elementAt in interface ILcdIntegerIndexedModel
      Parameters:
      i - an index into this ILcdModel.
      Returns:
      the element at the specified index.
    • indexOf

      public int indexOf(Object aObject)
      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 smallest i for which this.elementAt(i).equals(aElement).
      Specified by:
      indexOf in interface ILcdIntegerIndexedModel
      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()
      Overrides:
      finalize in class Object