Class TLcdEarthGXYMultivaluedRasterPainter

java.lang.Object
com.luciad.view.gxy.ALcdGXYPainter
com.luciad.earth.view.gxy.ALcdEarthGXYPainter
com.luciad.earth.view.gxy.TLcdEarthGXYMultivaluedRasterPainter
All Implemented Interfaces:
ILcdCloneable, ILcdPropertyChangeSource, ILcdStatusSource, ILcdGXYPainter, ILcdGXYPainterProvider, Serializable, Cloneable

public class TLcdEarthGXYMultivaluedRasterPainter extends ALcdEarthGXYPainter implements ILcdStatusSource
This ILcdGXYPainter can paint the multi-valued raster data of ILcdEarthTileSet instances in a 2D view.

Supported objects

This painter can visualize any ILcdEarthTileSet that can produce tiles with multi-valued raster data. The tile data should be a TLcdEarthMultivaluedData. The first multi-valued raster coverage in the tile set that can produce such tiles will be used (see chooseTileSetCoverage(com.luciad.earth.tileset.ILcdEarthTileSet)).

Visualization

The data is visualized by painting a grid of icons. The horizontal and vertical distance between the icons can be controlled using the setDeltaX(int) and setDeltaY(int) methods. The actual painting of the icons is delegated to the ILcdParameterizedIcon that is set. Note that a valid parameterized icon must be set on this painter before it can be used. The tile level is chosen such that each painted icon in the view maps to approximately one raster value, if possible.

If some tiles are not available, the tiles at lower levels will be used automatically to avoid gaps.

If required this painter will transform the raster data between different coordinate systems.

Incremental visualization

If the tile set supports asynchronous tile production, the visualization can be done incrementally. This means that the tiles will be requested asynchronously and the view will be repainted as the tiles become available. To enable this the ALcdEarthGXYPainter.isAsynchronousTileRequestAllowed() and ALcdEarthGXYPainter.isRepaintViewWhenTileAvailable() should be set to true (default).

Caching

By default only the tiles necessary for the view will be cached using hard references (see setCacheSize(int)). Other tiles will also be cached if there is enough memory (see isSoftCachingEnabled()). Tiles that reside in either of these caches will be updated automatically every minute (see getUpdateInterval()). You can use the updateTiles(com.luciad.view.gxy.ILcdGXYView) method to update all tiles that are currently cached immediately.

Performance considerations

  • To achieve optimal performance the reference of the tile set and the world reference should match. If this is not the case the raster data will need to be warped on-the-fly.
  • When incremental visualization is enabled other layers may also be repainted more frequently. This could result in reduced performance if this takes too much time.
  • When incremental visualization is enabled in combination with asynchronous painting it may sometimes take a significant amount of time before a paint is completed. More specifically this situation occurs if the painting is interrupted before it can finish due to a repaint for tile that has just become available. To avoid this you can disable the interruption of paints (see TLcdGXYAsynchronousPaintQueue.setInterruptPainting(boolean))
Since:
10.1
See Also:
  • Constructor Details

  • Method Details

    • getDeltaX

      public int getDeltaX()
      Returns the horizontal grid spacing of the icons.

      The default is 50.

      Returns:
      the horizontal distance between the icons (in #pixels)
    • setDeltaX

      public void setDeltaX(int aDeltaX)
      Sets the horizontal grid spacing of the icons.
      Parameters:
      aDeltaX - the horizontal distance between the icons (in #pixels)
    • getDeltaY

      public int getDeltaY()
      Returns the vertical grid spacing of the icons.

      The default is 50.

      Returns:
      the vertical distance between the icons (in #pixels)
    • setDeltaY

      public void setDeltaY(int aDeltaY)
      Sets the vertical grid spacing of the icons.
      Parameters:
      aDeltaY - the vertical distance between the icons (in #pixels)
    • getParameterizedIcon

      public ILcdParameterizedIcon getParameterizedIcon()
      Returns the parameterized icon that is used.

      The default is null

      Returns:
      the parameterized icon
    • setParameterizedIcon

      public void setParameterizedIcon(ILcdParameterizedIcon aParameterizedIcon)
      Sets the parameterized icon that is used.

      This parameter must be set to a non-null value before this painter can be used.

      Parameters:
      aParameterizedIcon - the parameterized icon
    • setCacheSize

      public void setCacheSize(int aCacheSize)
      This sets the size of the fixed cache which uses hard references (in #tiles).

      This painter will never paint more tiles for a view than fit in this cache. So if it is too small coarse data may be painted instead of the data at the optimal level of detail. To avoid this you can set the setAutoIncreaseCacheSize(boolean) property.

      Next to this cache there is also an optional cache that uses soft references (see isSoftCachingEnabled()).

      Overrides:
      setCacheSize in class ALcdEarthGXYPainter
      Parameters:
      aCacheSize - the new cache size
    • clearCache

      public void clearCache()
      Clears both the fixed cached cache and the soft cache if it is enabled.
      Overrides:
      clearCache in class ALcdEarthGXYPainter
      See Also:
    • clearCache

      public void clearCache(Object aObject)
      Clears both the fixed cached cache and the soft cache, if it is enabled, for an object.
      Parameters:
      aObject - the object whose cache should be cleared
      See Also:
    • setAsynchronousTileRequestAllowed

      public void setAsynchronousTileRequestAllowed(boolean aAsynchronousTileRequestAllowed)
      Description copied from class: ALcdEarthGXYPainter
      Sets whether the tiles can be requested asynchronously.
      Overrides:
      setAsynchronousTileRequestAllowed in class ALcdEarthGXYPainter
      Parameters:
      aAsynchronousTileRequestAllowed - True if the tiles can be requested asynchronously
      See Also:
    • setRepaintViewWhenTileAvailable

      public void setRepaintViewWhenTileAvailable(boolean aRepaintViewWhenTileAvailable)
      Description copied from class: ALcdEarthGXYPainter
      Sets whether the view is repainted when a tile becomes available.
      Overrides:
      setRepaintViewWhenTileAvailable in class ALcdEarthGXYPainter
      Parameters:
      aRepaintViewWhenTileAvailable - whether the view should repainted when a tile becomes available
    • updateTiles

      public void updateTiles(ILcdGXYView aGXYView)
      Updates all tiles that are cached in both the fixed cache and the soft cache.
      Parameters:
      aGXYView - the view that this painter is painting in
      See Also:
    • updateTiles

      public void updateTiles(Object aObject, ILcdGXYView aGXYView)
      Updates all tiles that are cached in both the fixed cache and the soft cache for an object.
      Parameters:
      aObject - the object whose tiles should be updated
      aGXYView - the view that this painter is painting in
      See Also:
    • isAutoIncreaseCacheSize

      public boolean isAutoIncreaseCacheSize()
      Returns whether the size of the fixed cache will be increased automatically if it is too small to contain all visible tiles at the optimal level of detail.
      Returns:
      true if the size of the fixed cache will be increased automatically if it is too small to contain
      See Also:
    • setAutoIncreaseCacheSize

      public void setAutoIncreaseCacheSize(boolean aAutoIncreaseCacheSize)
      Sets whether the size of the fixed cache should be increased automatically if it is too small to contain all visible tiles at the optimal level of detail.
      Parameters:
      aAutoIncreaseCacheSize - whether if the size of the fixed cache should be increased automatically if it is too small to contain
      See Also:
    • isSoftCachingEnabled

      public boolean isSoftCachingEnabled()
      Returns whether the soft cache is enabled or not.

      If the soft cache is enabled all tiles that have been retrieved will be cached, even those outside the view, as long as there is enough memory available.

      The soft cache is disabled by default.

      Returns:
      true if the soft cache is enabled
      See Also:
    • setSoftCachingEnabled

      public void setSoftCachingEnabled(boolean aSoftCachingEnabled)
      Enables or disables the soft cache.
      Parameters:
      aSoftCachingEnabled - whether the soft cache should be enabled
      See Also:
    • setUpdateInterval

      public void setUpdateInterval(long aTime)
      Sets the time between two updates for a tile.
      Parameters:
      aTime - the time in milliseconds
      See Also:
    • getUpdateInterval

      public long getUpdateInterval()
      Returns the time between two updates for a tile.

      The tiles in the internal cache and the soft cache will be updated by invoking ILcdEarthTileSet.updateTile(com.luciad.earth.tileset.ALcdEarthTile, com.luciad.earth.tileset.TLcdEarthTileOperationMode, com.luciad.earth.tileset.ILcdEarthTileSetCallback, java.lang.Object) if they are older than this time. The tiles will never be updated automatically if Long.MAX_VALUE is set as the time. The tiles will be updated continuously if 0 is set as the time.

      The default time is 1 minute.

      Returns:
      the time in milliseconds
    • isAllowOutdatedTiles

      public boolean isAllowOutdatedTiles()
      Returns whether outdated tiles may be returned if an exception occurs while retrieving a tile.

      If enabled, any cached version of the requested tile may be returned if an exception occurs. Otherwise the tile will not be painted.

      The default value is true.

      Returns:
      true if outdated tiles may be returned if an exception occurs while retrieving a tile
    • setAllowOutdatedTiles

      public void setAllowOutdatedTiles(boolean aAllowOutdatedTiles)
      Sets whether outdated tiles may be returned if an exception occurs while retrieving a tile.
      Parameters:
      aAllowOutdatedTiles - true if outdated tiles may be returned if an exception occurs while retrieving a tile
      See Also:
    • setExceptionHandler

      public void setExceptionHandler(ILcdExceptionHandler aExceptionHandler)
      Description copied from class: ALcdEarthGXYPainter
      Sets the exception handler that is used to handle exceptions that occur during tile retrieval.
      Overrides:
      setExceptionHandler in class ALcdEarthGXYPainter
      Parameters:
      aExceptionHandler - the exception handler
    • getTileContext

      public TLcdEarthTileContext getTileContext(Object aObject)
      Returns the tile context for the most recent paint of an object.

      This method may return null if the specified object has never been painted or if its cache as been cleared.

      The set of painted tiles may or may not contain some painted tiles if they are no longer available (for example due to garbage collection).

      The returned map will never change and is thread-safe for reading.

      Parameters:
      aObject - the object
      Returns:
      the context or null
    • getTileSet

      protected ILcdEarthTileSet getTileSet(Object aObject)
      The first time the tile set for an object is retrieved this base tile set is configured and then wrapped with an asynchronous tile set to ensure smooth painting.
      Overrides:
      getTileSet in class ALcdEarthGXYPainter
      Parameters:
      aObject - the object being painted
      Returns:
      the tile set
    • configureBaseTileSet

      protected ILcdEarthTileSet configureBaseTileSet(Object aObject, ILcdEarthTileSet aTileSet)
      Configures the base tile set.

      The default implementation just returns the base tile set.

      This method can be overridden to add custom tile set wrappers to the tile set.

      Parameters:
      aObject - the object being painted
      aTileSet - the base tile set
      Returns:
      the configured tile set
      See Also:
    • createAsynchronousTileSet

      protected ILcdEarthTileSet createAsynchronousTileSet(Object aObject, ILcdEarthTileSet aTileSet)
      Creates a tile set that can produce tiles asynchronously.

      The default implementation creates a new asynchronous tile set that uses 1 thread for tile production unless the tile set already is an asynchronous tile set.

      Parameters:
      aObject - the object being painted
      aTileSet - the tile set
      Returns:
      the asynchronous tile set
      See Also:
    • chooseTileSetCoverage

      protected ILcdEarthTileSetCoverage chooseTileSetCoverage(ILcdEarthTileSet aTileSet)
      Chooses a coverage from the given tile set to be drawn by this painter.

      The default implementation returns the first coverage that is valid.

      Specified by:
      chooseTileSetCoverage in class ALcdEarthGXYPainter
      Parameters:
      aTileSet - the tile set whose tiles are being painted
      Returns:
      the coverage from which tiles should be obtained
      See Also:
    • isValidCoverage

      protected boolean isValidCoverage(ILcdEarthTileSetCoverage aCoverage)
      Returns whether the given coverage can be drawn by this painter.

      The default implementation returns true if the coverage implements ILcdEarthRasterTileSetCoverage and the tiles set supports a format with TLcdEarthMultivaluedData as format class and no format name with the specified coverage.

      Parameters:
      aCoverage - the candidate coverage
      Returns:
      true if the given coverage can be painted
      See Also:
    • paint

      public void paint(Graphics aGraphics, int aMode, ILcdGXYContext aContext)
      Description copied from interface: ILcdGXYPainter
      Displays the representation of the object in the given mode on the Graphics passed, taking into account the supplied context.

      The visual representation of an object depends on the context. Depending on the context (e.g. is the location covered by the view), an object may or may not have a representation. The context contains:

      • transformations which allow to compute the location in view space of points and bounds given in model, space
      • a pen which can connect points with a line or create arcs around a point,
      • the view for which the object's representation must be painted. This can be useful when the painted object depends on the scale of the view, or the presence of other layers in the view.
      • the current location(s) of the mouse or input device and the last location(s) the mouse or input device was pressed.

      The mode passed in this method indicates what part of the object must be painted, whether it should be painted as selected or not, and whether user interaction (via mouse movements) must be taken into account.

      When the mode passed contains either TRANSLATING, RESHAPING or CREATING, this method is also responsible for interpreting interaction on the representation of an object and modifying the representation of the object accordingly. The painter is not responsible for modifying the object itself, this is done by a corresponding ILcdGXYEditor . Implementations of ILcdGXYPainter and ILcdGXYEditor interfaces must be consistent for an object: the painter must display the result of the user interaction on the object, while the editor is responsible for modifying the object as a result of the user interaction. A good practice to ensure a consistent implementation is to implement both the ILcdGXYPainter and ILcdGXYEditor interfaces in a single class.

      When the mode passed includes SNAPS, the part of the representation which corresponds to the object returned as snap target by the method snapTarget must be painted in order to provide the user with a visual indication of the snap target.

      The Graphics passed in this method can be different from the Graphics returned by a view due to techniques such as double buffering (as applied in Swing). Basic drawing operations must always be performed on the Graphics passed as an argument in this method.

      Specified by:
      paint in interface ILcdGXYPainter
      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aMode - the mode the object is represented in (see class documentation).
      aContext - the ILcdGXYContext the drawing depends on.
    • clone

      public Object clone()
      Description copied from interface: ILcdCloneable

      Makes Object.clone() public.

      When for example extending from java.lang.Object, it can be implemented like this:
      
       public Object clone() {
         try {
           return super.clone();
         } catch ( CloneNotSupportedException e ) {
           // Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
           throw new RuntimeException( e );
         }
       }
       
      Specified by:
      clone in interface ILcdCloneable
      Specified by:
      clone in interface ILcdGXYPainterProvider
      Overrides:
      clone in class ALcdEarthGXYPainter
      Returns:
      a clone of this painter provider.
      See Also:
    • addStatusListener

      public void addStatusListener(ILcdStatusListener aListener)
      Description copied from interface: ILcdStatusSource

      Registers the given listener so it will receive status events from this source.

      In case you need to register a listener which keeps a reference to an object with a shorter life-time than this status source, you can use a ALcdWeakStatusListener instance as status listener.

      Specified by:
      addStatusListener in interface ILcdStatusSource
      Parameters:
      aListener - The listener to be notified when the status has changed.
    • removeStatusListener

      public void removeStatusListener(ILcdStatusListener aListener)
      Description copied from interface: ILcdStatusSource
      Removes the specified listener so it is no longer notified.
      Specified by:
      removeStatusListener in interface ILcdStatusSource
      Parameters:
      aListener - The listener to remove.