Perforce JViews Charts Sample: Importing a Swing Table Model


Description

This sample loads data stored in a Swing TableModel and displays it in a chart as polylines. It also shows how to print the chart to PDF.

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-tablemodel.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

This sample shows how to import a Swing TableModel into an IlvChart. The data is stored in a Swing table model that is wrapped within an IlvSwingTableDataSource. This specialized data source handles an in-out notification mechanism so that updates on the table model itself are propagated to the chart data model (the data set containing the data), and updates on the chart data model are propagated to the original table model. You can see this mechanism in action if you modify data in a cell of a table. The chart is automatically updated to reflect the new value.

The printing support is provided through the JViews Printing framework. Printing the table along with the chart in the same document is performed by means of an IlvChartPrintableDocument subclass. This subclass computes the location of the table in the page and adds a table printable object to all the document pages.

The PDF generation is provided through the JViews Printing framework and Apache FOP.

Installation Directory

The Importing a Swing Table Model sample is installed here.

Classes Involved

Source Files

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