Printing Gantt and Schedule charts
Describes the main classes in the printing API and explains how to use them.
Explains the relation between the classes in the
JViews Gantt API.
Describes the main classes in the
JViews Gantt printing framework and explains the relationship between the classes.
Explains how to run and use this sample application.
Describes the properties of the main classes in the Resource Data chart printing framework.
Explains how to initiate and process a printing task.
Overview
The
IlvGanttChart and
IlvScheduleChart classes are UI components designed to display your projects on screen. To distribute and to exchange the projects, you may need to print the projects on paper. You may also need to print not only the visible part of the projects but also the part that is not visible.
JViews Gantt provides APIs that allow you to print the Gantt or Schedule charts in a document (single or multiple pages) without scrolling the UI. These APIs collectively are referred to as the JViews Gantt printing framework.
NOTE Before reading this section you should familiarize yourself with sections
The generic printing framework and
Printing framework for manager content of
Advanced Features of Rogue Wave® JViews Framework.
Introduction
The
JViews Gantt printing framework extends the basic Rogue Wave®
JViews Framework printing framework to add support to
IlvGanttChart and
IlvScheduleChart objects. The generic classes of the
ilog.views.util.print package have been subclassed to handle specific Gantt properties.
These classes are:
IlvGanttPrintableDocument: A Gantt printable document defines the printing configuration and contains the Gantt data you want to print in a set of pages.
For information on how to use these classes, see
Printing Framework API.
The following figure shows the associations between classes for printing a Gantt chart.
The GanttPrintExample demo
The GanttPrintExample demo is a simple example for printing a Gantt chart.
To run the demo:
1. Open the file:
2. Follow the instructions to run the example given in the print demo.
The source code of this example can be found in:
To use Gantt printing:
IlvGanttChart gantt = ...;
IlvGanttPrintingController printController =
new IlvGanttPrintingController(gantt);
printController.printPreview((java.awt.Frame)gantt.getTopLevelAncestor());
The following figure shows the result of invoking the printPreview method:
Printing Framework API
The following classes are involved in the JViews Gantt printing framework:
IlvGanttPrintableDocument
The Gantt printable document stores the printed document structure and defines a set of parameters to customize the printing (the printed data window, which part of the Gantt is printed, how the Gantt fits on the page, and so on). The printable document is responsible for creating and populating the pages.
The following table shows the different properties you can customize for printing.
Property | Description |
Divider position | Defines the position on the page that separates the table and the Gantt sheet (the value must be between 0 and 1). |
Number of pages per band | The JViews Gantt printing framework provides support for multipage printing through the “pages per band” property. This represents the number of horizontal pages you want printed between the start and the end date. |
Repeat table | Indicates whether the table should be printed repeatedly on every page. |
Start date | The start date of the first printed page. This defines the beginning of the printed data. |
End date | The end date for the last printed page in a band. This defines the end of the printed data. |
Number of columns of the table | Indicates the number of table columns to be printed. |
NOTE All these properties are also accessible from the JViews Gantt Print Setup dialog box, which you can invoke by calling the method setupDialog on the IlvGanttPrintingController instance.
The following table summarizes the
IlvGanttPrintableDocument properties.
Property | Methods | Default value when automatically created | Field in JViews Gantt Designer |
Divider position | | 0.5 | Table, Table size |
End date of the last page in a band | | The chart visible time + the chart visible duration | Print Range, Dates, To |
Number of pages per band | | 2 | Print Range, Fit to |
Whether the table is printed repeatedly on every page | | False | Table, Print table on all pages |
Start date of the first page | | The chart visible time | Print Range, Dates, From |
Number of columns of the table | | The chart table column count | Table, Print <n> table column(s) |
The following figure shows the default print settings.
With these settings, you get two pages in the Print Preview window. You can see that the table, with its six columns, is only displayed on the first page occupying 50% of the page size.
The following figure shows the second page of the Print Preview dialog.
IlvGanttPrintingController
The printing controller controls the printing process. It initiates the printer job, handles the Setup and Preview dialog boxes, and configures the document accordingly.
The configuration of the document can be done:
Automatically, by using the following constructor:
public IlvGanttPrintingController(IlvHierarchyChart chart)
In this case, a printable document is created with the pages oriented in landscape, two pages per band, and all the columns of the Gantt table printed on the first page only (occupying half of the page size). See
Examples.
Through code, by creating a Gantt printable document and setting the parameters as described in section
IlvGanttPrintableDocument.
IlvPrintableGanttSheet
An instance of the class
IlvPrintableGanttSheet represents the concrete Gantt sheet object that can be printed. It extends the
IlvPrintableComponent class, which itself is a subclass of
IlvPrintableObject.
IlvPrintableGanttSheet lets you print the
IlvGanttSheet within a region of the printable area of an
IlvPage.
The way the Gantt fills the region is determined by the different document properties. Consequently, you do not need to use the
IlvPrintableGanttSheet class directly if you want to print using the parameters provided by the Setup dialog box. You will need this class only if you want to control your
IlvPrintableDocument object by creating pages and adding your own
IlvPrintableObject instances.
For information on
IlvPrintable,
IlvPrintableDocument, and I
lvPrintableObject, see
The generic printing framework in
Advanced Features of Rogue Wave® JViews Framework.
IlvPrintableTimeScale
An instance of the class
IlvPrintableTimeScale represents the concrete time scale object that can be printed. It also extends
IlvPrintableComponent, which, as you saw in
IlvPrintableGanttSheet, is a subclass of
IlvPrintableObject.
IlvPrintableTimeScale lets you print a portion of the
IlvTimeScale object within an
IlvPage.
The way the Gantt fills the region is determined by the different document properties. Consequently you do not need to use the
IlvPrintableTimeScale class directly if you want to print using the parameters provided by the Setup dialog box. You will need this class only if you want to control your
IlvPrintableDocument by creating pages and adding your own
IlvPrintableObject instances.
For information on
IlvPrintableDocument,
IlvPrintableComponent, and
IlvPrintableObject, see
The generic printing framework in
Advanced Features of Rogue Wave JViews Framework.
How it works
A printing task is initiated and processed by an
IlvGanttPrintingController instance:
by code, via the method
print, or
from a GUI request using the Setup or Preview dialog, via the methods:
IlvPrintingController.printPreview(Window)
and
IlvPrintingController.setupDialog(Window, boolean, boolean)
When a printing task is initiated, the document associated with the printing controller is prepared for printing: pages are initialized with the printable objects and added to the document.
NOTE See section
IlvGanttPrintingController for a description of how a document is associated with the
IlvGanttPrintingController.
This section covers:
Handling pages
Pages of a Gantt document are instances of the
IlvPage class. They handle a collection of printable objects, instances of
IlvPrintableObject.
Populating a page
Pages created by an
IlvGanttPrintableDocument are populated in the
createPages method. You may override the
createPages method if you want to add additional printable objects to the page.
The createPages implementation uses the following printable objects:
The following figure shows the associations between classes for populating a page.
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.