skip to main content
Gantt > Programmer's documentation > Developing with the JViews Charts SDK > Using Load-On-Demand > The tile cache
 
The tile cache
The abstract class IlvDataTileCache specifies the methods that can be used to implement a strategy for caching and releasing tiles. The API of this class is based on a callback model, in which the controller invokes some methods when specific events occur. The following methods are concerned:
*tileCached
Called when the controller decides to put a tile in the cache.
*tileRetrieved
Called when the controller wants to recover a tile.
*tileAboutToLoad
Called when the controller has requested the loading of a tile.
The JViews Charts library provides a default cache implementation in the IlvDefaultDataTileCache class. This class implements a memory-sensitive cache where tiles are released whenever the application requires memory to be freed. You can control the load of this cache by specifying minimum and maximum capacities. For more information on the meaning of these capacities, please refer to the Reference Manual.
NOTE The IlvDefaultDataTileCache class tries to release tiles in a LRU (Least Recently Used) order so that it first unloads the tiles that have been visited the least recently. However, since the memory-sensitive part is based on an external mechanism, this order may not always be verified.
Although this default cache implementation offers a good and ready-to-use solution in general cases, you might want to subclass IlvDataTileCache and implement more efficient cache strategies that take into account application-specific criteria for choosing when and which tiles should be kept or released.
The tile loader
Just as IlvLODDataSet is the bridge between the load-on-demand mechanism and the chart data model, the tile loader performs the connection between this mechanism and the actual data. The IlvDataTileLoader interface specifies the methods needed for this connection. The tile controller uses the tile loader as it uses the tile cache: methods are called when specific events occur. The IlvDataTileLoader interface includes the following methods:
*load
Called to load the contents of a new tile.
*release
Called to release a tile.
*getXRange and getYRange
Returns the limits of the x- and y-values provided by the loader.
The process of loading a tile is usually divided into three main steps:
1. Fetch the data corresponding to the tile.
This operation is based on the x-range of the corresponding tile, which can be accessed with the getRange method.
2. Fill the tile with the data.
This operation is performed by means of the setData method.
3. Notify the tile loader that loading is complete.
This last operation is performed by calling the loadComplete method.
The load-on-demand framework does not contain any concrete implementation of the IlvDataTileLoader interface, as such implementations depend on the origin of the data.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.