skip to main content
Gantt > Programmer's documentation > Developing with the JViews Gantt SDK > Printing > Printing a Resource Data chart
 
Printing a Resource Data chart
Explains how to use the printing APIs.
*Introduction
*Describes the APIs provided for printing the Resource Data chart in a single or multi-page document.
*The Printing Resource Data chart Example
*Describes how to run and use the example.
*Printing framework API
*Describes the properties of the main classes in the Resource Data chart printing framework.
Introduction
The IlvResourceDataChart class is a UI component designed to display numerical information derived from resources in an on screen Gantt data model. To distribute and exchange this numerical information, you may need to print the Resource Data chart on paper. JViews Gantt provides APIs for printing the Resource Data chart in a single or multi-page document without having to scroll the user interface.
The Rogue Wave® JViews Resource Data chart printing framework extends the basic Rogue Wave JViews Charts printing framework to add support to the IlvResourceDataChart object.
The generic classes of the ilog.views.schedule.print have been subclassed to handle specific Resource Data chart properties. These classes are:
*IlvResourceDataChartPrintingController: Controls the printing process.
*IlvResourceDataChartPrintableDocument: Defines the printing configuration and contains the Resource Data chart data you want to print in a set of pages.
*IlvPrintableResourceDataChart: Used to print a part of an IlvResourceDataChart object.
The following figure shows the associations between classes for printing a Resource Data chart.
The Printing Resource Data chart Example
The Printing Resource Data chart Example is a simple sample of printing a Resource Data chart.
To run this example:
1. Open the file:
<installdir>/jviews-gantt/samples/printResourceData
2. Follow the instructions to run the Resource Data chart Printing sample.
The source code of this sample can be found in:
<installdir>/jviews-gantt/samples/printResourceData/src/print/ResourceDataPrintActions.java
To print the Resource Data chart:
1. Create an instance of an IlvResourceDataChartPrintingController:
IlvResourceDataChart chart = ...;
IlvResourceDataChartPrintingController printController =
    new IlvResourceDataChartPrintingController(chart);
2. Invoke on that instance the action you want to see performed. For example print(), setupDialog(), or printPreview() as shown below:
printController.printPreview(JOptionPane.getFrameForComponent(chart));
The following figure shows the result of invoking the printPreview method.
Printing framework API
The following classes are involved in the Resource Data chart printing framework:
*IlvResourceDataChartPrintableDocument
*IlvResourceDataChartPrintingController
*IlvPrintableResourceDataChart
IlvResourceDataChartPrintableDocument
The IlvResourceDataChartPrintableDocument class stores the document print structure and a set of parameters to customize printing, such as:
*The printed data window; that is, the part of the chart to be printed.
*How the chart fits on the page.
This class extends IlvChartPrintableDocument and thus supports the properties contained in that class. It is used to create and populate pages to be printed. It also supports a convenient way of defining the printed data window using a start date and a duration. The previous figure shows the customizable properties of this class.
The following table shows the customizable properties of an IlvResourceDataChartPrintableDocument instance.
Property
Description
Default
start
The start date of the first printed page. This sets the beginning of the printed data window.
The chart visible time
duration
The duration to the last printed page. This is used to set the end of the printed data window.
The chart visible duration.
NOTE All these properties are accessible from the JViews Resource Data chart Print Setup dialog box. You can invoke this dialog box by calling the method setupDialog on an IlvResourceDataChartPrintingController instance.
IlvResourceDataChartPrintingController
The IlvResourceDataChartPrintingController class controls the printing process. It initiates the printer job, handles the Setup and Preview dialog boxes, and configures the document accordingly. This class extends IlvChartPrintingController. By default it provides the chart Setup window.
Document configuration can be done in the following ways:
*Automatically, by using the following constructor:
public IlvResourceDataChartPrintingController(IlvResourceDataChart chart)
When you call this function a single landscape oriented printable document page is created. The printed data window size is equal to the visible data ranges on the x-axis.
*Programmatically, by creating a Resource Data chart printable document and setting the parameters as described in IlvResourceDataChartPrintableDocument section.
IlvPrintableResourceDataChart
The IlvPrintableResourceDataChart class represents a printable Resource Data chart object. It extends the IlvPrintableChart class. This class allows you to print the IlvResourceDataChart within the printable area of an IlvPage.
The way the Resource Data chart fills the region is determined by the document properties. You do not need to call IlvPrintableResourceDataChart directly to print using parameters provided by the Setup dialog box. This class is necessary only if you want to control your IlvPrintableDocument object by creating pages and adding IlvPrintableObject instances.
For information on IlvPrintableDocument, and IlvPrintableObject, see The generic printing framework in Advanced Features of Rogue Wave® JViews Framework.
To see how IlvPrintableResourceDataChart is used, see the print implementation in the Resource Data chart demo. This demo can be found at:
<installdir>/jviews-gantt/samples/printResourceData
The sample Synchronized Schedule and Load charts shows how to implement a printable document composed of a Gantt chart on top of a Resource Data chart. This sample can be found at:
<installdir>/jviews-gantt/samples/resourceLoadChart

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