Class TLcdEarthGXYRasterPainter
- All Implemented Interfaces:
ILcdCloneable
,ILcdPropertyChangeSource
,ILcdStatusSource
,ILcdGXYPainter
,ILcdGXYPainterProvider
,Serializable
,Cloneable
- Direct Known Subclasses:
TLcdEarthGXYSinglevaluedRasterPainter
,TLcdHypsometricEarthPainter
ILcdGXYPainter
can paint the raster data of ILcdEarthTileSet
instances in a 2D view.
This painter has been replaced by TLcdGXYImagePainter
. Please consider using it
instead of this one.
Supported objects
This painter can visualize anyILcdEarthTileSet
that can
produce tiles with raster data. The tile data should however be supported by the createRasterTile(com.luciad.earth.tileset.ALcdEarthTile)
implementation. The default
implementation only supports RenderedImage
s as tile data. The first
coverage in the tile set that can produce tiles with a RenderedImage
will be used
(see chooseTileSetCoverage(com.luciad.earth.tileset.ILcdEarthTileSet)
).
Visualization
By default the tile level is chosen such that each pixel in the view maps to at least one raster value, if possible. This avoids pixelation effects (e.g. that individual pixels are visible). To achieve this a tile level is chosen with a higherpixel
density
than the view. This behavior can be changed by either setting the quality
or by overriding the chooseTileSetLevel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, com.luciad.shape.ILcdBounds)
method.
If some tiles are not available, the tiles at lower levels will be used automatically to avoid
gaps.
If required this painter will warp the raster data between different coordinate systems,
otherwise it will just paint their linearly scaled images.
The bounds of the tile set will be painted instead of the tiles if the pixel density of the least
detailed level is too high
. There is no limit on the pixel
density by default so the bounds of a tile set will never be painted unless the start resolution
factor is set to a lower value. Typically this is fine for tile sets that cover the entire world
but it may be necessary to lower the start resolution factor if there are multiple smaller tile
sets in a view.
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 theALcdEarthGXYPainter.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 (seesetCacheSize(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:
- 8.2
- See Also:
-
Field Summary
Fields inherited from class com.luciad.view.gxy.ALcdGXYPainter
defaultCreationFillStyle, defaultCreationLineStyle, defaultFillStyle, defaultLineStyle, fWorkBounds
Fields inherited from interface com.luciad.view.gxy.ILcdGXYPainter
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
-
Constructor Summary
ConstructorDescriptionCreates a new earth 2D raster painter with the default cache size.TLcdEarthGXYRasterPainter
(int aCacheSize) Creates a new earth 2D raster painter with the given cache size. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addStatusListener
(ILcdStatusListener aStatusListener) Registers the given listener so it will receive status events from this source.protected TLcdEarthTileFormat
chooseTileFormat
(ILcdEarthTileSet aTileSet, ILcdEarthTileSetCoverage aCoverage) Chooses a tile format from the given tile set and coverage to be used for producing tiles.protected ILcdEarthTileSetCoverage
chooseTileSetCoverage
(ILcdEarthTileSet aTileSet) Chooses a coverage from the given tile set to be drawn by this painter.protected int
chooseTileSetLevel
(Graphics aGraphics, int aMode, ILcdGXYContext aContext, ILcdBounds aViewModelBounds) Called bypaint(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
to choose the level in the tile set that should be painted.void
Clears both the fixed cached cache and the soft cache if it is enabled.void
clearCache
(Object aObject) Clears both the fixed cached cache and the soft cache, if it is enabled, for an object.clone()
MakesObject.clone()
public.protected ILcdEarthTileSet
configureBaseTileSet
(Object aObject, ILcdEarthTileSet aTileSet) Configures the base tile set.protected ILcdEarthTileSet
createAsynchronousTileSet
(Object aObject, ILcdEarthTileSet aTileSet) Creates a tile set that can produce tiles asynchronously.protected ILcdTile
createRasterTile
(ALcdEarthTile aTile) Creates anILcdTile
corresponding to the specifiedALcdEarthTile
.Returns the style that is used when painting the fill of the bounds of tile set.Returns the style that is used when painting the outline of the bounds of tile set.float
int
Returns the size of the fixed cache which uses hard references (in #tiles).float
Returns the display name of thisILcdGXYPainter
.protected ILcdTile
Returns a representative empty tile for this painter.int
Returns the sampling rate used when transforming the raster.boolean
Returns whether this painter caches the warped raster images it has painted.protected double
getPixelDensity
(int aLevel) Returns the pixel density of the data (in the tile set reference) at the given level.double
Returns the current painting quality.protected TLcdEarthTileFormat
Returns the tile format used to request tiles.double
Returns the highest pixel density (number of raster pixels per screen pixel) at which a tile set is painted.getTileContext
(Object aObject) Returns the tile context for the most recent paint of an object.protected ILcdEarthTileSet
getTileSet
(Object aObject) The first time the tile set for an object is retrieved this base tile set isconfigured
and thenwrapped
with an asynchronous tile set to ensure smooth painting.float
long
Returns the time between two updates for a tile.int
Returns the width and height of the block in which the raster transformation is approximated using bilinear interpolation.boolean
Returns whether outdated tiles may be returned if an exception occurs while retrieving a tile.boolean
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.boolean
Returns whether the fill of the bounds of a tile set is painted.boolean
Returns whether the outline of the bounds of a tile set is painted.boolean
Returns whether a request for parent tiles may be made when tiles are requested.boolean
Returns whether the soft cache is enabled or not.protected boolean
isValidCoverage
(ILcdEarthTileSetCoverage aCoverage) Returns whether the given coverage can be drawn by this painter.void
paint
(Graphics aGraphics, int aMode, ILcdGXYContext aContext) Displays the representation of the object in the given mode on the Graphics passed, taking into account the supplied context.void
Releases the hard references to all tiles of all objects painted by this painter.void
releaseHardReferencedCache
(Object aObject) Releases the hard references to all tiles for a particular objectvoid
removeStatusListener
(ILcdStatusListener aStatusListener) Removes the specified listener so it is no longer notified.void
setAllowOutdatedTiles
(boolean aAllowOutdatedTiles) Sets whether outdated tiles may be returned if an exception occurs while retrieving a tile.void
setAsynchronousTileRequestAllowed
(boolean aAsynchronousTileRequestAllowed) Sets whether the tiles can be requested asynchronously.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.void
setBoundsFillStyle
(ILcdGXYPainterStyle aFillStyle) Sets the style that is used when painting the fill of the bounds of tile set.void
setBoundsLineStyle
(ILcdGXYPainterStyle aLineStyle) Sets the style that is used when painting the outline of the bounds of tile set.void
setBrightness
(float aBrightness) Sets the brightness that is applied to painted tiles.void
setCacheSize
(int aCacheSize) Sets the size of the fixed cache which uses hard references (in #tiles).void
setColorModel
(ColorModel aColorModel) Sets the ColorModel that determines how a tile pixel is transformed into color components for a screen pixel.void
setContrast
(float aContrast) Sets the contrast that is applied to painted tiles.void
setExceptionHandler
(ILcdExceptionHandler aExceptionHandler) Sets the exception handler that is used to handle exceptions that occur during tile retrieval.void
void
setOversamplingRate
(int aOverSamplingRate) Sets the number of samples used per pixel when transforming a raster.void
setPaintBoundsFill
(boolean aPaint) Sets whether the fill of the bounds of a tile set is painted when thepixel density is too high
.void
setPaintBoundsOutline
(boolean aPaint) Sets whether the outline of the bounds of a tile set is painted when thepixel density is too high
.void
setPaintCache
(boolean aCache) Specifies whether this painter should cache the warped raster images it has painted.void
setParentTileRequestAllowed
(boolean aParentTileRequestAllowed) Sets whether parent tiles of the visible tiles may be requested.void
setQuality
(double aQuality) Sets the quality of the painted result.void
setRepaintViewWhenTileAvailable
(boolean aRepaintViewWhenTileAvailable) Sets whether the view is repainted when a tile becomes available.void
setRGBImageFilter
(RGBImageFilter aRGBImageFilter) Sets the optional filter that is applied to painted tiles.void
setSoftCachingEnabled
(boolean aSoftCachingEnabled) Enables or disables the soft cache.void
setStartResolutionFactor
(double aStartResolutionFactor) Sets the highest pixel density (number of raster pixels per screen pixel) at which a tile set is painted.void
setTransparency
(float aTransparency) Sets the transparency factor that is applied to painted tiles.void
setUpdateInterval
(long aTime) Sets the time between two updates for a tile.void
setWarpBlockSize
(int aWarpBlockSize) Sets the width and height of the block in which the raster transformation is approximated using bilinear interpolation.void
updateTiles
(ILcdGXYView aGXYView) Updates all tiles that are cached in both the fixed cache and the soft cache.void
updateTiles
(Object aObject, ILcdGXYView aGXYView) Updates all tiles that are cached in both the fixed cache and the soft cache for an object.Methods inherited from class com.luciad.earth.view.gxy.ALcdEarthGXYPainter
boundsSFCT, getExceptionHandler, getObject, getTileSet, getTileSetCoverage, isAsynchronousTileRequestAllowed, isRepaintViewWhenTileAvailable, isTouched
Methods inherited from class com.luciad.view.gxy.ALcdGXYPainter
addPropertyChangeListener, anchorPointSFCT, firePropertyChangeEvent, firePropertyChangeEvent, getCursor, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn, snapTarget, supportSnap
-
Constructor Details
-
TLcdEarthGXYRasterPainter
public TLcdEarthGXYRasterPainter(int aCacheSize) Creates a new earth 2D raster painter with the given cache size. The cache size will be increased automatically if it is too small to contain all visible tiles.- Parameters:
aCacheSize
- the maximum number of entries in the cache- See Also:
-
TLcdEarthGXYRasterPainter
public TLcdEarthGXYRasterPainter()Creates a new earth 2D raster painter with the default cache size. The cache size will be increased automatically if it is too small to contain all visible tiles.
-
-
Method Details
-
getColorModel
- Returns:
- the color model
- See Also:
-
setColorModel
Sets the ColorModel that determines how a tile pixel is transformed into color components for a screen pixel. If it is not set, the raster tiles created bycreateRasterTile(com.luciad.earth.tileset.ALcdEarthTile)
determine the ColorModel.- Parameters:
aColorModel
- the color model
-
getRGBImageFilter
- Returns:
- the image filter
- See Also:
-
setRGBImageFilter
Sets the optional filter that is applied to painted tiles. The filter should be spatially invariant. Any brightness and transparency settings are applied on top of it.- Parameters:
aRGBImageFilter
- the new image filter ornull
-
getTransparency
public float getTransparency()- Returns:
- the transparency
- See Also:
-
setTransparency
public void setTransparency(float aTransparency) Sets the transparency factor that is applied to painted tiles. It is an alpha value between 0 and 1, with 0 being perfectly transparent, and 1 (the default) being perfectly opaque.- Parameters:
aTransparency
- the transparency
-
getBrightness
public float getBrightness()- Returns:
- the brightness
- See Also:
-
setBrightness
public void setBrightness(float aBrightness) Sets the brightness that is applied to painted tiles. It is a value in[0, 2]
. A value of 1 (the default) leaves the brightness unchanged. Values larger than 1 makes the colors brighter, while a value smaller than 1 makes the colors less bright.- Parameters:
aBrightness
- the brightness
-
getContrast
public float getContrast()- Returns:
- the contrast
- See Also:
-
setContrast
public void setContrast(float aContrast) Sets the contrast that is applied to painted tiles. It is a value in[0, 2]
. A value of 1 (the default) leaves the contrast unchanged. A value larger than 1 enhances the contrast of dark colors by making them brighter, while a value smaller than 1 enhances the contrast of bright colors by making them darker.- Parameters:
aContrast
- the contrast
-
setWarpBlockSize
public void setWarpBlockSize(int aWarpBlockSize) Sets the width and height of the block in which the raster transformation is approximated using bilinear interpolation. This transformation is only applied if the reference of the tile set and view do not match. Smaller values result in more accurate results, but also larger computation times. The default is 64. With a value of 1, every pixel is transformed without approximation.- Parameters:
aWarpBlockSize
- the width and height, expressed in pixels.
-
getWarpBlockSize
public int getWarpBlockSize()Returns the width and height of the block in which the raster transformation is approximated using bilinear interpolation.- Returns:
- the warp block size
- See Also:
-
setOversamplingRate
public void setOversamplingRate(int aOverSamplingRate) Sets the number of samples used per pixel when transforming a raster. The default is 1. The total number of samples used per pixel equals(aOverSamplingRate * aOverSamplingRate)
. For instance, if the oversampling rate is set to 2, the painter will take 4 samples per pixel and average their values. This increases the image quality, especially if the raster contains sharp edges, but it also increases the computational cost. This property is only relevant for rasters that have to be warped, that is, when the model reference of the raster is different from the world reference of the view.- Parameters:
aOverSamplingRate
- the number of samples used per pixel in one direction.
-
getOversamplingRate
public int getOversamplingRate()Returns the sampling rate used when transforming the raster. The returned value equals the number of samples used per pixel in one direction.- Returns:
- the oversampling rate
- See Also:
-
getCacheSize
public int getCacheSize()Returns 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 thesetAutoIncreaseCacheSize(boolean)
property. Next to this cache there is also an optional cache that uses soft references (seeisSoftCachingEnabled()
).- Overrides:
getCacheSize
in classALcdEarthGXYPainter
- Returns:
- the cache size
-
setCacheSize
public void setCacheSize(int aCacheSize) Sets the size of the fixed cache which uses hard references (in #tiles).- Overrides:
setCacheSize
in classALcdEarthGXYPainter
- Parameters:
aCacheSize
- the new cache size- See Also:
-
clearCache
public void clearCache()Clears both the fixed cached cache and the soft cache if it is enabled.- Overrides:
clearCache
in classALcdEarthGXYPainter
- See Also:
-
clearCache
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:
-
releaseHardReferencedCache
public void releaseHardReferencedCache()Releases the hard references to all tiles of all objects painted by this painter.- See Also:
-
releaseHardReferencedCache
Releases the hard references to all tiles for a particular object Normally the painter keeps a hard reference to the set of tiles needed in the last paint. This ensures that this data is immediately available in subsequent paints. Doing this is essential when usingincremental visualization
, otherwise data might disappear. However this cache is not cleaned up automatically when the data is not painted anymore (ex. the layer is set to invisible). In this case you can use this method to allow garbage collection of this data when the memory is needed for other purposes. So calling this indicates the data may be garbage collected but usually this will only happen if there is memory pressure. Typically this method should only be invoked when the object no longer needs to be painted. For example when the layer is set to invisible.- Parameters:
aObject
- the object whose tiles should not be hard-referenced anymore
-
setAsynchronousTileRequestAllowed
public void setAsynchronousTileRequestAllowed(boolean aAsynchronousTileRequestAllowed) Description copied from class:ALcdEarthGXYPainter
Sets whether the tiles can be requested asynchronously.- Overrides:
setAsynchronousTileRequestAllowed
in classALcdEarthGXYPainter
- 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 classALcdEarthGXYPainter
- Parameters:
aRepaintViewWhenTileAvailable
- whether the view should repainted when a tile becomes available
-
updateTiles
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
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 updatedaGXYView
- 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:
-
setPaintCache
public void setPaintCache(boolean aCache) Specifies whether this painter should cache the warped raster images it has painted. Caching it may improve performance if it can be reused but increases memory usage. The default isfalse
.This property is only relevant for rasters that have to be warped, that is, when the model reference of the raster is different from the world reference of the view.
-
getPaintCache
public boolean getPaintCache()Returns whether this painter caches the warped raster images it has painted.- 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 invokingILcdEarthTileSet.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 ifLong.MAX_VALUE
is set as the time. The tiles will be updated continuously if0
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 istrue
.- 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:
-
getQuality
public double getQuality()Returns the current painting quality.- Returns:
- the current painting quality
- See Also:
-
setQuality
public void setQuality(double aQuality) Sets the quality of the painted result. The quality influences how quickly the level of detail changes when zooming in or out. The value should be between 0 and 1. A value of 1 means that the tile level is chosen such that each pixel in the view maps to at least one raster value, if possible. This avoids pixelation effects (e.g. that individual pixels are visible). A value of0.25
means that 4 pixels in the view will map to one raster value on average. A value of 0 means that you only the least detailed level will be painted. The default value is1.0
.- Parameters:
aQuality
- the new quality
-
setExceptionHandler
Description copied from class:ALcdEarthGXYPainter
Sets the exception handler that is used to handle exceptions that occur during tile retrieval.- Overrides:
setExceptionHandler
in classALcdEarthGXYPainter
- Parameters:
aExceptionHandler
- the exception handler
-
setStartResolutionFactor
public void setStartResolutionFactor(double aStartResolutionFactor) Sets the highest pixel density (number of raster pixels per screen pixel) at which a tile set is painted. If the pixel density is too high, the bounds may be painted instead. This can avoid having to load a large number of tiles to fill a relatively small view. The default value isDouble.POSITIVE_INFINITY
which result in always painting the tiles.- Parameters:
aStartResolutionFactor
- the start resolution factor- See Also:
-
getStartResolutionFactor
public double getStartResolutionFactor()Returns the highest pixel density (number of raster pixels per screen pixel) at which a tile set is painted.- Returns:
- the start resolution factor
- See Also:
-
isParentTileRequestAllowed
public boolean isParentTileRequestAllowed()Returns whether a request for parent tiles may be made when tiles are requested.- Returns:
- whether the parent tiles of the visible tiles may be requested
- Since:
- 2018.0
- See Also:
-
setParentTileRequestAllowed
public void setParentTileRequestAllowed(boolean aParentTileRequestAllowed) Sets whether parent tiles of the visible tiles may be requested. This istrue
by default, because it benefits user experience (e.g. data is immediately available when zooming out). Disabling this might be required to support stringent operation conditions that require the minimum possible amount of tile requests; in this case, only the visible tiles will be requested.- Parameters:
aParentTileRequestAllowed
- whether the parent tiles of the visible tiles may be requested- Since:
- 2018.0
-
setPaintBoundsOutline
public void setPaintBoundsOutline(boolean aPaint) Sets whether the outline of the bounds of a tile set is painted when thepixel density is too high
. Note that if this flag is set totrue
then the bounds line style must be valid. The default value istrue
.- Parameters:
aPaint
-true
if the outline of the bounds of a tile set should be painted.- See Also:
-
setPaintBoundsFill
public void setPaintBoundsFill(boolean aPaint) Sets whether the fill of the bounds of a tile set is painted when thepixel density is too high
. Note that if this flag is set totrue
then the bounds fill style must be valid. The default value istrue
.- Parameters:
aPaint
-true
if the fill of the bounds of a tile set should be painted.- See Also:
-
isPaintBoundsOutline
public boolean isPaintBoundsOutline()Returns whether the outline of the bounds of a tile set is painted.- Returns:
- whether the outline of the bounds of a tile set is painted.
- See Also:
-
isPaintBoundsFill
public boolean isPaintBoundsFill()Returns whether the fill of the bounds of a tile set is painted.- Returns:
- whether the fill of the bounds of a tile set is painted.
- See Also:
-
setBoundsLineStyle
Sets the style that is used when painting the outline of the bounds of tile set. If the outline style is set tonull
andpaint bounds outline
is enabled the result visual result on screen is undefined. The default value is a red line style.- Parameters:
aLineStyle
- the line style to use- See Also:
-
setBoundsFillStyle
Sets the style that is used when painting the fill of the bounds of tile set. If the fill style is set tonull
andpaint bounds fill
is enabled the result visual result on screen is undefined. The default value is a red hatched fill style.- Parameters:
aFillStyle
- the fill style to use- See Also:
-
getBoundsLineStyle
Returns the style that is used when painting the outline of the bounds of tile set.- Returns:
- the line style
- See Also:
-
getBoundsFillStyle
Returns the style that is used when painting the fill of the bounds of tile set.- Returns:
- the fill style
- See Also:
-
getTileContext
Returns the tile context for the most recent paint of an object. This method may returnnull
if the specified object has never been painted, if its cache as beencleared
. 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
-
setObject
- Specified by:
setObject
in interfaceILcdGXYPainter
- Overrides:
setObject
in classALcdEarthGXYPainter
- Parameters:
aObject
- the object for which the representation shall be handled by this painter.- See Also:
-
getTileSet
The first time the tile set for an object is retrieved this base tile set isconfigured
and thenwrapped
with an asynchronous tile set to ensure smooth painting.- Overrides:
getTileSet
in classALcdEarthGXYPainter
- Parameters:
aObject
- the object being painted- Returns:
- the tile set
-
configureBaseTileSet
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 paintedaTileSet
- the base tile set- Returns:
- the configured tile set
- See Also:
-
createAsynchronousTileSet
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 paintedaTileSet
- the tile set- Returns:
- the asynchronous tile set
- See Also:
-
getRequestFormat
Returns the tile format used to request tiles.- Returns:
- the tile format used to request tiles.
-
chooseTileSetCoverage
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 classALcdEarthGXYPainter
- Parameters:
aTileSet
- the tile set whose tiles are being painted- Returns:
- the coverage from which tiles should be obtained
- See Also:
-
isValidCoverage
Returns whether the given coverage can be drawn by this painter. The returned coverage should support a format that can be handled bycreateRasterTile(com.luciad.earth.tileset.ALcdEarthTile)
. The default implementation returnstrue
if the coverage is araster coverage
and the tiles set supports a format withRenderedImage
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:
-
chooseTileFormat
protected TLcdEarthTileFormat chooseTileFormat(ILcdEarthTileSet aTileSet, ILcdEarthTileSetCoverage aCoverage) Chooses a tile format from the given tile set and coverage to be used for producing tiles. The format should be supported bycreateRasterTile(com.luciad.earth.tileset.ALcdEarthTile)
. The default implementation returns a format withRenderedImage
as format class and no format name.- Parameters:
aTileSet
- the tile set whose tiles are being paintedaCoverage
- the coverage whose tiles are being painted.- Returns:
- the format in which tiles should be obtained
-
paint
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 ofILcdGXYPainter
andILcdGXYEditor
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 theILcdGXYPainter
andILcdGXYEditor
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 interfaceILcdGXYPainter
- Parameters:
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented in (see class documentation).aContext
- theILcdGXYContext
the drawing depends on.
-
chooseTileSetLevel
protected int chooseTileSetLevel(Graphics aGraphics, int aMode, ILcdGXYContext aContext, ILcdBounds aViewModelBounds) Called bypaint(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
to choose the level in the tile set that should be painted. Note that tiles at lower levels may still be painted (ex. if some tiles at the desired level are not available). The default implementation chooses a level such that each pixel in the view maps to at least one raster value, if possible. If the pixel density of the least detailed levelis too high
then-1
is returned.- Parameters:
aGraphics
- the graphicsaMode
- the modeaContext
- the contextaViewModelBounds
- the bounds of the view in model coordinates- Returns:
- the level that should be painted or
-1
if the bounds should be painted instead
-
getEmptyTile
Returns a representative empty tile for this painter. For example, the tile's default value may be used when painting missing data.- Returns:
- an empty tile.
- Since:
- 2022.0
-
createRasterTile
Creates anILcdTile
corresponding to the specifiedALcdEarthTile
. The resulting raster tile is used in order to draw the output of a tile set usingTLcdRasterPainter
. The default implementation can only create a tile for tiles with aRenderedImage
as tile data.- Parameters:
aTile
- the tile to convert into a raster tile- Returns:
- a raster tile
-
getPixelDensity
protected double getPixelDensity(int aLevel) Returns the pixel density of the data (in the tile set reference) at the given level. The default implementation assumes that the coverage is aILcdEarthRasterTileSetCoverage
and returns its pixel density at the specified level.- Parameters:
aLevel
- a level- Returns:
- the pixel density
- See Also:
-
getDisplayName
Description copied from class:ALcdGXYPainter
Returns the display name of thisILcdGXYPainter
.- Specified by:
getDisplayName
in interfaceILcdGXYPainter
- Overrides:
getDisplayName
in classALcdGXYPainter
- Returns:
- the name that has been set using
setDisplayName()
, orthis.toString()
if no name has been set.
-
clone
Description copied from interface:ILcdCloneable
Makes
When for example extending fromObject.clone()
public.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 interfaceILcdCloneable
- Specified by:
clone
in interfaceILcdGXYPainterProvider
- Overrides:
clone
in classALcdEarthGXYPainter
- Returns:
- a clone of this painter provider.
- See Also:
-
addStatusListener
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 interfaceILcdStatusSource
- Parameters:
aStatusListener
- The listener to be notified when the status has changed.
-
removeStatusListener
Description copied from interface:ILcdStatusSource
Removes the specified listener so it is no longer notified.- Specified by:
removeStatusListener
in interfaceILcdStatusSource
- Parameters:
aStatusListener
- The listener to remove.
-