Package java.text

Examples of java.text.Bidi


            fChars[n++] = c;
        }
       
        text.first();
               
        fBidi = new Bidi(text);
        if (fBidi.isLeftToRight()) {
            fBidi = null;
        }

        text.first();
View Full Code Here


        int[] charsLtoV = null;
        byte[] charLevels = null;

        if (fBidi != null) {
            Bidi lineBidi = fBidi.createLineBidi(startPos, limitPos);
            charLevels = BidiUtils.getLevels(lineBidi);
            int[] charsVtoL = BidiUtils.createVisualToLogicalMap(charLevels);
            charsLtoV = BidiUtils.createInverseMap(charsVtoL);
        }
View Full Code Here

        fChars = newChars;
       
        if (fBidi != null || Bidi.requiresBidi(newChars, newCharIndex, newCharIndex + 1) ||
                newParagraph.getAttribute(TextAttribute.BIDI_EMBEDDING) != null) {

            fBidi = new Bidi(newParagraph);
            if (fBidi.isLeftToRight()) {
                fBidi = null;
            }
        }
       
View Full Code Here

        System.arraycopy(fChars, 0, newChars, 0, deletePos-fStart);
        System.arraycopy(fChars, changedIndex+1, newChars, changedIndex, end-deletePos);
        fChars = newChars;
       
        if (fBidi != null) {
            fBidi = new Bidi(newParagraph);
            if (fBidi.isLeftToRight()) {
                fBidi = null;
            }
        }
       
View Full Code Here

                                              Map attributes) {

        boolean isDirectionLTR = true;
        byte[] levels = null;
        int[] charsLtoV = null;
        Bidi bidi = null;
        int characterCount = chars.length;

        boolean requiresBidi = false;
        byte[] embs = null;

        AttributeValues values = null;
        if (attributes != null) {
            values = AttributeValues.fromMap(attributes);
            if (values.getRunDirection() >= 0) {
                isDirectionLTR = values.getRunDirection() == 0;
                requiresBidi = !isDirectionLTR;
            }
            if (values.getBidiEmbedding() != 0) {
                requiresBidi = true;
                byte level = (byte)values.getBidiEmbedding();
                embs = new byte[characterCount];
                for (int i = 0; i < embs.length; ++i) {
                    embs[i] = level;
                }
            }
        }

        // dlf: get baseRot from font for now???

        if (!requiresBidi) {
            requiresBidi = Bidi.requiresBidi(chars, 0, chars.length);
        }

        if (requiresBidi) {
          int bidiflags = values == null
              ? Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT
              : values.getRunDirection();

          bidi = new Bidi(chars, 0, embs, 0, chars.length, bidiflags);
          if (!bidi.isLeftToRight()) {
              levels = BidiUtils.getLevels(bidi);
              int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels);
              charsLtoV = BidiUtils.createInverseMap(charsVtoL);
              isDirectionLTR = bidi.baseIsLeftToRight();
          }
        }

        Decoration decorator = Decoration.getDecoration(values);
View Full Code Here

                                              boolean isDirectionLTR,
                                              float[] baselineOffsets) {

        factory.setLineContext(0, chars.length);

        Bidi lineBidi = factory.getLineBidi();
        int[] charsLtoV = null;
        byte[] levels = null;

        if (lineBidi != null) {
            levels = BidiUtils.getLevels(lineBidi);
View Full Code Here

                                                  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);
    }
View Full Code Here

    assertFalse(line.isRightToLeft());
  }

    public void testCreateLineBidiInvalid() {
        //regression for HARMONY-1050
        Bidi bidi = new Bidi("str", 1);
        try {
            bidi.createLineBidi(-1, 1);
            fail("Expected IAE");          
        } catch (IllegalArgumentException e) {
            // Expected
        }
       
        try {
            bidi.createLineBidi(1, -1);
            fail("Expected IAE");          
        } catch (IllegalArgumentException e) {
            // Expected
        }
       
        try {
            bidi.createLineBidi(-1, -1);
            fail("Expected IAE");          
        } catch (IllegalArgumentException e) {
            // Expected
        }

        try {
            bidi.createLineBidi(2, 1);
            fail("Expected IAE");          
        } catch (IllegalArgumentException e) {
            // Expected
        }
       
        bidi.createLineBidi(2, 2);

        try {
            bidi.createLineBidi(2, 4);
            fail("Expected IAE");          
        } catch (IllegalArgumentException e) {
            // Expected
        }
    }
View Full Code Here

        }
    }
   
  public void testIncompatibleLineAlgorithm() {
    // ICU treat a new line as in the same run, however RI does not
    bd = new Bidi("aaaaa".toCharArray(), 0,
        new byte[] { -2, -1, -3, -3, -2 }, 0, 5,
        Bidi.DIRECTION_RIGHT_TO_LEFT);
    Bidi line = bd.createLineBidi(1, 4);
    assertFalse(line.baseIsLeftToRight());
    assertEquals(1, line.getBaseLevel());
    assertEquals(3, line.getLength());
    assertEquals(1, line.getLevelAt(0));
    assertEquals(1, line.getLevelAt(1));
    assertEquals(1, line.getLevelAt(2));
    assertEquals(1, line.getLevelAt(1000));
    assertEquals(1, line.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 3, 1 }, }, line);
    assertFalse(line.isLeftToRight());
    assertFalse(line.isMixed());
    assertTrue(line.isRightToLeft());
  }
View Full Code Here

                {3, 5},
                {5, 7},
                {7, 9},
        };
       
        Bidi bi = new Bidi(defText, 0);
        final int count = bi.getRunCount();
        for (int i = 0; i < count; i++) {
            assertEquals(expectedRuns[i][0], bi.getRunStart(i));
            assertEquals(expectedRuns[i][1], bi.getRunLimit(i));
        }
    }
View Full Code Here

TOP

Related Classes of java.text.Bidi

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.