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.
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()
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.