| The Essential JViews Framework > Managers > Managing Layers > Caching Layers |
Caching Layers |
INDEX
PREVIOUS
NEXT
|
As described in Triple Buffering Layers, the triple buffer is used to cache a set of layers. The constraint is that these layers must be contiguous from layer 0 to layer n. What happens if you want cache layers that are not contiguous or the layer whose index is not 0 since JViews 8.1, IlvManagerView allows you to cache any layer for that view.
To enable or disable any arbitrary 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)
A layer cached for a view means that the layer will first draw into a buffered image having 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 layers behind 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, like for example 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 IlvManager.applyToObject), the cache is automatically invalidated.
If you hesitate between enabling the layer cache and the triple buffer, 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 buffer. In this case, triple buffer has better performance than layer caches because the latter has to handle transparency.
If the layers you want to cache or to buffer are not contiguous, you have to use layer caches.
However, you can 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 on top of the layer n. In this way, you will get the best performance.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |