| java.lang.Object java.text.Bidi
Bidi | final public class Bidi (Code) | | Bidi is the class providing the bidirectional algorithm. The algorithm is
defined in the Unicode Standard Annex #9, version 13, also described in The
Unicode Standard, Version 4.0 .
Use a Bidi object to get the information on the position reordering of a
bidirectional text, such as Arabic or Hebrew. The natural display ordering of
horizontal text in these languages is from right to left, while they order
numbers from left to right.
If the text contains multiple runs, the information of each run can be
obtained from the run index. The level of any particular run indicates the
direction of the text as well as the nesting level. Left-to-right runs have
even levels while right-to-left runs have odd levels.
|
Constructor Summary | |
public | Bidi(AttributedCharacterIterator paragraph) Create a Bidi object from the AttributedCharacterIterator of a paragraph
text.
The RUN_DIRECTION attribute determines the base direction of the
bidirectional text. | public | Bidi(char[] text, int textStart, byte[] embeddings, int embStart, int paragraphLength, int flags) Create a Bidi object.
Parameters: text - the char array of the paragraph text. Parameters: textStart - the start offset of the text array to perform the algorithm. Parameters: embeddings - the embedding level array of the paragraph text, specifyingthe embedding level information for each character. | public | Bidi(String paragraph, int flags) Create a Bidi object.
Parameters: paragraph - the String containing the paragraph text to perform thealgorithm. Parameters: flags - indicates the base direction of the bidirectional text. |
Method Summary | |
public boolean | baseIsLeftToRight() Return whether the base level is from left to right. | public Bidi | createLineBidi(int lineStart, int lineLimit) Create a new Bidi object containing the information of one line from this
object.
Parameters: lineStart - the start offset of the line. Parameters: lineLimit - the limit of the line. | public int | getBaseLevel() Return the base level. | public int | getLength() Return the length of the text in the Bidi object. | public int | getLevelAt(int offset) Return the level of a specified character.
Parameters: offset - the offset of the character. | public int | getRunCount() Return the number of runs in the bidirectional text. | public int | getRunLevel(int run) Return the level of a specified run.
Parameters: run - the index of the run. | public int | getRunLimit(int run) Return the limit offset of a specified run.
Parameters: run - the index of the run. | public int | getRunStart(int run) Return the start offset of a specified run.
Parameters: run - the index of the run. | public boolean | isLeftToRight() Return whether the text is from left to right, that is, both the base
direction and the text direction is from left to right. | public boolean | isMixed() Return whether the text direction is mixed. | public boolean | isRightToLeft() Return whether the text is from right to left, that is, both the base
direction and the text direction is from right to left. | public static void | reorderVisually(byte[] levels, int levelStart, Object[] objects, int objectStart, int count) Reorder a range of objects according to their specified levels. | public static boolean | requiresBidi(char[] text, int start, int limit) Return whether a range of characters of a text requires a Bidi object to
display properly.
Parameters: text - the char array of the text. Parameters: start - the start offset of the range of characters. Parameters: limit - the limit offset of the range of characters. | public String | toString() Return the internal message of the Bidi object, used in debugging. |
DIRECTION_DEFAULT_LEFT_TO_RIGHT | final public static int DIRECTION_DEFAULT_LEFT_TO_RIGHT(Code) | | Constant that indicates the default base level. If there is no strong
character, then set the paragraph level to left-to-right.
|
DIRECTION_DEFAULT_RIGHT_TO_LEFT | final public static int DIRECTION_DEFAULT_RIGHT_TO_LEFT(Code) | | Constant that indicates the default base level. If there is no strong
character, then set the paragraph level to right-to-left.
|
DIRECTION_LEFT_TO_RIGHT | final public static int DIRECTION_LEFT_TO_RIGHT(Code) | | Constant that specifies the default base level as
left-to-right.
|
DIRECTION_RIGHT_TO_LEFT | final public static int DIRECTION_RIGHT_TO_LEFT(Code) | | Constant that specifies the default base level right-to-left.
|
Bidi | public Bidi(AttributedCharacterIterator paragraph)(Code) | | Create a Bidi object from the AttributedCharacterIterator of a paragraph
text.
The RUN_DIRECTION attribute determines the base direction of the
bidirectional text. If it's not specified explicitly, the algorithm uses
DIRECTION_DEFAULT_LEFT_TO_RIGHT by default.
The BIDI_EMBEDDING attribute specifies the level of embedding for each
character. Values between -1 and -62 denote overrides at the level's
absolute value, values from 1 to 62 indicate embeddings, and the 0 value
indicates the level is calculated by the algorithm automatically. For the
character with no BIDI_EMBEDDING attribute or with a improper attribute
value, such as a null value, the algorithm treats its embedding level as
0.
The NUMERIC_SHAPING attribute specifies the instance of NumericShaper
used to convert European digits to other decimal digits before performing
the bidi algorithm.
Parameters: paragraph - See Also: java.awt.font.TextAttribute.BIDI_EMBEDDING See Also: java.awt.font.TextAttribute.NUMERIC_SHAPING See Also: java.awt.font.TextAttribute.RUN_DIRECTION |
Bidi | public Bidi(char[] text, int textStart, byte[] embeddings, int embStart, int paragraphLength, int flags)(Code) | | Create a Bidi object.
Parameters: text - the char array of the paragraph text. Parameters: textStart - the start offset of the text array to perform the algorithm. Parameters: embeddings - the embedding level array of the paragraph text, specifyingthe embedding level information for each character. Valuesbetween -1 and -62 denote overrides at the level's absolutevalue, values from 1 to 62 indicate embeddings, and the 0value indicates the level is calculated by the algorithmautomatically. Parameters: embStart - the start offset of the embeddings array to perform thealgorithm. Parameters: paragraphLength - the length of the text to perform the algorithm. It must betext.length >= textStart + paragraphLength, andembeddings.length >= embStart + paragraphLength. Parameters: flags - indicates the base direction of the bidirectional text. It isexpected that this will be one of the direction constantvalues defined in this class. An unknown value is treated asDIRECTION_DEFAULT_LEFT_TO_RIGHT. See Also: Bidi.DIRECTION_LEFT_TO_RIGHT See Also: Bidi.DIRECTION_RIGHT_TO_LEFT See Also: Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT See Also: Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT |
baseIsLeftToRight | public boolean baseIsLeftToRight()(Code) | | Return whether the base level is from left to right.
true if the base level is from left to right. |
createLineBidi | public Bidi createLineBidi(int lineStart, int lineLimit)(Code) | | Create a new Bidi object containing the information of one line from this
object.
Parameters: lineStart - the start offset of the line. Parameters: lineLimit - the limit of the line. the new line Bidi object. In this new object, the indices willrange from 0 to (limit - start - 1). |
getBaseLevel | public int getBaseLevel()(Code) | | Return the base level.
the int value of the base level. |
getLength | public int getLength()(Code) | | Return the length of the text in the Bidi object.
the int value of the length. |
getLevelAt | public int getLevelAt(int offset)(Code) | | Return the level of a specified character.
Parameters: offset - the offset of the character. the int value of the level. |
getRunCount | public int getRunCount()(Code) | | Return the number of runs in the bidirectional text.
the int value of runs, at least 1. |
getRunLevel | public int getRunLevel(int run)(Code) | | Return the level of a specified run.
Parameters: run - the index of the run. the level of the run. |
getRunLimit | public int getRunLimit(int run)(Code) | | Return the limit offset of a specified run.
Parameters: run - the index of the run. the limit offset of the run. |
getRunStart | public int getRunStart(int run)(Code) | | Return the start offset of a specified run.
Parameters: run - the index of the run. the start offset of the run. |
isLeftToRight | public boolean isLeftToRight()(Code) | | Return whether the text is from left to right, that is, both the base
direction and the text direction is from left to right.
true if the text is from left to right. |
isMixed | public boolean isMixed()(Code) | | Return whether the text direction is mixed.
true if the text direction is mixed. |
isRightToLeft | public boolean isRightToLeft()(Code) | | Return whether the text is from right to left, that is, both the base
direction and the text direction is from right to left.
true if the text is from right to left. |
reorderVisually | public static void reorderVisually(byte[] levels, int levelStart, Object[] objects, int objectStart, int count)(Code) | | Reorder a range of objects according to their specified levels. This is a
convenience function that does not use a Bidi object. The range of
objects at index from objectStart to objectStart + count will be
reordered according to the range of levels at index from levelStart to
levelStart + count.
Parameters: levels - the level array, which is already determined. Parameters: levelStart - the start offset of the range of the levels. Parameters: objects - the object array to reorder. Parameters: objectStart - the start offset of the range of objects. Parameters: count - the count of the range of objects to reorder. |
requiresBidi | public static boolean requiresBidi(char[] text, int start, int limit)(Code) | | Return whether a range of characters of a text requires a Bidi object to
display properly.
Parameters: text - the char array of the text. Parameters: start - the start offset of the range of characters. Parameters: limit - the limit offset of the range of characters. true if the range of characters requires a Bidi object. |
toString | public String toString()(Code) | | Return the internal message of the Bidi object, used in debugging.
a string containing the internal message. |
|
|