skip to main content
Programmer's documentation > Developing with the JViews Charts SDK > Accessible charts > High contrast mode
 
High contrast mode
A high contrast mode supports people with low vision. On Microsoft® Windows® systems, high contrast mode is available from the Control Panel; in the Ease of Access Center in Windows 7 and equivalent facilities in other versions of Windows.
To detect high contrast mode in Java™, use the IlvSwingUtil.isHighContrastMode utility. The high contrast mode affects all standard Swing GUI elements (JPanel, JButton, and so on). Custom Swing elements might need special code to adapt to high contrast mode.
In JViews Charts, you can set larger fonts and brighter colors by designing a special cascading style sheet (CSS) for this mode. You can use the cascading feature to combine different CSS files.
A chart might have a style sheet for everything except colors and fonts, a style sheet defining the colors and fonts for normal mode, and a different style sheet defining brighter colors and larger fonts for high contrast mode. The choice of style sheet can be implemented by checking IlvSwingUtil.isHighContrastMode.
if (IlvSwingUtil.isHighContrastMode()) {
  chart.setStyleSheets(new String[] { "main.css", "highContrast.css" });
} else {
  chart.setStyleSheets(new String[] { "main.css", "normalContrast.css" });
}
Instead of using two different style files, you can also specify a high contrast and a normal contrast theme in the same style file, by using the CSS pseudo-class high-contrast. The following code example shows this kind of CSS file:
chart {
   defaultColors : "#6394ef,#ce6394";
   background : "#EBEBEB";
}
chart:high-contrast {
   defaultColors : "#8cbeff,#ff8cff";
   background : "#FFFFFF";
}
The chart's pseudo-classes are initialized to contain the high-contrast pseudo-class depending on the contrast theme detected from the operating system. To change the setting, you can call in Java:
chart.addPseudoClass("high-contrast"); or
chart.removePseudoClass("high-contrast");

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