Java Code Examples for java.text.Bidi#baseIsLeftToRight()
The following examples show how to use
java.text.Bidi#baseIsLeftToRight() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextLine.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Create a TextLine from the text. chars is just the text in the iterator. */ public static TextLine standardCreateTextLine(FontRenderContext frc, AttributedCharacterIterator text, char[] chars, float[] baselineOffsets) { StyledParagraph styledParagraph = new StyledParagraph(text, chars); Bidi bidi = new Bidi(text); if (bidi.isLeftToRight()) { bidi = null; } int layoutFlags = 0; // no extra info yet, bidi determines run and line direction TextLabelFactory factory = new TextLabelFactory(frc, chars, bidi, layoutFlags); boolean isDirectionLTR = true; if (bidi != null) { isDirectionLTR = bidi.baseIsLeftToRight(); } return createLineFromText(chars, styledParagraph, factory, isDirectionLTR, baselineOffsets); }
Example 2
Source File: TextLine.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Create a TextLine from the text. chars is just the text in the iterator. */ public static TextLine standardCreateTextLine(FontRenderContext frc, AttributedCharacterIterator text, char[] chars, float[] baselineOffsets) { StyledParagraph styledParagraph = new StyledParagraph(text, chars); Bidi bidi = new Bidi(text); if (bidi.isLeftToRight()) { bidi = null; } int layoutFlags = 0; // no extra info yet, bidi determines run and line direction TextLabelFactory factory = new TextLabelFactory(frc, chars, bidi, layoutFlags); boolean isDirectionLTR = true; if (bidi != null) { isDirectionLTR = bidi.baseIsLeftToRight(); } return createLineFromText(chars, styledParagraph, factory, isDirectionLTR, baselineOffsets); }
Example 3
Source File: Helper.java From Android-RTEditor with Apache License 2.0 | 6 votes |
/** * This method determines if the direction of a substring is right-to-left. * If the string is empty that determination is based on the default system language * Locale.getDefault(). * The method can handle invalid substring definitions (start > end etc.), in which case the * method returns False. * * @return True if the text direction is right-to-left, false otherwise. */ public static boolean isRTL(CharSequence s, int start, int end) { if (s == null || s.length() == 0) { // empty string --> determine the direction from the default language return isRTL(Locale.getDefault()); } if (start == end) { // if no character is selected we need to expand the selection start = Math.max(0, --start); if (start == end) { end = Math.min(s.length(), ++end); } } try { Bidi bidi = new Bidi(s.subSequence(start, end).toString(), Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT); return ! bidi.baseIsLeftToRight(); } catch (IndexOutOfBoundsException e) { return false; } }
Example 4
Source File: TextLine.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Create a TextLine from the text. chars is just the text in the iterator. */ public static TextLine standardCreateTextLine(FontRenderContext frc, AttributedCharacterIterator text, char[] chars, float[] baselineOffsets) { StyledParagraph styledParagraph = new StyledParagraph(text, chars); Bidi bidi = new Bidi(text); if (bidi.isLeftToRight()) { bidi = null; } int layoutFlags = 0; // no extra info yet, bidi determines run and line direction TextLabelFactory factory = new TextLabelFactory(frc, chars, bidi, layoutFlags); boolean isDirectionLTR = true; if (bidi != null) { isDirectionLTR = bidi.baseIsLeftToRight(); } return createLineFromText(chars, styledParagraph, factory, isDirectionLTR, baselineOffsets); }
Example 5
Source File: TextLine.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Create a TextLine from the text. chars is just the text in the iterator. */ public static TextLine standardCreateTextLine(FontRenderContext frc, AttributedCharacterIterator text, char[] chars, float[] baselineOffsets) { StyledParagraph styledParagraph = new StyledParagraph(text, chars); Bidi bidi = new Bidi(text); if (bidi.isLeftToRight()) { bidi = null; } int layoutFlags = 0; // no extra info yet, bidi determines run and line direction TextLabelFactory factory = new TextLabelFactory(frc, chars, bidi, layoutFlags); boolean isDirectionLTR = true; if (bidi != null) { isDirectionLTR = bidi.baseIsLeftToRight(); } return createLineFromText(chars, styledParagraph, factory, isDirectionLTR, baselineOffsets); }
Example 6
Source File: TextLine.java From Java8CN with Apache License 2.0 | 6 votes |
/** * Create a TextLine from the text. chars is just the text in the iterator. */ public static TextLine standardCreateTextLine(FontRenderContext frc, AttributedCharacterIterator text, char[] chars, float[] baselineOffsets) { StyledParagraph styledParagraph = new StyledParagraph(text, chars); Bidi bidi = new Bidi(text); if (bidi.isLeftToRight()) { bidi = null; } int layoutFlags = 0; // no extra info yet, bidi determines run and line direction TextLabelFactory factory = new TextLabelFactory(frc, chars, bidi, layoutFlags); boolean isDirectionLTR = true; if (bidi != null) { isDirectionLTR = bidi.baseIsLeftToRight(); } return createLineFromText(chars, styledParagraph, factory, isDirectionLTR, baselineOffsets); }
Example 7
Source File: TextLine.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * Create a TextLine from the text. chars is just the text in the iterator. */ public static TextLine standardCreateTextLine(FontRenderContext frc, AttributedCharacterIterator text, char[] chars, float[] baselineOffsets) { StyledParagraph styledParagraph = new StyledParagraph(text, chars); Bidi bidi = new Bidi(text); if (bidi.isLeftToRight()) { bidi = null; } int layoutFlags = 0; // no extra info yet, bidi determines run and line direction TextLabelFactory factory = new TextLabelFactory(frc, chars, bidi, layoutFlags); boolean isDirectionLTR = true; if (bidi != null) { isDirectionLTR = bidi.baseIsLeftToRight(); } return createLineFromText(chars, styledParagraph, factory, isDirectionLTR, baselineOffsets); }
Example 8
Source File: TextLine.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Create a TextLine from the text. chars is just the text in the iterator. */ public static TextLine standardCreateTextLine(FontRenderContext frc, AttributedCharacterIterator text, char[] chars, float[] baselineOffsets) { StyledParagraph styledParagraph = new StyledParagraph(text, chars); Bidi bidi = new Bidi(text); if (bidi.isLeftToRight()) { bidi = null; } int layoutFlags = 0; // no extra info yet, bidi determines run and line direction TextLabelFactory factory = new TextLabelFactory(frc, chars, bidi, layoutFlags); boolean isDirectionLTR = true; if (bidi != null) { isDirectionLTR = bidi.baseIsLeftToRight(); } return createLineFromText(chars, styledParagraph, factory, isDirectionLTR, baselineOffsets); }
Example 9
Source File: TextLine.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Create a TextLine from the text. chars is just the text in the iterator. */ public static TextLine standardCreateTextLine(FontRenderContext frc, AttributedCharacterIterator text, char[] chars, float[] baselineOffsets) { StyledParagraph styledParagraph = new StyledParagraph(text, chars); Bidi bidi = new Bidi(text); if (bidi.isLeftToRight()) { bidi = null; } int layoutFlags = 0; // no extra info yet, bidi determines run and line direction TextLabelFactory factory = new TextLabelFactory(frc, chars, bidi, layoutFlags); boolean isDirectionLTR = true; if (bidi != null) { isDirectionLTR = bidi.baseIsLeftToRight(); } return createLineFromText(chars, styledParagraph, factory, isDirectionLTR, baselineOffsets); }
Example 10
Source File: Helper.java From memoir with Apache License 2.0 | 6 votes |
/** * This method determines if the direction of a substring is right-to-left. * If the string is empty that determination is based on the default system language * Locale.getDefault(). * The method can handle invalid substring definitions (start > end etc.), in which case the * method returns False. * * @return True if the text direction is right-to-left, false otherwise. */ public static boolean isRTL(CharSequence s, int start, int end) { if (s == null || s.length() == 0) { // empty string --> determine the direction from the default language return isRTL(Locale.getDefault()); } if (start == end) { // if no character is selected we need to expand the selection start = Math.max(0, --start); if (start == end) { end = Math.min(s.length(), ++end); } } try { Bidi bidi = new Bidi(s.subSequence(start, end).toString(), Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT); return ! bidi.baseIsLeftToRight(); } catch (IndexOutOfBoundsException e) { return false; } }
Example 11
Source File: BidiConformance.java From hottub with GNU General Public License v2.0 | 4 votes |
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); }
Example 12
Source File: BidiConformance.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
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); }
Example 13
Source File: BidiConformance.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
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); }
Example 14
Source File: BidiConformance.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
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); }
Example 15
Source File: BidiConformance.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
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); }
Example 16
Source File: BidiConformance.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
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); }
Example 17
Source File: BidiConformance.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
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); }
Example 18
Source File: BidiConformance.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
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); }
Example 19
Source File: BidiConformance.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
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); }
Example 20
Source File: BidiConformance.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
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); }