Triple buffering is used to cache a set of layers for
one view. The constraint is that these layers must be contiguous from
layer 0 to layer n. If you want cache layers that are not contiguous
or a layer whose index is not 0, since JViews 8.1,
IlvManagerView allows you to cache any layer for the view concerned.
To enable or disable a layer cache for the view, you
can call the following method:
void setLayerCached(int layer, boolean enabled)
To know if a given layer is cached or not, call the following
method:
boolean isLayerCached(int layer)
When a layer for a view is cached, it will first draw
into a buffered image of the same size as the view. When the view
needs to be repainted, the buffered image is displayed on the screen.
The buffered image must be transparent so that layers behind it are
not hidden.
You can enable the cache on any layer. Usually, caches
are enabled on layers having many static graphic objects, that is,
objects whose drawing does not change frequently, such as layers containing
map (cartographic) information. However, this does not mean that the
content of the cached layers cannot be changed. It just means that
the speed benefit of the cache is higher when the content of the layer
changes rarely. When you make a change to a graphic object such as
inserting, removing, or applying an operation (see
applyToObject), the cache is automatically invalidated.
If you hesitate between enabling the layer cache and
using triple buffering, the following facts can help you make the
choice:
If the layers you want to cache or to
buffer are contiguous and their indexes are from 0 to n, you should
use triple buffering. In this case, triple buffering gives better
performance than layer caches because the latter have to handle transparency.
If the layers you want to cache or to
buffer are not contiguous, you have to use layer caches.
You can also use both features for the same view. You
can triple buffer contiguous layers from 0 to n, and in addition you
can cache any layer above layer n. In this way, you will get the best
performance.
Note
With some very rare configurations (Java ™
SE
and OS), the transparent buffered image might not give good performance.
In this case, you can perform a test to see if layer caches can improve
performance.