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:
- lodData.dat - Contains 100 000 32-bit integer records that will be loaded according to the visible range displayed by the charts located at the bottom of the panel.
- sampleData.dat - Contains 1000 sample records computed from the data stored in the lodData.dat file. The top-most chart displays the contents of this file, thus providing an overview of all the data. Several controls and interactions let you change the behavior of the load-on-demand mechanism as well as the visible data displayed by the charts.
How to Use the Sample
- Check the Show cached tiles toggle to display the cached tiles in the sample chart.
- Check the Show loading tiles toggle to display loading tiles in the load-on-demand charts.
- Adjust the Lag slider to specify a duration in milliseconds during which the loading thread will sleep, thus simulating a lag in data transfer.
- Use the double slider located at the footer of the sample chart to modify its visible range.
-
Several interactions let you modify the visible range of the
load-on-demand charts:
- Click and drag the green or red indicator displayed by the sample chart.
- Use the scroll bars located at the footer of load-on-demand charts.
- Use the Pan, Zoom, and Scroll interactors set on these charts.
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
- Using load-on-demand data sets.
- Writing a simple data reader.
- Using and subclassing the
IlvDataIndicator
class. - Creating an interactor to modify the location of an indicator.
Detailed Description
The panel of this sample is composed of three parts:
- A control panel, which lets you change some behaviors of the load-on-demand mechanism.
- An overview chart, which displays the contents of the
sampleData.dat file. This file is read by a custom data reader,
implemented by the
BinaryInt32Reader
class. - Two load-on-demand charts, which display different parts of the data stored in the lodData.dat file.
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
- ilog.views.chart.IlvChart
- ilog.views.chart.data.lod.IlvLODDataSet
- ilog.views.chart.data.lod.IlvDataTileController
- ilog.views.chart.data.lod.IlvDefaultDataTileCache
- ilog.views.chart.data.lod.IlvDataTileLoader
- ilog.views.chart.data.lod.DataTileListener
- ilog.views.chart.graphic.IlvDataIndicator
Source Files
- lod.LODDemo
- lod.AAController
- lod.BinaryInt32Reader
- lod.CachedTileListener
- lod.DataTileLoader
- lod.OverviewIndicator
- lod.OverviewInteractor