Performance guidelines for GXY views
Background layers
Many applications work with 2D views that contain relatively static background layers, and dynamic foreground layers. In these
cases, it is useful to identify the background layers and set the property numberOfCachedBackgroundLayers
of the interface ILcdGXYView
. This is a hint for the view that the given number of background layers should be cached in an image. When the view has to
be re-painted, for example due to changes in the foreground layer, the cached layers can then be repainted quickly.
Smart panning
TLcdGXYViewJPanel
and TLcdGXYViewCanvas
offer a smart panning functionality. If it is enabled, panning operations will re-use the cached background layers image
and only paint the newly exposed areas for those layers. This can noticeably improve performance for models with many objects
or complex painting algorithms.
Notice, however, that smart panning may cause incorrect renderings in some circumstances. For example, consider an object of which the visual representation is larger than its bounds, such as a point represented by an icon. If a pan operation exposes the part of the object outside its bounds, the object will not get painted on the newly exposed area.
Preventing raster warping
On-the-fly warping between projections is a relatively expensive operation when painting raster data. To improve performance, the current view reference should therefore be equal to the model reference of the raster data. The painters automatically select a more efficient non-warping mode in such cases.
Tuning raster painter settings
The TLcdGXYImagePainter
and all ILcdRasterPainter
implementations provide a few basic properties to control whether a given raster is visible at a given scale:
-
startResolutionFactor
is the highest pixel density (number of raster pixels per screen pixel) at which a raster is painted. Small values (for example 2.0) generally improve performance, by not displaying the raster or raster level if its resolution appears to be high, relative to the resolution of the view. -
stopResolutionFactor
is the lowest pixel density (number of raster pixels per screen pixel) at which a raster is painted. Small values (for example 0.5) prevent the display of the raster or raster level if its resolution appears to be low, relative to the resolution of the view. -
forcePainting
is a flag that allows to override the above settings. Although useful for testing, setting this flag generally causes performance to peak when zooming out on large raster data.
If you are working with multilevel raster data, the TLcdGXYImagePainter
and other multilevel raster painters will select the appropriate level to paint in the current view, based on a number of
settings. Tweaking these settings, in addition to the above properties, can help finding a right balance between quality and
performance.
-
levelSwitchFactor
is the factor that affects the scale point at which a raster level is selected. The default value is 1.0: as soon as a single raster pixel would project to several screen pixels, a higher resolution level is used. This way, the highest practical raster quality is chosen. A value smaller than 1.0 (for example 0.2) delays this switching: a single raster pixel may project to multiple screen pixels. Setting a small value may cause pixelating effects, but it will generally improve the painting performance. -
levelSwitchScales
is an optional list of scales that can achieve the same effects as thelevelSwitchFactor
. It explicitly expresses the scales at which the painter switches between raster levels, instead of relying on a single factor.
These properties can be combined with the properties of the layer, such as the scale range.