skip to main content
Gantt > Developing with design tools > Using the Designer > Getting started > Integrating your development into an application
 
Integrating your development into an application
Explains how to integrate a complete Gantt chart or a customized style sheet into an application.
*Overview
*Explains the integration options available.
*Integrating a Gantt chart into an application
*Describes how to add a Gantt chart to an application.
*Integrating a style sheet into an application
*Describes the code used to add custom styling to a custom data model.
Overview
You can integrate a complete Gantt chart into an application through the project file or you can integrate only the style sheet to have the styling developed in the Designer applied to real data in an application.
Integrating a Gantt chart into an application
When you have saved your Gantt chart in the Designer, you have a project file that you can use to integrate the chart component into an application. There are sample project files in:
<installdir>/jviews-gantt/bin/designer/data/examples
See also the gallery of Designer projects supplied in the JViews Gantt samples at:
<installdir>/jviews-gantt/samples/gallery
To integrate a chart component into an application:
1. Make sure that all the project files are accessible from the application.
The .igpr, .css, and .xml files must all be accessible from the application.
2. Create the Gantt chart instance and load the project file into the application.
Creating the Gantt chart instance and loading the project file shows you how to create an instance of a Gantt chart, which can be an instance of IlvGanttChart as in this example or of IlvScheduleChart, and load the project file into the application.
Example 1 – Creating the Gantt chart instance and loading the project file
IlvGanttChart chart = new IlvGanttChart();
try {
     URL project = ...;
     // Apply the project file to the chart
        chart.setProject(project);
     } catch (IOException e) {
     ...;
     } catch (IlvStylingException se) {
     ...;
      }
The Gantt chart is thus configured according to the settings of the project file.
The project file contains the type of chart it was saved for, which can be an activity-oriented Gantt chart ( IlvGanttChart ) or a resource-oriented Gantt chart ( IlvScheduleChart ).
The code for creating the Gantt chart instance and loading the project file is shown in:
<installdir>/jviews-gantt/codefragments/application/loadProject/src/LoadProject.java
When you run this example it displays buttons that allow you to choose the type of chart developed in the Designer. You must then select the path to your chart. If the type of chart used in the project does not correspond to the type of chart you have chosen to load, you will receive an error message.
NOTE A project file includes both the data and the style sheet. When a project is set, it replaces any data source and style sheets that may already be set on the chart.
This code allows you to integrate your Gantt chart into an application, for example, a Swing application. You still need to write the code for using the Gantt chart in the application. JViews Gantt does not provide any special facilities for creating menus or toolbars, for example. You need to develop such features in your application for yourself. See Writing an application for more information.
Integrating a style sheet into an application
If you have a custom data model and your application is already defined, you can use the Designer for styling only on a sample of dummy data or on an XML dump of your data. Then you can integrate the style sheet from the Designer into your application. You can apply the styling defined in the style sheet to the real data used in the application. The Designer makes it much easier to write the style sheet.
Follow these steps to style the chart component of your application using an existing project style.
1. Make sure that the project style sheet is accessible from the application.
The .css file must be accessible from the application.
2. In the application, after creating the chart and loading the data model, use the code shown in Loading a style sheet Into an application:
Example 2 – Loading a style sheet Into an application
try {
  chart.setStyleSheets(new String[]{"..."});
} catch (IlvStylingException x) {
   System.err.println("Cannot load style sheets: " + x.getMessage());
}
See Applying styles in Developing with the SDK for more information on how to load style sheets.
You can also look at the Gantt and Schedule chart CSS samples in:
<installdir>/jviews-gantt/samples/cssGantt
<installdir>/jviews-gantt/samples/cssSchedule

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