public class IlvBidiUtil extends Object
IlvBidiUtil
class consists of static definitions and methods
that are of general use when working with bidirectional text. Instances of
this class cannot be created.Modifier and Type | Field and Description |
---|---|
static String |
ADVANCED_BIDI
System property used to control level of bidi support
|
static String |
BASE_TEXT_DIRECTION
Name of the baseTextDirection property, used by IlvSDMNodes and Links
|
static int |
COMPONENT_DIRECTION
Constant defines that the base text direction corresponds to the current
component orientation
|
static String |
COMPONENT_DIRECTION_NAME
Textual notation for COMPONENT_DIRECTION
|
static int |
CONTEXTUAL_DIRECTION
Constant defines the contextual base text direction.
|
static String |
CONTEXTUAL_DIRECTION_NAME
Textual notation for CONTEXTUAL_DIRECTION
|
static int |
CONTEXTUAL_LEFT_TO_RIGHT
Constant defines the contextual base text direction with left-to-right
preference.
|
static String |
CONTEXTUAL_LEFT_TO_RIGHT_NAME
Textual notation for CONTEXTUAL_LEFT_TO_RIGHT
|
static int |
CONTEXTUAL_RIGHT_TO_LEFT
Constant defines the contextual base text direction with right-to-left
preference.
|
static String |
CONTEXTUAL_RIGHT_TO_LEFT_NAME
Textual notation for CONTEXTUAL_RIGHT_TO_LEFT
|
static int |
INHERITED_DIRECTION
Constant defines that the base text direction of the current object is
inherited from its parent
|
static String |
INHERITED_DIRECTION_NAME
Textual notation for INHERITED_DIRECTION
|
static int |
LEFT_TO_RIGHT
Constant defines the left-to-right base text direction
|
static String |
LEFT_TO_RIGHT_NAME
Textual notation for LEFT_TO_RIGHT direction
|
static String |
LRE
Left-To-Right Embedding.
|
static String |
LRM
Simple Left-To-Right Mark.
|
static String |
PDF
Pop Directional Format.
|
static int |
RIGHT_TO_LEFT
Constant defines the right-to-left base text direction
|
static String |
RIGHT_TO_LEFT_NAME
Textual notation for RIGHT_TO_LEFT direction
|
static String |
RLE
Right-To-Left Embedding.
|
static String |
RLM
Simple Right-To-Left Mark.
|
static int |
UNDEFINED_DIRECTION
Constant used internally to show missing of base text direction definition.
|
static String |
UNDEFINED_DIRECTION_NAME
Textual notation for UNDEFINED_DIRECTION
|
Modifier and Type | Method and Description |
---|---|
static String |
bidiTransform(String str,
boolean isRTL)
Returns string, transformed from Logical to Visual Left-To-Right format
with symmetric swapping and reshaping of the text.
|
static void |
checkBaseTextDirectionChoice(int choice,
boolean allowUndefined,
boolean allowExtContextual)
Checks whether the input value is a valid base text direction choice.
|
static boolean |
checkStrongDir(String str,
boolean isRTL)
Check if string started from the embedded direction mark, which corresponds
to given direction.
|
static AttributedString |
getAttrStringWithMarks(AttributedString astr)
Add RLM characters to the start and end of AttributedString.
|
static AttributedString |
getAttrStringWithMarks(AttributedString astr,
boolean isRTL,
boolean start,
boolean end)
Add simple direction marks to the start and end of AttributedString.
|
static int |
getBaseTextDirectionFromName(String baseTextDirectionName)
Returns base text direction, which corresdponds to given textual notation.
|
static String |
getBaseTextDirectionName(int baseTextDirection)
Returns textual notation of the given base text direction Allowed input
values are:
UNDEFINED_DIRECTION
INHERITED_DIRECTION
COMPONENT_DIRECTION
LEFT_TO_RIGHT
RIGHT_TO_LEFT
CONTEXTUAL_DIRECTION
CONTEXTUAL_LEFT_TO_RIGHT
CONTEXTUAL_RIGHT_TO_LEFT
|
static DocumentFilter |
getBidiDocumentHandler(JTextComponent jText,
ComponentOrientation co)
Return document filter fo JTextComponent, Used in case of CONTEXTUAL base
text direction.
|
static String |
getCombinedString(String text,
int textDirection,
ComponentOrientation co,
boolean override)
Returns string which is started from LRE or RLE depending on given base
text direction and component orientation.
|
static String |
getDirectedSimpleHTMLText(String text,
int textDirection)
If a tooltip is given as HTML specification, this method returns a HTML
specification by adding Bidi control characters to the text sections
(between the tags).
|
static String |
getDirectedString(String text,
int textDirection)
Returns string which is started from LRE or RLE depending on given base
text direction.
|
static String |
getDirectedString(String text,
int textDirection,
ComponentOrientation co)
Returns string which is started from LRE or RLE depending on given base
text direction and component orientation.
|
static String |
getEmbeddableCombinedString(String text,
int textDirection,
ComponentOrientation co,
boolean override)
Returns string which is started from LRE or RLE depending on given base
text direction and component orientation and ended with PDF.
|
static AttributedCharacterIterator |
getIteratorWithMarks(AttributedCharacterIterator aIter)
Get AttributedCharacterIterator for AttributedString, started and ended
with RLM marks.
|
static AttributedCharacterIterator |
getIteratorWithMarks(AttributedCharacterIterator aIter,
boolean isRTL,
boolean start,
boolean end)
Get AttributedCharacterIterator for AttributedString, started and/or ended
with one of simple direction marks.
|
static String |
getStringWithMarks(String str)
Returns string, which is started and ended with RLM character.
|
static String |
getStringWithMarks(String str,
boolean isRTL,
boolean start,
boolean end)
Returns string, which is started and/or ended with one of simple direction
marks.
|
static String |
getStringWithMarks(String str,
boolean isRTL,
boolean start,
boolean end,
boolean strong)
Returns string, which is started and/or ended with simple or embedded
direction marks.
|
static String |
getStringWithMarks(String str,
String btd)
Returns string, which is started and ended with direction marks based on
given value of baseTextDirection.
|
static boolean |
isAdvancedBidiOn()
Check if advanced bidi is switched on.
|
static boolean |
isStringRTL(IlvBaseTextDirectionInterface obj,
String str,
ComponentOrientation co)
Returns
true if the input text of the input object should be
displayed in right-to-left direction; otherwise returns false . |
static boolean |
isStringRTL(String str,
ComponentOrientation co)
Determines, in which order (left-to-right or right-to-left) the given text
should be displayed.
|
static boolean |
isStringRTL(String str,
int defBaseTextDirection)
Determines, in which order (left-to-right or right-to-left) the given text
should be displayed.
|
static boolean |
isStringRTL(String str,
int bTextDirection,
ComponentOrientation co)
Determines, in which order (left-to-right or right-to-left) the given text
should be displayed.
|
static boolean |
isStringRTL(String str,
int bTextDirection,
int defBaseTextDirection)
Determines, in which order (left-to-right or right-to-left) the given text
should be displayed.
|
static String |
removeAllBidiMarks(String str)
Remove bidi marks, used in JViews
|
static AttributedString |
removeMarksFromAttrString(AttributedString astr)
Removes bidi marks from the start and from the end of the given
AttributedString.
|
static String |
removeMarksFromString(String str)
Removes bidi marks from the start and from the end of the string
|
static void |
setAdvancedBidiOn(boolean newValue)
Allows to switch advanced bidi off in applets.
|
static void |
setBidiDocumentHandler(JTextComponent jText,
ComponentOrientation co)
Add document filter fo JTextComponent.
|
public static final String LRM
public static final String RLM
public static final String LRE
public static final String RLE
public static final String PDF
public static final int UNDEFINED_DIRECTION
public static final int INHERITED_DIRECTION
public static final int COMPONENT_DIRECTION
public static final int LEFT_TO_RIGHT
public static final int RIGHT_TO_LEFT
public static final int CONTEXTUAL_DIRECTION
public static final int CONTEXTUAL_LEFT_TO_RIGHT
CONTEXTUAL_DIRECTION
: the real text direction is determined from
the text itself, if it contains at least one character with the strong
left-to-right or right-to-left direction. If the text doesn't contain any
character with the strong direction, the real text direction is
left-to-right.public static final int CONTEXTUAL_RIGHT_TO_LEFT
CONTEXTUAL_DIRECTION
: the real text direction is determined from
the text itself, if it contains at least one character with the strong
left-to-right or right-to-left direction. If the text doesn't contain any
character with the strong direction, the real text direction is
right-to-left.public static final String UNDEFINED_DIRECTION_NAME
public static final String INHERITED_DIRECTION_NAME
public static final String COMPONENT_DIRECTION_NAME
public static final String LEFT_TO_RIGHT_NAME
public static final String RIGHT_TO_LEFT_NAME
public static final String CONTEXTUAL_DIRECTION_NAME
public static final String CONTEXTUAL_LEFT_TO_RIGHT_NAME
public static final String CONTEXTUAL_RIGHT_TO_LEFT_NAME
public static final String ADVANCED_BIDI
public static final String BASE_TEXT_DIRECTION
public static void checkBaseTextDirectionChoice(int choice, boolean allowUndefined, boolean allowExtContextual)
INHERITED_DIRECTION
COMPONENT_DIRECTION
LEFT_TO_RIGHT
RIGHT_TO_LEFT
CONTEXTUAL_DIRECTION
UNDEFINED_DIRECTION
, if the parameter
allowUndefined
is true.CONTEXTUAL_LEFT_TO_RIGHT
and CONTEXTUAL_RIGHT_TO_LEFT
, if the parameter allowExtContextual
is true.choice
- The base text direction valueallowUndefined
- Whether UNDEFINED_DIRECTION
is allowed.allowExtContextual
- Whether CONTEXTUAL_LEFT_TO_RIGHT
and
CONTEXTUAL_RIGHT_TO_LEFT
are allowed.public static boolean isStringRTL(IlvBaseTextDirectionInterface obj, String str, ComponentOrientation co)
true
if the input text of the input object should be
displayed in right-to-left direction; otherwise returns false
.obj
- The object.str
- The text to be displayed.co
- The component orientation.public static boolean isStringRTL(String str, int defBaseTextDirection)
str
- TextdefBaseTextDirection
- Base text direction used as a default in case, if text doesn't
contain any character with strong direction. May have one of the
following values:
LEFT_TO_RIGHT
: left-to-right text direction.
RIGHT_TO_LEFT
: right-to-left text direction.
true
, if given text should be displayed in
right-to-left order, otherwise returns false
public static boolean isStringRTL(String str, ComponentOrientation co)
str
- Textco
- ComponentOrientation of the object, containing texttrue
, if given text should be displayed in
right-to-left order, otherwise returns false
ComponentOrientation
public static boolean isStringRTL(String str, int bTextDirection, ComponentOrientation co)
str
- TextbTextDirection
- Resolved base text direction, e.g. one of the following values:
LEFT_TO_RIGHT
: left-to-right text direction.
RIGHT_TO_LEFT
: right-to-left text direction.
CONTEXTUAL_DIRECTION
: contextual text direction.
co
- ComponentOrientation of the object, containing texttrue
, if given text should be displayed in
right-to-left order, otherwise returns false
ComponentOrientation
public static boolean isStringRTL(String str, int bTextDirection, int defBaseTextDirection)
str
- TextbTextDirection
- Resolved base text direction, e.g. one of the following values:
LEFT_TO_RIGHT
: left-to-right text direction.
RIGHT_TO_LEFT
: right-to-left text direction.
CONTEXTUAL_DIRECTION
: contextual text direction.
defBaseTextDirection
- Base text direction used as a default in case, if
ComponentOrientation is undefined. with strong direction. May have
one of the following values:
LEFT_TO_RIGHT
: left-to-right text direction.
RIGHT_TO_LEFT
: right-to-left text direction.
true
, if given text should be displayed in
right-to-left order, otherwise returns false
public static String getStringWithMarks(String str)
str
- Source textpublic static String getStringWithMarks(String str, String btd)
str
- Source textbtd
- Resolved base text direction, e.g. one of the following values:
LTR
: left-to-right text direction.
RTL
: right-to-left text direction.
CONTEXTUAL
: contextual text direction.
public static String getStringWithMarks(String str, boolean isRTL, boolean start, boolean end)
str
- Source textisRTL
- If true
, RLM
is added; otherwise, used
LRM
.start
- If true
, direction mark id added to the start of
string.end
- If true
, direction mark id added to the end of
string.public static String getStringWithMarks(String str, boolean isRTL, boolean start, boolean end, boolean strong)
str
- Source textisRTL
- If true
, then rtl marks are added; otherwise, ltr
marks are used.start
- If true
, corresponding mark id added to the start of
the string.end
- If true
, corresponding marker id added to the end of
the string.strong
- If false
, simple marks are added; otherwise, embedded
direction marks are used.public static String getDirectedString(String text, int textDirection, ComponentOrientation co)
text
- Source texttextDirection
- Resolved base text direction, one of the following:
LEFT_TO_RIGHT
: left-to-right base text direction.
RIGHT_TO_LEFT
: right-to-left base text direction.
CONTEXTUAL_DIRECTION
: contextual base text
direction.
co
- Component orientationpublic static String getDirectedString(String text, int textDirection)
text
- Source texttextDirection
- Resolved base text direction, one of the following:
LEFT_TO_RIGHT
: left-to-right base text direction.
RIGHT_TO_LEFT
: right-to-left base text direction.
CONTEXTUAL_LEFT_TO_RIGHT
: contextual base text
direction with preference left-to-right if no strongly directional
character is found.
CONTEXTUAL_RIGHT_TO_LEFT
: contextual base text
direction with preference right-to-left if no strongly directional
character is found.
public static String getCombinedString(String text, int textDirection, ComponentOrientation co, boolean override)
The returned string cannot be used to construct larger strings. If you want
to create a larger string through string concatenation, use
getEmbeddableCombinedString(String, int, ComponentOrientation, boolean)
instead of this method.
text
- Source texttextDirection
- Resolved base text direction, one of the following:
LEFT_TO_RIGHT
: left-to-right base text direction.
RIGHT_TO_LEFT
: right-to-left base text direction.
CONTEXTUAL_DIRECTION
: contextual base text
direction.
co
- Component orientationoverride
- If true
, previous LRE or RLE marks introduced by this
method are removed first. If false
, bidi marks in the
source text are kept unmodified.public static String getEmbeddableCombinedString(String text, int textDirection, ComponentOrientation co, boolean override)
The returned string can be used as a substring of larger strings.
text
- Source texttextDirection
- Resolved base text direction, one of the following:
LEFT_TO_RIGHT
: left-to-right base text direction.
RIGHT_TO_LEFT
: right-to-left base text direction.
CONTEXTUAL_DIRECTION
: contextual base text
direction.
co
- Component orientationoverride
- If true
, previous LRE or RLE marks introduced by this
method are removed first. If false
, bidi marks in the
source text are kept unmodified.public static String getDirectedSimpleHTMLText(String text, int textDirection)
IlvSwingUtil.createMultiLineToolTipText(java.lang.String[], int)
.text
- HTML source texttextDirection
- Resolved base text direction, one of the following:
LEFT_TO_RIGHT
: left-to-right base text direction.
RIGHT_TO_LEFT
: right-to-left base text direction.
CONTEXTUAL_LEFT_TO_RIGHT
: contextual base text
direction with preference left-to-right if no strongly directional
character is found.
CONTEXTUAL_RIGHT_TO_LEFT
: contextual base text
direction with preference right-to-left if no strongly directional
character is found.
public static String removeAllBidiMarks(String str)
str
- Source textpublic static String removeMarksFromString(String str)
str
- Text started and/or ended with bidi markspublic static AttributedString getAttrStringWithMarks(AttributedString astr)
astr
- Source attributed stringAttributedString
public static AttributedString getAttrStringWithMarks(AttributedString astr, boolean isRTL, boolean start, boolean end)
astr
- Source attributed stringisRTL
- If true
, RLM is added; otherwise used LRM.start
- If true
, mark is added to the start of string.end
- If true
, mark is added to the end of string.AttributedString
,
IlvAttributedStringUtil
public static AttributedCharacterIterator getIteratorWithMarks(AttributedCharacterIterator aIter)
aIter
- Iterator for source AttributedStringAttributedString
,
IlvAttributedStringUtil
public static AttributedCharacterIterator getIteratorWithMarks(AttributedCharacterIterator aIter, boolean isRTL, boolean start, boolean end)
aIter
- Iterator for source AttributedStringisRTL
- If true
, RLM marks are added; otherwise LRM marks are
used.start
- If true
, bidi mark is added to the start of
AttributedStringend
- If true
, bidi mark is added to the end of
AttributedStringAttributedString
,
IlvAttributedStringUtil
public static AttributedString removeMarksFromAttrString(AttributedString astr)
astr
- Source AttributedStringAttributedString
,
IlvAttributedStringUtil
public static boolean checkStrongDir(String str, boolean isRTL)
str
- Source stringisRTL
- Direction of the texttrue
, if string starts with the embedded
direction mark, suitable for given text direction.public static String getBaseTextDirectionName(int baseTextDirection)
baseTextDirection
- The base text direction value.public static int getBaseTextDirectionFromName(String baseTextDirectionName)
baseTextDirectionName
- Textual notationpublic static String bidiTransform(String str, boolean isRTL)
str
- Source stringisRTL
- If true
, source format is Logical RTL; otherwise, it
is Logical LTR.public static boolean isAdvancedBidiOn()
true
if bidi is on.public static void setAdvancedBidiOn(boolean newValue)
newValue
- New value if advanced bidi switcher.public static DocumentFilter getBidiDocumentHandler(JTextComponent jText, ComponentOrientation co)
jText
- JTextComponentco
- ComponentOrientation, used to determine default base text
directionpublic static void setBidiDocumentHandler(JTextComponent jText, ComponentOrientation co)
jText
- Text componentco
- ComponentOrientation, used to determine default base text
direction© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.