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


Java Bidi.reorderVisually方法代碼示例

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


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

示例1: visualSortedCopy

import java.text.Bidi; //導入方法依賴的package包/類
static List<ILayoutElement> visualSortedCopy(List<ILayoutElement> elems) {
    ILayoutElement[] elemsArray = new ILayoutElement[elems.size()];
    byte[] bidiLevels = new byte[elemsArray.length];

    int t = 0;
    for (ILayoutElement elem : elems) {
        elemsArray[t] = elem;
        bidiLevels[t] = 0;
        if (elem instanceof ITextElement) {
            ITextElement textElem = (ITextElement)elem;
            bidiLevels[t] = (byte)textElem.getBidiLevel();
        }
        t++;
    }

    Bidi.reorderVisually(bidiLevels, 0, elemsArray, 0, elemsArray.length);

    return Arrays.asList(elemsArray);
}
 
開發者ID:anonl,項目名稱:gdx-styledtext,代碼行數:20,代碼來源:LayoutUtil.java

示例2: testReorderVisually

import java.text.Bidi; //導入方法依賴的package包/類
public void testReorderVisually() {
	String[] init = new String[] { "a", "b", "c", "d" };
	String[] s = new String[4];

	System.arraycopy(init, 0, s, 0, s.length);
	Bidi.reorderVisually(new byte[] { 2, 1, 3, 0 }, 0, s, 0, 4);
	assertEquals("[c, b, a, d]", Arrays.asList(s).toString());

	System.arraycopy(init, 0, s, 0, s.length);
	Bidi.reorderVisually(new byte[] { 1, 3 }, 0, s, 1, 2);
	assertEquals("[a, c, b, d]", Arrays.asList(s).toString());

	System.arraycopy(init, 0, s, 0, s.length);
	Bidi.reorderVisually(new byte[] { 2, 1, 3, 0 }, 1, s, 1, 2);
	assertEquals("[a, c, b, d]", Arrays.asList(s).toString());

	System.arraycopy(init, 0, s, 0, s.length);
	Bidi.reorderVisually(new byte[] { 2, 1, 2, 1 }, 1, s, 0, 3);
	assertEquals("[c, b, a, d]", Arrays.asList(s).toString());

	System.arraycopy(init, 0, s, 0, s.length);
	Bidi.reorderVisually(new byte[] { 2, 1, 0, 1 }, 1, s, 0, 3);
	assertEquals("[a, b, c, d]", Arrays.asList(s).toString());
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:25,代碼來源:BidiTest.java

示例3: 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

示例4: layoutBidi

import java.text.Bidi; //導入方法依賴的package包/類
private int layoutBidi(String str) {
	final char[] text = str.toCharArray();

	/* Avoid performing full bidirectional analysis if text has no "strong" right-to-left characters */
	if (!Bidi.requiresBidi(text, 0, text.length))
		return layoutFont(text, 0, text.length, Font.LAYOUT_LEFT_TO_RIGHT);

	final Bidi bidi = new Bidi(text, 0, null, 0, text.length, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);

	/* If text is entirely right-to-left, then just lay it out */
	if (bidi.isRightToLeft())
		return layoutFont(text, 0, text.length, Font.LAYOUT_RIGHT_TO_LEFT);

	/* Otherwise text has a mixture of LTR and RLT, and it requires full bidirectional analysis */
	final int runCount = bidi.getRunCount();
	final byte[] levels = new byte[runCount];
	final Integer[] ranges = new Integer[runCount];

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

	int width = 0;

	for (int i = 0; i < runCount; i++) {
		final int index = ranges[i];
		width += layoutFont(text, bidi.getRunStart(index), bidi.getRunLimit(index), (bidi.getRunLevel(index) & 1));
	}
	return width;
}
 
開發者ID:ImpactDevelopment,項目名稱:ClientAPI,代碼行數:33,代碼來源:FontCache.java

示例5: testMethod_reorderVisually1

import java.text.Bidi; //導入方法依賴的package包/類
private void testMethod_reorderVisually1() {
    System.out.println("*** Test reorderVisually() 1");

    for (int textNo = 0; textNo < data4reorderVisually.length; textNo++) {
        Object[] objects = data4reorderVisually[textNo][0];
        byte[] levels = getLevels(data4reorderVisually[textNo]);
        Object[] expectedObjects = data4reorderVisually[textNo][2];

        Bidi.reorderVisually(levels, 0, objects, 0, objects.length);

        checkResult("textNo=" + textNo + ": reorderVisually(levels=[" +
            toString(levels) + "], objects=[" + toString(objects) + "])",
            expectedObjects, objects);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:16,代碼來源:BidiConformance.java

示例6: reorderRunsVisually

import java.text.Bidi; //導入方法依賴的package包/類
private static void reorderRunsVisually(BidiRun[] bidiRuns) {
  if (bidiRuns.length > 1) {
    byte[] levels = new byte[bidiRuns.length];
    for (int i = 0; i < bidiRuns.length; i++) {
      levels[i] = bidiRuns[i].level;
    }
    Bidi.reorderVisually(levels, 0, bidiRuns, 0, levels.length);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:LineLayout.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: layoutBidiString

import java.text.Bidi; //導入方法依賴的package包/類
/**
     * Split a string into contiguous LTR or RTL sections by applying the Unicode Bidirectional Algorithm. Calls layoutString()
     * for each contiguous run to perform further analysis.
     *
     * @param glyphList will hold all new Glyph objects allocated by layoutFont()
     * @param text      the string to lay out
     * @param start     the offset into text at which to start the layout
     * @param limit     the (offset + length) at which to stop performing the layout
     * @return the total advance (horizontal distance) of this string
     */
    private int layoutBidiString(List<Glyph> glyphList, char text[], int start, int limit, ColorCode colors[])
    {
        int advance = 0;

        /* Avoid performing full bidirectional analysis if text has no "strong" right-to-left characters */
        if (Bidi.requiresBidi(text, start, limit))
        {
            /* Note that while requiresBidi() uses start/limit the Bidi constructor uses start/length */
            Bidi bidi = new Bidi(text, start, null, 0, limit - start, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);

            /* If text is entirely right-to-left, then insert an EntryText node for the entire string */
            if (bidi.isRightToLeft())
            {
                return layoutStyle(glyphList, text, start, limit, Font.LAYOUT_RIGHT_TO_LEFT, advance, colors);
            }

            /* Otherwise text has a mixture of LTR and RLT, and it requires full bidirectional analysis */
            else
            {
                int runCount = bidi.getRunCount();
                byte levels[] = new byte[runCount];
                Integer ranges[] = new Integer[runCount];

                /* Reorder contiguous runs of text into their display order from left to right */
                for (int index = 0; index < runCount; index++)
                {
                    levels[index] = (byte) bidi.getRunLevel(index);
                    ranges[index] = new Integer(index);
                }
                Bidi.reorderVisually(levels, 0, ranges, 0, runCount);

                /*
* Every GlyphVector must be created on a contiguous run of left-to-right or right-to-left text. Keep track of
* the horizontal advance between each run of text, so that the glyphs in each run can be assigned a position relative
* to the start of the entire string and not just relative to that run.
*/
                for (int visualIndex = 0; visualIndex < runCount; visualIndex++)
                {
                    int logicalIndex = ranges[visualIndex];

                    /* An odd numbered level indicates right-to-left ordering */
                    int layoutFlag = (bidi.getRunLevel(logicalIndex) & 1) == 1 ? Font.LAYOUT_RIGHT_TO_LEFT : Font.LAYOUT_LEFT_TO_RIGHT;
                    advance = layoutStyle(glyphList, text, start + bidi.getRunStart(logicalIndex), start + bidi.getRunLimit(logicalIndex),
                                          layoutFlag, advance, colors);
                }
            }

            return advance;
        }

        /* If text is entirely left-to-right, then insert an EntryText node for the entire string */
        else
        {
            return layoutStyle(glyphList, text, start, limit, Font.LAYOUT_LEFT_TO_RIGHT, advance, colors);
        }
    }
 
開發者ID:cubex2,項目名稱:BetterFonts,代碼行數:67,代碼來源:StringCache.java

示例9: 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

示例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: layoutBidiString

import java.text.Bidi; //導入方法依賴的package包/類
/**
 * Split a string into contiguous LTR or RTL sections by applying the Unicode Bidirectional Algorithm. Calls layoutString()
 * for each contiguous run to perform further analysis.
 *
 * @param glyphList will hold all new Glyph objects allocated by layoutFont()
 * @param text      the string to lay out
 * @param start     the offset into text at which to start the layout
 * @param limit     the (offset + length) at which to stop performing the layout
 * @return the total advance (horizontal distance) of this string
 */
private int layoutBidiString(List<Glyph> glyphList, char text[], int start, int limit, ColorCode colors[]) {
    int advance = 0;

    /* Avoid performing full bidirectional analysis if text has no "strong" right-to-left characters */
    if (Bidi.requiresBidi(text, start, limit)) {
        /* Note that while requiresBidi() uses start/limit the Bidi constructor uses start/length */
        Bidi bidi = new Bidi(text, start, null, 0, limit - start, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);

        /* If text is entirely right-to-left, then insert an EntryText node for the entire string */
        if (bidi.isRightToLeft()) {
            return layoutStyle(glyphList, text, start, limit, Font.LAYOUT_RIGHT_TO_LEFT, advance, colors);
        }

        /* Otherwise text has a mixture of LTR and RLT, and it requires full bidirectional analysis */
        else {
            int runCount = bidi.getRunCount();
            byte levels[] = new byte[runCount];
            Integer ranges[] = new Integer[runCount];

            /* Reorder contiguous runs of text into their display order from left to right */
            for (int index = 0; index < runCount; index++) {
                levels[index] = (byte) bidi.getRunLevel(index);
                ranges[index] = new Integer(index);
            }
            Bidi.reorderVisually(levels, 0, ranges, 0, runCount);

            /*
             * Every GlyphVector must be created on a contiguous run of left-to-right or right-to-left text. Keep track of
             * the horizontal advance between each run of text, so that the glyphs in each run can be assigned a position relative
             * to the start of the entire string and not just relative to that run.
             */
            for (int visualIndex = 0; visualIndex < runCount; visualIndex++) {
                int logicalIndex = ranges[visualIndex];

                /* An odd numbered level indicates right-to-left ordering */
                int layoutFlag = (bidi.getRunLevel(logicalIndex) & 1) == 1 ? Font.LAYOUT_RIGHT_TO_LEFT : Font.LAYOUT_LEFT_TO_RIGHT;
                advance = layoutStyle(glyphList, text, start + bidi.getRunStart(logicalIndex), start + bidi.getRunLimit(logicalIndex),
                        layoutFlag, advance, colors);
            }
        }

        return advance;
    }

    /* If text is entirely left-to-right, then insert an EntryText node for the entire string */
    else {
        return layoutStyle(glyphList, text, start, limit, Font.LAYOUT_LEFT_TO_RIGHT, advance, colors);
    }
}
 
開發者ID:chedim,項目名稱:minedriod,代碼行數:60,代碼來源:StringCache.java

示例12: 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

示例13: 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

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