Perforce JViews Gantt Sample: Rendering a Custom Data Model
Description
This sample shows a project scheduling application that displays application-specific data. It shows an activity-oriented Gantt Chart that has been customized using the SDK to render and edit user-defined activity properties. The sample also shows customized rendering of constraint links and table columns.
How to Use the Sample
-
On the left of the sample window, an
IlvJTable
object shows the activity properties. The first column of the table shows the hierarchy of activities in the form of a tree. Click the expand/collapse icon to expand or collapse an activity with child activities. The other columns are used to show more activity properties. -
On the right of the sample window, the Gantt chart uses an
IlvGanttSheet
object to visualize the activities.
Note: Parent activities are rendered differently than child activities. - A time scale is displayed at the top of the Gantt sheet.
-
This sample has the following keyboard accelerators:
- Ctrl+Z : zoom
- Ctrl+U : unzoom
- Ctrl+F : fit to view
- Ctrl+Enter : toggle selected row expand/collapse
- Ctrl+2 : increase row height
- Ctrl+Shift+2 : decrease row height
- Arrow Keys : scroll
- Refer to the Detailed Description section for more information on the different actions you can perform.
How to Run the Sample as an Application
This sample can
be run as an application.
The installation directory contains
an executable JAR file,
custom-data.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
IlvGeneralActivity
instances that contain user-defined properties. -
Developing an activity factory for the Gantt Chart that will
create
IlvGeneralActivity
objects on request. -
Developing a customized
IlvActivityRendererFactory
class for the Gantt Chart that will create specialized renderers for the custom activities. -
Piecing together an
IlvActivityCompositeRenderer
from several elementary activity renderers. -
Extending a subclass of
IlvActivityGraphicRenderer
. -
Developing a customized
IlvConstraintGraphicFactory
class for the Gantt Chart that will create specialized renderers for the constraint links. - Creating a table column that will allow the user to display and edit the priority property of each activity.
- Customizing the icons of the table's tree column.
Detailed Description
The user interface of this sample is the same as the Gantt sample on which it is based. It has the following differences:
- Some custom activities have a completion percentage. This completion status is rendered as a thin black bar below the main bar. Its length is proportional to the completion percentage.
- Leaf custom activities have a priority assigned. It is rendered as a thin yellow bar below the main bar and the completion bar.
- The priorities are also visible and editable in an additional column of the table. Priorities are displayed in different colors depending on their value. Editing a priority is initiated by double-clicking it. A slider component is displayed to allow adjustment of the value.
- The long "development" activities are split into several intervals, raking into account the week-ends as breaks. They also carry an alpha and a beta milestone. These features of the activities are specified through custom properties and are rendered by custom renderers.
Installation Directory
The Rendering a Custom Data Model sample is installed here.
Classes Involved
- ilog.views.gantt.IlvGanttChart
- ilog.views.gantt.model.IlvPropertyHolderActivity
- ilog.views.gantt.model.general.IlvGeneralActivity
- ilog.views.gantt.graphic.IlvActivityRendererFactory
- ilog.views.gantt.graphic.renderer.IlvActivityRenderer
- ilog.views.gantt.graphic.renderer.IlvActivityCompositeRenderer
- ilog.views.gantt.graphic.renderer.IlvActivityGraphicRenderer
- ilog.views.gantt.graphic.IlvConstraintGraphicFactory
- ilog.views.gantt.swing.IlvJTable
- ilog.views.gantt.swing.IlvTreeColumn
- ilog.views.gantt.property.IlvStringProperty
Source Files
-
customData.CustomGanttExample
The main sample application is an extension of the Gantt Chart which illustrates the basics of creating and using
IlvGanttChart
objects. -
customData.ComplexEngineeringProject
A customized Gantt model that uses properties for storing the completion status, the priority, the start and end time of activities spread across multiple interval, and the location of specific milestones.
-
customData.CustomActivityFactory
A customized factory for activities that creates instances of
IlvGeneralActivity
with a priority property. -
customData.CompletionProperty
Access to an activity's completion percentage, as a number.
-
customData.FormattedCompletionProperty
Access to an activity's completion percentage, as a formatted string.
-
customData.PriorityProperty
Access to an activity's priority property, as a number.
-
customData.FormattedPriorityProperty
Access to an activity's priority property, as a formatted string.
-
customData.CustomActivityRendererFactory
-
customData.CustomConstraintGraphicFactory
A factory for activity renderers that distinguishes parent activities, leaf activities, and milestones.
-
customData.CustomActivityRenderer
The
IlvActivityRenderer
implementation, which displays each activity with one or more main bars, additional bars indicating the completion status and the priority, and milestone symbols. -
customData.CompletionBar
The
IlvActivityRenderer
implementation which displays just the completion bar of each activity. -
customData.PriorityBar
The
IlvActivityRenderer
implementation which displays just the priority indicator of each activity. -
customData.PriorityColumn
A column definition for the priority property of a custom activity that can be added to the
IlvJTable
component of the Gantt Chart.