When tiles are displayed on a view, the tile loading is performed
for the
IlvTiledLayer
s by an IlvTileLoader, mainly through the call of the
load method. Up until JViews Maps 8.1, this was
performed in the Swing thread, which could cause GUI freezes
because the code could be CPU intensive.
You can execute the tile loading code in separate threads by means
of the IlvThreadedTileLoader class. This class
implements the
IlvTileLoader
interface, and acts as a wrapper for a delegate
IlvTileLoader
executing the tile loading code.
Internally, an IlvThreadedTileLoader object holds a queue in
which
load
and
release
calls (from the IlvTileController on the
IlvThreadedTileLoader
) are stacked, and processed as soon as possible by a dedicated
thread. This way, all tile loading is performed asynchronously and
the application remains responsive even if tens of megabytes of
data are loaded for display on the view.
The source code for the Map Builder demonstration, which contains
all of the code described in this section, can be found at <installdir> /jviews-maps810/samples/mapbuilder/index.html
The following code sample shows how to use an
IlvThreadedTileLoader
that encapsulates another tile loader:
IlvTiledLayer tiledLayer; // this is the tile loader that performs the real loading, such as IlvShapeFileTileLoader IlvTileLoader tileLoader; // Create a threaded tile loader that encapsulates the previous one IlvThreadedTileLoader threadedTileLoader = new IlvThreadedTileLoader(tileLoader,true); // Configure this threaded tile loader : // set the minimum java thread priority for loading tiles threadedTileLoader.setThreadPriority(Thread.MIN_PRIORITY); // set to repaint the view after each tile is loaded threadedTileLoader.setRepaintPolicy(IlvThreadedTileLoader.REPAINT_AFTER_EACH_TI LE); // Set this threaded tile loader on the IlvTiledLayer tiledLayer.setTileLoader(threadedTileLoader);