Globalization support

The globalization support provided in JViews Framework includes multicultural services, based around locales and component orientation, and bidirectional text through the capability to specify base text direction.

Locale and component orientation

By using features of JViews Framework you can implement applications that support many different languages and cultures. JViews Framework provides some multicultural support; similarly to Swing objects, you can set the locale and the component orientation for IlvGraphic objects. By using this feature, you can implement your own subclasses that need access to a component orientation or locale.
To access locale and component orientation, use the methods:
  • public Locale getLocale()
  • public ULocale getULoacle()
  • public ComponentOrientation getComponentOrientation()
The class com.ibm.icu.util.ULocale is an enhanced mechanism for locale and serves the same purpose as java.util.Locale.
Locale and component orientation are inherited by default from the Swing component that displays the graphic objects, usually an instance of IlvManagerView. By using some graphic objects (IlvManager, IlvGrapher) you can specify locale and component orientation explicitly. Then, the graphic objects nested inside those graphic objects inherit those explicit settings.

Base text direction in JViews Framework

Rogue Wave® JViews products provide graphic objects that can display text:IlvLabel, IlvZoomableLabel, IlvText. You can also implement your own graphic objects to display text.
If you display mixed text from different languages, you might mix text that is written left to right, such as English, with text that is written right to left, such as Arabic or Hebrew. The base text direction is important for such mixed text, because it defines the order of the segments of uniform language inside a sentence. That order determines how the segments are arranged within the sentence. See Base text direction.
For example, a long English text with few Arabic words probably uses the base text direction left to right; a long Arabic text with few English words probably uses the base text direction right to left. The following figure shows four IlvText objects. The objects on the left show the English text “One ... Two ... Three” mixed with Arabic words inside the English text. The objects on the right show the Arabic for “one ... two ... three” mixed with English words inside the Arabic text.
Text
in row 2, cell 2 read from left to right consists of the English word
one followed by the Arabic word for one (wahid), the English word
two followed by the Arabic word for two (ithnain), and the English
word three. Text in row 2, cell 3 also read from left to right  consists
of the Arabic word for one (wahid) followed by the English word one,
the Arabic word for two (ithnain) followed by the English word two,
and the Arabic word for three (thalatha). Text in row 3, cell 3 read
from right to left consists of the Arabic word for one (wahid) followed
by the English word one, the Arabic word for two (ithnain) followed
by the English word two, and the Arabic word for three (thalatha).
Text in row 3, cell 2 read from right to left consists of the English
word one followed by the Arabic word for one (wahid), the English
word two followed by the Arabic word for two (ithnain), and the English
word three.
Base text direction in IlvText objects
The objects in the upper row have the base text direction left to right and the objects in the lower row have the base text direction right to left. For an English user, the upper left text looks correct, since the majority of the text is English and an English user expects the reading direction left to right. For an Arabic user, the lower right text looks correct, since the majority of the text is Arabic and an Arabic user expects the reading direction right to left.
The base class IlvGraphic contains the properties for base text direction. The predefined subclasses of IlvGraphic use those properties. If you implement your own class for displaying text and want to support a mix of different languages, your implementation should comply with the setting of base text direction as well.
Support for base text direction can be disabled by setting the Java system property ilog.jviews.bidi.support.on to false. This property is switched on by default. To test whether base text direction support is enabled, use:
ilog.views.util.text.IlvBidiUtil.isAdvancedBidiOn()
In the class IlvGraphic, the following methods control base text direction.
public void setBaseTextDirection(int direction)
public int getBaseTextDirection()
The possible values are:
  • IlvConstants.COMPONENT_DIRECTION: The base text direction is calculated from the component orientation of the graphic object.
  • IlvConstants.INHERITED_DIRECTION: If the graphic object is contained in another graphic object. for example, in a manager, the graphic object inherits the setting from the parent graphic object.
  • IlvConstants.LEFT_TO_RIGHT: The base text direction is left to right.
  • IlvConstants.RIGHT_TO_LEFT: The base text direction is right to left.
  • IlvConstants.CONTEXTUAL_DIRECTION: The base text direction is calculated from the text that is displayed. It uses a heuristic to determine the base text direction by analyzing the Unicode characters to be displayed. See IlvBidiUtil.isStringRTL(java.lang.String, int).
When you decide how to display a string, the component and inherited direction might be inconvenient. Therefore the following method is provided:
public int getResolvedBaseTextDirection()
This method resolves the component and inherited directions and returns only three choices:
  • IlvConstants.LEFT_TO_RIGHT
  • IlvConstants.RIGHT_TO_LEFT
  • IlvConstants.CONTEXTUAL_DIRECTION.