skip to main content
Gantt > Programmer's documentation > Developing with the JViews Gantt SDK > Styling > Using style sheets
 
Using style sheets
Explains how to use style sheets in JViews Gantt.
*Applying styles
*Explains the classes used to apply a style sheet to a chart and describes how the internal mechanism functions.
*Disabling styling
*Explains the parameters to pass to specific methods to disable styling.
Applying styles
The IlvHierarchyChart class, the common superclass of IlvGanttChart and IlvScheduleChart, implements the IlvStylable interface. The IlvScheduleDataChart class, the superclass of IlvResourceDataChart, also implements the IlvStylable interface. This interface defines several methods that can be used to control styling. The following example shows the typical code involved in applying a style sheet to a chart.
try {
  chart.setStyleSheets(new String[]{"simple.css"});
} catch (IlvStylingException x) {
  System.err.println("Cannot load style sheets: " + x.getMessage());
}
You can integrate a style sheet generated with the Designer in this way. See Integrating a style sheet into an application in Using the Designer.
The following table shows the IlvHierarchyChart and IlvScheduleDataChart methods that can be used to control styling.
The following table shows the methods for controlling styling.
Where used
Methods
Style Sheets
Debugging
When style sheets are set on a chart, the initial state of the chart is saved internally. When new style sheets are set or styling is disabled completely, the chart is first restored to its saved state. Then, the new style sheets are interpreted in order to customize the chart. This ensures that when you set new style sheets, they will customize the chart beginning from a known state. This also prevents undesired compound customizations that would result from successively applying multiple sets of style sheets.
As a consequence, you should keep two points in mind when you apply style sheets to a Gantt, Schedule, or Resource Data chart and you use Java™ code to customize a chart by calling its APIs:
*If the Java code customizes the chart before you set style sheets, the style sheets may override or suppress the Java customization. When you set new style sheets or disable styling completely, the customization performed by the Java code is restored, because it was saved as part of the state of the chart.
*If the Java code customizes the chart after you set style sheets, the Java code may override or suppress customizations performed by the style sheets. When you set new style sheets or disable styling completely, the customization performed by the Java code is lost because it was not saved as part of the state of the chart.
Disabling styling
When you globally disable styling, the chart is told that no styles are specified and it removes any overhead related to styling. Note that this is different from setting an empty style sheet on the chart, since the chart will still try to match CSS rules in this case.
To disable styling:
1. Pass null to the setStyleSheets method of IlvHierarchyChart and IlvScheduleDataChart.
The CSS samples are provided with JViews Gantt to show how you can use style sheets with CSS syntax to customize the appearance of your Gantt, Schedule, or Resource Data charts.

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