Class TLcdEarthGXYMultivaluedRasterPainter
- All Implemented Interfaces:
ILcdCloneable
,ILcdPropertyChangeSource
,ILcdStatusSource
,ILcdGXYPainter
,ILcdGXYPainterProvider
,Serializable
,Cloneable
ILcdGXYPainter
can paint the multi-valued raster data of ILcdEarthTileSet
instances in a 2D view.
Supported objects
This painter can visualize anyILcdEarthTileSet
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 thesetDeltaX(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 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:
- 10.1
- 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 multi-valued raster painter with the default settings. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addStatusListener
(ILcdStatusListener aListener) Registers the given listener so it will receive status events from this source.protected ILcdEarthTileSetCoverage
chooseTileSetCoverage
(ILcdEarthTileSet aTileSet) Chooses a coverage from the given tile set to be drawn by this painter.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.int
Returns the horizontal grid spacing of the icons.int
Returns the vertical grid spacing of the icons.Returns the parameterized icon that is used.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.long
Returns the time between two updates for a tile.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 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
removeStatusListener
(ILcdStatusListener aListener) 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
setCacheSize
(int aCacheSize) This sets the size of the fixed cache which uses hard references (in #tiles).void
setDeltaX
(int aDeltaX) Sets the horizontal grid spacing of the icons.void
setDeltaY
(int aDeltaY) Sets the vertical grid spacing of the icons.void
setExceptionHandler
(ILcdExceptionHandler aExceptionHandler) Sets the exception handler that is used to handle exceptions that occur during tile retrieval.void
setParameterizedIcon
(ILcdParameterizedIcon aParameterizedIcon) Sets the parameterized icon that is used.void
setRepaintViewWhenTileAvailable
(boolean aRepaintViewWhenTileAvailable) Sets whether the view is repainted when a tile becomes available.void
setSoftCachingEnabled
(boolean aSoftCachingEnabled) Enables or disables the soft cache.void
setUpdateInterval
(long aTime) Sets the time between two updates for a tile.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, getCacheSize, getExceptionHandler, getObject, getTileSet, getTileSetCoverage, isAsynchronousTileRequestAllowed, isRepaintViewWhenTileAvailable, isTouched, setObject
Methods inherited from class com.luciad.view.gxy.ALcdGXYPainter
addPropertyChangeListener, anchorPointSFCT, firePropertyChangeEvent, firePropertyChangeEvent, getCursor, getDisplayName, getGXYPainter, isTraceOn, removePropertyChangeListener, setClassTraceOn, setDisplayName, setTraceOn, snapTarget, supportSnap
-
Constructor Details
-
TLcdEarthGXYMultivaluedRasterPainter
public TLcdEarthGXYMultivaluedRasterPainter()Creates a new multi-valued raster painter with the default settings. Note that an icon must be set before this painter can be used.- See Also:
-
-
Method Details
-
getDeltaX
public int getDeltaX()Returns the horizontal grid spacing of the icons. The default is50
.- 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 is50
.- 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
Returns the parameterized icon that is used. The default isnull
- Returns:
- the parameterized icon
-
setParameterizedIcon
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 thesetAutoIncreaseCacheSize(boolean)
property. Next to this cache there is also an optional cache that uses soft references (seeisSoftCachingEnabled()
).- Overrides:
setCacheSize
in classALcdEarthGXYPainter
- 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 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:
-
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:
-
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:
-
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
-
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 or 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
-
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:
-
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 default implementation returnstrue
if the coverage implementsILcdEarthRasterTileSetCoverage
and the tiles set supports a format withTLcdEarthMultivaluedData
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
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.
-
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:
aListener
- 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:
aListener
- The listener to remove.
-