當前位置: 首頁>>代碼示例>>Java>>正文


Java Bidi.getRunLimit方法代碼示例

本文整理匯總了Java中java.text.Bidi.getRunLimit方法的典型用法代碼示例。如果您正苦於以下問題:Java Bidi.getRunLimit方法的具體用法?Java Bidi.getRunLimit怎麽用?Java Bidi.getRunLimit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.text.Bidi的用法示例。


在下文中一共展示了Bidi.getRunLimit方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getLevels

import java.text.Bidi; //導入方法依賴的package包/類
/**
 * Return the level of each character into the levels array starting at start.
 * This is a convenience method for clients who prefer to use an explicit levels
 * array instead of iterating over the runs.
 *
 * @param levels the array to receive the character levels
 * @param start the starting offset into the the array
 * @throws IndexOutOfBoundsException if <code>start</code> is less than 0 or
 * <code>start + getLength()</code> is greater than <code>levels.length</code>.
 */
public static void getLevels(Bidi bidi, byte[] levels, int start) {
    int limit = start + bidi.getLength();

    if (start < 0 || limit > levels.length) {
        throw new IndexOutOfBoundsException("levels.length = " + levels.length +
            " start: " + start + " limit: " + limit);
    }

    int runCount = bidi.getRunCount();
    int p = start;
    for (int i = 0; i < runCount; ++i) {
        int rlimit = start + bidi.getRunLimit(i);
        byte rlevel = (byte)bidi.getRunLevel(i);

        while (p < rlimit) {
            levels[p++] = rlevel;
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:30,代碼來源:BidiUtils.java

示例2: getLevels

import java.text.Bidi; //導入方法依賴的package包/類
/**
 * Return the level of each character into the levels array starting at start.
 * This is a convenience method for clients who prefer to use an explicit levels
 * array instead of iterating over the runs.
 *
 * @param levels the array to receive the character levels
 * @param start the starting offset into the array
 * @throws IndexOutOfBoundsException if {@code start} is less than 0 or
 * {@code start + getLength()} is greater than {@code levels.length}.
 */
public static void getLevels(Bidi bidi, byte[] levels, int start) {
    int limit = start + bidi.getLength();

    if (start < 0 || limit > levels.length) {
        throw new IndexOutOfBoundsException("levels.length = " + levels.length +
            " start: " + start + " limit: " + limit);
    }

    int runCount = bidi.getRunCount();
    int p = start;
    for (int i = 0; i < runCount; ++i) {
        int rlimit = start + bidi.getRunLimit(i);
        byte rlevel = (byte)bidi.getRunLevel(i);

        while (p < rlimit) {
            levels[p++] = rlevel;
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:30,代碼來源:BidiUtils.java

示例3: assertRunArrayEquals

import java.text.Bidi; //導入方法依賴的package包/類
public static void assertRunArrayEquals(int[][] expected, Bidi bidi) {
	assertEquals("different length", expected.length, bidi.getRunCount());

	FORRUN: for (int i = 0; i < bidi.getRunCount(); i++) {
		int[] butWas = new int[] { bidi.getRunStart(i),
				bidi.getRunLimit(i), bidi.getRunLevel(i) };

		for (int j = 0; j < expected.length; j++) {
			if (expected[j][0] == butWas[0] && expected[j][1] == butWas[1]
					&& expected[j][2] == butWas[2]) {
				continue FORRUN;
			}
		}
		fail("expected [" + i + "] " + " start: " + butWas[0] + " limit: "
				+ butWas[1] + " level: " + butWas[2]);
	}
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:18,代碼來源:BidiTest.java

示例4: main

import java.text.Bidi; //導入方法依賴的package包/類
public static void main(String[] args) {
    boolean err = false;
    String string = "\u05D0\u05D1\u05D2";
    Bidi bidi = new Bidi(string, Bidi.DIRECTION_LEFT_TO_RIGHT);

    int result = bidi.getRunCount();
    if (result != 1) {
        System.err.println("Incorrect run count: " + result);
        err = true;
    }

    result = bidi.getRunStart(0);
    if (result != 0) {
        System.err.println("Incorrect run start: " + result);
        err = true;
    }

    result = bidi.getRunLimit(0);
    if (result != 3) {
        System.err.println("Incorrect run limit: " + result);
        err = true;
    }

    result = bidi.getRunLevel(0);
    if (result != 1) {
        System.err.println("Incorrect run level: " + result);
        err = true;
    }

    if (err) {
        throw new RuntimeException("Failed.");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:34,代碼來源:Bug8005277.java

示例5: testBidi

import java.text.Bidi; //導入方法依賴的package包/類
void testBidi(String string, int rtlstart, int rtllength) {
    Bidi bidi = new Bidi(string, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    for (int i = 0; i < bidi.getRunCount(); ++i) {
        if ((bidi.getRunLevel(i) & 1) != 0) {
            if (bidi.getRunStart(i) != rtlstart ||
                bidi.getRunLimit(i) != rtlstart + rtllength) {
                throw new RuntimeException("first rtl run didn't match " + rtlstart + ", " + rtllength);
            }
            break;
        }
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:13,代碼來源:BidiSurrogateTest.java

示例6: testEachMethod

import java.text.Bidi; //導入方法依賴的package包/類
private void testEachMethod(Bidi bidi,
                            String text,
                            String expectedLevels,
                            boolean expectedBaseIsLTR,
                            boolean expectedIsLTR,
                            boolean expectedIsRTL
                           ) {
    /* Test baseIsLeftToRight() */
    boolean actualBoolean = bidi.baseIsLeftToRight();
    checkResult("baseIsLeftToRight()", expectedBaseIsLTR, actualBoolean);

    /* Test getBaseLevel() */
    int expectedInt = (expectedBaseIsLTR) ? 0 : 1;
    int actualInt = bidi.getBaseLevel();
    checkResult("getBaseLevel()", expectedInt, actualInt);

    /* Test getLength() */
    expectedInt = text.length();
    actualInt = bidi.getLength();
    checkResult("getLength()", expectedInt, actualInt);

    /* Test getLevelAt() */
    sb.setLength(0);
    for (int i = 0; i < text.length(); i++) {
        sb.append(bidi.getLevelAt(i));
    }
    checkResult("getLevelAt()", expectedLevels, sb.toString());

    /* Test getRunCount() */
    expectedInt = getRunCount(expectedLevels);
    actualInt = bidi.getRunCount();
    checkResult("getRunCount()", expectedInt, actualInt);

    /* Test getRunLevel(), getRunLimit() and getRunStart() */
    if (expectedInt == actualInt) {
        int runCount = expectedInt;
        int[] expectedRunLevels = getRunLevels_int(runCount, expectedLevels);
        int[] expectedRunLimits = getRunLimits(runCount, expectedLevels);
        int[] expectedRunStarts = getRunStarts(runCount, expectedLevels);
        int[] actualRunLevels = new int[runCount];
        int[] actualRunLimits = new int[runCount];
        int[] actualRunStarts = new int[runCount];

        for (int k = 0; k < runCount; k++) {
            actualRunLevels[k] = bidi.getRunLevel(k);
            actualRunLimits[k] = bidi.getRunLimit(k);
            actualRunStarts[k] = bidi.getRunStart(k);
        }

        checkResult("getRunLevel()", expectedRunLevels, actualRunLevels);
        checkResult("getRunStart()", expectedRunStarts, actualRunStarts);
        checkResult("getRunLimit()", expectedRunLimits, actualRunLimits);
    }

    /* Test isLeftToRight() */
    boolean expectedBoolean = expectedIsLTR;
    actualBoolean = bidi.isLeftToRight();
    checkResult("isLeftToRight()", expectedBoolean, actualBoolean);

    /* Test isMixed() */
    expectedBoolean = !(expectedIsLTR || expectedIsRTL);
    actualBoolean = bidi.isMixed();
    checkResult("isMixed()", expectedBoolean, actualBoolean);

    /* Test isRightToLeft() */
    expectedBoolean = expectedIsRTL;
    actualBoolean = bidi.isRightToLeft();
    checkResult("isRightToLeft()", expectedBoolean, actualBoolean);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:70,代碼來源:BidiConformance.java

示例7: bidiReorder

import java.text.Bidi; //導入方法依賴的package包/類
/**
 * Apply Unicode Bidirectional Algorithm to string and return a new possibly
 * reordered string for visual rendering.
 */
private String bidiReorder(String par1Str)
{
    if (par1Str != null && Bidi.requiresBidi(par1Str.toCharArray(), 0, par1Str.length()))
    {
        Bidi bidi = new Bidi(par1Str, -2);
        byte[] abyte = new byte[bidi.getRunCount()];
        String[] astring = new String[abyte.length];
        int i;

        for (int j = 0; j < abyte.length; ++j)
        {
            int k = bidi.getRunStart(j);
            i = bidi.getRunLimit(j);
            int l = bidi.getRunLevel(j);
            String s1 = par1Str.substring(k, i);
            abyte[j] = (byte) l;
            astring[j] = s1;
        }

        String[] astring1 = astring.clone();
        Bidi.reorderVisually(abyte, 0, astring, 0, abyte.length);
        StringBuilder stringbuilder = new StringBuilder();
        i = 0;

        while (i < astring.length)
        {
            byte b0 = abyte[i];
            int i1 = 0;

            while (true)
            {
                if (i1 < astring1.length)
                {
                    if (!astring1[i1].equals(astring[i]))
                    {
                        ++i1;
                        continue;
                    }

                    b0 = abyte[i1];
                }

                if ((b0 & 1) == 0)
                {
                    stringbuilder.append(astring[i]);
                }
                else
                {
                    for (i1 = astring[i].length() - 1; i1 >= 0; --i1)
                    {
                        char c0 = astring[i].charAt(i1);

                        if (c0 == 40)
                        {
                            c0 = 41;
                        }
                        else if (c0 == 41)
                        {
                            c0 = 40;
                        }

                        stringbuilder.append(c0);
                    }
                }

                ++i;
                break;
            }
        }

        return stringbuilder.toString();
    }
    else
    {
        return par1Str;
    }
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:82,代碼來源:SmallFontRenderer.java

示例8: bidiReorder

import java.text.Bidi; //導入方法依賴的package包/類
/**
 * Apply Unicode Bidirectional Algorithm to string and return a new possibly
 * reordered string for visual rendering.
 */
private String bidiReorder(String par1Str)
{
    if (par1Str != null && Bidi.requiresBidi(par1Str.toCharArray(), 0, par1Str.length())) {
        Bidi bidi = new Bidi(par1Str, -2);
        byte[] abyte = new byte[bidi.getRunCount()];
        String[] astring = new String[abyte.length];
        int i;

        for (int j = 0; j < abyte.length; ++j) {
            int k = bidi.getRunStart(j);
            i = bidi.getRunLimit(j);
            int l = bidi.getRunLevel(j);
            String s1 = par1Str.substring(k, i);
            abyte[j] = (byte) l;
            astring[j] = s1;
        }

        String[] astring1 = astring.clone();
        Bidi.reorderVisually(abyte, 0, astring, 0, abyte.length);
        StringBuilder stringbuilder = new StringBuilder();
        i = 0;

        while (i < astring.length) {
            byte b0 = abyte[i];
            int i1 = 0;

            while (true) {
                if (i1 < astring1.length) {
                    if (!astring1[i1].equals(astring[i])) {
                        ++i1;
                        continue;
                    }

                    b0 = abyte[i1];
                }

                if ((b0 & 1) == 0) {
                    stringbuilder.append(astring[i]);
                }
                else {
                    for (i1 = astring[i].length() - 1; i1 >= 0; --i1) {
                        char c0 = astring[i].charAt(i1);

                        if (c0 == 40) {
                            c0 = 41;
                        }
                        else if (c0 == 41) {
                            c0 = 40;
                        }

                        stringbuilder.append(c0);
                    }
                }

                ++i;
                break;
            }
        }

        return stringbuilder.toString();
    }
    else {
        return par1Str;
    }
}
 
開發者ID:BubbleTrouble14,項目名稱:ARKCraft,代碼行數:70,代碼來源:SmallFontRenderer.java

示例9: visualToLogical

import java.text.Bidi; //導入方法依賴的package包/類
/**
 * Handles the LTR and RTL direction of the given words. The whole implementation stands and falls with the given
 * word. If the word is a full line, the results will be the best. If the word contains of single words or
 * characters, the order of the characters in a word or words in a line may wrong, due to RTL and LTR marks and
 * characters!
 * 
 * Based on http://www.nesterovsky-bros.com/weblog/2013/07/28/VisualToLogicalConversionInJava.aspx
 * 
 * @param text The word that shall be processed
 * @return new word with the correct direction of the containing characters
 */
public static String visualToLogical(String text)
{
    if (!CharUtils.isBlank(text))
    {
        Bidi bidi = new Bidi(text, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
        if (!bidi.isLeftToRight())
        {
            // collect individual bidi information
            int runCount = bidi.getRunCount();
            byte[] levels = new byte[runCount];
            Integer[] runs = new Integer[runCount];

            for (int i = 0; i < runCount; i++)
            {
                levels[i] = (byte) bidi.getRunLevel(i);
                runs[i] = i;
            }

            // reorder individual parts based on their levels
            Bidi.reorderVisually(levels, 0, runs, 0, runCount);

            // collect the parts based on the direction within the run
            StringBuilder result = new StringBuilder();

            for (int i = 0; i < runCount; i++)
            {
                int index = runs[i];
                int start = bidi.getRunStart(index);
                int end = bidi.getRunLimit(index);
                int level = levels[index];

                if ((level & 1) != 0)
                {
                    while (--end >= start)
                    {
                        char character = text.charAt(end);
                        if (Character.isMirrored(text.codePointAt(end))
                                && MIRRORING_CHAR_MAP.containsKey(character))
                        {
                            result.append(MIRRORING_CHAR_MAP.get(character));
                        }
                        else
                        {
                            result.append(character);
                        }
                    }
                }
                else
                {
                    result.append(text, start, end);
                }
            }

            return result.toString();
        }
    }
    return text;
}
 
開發者ID:torakiki,項目名稱:sambox,代碼行數:70,代碼來源:BidiUtils.java

示例10: bidiReorder

import java.text.Bidi; //導入方法依賴的package包/類
/**
 * Apply Unicode Bidirectional Algorithm to string and return a new possibly reordered string for visual rendering.
 */
private String bidiReorder(String par1Str)
{
    if (par1Str != null && Bidi.requiresBidi(par1Str.toCharArray(), 0, par1Str.length()))
    {
        Bidi bidi = new Bidi(par1Str, -2);
        byte[] abyte = new byte[bidi.getRunCount()];
        String[] astring = new String[abyte.length];
        int i;

        for (int j = 0; j < abyte.length; ++j)
        {
            int k = bidi.getRunStart(j);
            i = bidi.getRunLimit(j);
            int l = bidi.getRunLevel(j);
            String s1 = par1Str.substring(k, i);
            abyte[j] = (byte) l;
            astring[j] = s1;
        }

        String[] astring1 = astring.clone();
        Bidi.reorderVisually(abyte, 0, astring, 0, abyte.length);
        StringBuilder stringbuilder = new StringBuilder();
        i = 0;

        while (i < astring.length)
        {
            byte b0 = abyte[i];
            int i1 = 0;

            while (true)
            {
                if (i1 < astring1.length)
                {
                    if (!astring1[i1].equals(astring[i]))
                    {
                        ++i1;
                        continue;
                    }

                    b0 = abyte[i1];
                }

                if ((b0 & 1) == 0)
                {
                    stringbuilder.append(astring[i]);
                }
                else
                {
                    for (i1 = astring[i].length() - 1; i1 >= 0; --i1)
                    {
                        char c0 = astring[i].charAt(i1);

                        if (c0 == 40)
                        {
                            c0 = 41;
                        }
                        else if (c0 == 41)
                        {
                            c0 = 40;
                        }

                        stringbuilder.append(c0);
                    }
                }

                ++i;
                break;
            }
        }

        return stringbuilder.toString();
    }
    else
    {
        return par1Str;
    }
}
 
開發者ID:Archiving,項目名稱:ARKCraft-Code,代碼行數:81,代碼來源:SmallFontRenderer.java

示例11: bidiReorder

import java.text.Bidi; //導入方法依賴的package包/類
/**
 * Apply Unicode Bidirectional Algorithm to string and return a new possibly reordered string for visual rendering.
 */
private String bidiReorder(String par1Str) {
    if (par1Str != null && Bidi.requiresBidi(par1Str.toCharArray(), 0, par1Str.length())) {
        Bidi bidi = new Bidi(par1Str, -2);
        byte[] abyte = new byte[bidi.getRunCount()];
        String[] astring = new String[abyte.length];
        int i;

        for (int j = 0; j < abyte.length; ++j) {
            int k = bidi.getRunStart(j);
            i = bidi.getRunLimit(j);
            int l = bidi.getRunLevel(j);
            String s1 = par1Str.substring(k, i);
            abyte[j] = (byte) l;
            astring[j] = s1;
        }

        String[] astring1 = astring.clone();
        Bidi.reorderVisually(abyte, 0, astring, 0, abyte.length);
        StringBuilder stringbuilder = new StringBuilder();
        i = 0;

        while (i < astring.length) {
            byte b0 = abyte[i];
            int i1 = 0;

            while (true) {
                if (i1 < astring1.length) {
                    if (!astring1[i1].equals(astring[i])) {
                        ++i1;
                        continue;
                    }

                    b0 = abyte[i1];
                }

                if ((b0 & 1) == 0) {
                    stringbuilder.append(astring[i]);
                } else {
                    for (i1 = astring[i].length() - 1; i1 >= 0; --i1) {
                        char c0 = astring[i].charAt(i1);

                        if (c0 == 40) {
                            c0 = 41;
                        } else if (c0 == 41) {
                            c0 = 40;
                        }

                        stringbuilder.append(c0);
                    }
                }

                ++i;
                break;
            }
        }

        return stringbuilder.toString();
    } else {
        return par1Str;
    }
}
 
開發者ID:dmillerw,項目名稱:LoreExpansion_old,代碼行數:65,代碼來源:SmallFontRenderer.java

示例12: func_78283_c

import java.text.Bidi; //導入方法依賴的package包/類
private String func_78283_c(String p_78283_1_) {
   if(p_78283_1_ != null && Bidi.requiresBidi(p_78283_1_.toCharArray(), 0, p_78283_1_.length())) {
      Bidi var2 = new Bidi(p_78283_1_, -2);
      byte[] var3 = new byte[var2.getRunCount()];
      String[] var4 = new String[var3.length];

      int var7;
      for(int var5 = 0; var5 < var3.length; ++var5) {
         int var6 = var2.getRunStart(var5);
         var7 = var2.getRunLimit(var5);
         int var8 = var2.getRunLevel(var5);
         String var9 = p_78283_1_.substring(var6, var7);
         var3[var5] = (byte)var8;
         var4[var5] = var9;
      }

      String[] var11 = (String[])var4.clone();
      Bidi.reorderVisually(var3, 0, var4, 0, var3.length);
      StringBuilder var12 = new StringBuilder();
      var7 = 0;

      while(var7 < var4.length) {
         byte var13 = var3[var7];
         int var14 = 0;

         while(true) {
            if(var14 < var11.length) {
               if(!var11[var14].equals(var4[var7])) {
                  ++var14;
                  continue;
               }

               var13 = var3[var14];
            }

            if((var13 & 1) == 0) {
               var12.append(var4[var7]);
            } else {
               for(var14 = var4[var7].length() - 1; var14 >= 0; --var14) {
                  char var10 = var4[var7].charAt(var14);
                  if(var10 == 40) {
                     var10 = 41;
                  } else if(var10 == 41) {
                     var10 = 40;
                  }

                  var12.append(var10);
               }
            }

            ++var7;
            break;
         }
      }

      return var12.toString();
   } else {
      return p_78283_1_;
   }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:61,代碼來源:FontRenderer.java

示例13: bidiReorder

import java.text.Bidi; //導入方法依賴的package包/類
/**
 * Apply Unicode Bidirectional Algorithm to string and return a new possibly reordered string for visual rendering.
 */
private String bidiReorder(String par1Str)
{
    if (par1Str != null && Bidi.requiresBidi(par1Str.toCharArray(), 0, par1Str.length()))
    {
        Bidi bidi = new Bidi(par1Str, -2);
        byte[] abyte = new byte[bidi.getRunCount()];
        String[] astring = new String[abyte.length];
        int i;

        for (int j = 0; j < abyte.length; ++j)
        {
            int k = bidi.getRunStart(j);
            i = bidi.getRunLimit(j);
            int l = bidi.getRunLevel(j);
            String s1 = par1Str.substring(k, i);
            abyte[j] = (byte)l;
            astring[j] = s1;
        }

        String[] astring1 = (String[])astring.clone();
        Bidi.reorderVisually(abyte, 0, astring, 0, abyte.length);
        StringBuilder stringbuilder = new StringBuilder();
        i = 0;

        while (i < astring.length)
        {
            byte b0 = abyte[i];
            int i1 = 0;

            while (true)
            {
                if (i1 < astring1.length)
                {
                    if (!astring1[i1].equals(astring[i]))
                    {
                        ++i1;
                        continue;
                    }

                    b0 = abyte[i1];
                }

                if ((b0 & 1) == 0)
                {
                    stringbuilder.append(astring[i]);
                }
                else
                {
                    for (i1 = astring[i].length() - 1; i1 >= 0; --i1)
                    {
                        char c0 = astring[i].charAt(i1);

                        if (c0 == 40)
                        {
                            c0 = 41;
                        }
                        else if (c0 == 41)
                        {
                            c0 = 40;
                        }

                        stringbuilder.append(c0);
                    }
                }

                ++i;
                break;
            }
        }

        return stringbuilder.toString();
    }
    else
    {
        return par1Str;
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:81,代碼來源:FontRenderer.java


注:本文中的java.text.Bidi.getRunLimit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。