本文整理了Java中java.text.Bidi
类的一些代码示例,展示了Bidi
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bidi
类的具体详情如下:
包路径:java.text.Bidi
类名称:Bidi
[英]Implements the Unicode Bidirectional Algorithm.
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.
[中]实现Unicode Bidirectional Algorithm。
使用Bidi对象获取双向文本(如阿拉伯语或希伯来语)的位置重新排序信息。这些语言中水平文本的自然显示顺序是从右到左,而数字顺序是从左到右。
如果文本包含多个运行,则可以从运行索引中获取每个运行的信息。任何特定梯段的级别指示文本的方向以及嵌套级别。从左到右的跑步级别为偶数,而从右到左的跑步级别为奇数。
代码示例来源:origin: robovm/robovm
int dir = this.baseIsLeftToRight()
? Bidi.DIRECTION_LEFT_TO_RIGHT
: Bidi.DIRECTION_RIGHT_TO_LEFT;
long parent = 0;
try {
parent = createUBiDi(text, 0, embeddings, 0, this.length, dir);
if (lineStart == lineLimit) {
return createEmptyLineBidi(parent);
return new Bidi(ubidi_setLine(parent, lineStart, lineLimit));
} finally {
ubidi_close(parent);
代码示例来源:origin: robovm/robovm
/**
* Indicates whether a range of characters of a text requires a {@code Bidi}
* object to display properly.
*
* @param text
* the char array of the text.
* @param start
* the start offset of the range of characters.
* @param limit
* the limit offset of the range of characters.
* @return {@code true} if the range of characters requires a {@code Bidi}
* object; {@code false} otherwise.
* @throws IllegalArgumentException
* if {@code start} or {@code limit} is negative; {@code start >
* limit} or {@code limit} is greater than the length of this
* object's paragraph text.
*/
public static boolean requiresBidi(char[] text, int start, int limit) {
if (limit < 0 || start < 0 || start > limit || limit > text.length) {
throw new IllegalArgumentException();
}
Bidi bidi = new Bidi(text, start, null, 0, limit - start, 0);
return !bidi.isLeftToRight();
}
代码示例来源:origin: stackoverflow.com
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
Bidi bidi = new Bidi(userList.get(position).getName(), Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
if(bidi.getBaseLevel() == 0)
convertView = myInflater.inflate(R.layout.list_add_friends_row, null);
else
convertView = myInflater.inflate(R.layout.list_add_friends_row_mirror, null);
...
代码示例来源:origin: stackoverflow.com
Bidi bidi = new Bidi(userList.get(position).getName(), Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
if(bidi.baseIsLeftToRight())
convertView = myInflater.inflate(R.layout.list_add_friends_row, null);
else
convertView = myInflater.inflate(R.layout.list_add_friends_row_mirror, null);
代码示例来源:origin: apache/pdfbox
Bidi bidi = new Bidi(word, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
if (!bidi.isMixed() && bidi.getBaseLevel() == Bidi.DIRECTION_LEFT_TO_RIGHT)
int runCount = bidi.getRunCount();
byte[] levels = new byte[runCount];
Integer[] runs = new Integer[runCount];
levels[i] = (byte)bidi.getRunLevel(i);
runs[i] = i;
Bidi.reorderVisually(levels, 0, runs, 0, runCount);
int start = bidi.getRunStart(index);
int end = bidi.getRunLimit(index);
代码示例来源:origin: stackoverflow.com
String paragraph = "hey what's up ضعيف";
int NO_FLAG = 0;
Bidi bidi = new Bidi(paragraph, NO_FLAG);
int runCount = bidi.getRunCount();
for (int i = 0; i < runCount; i++) {
String ltrtl = bidi.getRunLevel(i) % 2 == 0 ? "ltr" : "rtl";
String subString = paragraph.substring(bidi.getRunStart(i), bidi.getRunLimit(i));
Log.d(">>bidi:" + i, subString+" is "+ltrtl);
}
代码示例来源:origin: google/sagetv
java.text.Bidi booty = new java.text.Bidi(inText, java.text.Bidi.DIRECTION_LEFT_TO_RIGHT);
if (booty.isLeftToRight())
if (booty.isRightToLeft())
int runCounts = booty.getRunCount();
byte[] levelInfo = new byte[runCounts];
Object[] textObjs = new Object[runCounts];
for (int i = 0; i < runCounts; i++)
levelInfo[i] = (byte)booty.getRunLevel(i);
textObjs[i] = inText.substring(booty.getRunStart(i), booty.getRunLimit(i));
textObjs[i] = (levelInfo[i] % 2) == booty.getBaseLevel() ? textObjs[i].toString() :
new StringBuffer(textObjs[i].toString()).reverse().toString();
java.text.Bidi.reorderVisually(levelInfo, 0, textObjs, 0, runCounts);
StringBuffer newText = new StringBuffer(inText.length() + 1);
for (int i = 0; i < textObjs.length; i++)
代码示例来源:origin: geotools/geotools
final char[] chars = label.toCharArray();
final int length = label.length();
if (Bidi.requiresBidi(chars, 0, length)) {
Bidi bidi = new Bidi(label, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
if (bidi.isRightToLeft()) {
return font.layoutGlyphVector(
graphics.getFontRenderContext(),
length,
Font.LAYOUT_RIGHT_TO_LEFT);
} else if (bidi.isMixed()) {
String r = "";
for (int i = 0; i < bidi.getRunCount(); i++) {
String s1 = label.substring(bidi.getRunStart(i), bidi.getRunLimit(i));
if (bidi.getRunLevel(i) % 2 == 0) {
s1 = new StringBuffer(s1).reverse().toString();
代码示例来源:origin: robovm/robovm
Bidi temp = new Bidi(text, textStart, null, 0, paragraphLength, flags);
realEmbeddings = new byte[paragraphLength];
System.arraycopy(temp.offsetLevel, 0, realEmbeddings, 0, paragraphLength);
boolean needsDeletion = true;
try {
bidi = ubidi_open();
ubidi_setPara(bidi, realText, paragraphLength, flags, realEmbeddings);
needsDeletion = false;
} finally {
if (needsDeletion) {
ubidi_close(bidi);
代码示例来源:origin: org.tinyjee.jgraphx/jgraphx
boolean bidiRequired = Bidi.requiresBidi(labelChars, 0,
labelChars.length);
Bidi bidi = new Bidi(label,
Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
int runCount = bidi.getRunCount();
for (int i = 0; i < bidi.getRunCount(); i++)
bidi.getRunStart(i), bidi.getRunLimit(i));
rtlGlyphVectors[i] = font
.layoutGlyphVector(mxCurveLabelShape.frc,
代码示例来源:origin: robovm/robovm
private Bidi createEmptyLineBidi(long parent) {
// ICU4C doesn't allow this case, but the RI does.
Bidi result = new Bidi(parent);
result.length = 0;
result.offsetLevel = null;
result.runs = null;
result.unidirectional = true;
return result;
}
代码示例来源:origin: geotools/geotools
/** Gets the glyph vector for the main font */
public GlyphVector getTextGlyphVector(Graphics2D graphics) {
// arabic and hebrew are scripted and right to left, they do require full layout
// whilst western chars are easier to deal with. Find out which case we're dealing with,
// and create the glyph vector with the appropriate call
final char[] chars = label.toCharArray();
final int length = label.length();
if (Bidi.requiresBidi(chars, 0, length)
&& new Bidi(label, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT).isRightToLeft()) {
textGlyphVector =
getFont()
.layoutGlyphVector(
graphics.getFontRenderContext(),
chars,
0,
length,
Font.LAYOUT_RIGHT_TO_LEFT);
} else {
textGlyphVector = getFont().createGlyphVector(graphics.getFontRenderContext(), chars);
}
return textGlyphVector;
}
代码示例来源:origin: stackoverflow.com
getResources().updateConfiguration(config,
getResources().getDisplayMetrics());
Bidi bidi = new Bidi(app_locale,
Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
bidi.isRightToLeft();
YourGlobalClass.updateLanguage(getActivity(), "ar");
getResources().updateConfiguration(config,
getResources().getDisplayMetrics());
Bidi bidi = new Bidi(app_locale,
Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
bidi.isLeftToRight();
YourGlobalClass.updateLanguage(getActivity(), "en");
代码示例来源:origin: sjwall/MaterialTapTargetPrompt
final int layoutDirection = resources.getConfiguration().getLayoutDirection();
if (text != null && layoutDirection == View.LAYOUT_DIRECTION_RTL
&& new Bidi(text.toString(), Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT).isRightToLeft())
代码示例来源:origin: com.github.vatbub/common.view.core
if (style == ELLIPSIS && !new Bidi(text, Bidi.DIRECTION_LEFT_TO_RIGHT).isMixed()) {
int hit = computeTruncationIndex(font, text, width - ellipsisWidth);
if (hit < 0 || hit >= text.length()) {
代码示例来源:origin: com.github.librepdf/openpdf
Bidi bidi = new Bidi(new String(text),
(byte) (runDirection == PdfWriter.RUN_DIRECTION_RTL ? Bidi.DIRECTION_RIGHT_TO_LEFT : Bidi.DIRECTION_LEFT_TO_RIGHT));
for (int k = 0; k < totalTextLength; ++k) {
orderLevels[k] = (byte) bidi.getLevelAt(k);
indexChars[k] = k;
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.ibm.icu.base
/**
* Return true if the specified text requires bidi analysis. If this returns
* false, the text will display left-to-right. Clients can then avoid
* constructing a Bidi object. Text in the Arabic Presentation Forms area of
* Unicode is presumed to already be shaped and ordered for display, and so
* will not cause this method to return true.
*
* @param text the text containing the characters to test
* @param start the start of the range of characters to test
* @param limit the limit of the range of characters to test
*
* @return true if the range of characters requires bidi analysis
*
* @stable ICU 3.8
*/
public static boolean requiresBidi(char[] text,
int start,
int limit)
{
return java.text.Bidi.requiresBidi(text, start, limit);
}
代码示例来源:origin: at.bestsolution.eclipse/com.ibm.icu.base
/**
* Return true if the base direction is left-to-right
*
* @return true if the base direction is left-to-right
*
* @throws IllegalStateException if this call is not preceded by a successful
* call to <code>setPara</code> or <code>setLine</code>
*
* @stable ICU 3.8
*/
public boolean baseIsLeftToRight()
{
return bidi.baseIsLeftToRight();
}
代码示例来源:origin: at.bestsolution.eclipse/com.ibm.icu.base
/**
* Return the number of level runs.
*
* @return the number of level runs
*
* @throws IllegalStateException if this call is not preceded by a successful
* call to <code>setPara</code> or <code>setLine</code>
*
* @stable ICU 3.8
*/
public int getRunCount()
{
return bidi.getRunCount();
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.ibm.icu.base
/**
* Return true if the line is all left-to-right text and the base direction
* is left-to-right.
*
* @return true if the line is all left-to-right text and the base direction
* is left-to-right.
*
* @throws IllegalStateException if this call is not preceded by a successful
* call to <code>setPara</code>
* @stable ICU 3.8
*/
public boolean isLeftToRight()
{
return bidi.isLeftToRight();
}
内容来源于网络,如有侵权,请联系作者删除!