Perforce JViews Charts Sample: Using Load-On-Demand


Description

This sample demonstrates how to use the load-on-demand mechanism available in Perforce JViews Charts. Two binary files hold the data displayed by this sample:

How to Use the Sample

How to Run the Sample as an Application

This sample can be run as an application. The installation directory contains an executable JAR file, chart-lod.jar, that allows you to execute the sample with a double click from a file browser. Note that if you are using Internet Explorer, you can open the installation directory and execute the JAR file from the browser. This technique may not work in other Web browsers.

Alternatively, you can run the sample application from the command line. First check that the Ant utility is properly configured. If not, see the instructions on how to configure Ant for Perforce JViews.

Then, go to the installation directory of the sample and type:

ant run

Topics Covered

Detailed Description

The panel of this sample is composed of three parts:

The main focus of this sample is the implementation of the IlvDataTileLoader interface. In our case, data is read from a binary file that is accessed through a java.io.RandomAccessFile. This enables the loader to read only the records that lie within a given tile. Note also that loading is threaded so that it does not block the event dispatch thread. The DataTileLoader class that implements this mechanism also handles the case when loading should be interrupted, for example when a tile is released.

Another aspect of this sample is to provide a way to quickly navigate through the available data. To do so, it provides a subclass of the IlvDataIndicator class that implements an overview indicator. A chart can use such an indicator to display the visible range of other charts. In this sample, these indicators are used by the overview chart to display the range shown by the load-on-demand charts. We also add to the sample chart an instance of OverviewInteractor, which enables the user to drag the overview indicators and thereby modify the range shown by the load-on-demand charts. Other standard ways are provided to zoom and scroll the visible range of the load-on-demand charts, as described earlier.

Installation Directory

The Using Load-On-Demand sample is installed here.

Classes Involved

Source Files

Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All rights reserved. Legal terms.