Example usage for java.lang Character DIRECTIONALITY_LEFT_TO_RIGHT

List of usage examples for java.lang Character DIRECTIONALITY_LEFT_TO_RIGHT

Introduction

In this page you can find the example usage for java.lang Character DIRECTIONALITY_LEFT_TO_RIGHT.

Prototype

byte DIRECTIONALITY_LEFT_TO_RIGHT

To view the source code for java.lang Character DIRECTIONALITY_LEFT_TO_RIGHT.

Click Source Link

Document

Strong bidirectional character type "L" in the Unicode specification.

Usage

From source file:Main.java

public static void main(String[] args) {
    for (char ch = Character.MIN_VALUE; ch < Character.MAX_VALUE; ch++) {
        if (Character.DIRECTIONALITY_LEFT_TO_RIGHT == Character.getDirectionality(ch)) {
            String s = String.format("\\u%04x", (int) ch);
            System.out.println(s);
        }//w ww.j a  v a 2s .c  om
    }
}

From source file:Main.java

public static boolean isStrongLeftToRight(char c) {
    byte dir = Character.getDirectionality(c);
    return (dir == Character.DIRECTIONALITY_LEFT_TO_RIGHT)
            || (dir == Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING)
            || (dir == Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE);
}

From source file:android.text.TextDirectionHeuristics.java

private static int isRtlText(int directionality) {
    switch (directionality) {
    case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
        return STATE_FALSE;
    case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
    case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
        return STATE_TRUE;
    default:/*w  w  w  . j a  va 2s . co  m*/
        return STATE_UNKNOWN;
    }
}

From source file:android.text.TextDirectionHeuristics.java

private static int isRtlTextOrFormat(int directionality) {
    switch (directionality) {
    case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
    case Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:
    case Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:
        return STATE_FALSE;
    case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
    case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
    case Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:
    case Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:
        return STATE_TRUE;
    default:/*from   w w w. ja va  2s.co m*/
        return STATE_UNKNOWN;
    }
}

From source file:com.jecelyin.editor.v2.core.text.TextUtils.java

/**
 * Fallback algorithm to detect the locale direction. Rely on the fist char of the
 * localized locale name. This will not work if the localized locale name is in English
 * (this is the case for ICU 4.4 and "Urdu" script)
 *
 * @param locale/*from  w ww . j  a  va 2s. c  o  m*/
 * @return the layout direction. This may be one of:
 * {@link android.view.View#LAYOUT_DIRECTION_LTR} or
 * {@link android.view.View#LAYOUT_DIRECTION_RTL}.
 *
 * Be careful: this code will need to be updated when vertical scripts will be supported
 *
 * @hide
 */
private static int getLayoutDirectionFromFirstChar(Locale locale) {
    switch (Character.getDirectionality(locale.getDisplayName(locale).charAt(0))) {
    case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
    case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
        return View.LAYOUT_DIRECTION_RTL;

    case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
    default:
        return View.LAYOUT_DIRECTION_LTR;
    }
}