java.text.Bidi.requiresBidi()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中java.text.Bidi.requiresBidi()方法的一些代码示例,展示了Bidi.requiresBidi()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bidi.requiresBidi()方法的具体详情如下:
包路径:java.text.Bidi
类名称:Bidi
方法名:requiresBidi

Bidi.requiresBidi介绍

[英]Indicates whether a range of characters of a text requires a Bidiobject to display properly.
[中]

代码示例

代码示例来源: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: 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()) {

代码示例来源: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 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: org.apache.abdera/abdera-i18n

/**
 * Algorithm that analyzes properties of the text to determine text direction. If the majority of characters in the
 * text are RTL characters, then Direction.RTL will be returned.
 */
public static Direction guessDirectionFromTextProperties(String text) {
  if (text != null && text.length() > 0) {
    if (text.charAt(0) == 0x200F)
      return Direction.RTL; // if using the unicode right-to-left mark
    if (text.charAt(0) == 0x200E)
      return Direction.LTR; // if using the unicode left-to-right mark
    int c = 0;
    for (int n = 0; n < text.length(); n++) {
      char ch = text.charAt(n);
      if (java.text.Bidi.requiresBidi(new char[] {ch}, 0, 1))
        c++;
      else
        c--;
    }
    return c > 0 ? Direction.RTL : Direction.LTR;
  }
  return Direction.UNSPECIFIED;
}

代码示例来源:origin: rocks.xmpp/precis

@Override
  protected final CharSequence applyDirectionalityRule(final CharSequence input) {
    // 5. Directionality Rule: Apply the "Bidi Rule" defined in [RFC5893]
    // to strings that contain right-to-left code points (i.e., each of
    // the six conditions of the Bidi Rule must be satisfied); for
    // strings that do not contain right-to-left code points, there is
    // no special processing for directionality.
    if (Bidi.requiresBidi(input.toString().toCharArray(), 0, input.length())) {
      checkBidiRule(input);
    }
    return input;
  }
}

代码示例来源:origin: org.geotools/gt2-render

/**
 * recompute each time
 */
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 = font.layoutGlyphVector(graphics.getFontRenderContext(), chars, 
        0, length, Font.LAYOUT_RIGHT_TO_LEFT);
  else
    textGlyphVector = font.createGlyphVector(graphics.getFontRenderContext(), chars);
  return textGlyphVector;
}

代码示例来源:origin: org.geotools/gt-render

/**
 * recompute each time
 */
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 = font.layoutGlyphVector(graphics.getFontRenderContext(), chars, 
        0, length, Font.LAYOUT_RIGHT_TO_LEFT);
  else
    textGlyphVector = font.createGlyphVector(graphics.getFontRenderContext(), chars);
  return textGlyphVector;
}

代码示例来源:origin: org.geotools/gt-render

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

代码示例来源:origin: org.tinyjee.jgraphx/jgraphx

boolean bidiRequired = Bidi.requiresBidi(labelChars, 0,
    labelChars.length);

代码示例来源:origin: com.github.vlsi.mxgraph/jgraphx

boolean bidiRequired = Bidi.requiresBidi(labelChars, 0,
    labelChars.length);

相关文章