Examples of Bidi


Examples of java.text.Bidi

    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());
  }

  public void testComplicatedOverrideBidi() {
    bd = new Bidi("a\u05D0a\"a\u05D0\"\u05D0a".toCharArray(), 0,
        new byte[] { 0, 0, 0, -3, -3, 2, 2, 0, 3 }, 0, 9,
        Bidi.DIRECTION_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(9, bd.getLength());
View Full Code Here

Examples of java.text.Bidi

    assertFalse(Bidi.requiresBidi("aa\u05D0a".toCharArray(), 0, 2));
    assertTrue(Bidi.requiresBidi("aa\u05D0a".toCharArray(), 1, 3));
  }

  public void testHebrewOverrideEmbeddings() {
    bd = new Bidi(new char[] { '\u05D0', '\u05D0', '\u05D0' }, 0,
        new byte[] { (byte) -1, (byte) -2, (byte) -3 }, 0, 3,
        Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(3, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(2, bd.getLevelAt(1));
    assertEquals(3, bd.getLevelAt(2));
    assertEquals(1, bd.getLevelAt(1000));
    assertEquals(3, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 },
        { 2, 3, 3 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi(new char[] { '\u05D0', '\u05D0', '\u05D0' }, 0,
        new byte[] { (byte) -1, (byte) -2, (byte) -3 }, 0, 3,
        Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(3, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(2, bd.getLevelAt(1));
    assertEquals(3, bd.getLevelAt(2));
    assertEquals(1, bd.getLevelAt(1000));
    assertEquals(3, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 },
        { 2, 3, 3 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi(new char[] { '\u05D0', '\u05D0', '\u05D0' }, 0,
        new byte[] { (byte) -1, (byte) -2, (byte) -3 }, 0, 3,
        Bidi.DIRECTION_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(3, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(2, bd.getLevelAt(1));
    assertEquals(3, bd.getLevelAt(2));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(3, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 },
        { 2, 3, 3 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi(new char[] { '\u05D0', '\u05D0', '\u05D0' }, 0,
        new byte[] { (byte) -1, (byte) -2, (byte) -3 }, 0, 3,
        Bidi.DIRECTION_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(3, bd.getLength());
View Full Code Here

Examples of java.text.Bidi

    assertTrue(bd.isMixed());
    assertFalse(bd.isRightToLeft());
  }

  public void testCreateLineBidi() {
    bd = new Bidi("a\u05D0a\na\u05D0\"\u05D0a".toCharArray(), 0,
        new byte[] { 0, 0, 0, -3, -3, 2, 2, 0, 3 }, 0, 9,
        Bidi.DIRECTION_RIGHT_TO_LEFT);
    Bidi line = bd.createLineBidi(2, 7);
    assertFalse(line.baseIsLeftToRight());
    assertEquals(1, line.getBaseLevel());
    assertEquals(5, line.getLength());
    assertEquals(2, line.getLevelAt(0));
    assertEquals(1, line.getLevelAt(1));
    assertEquals(3, line.getLevelAt(2));
    assertEquals(3, line.getLevelAt(3));
    assertEquals(2, line.getLevelAt(4));
    assertEquals(1, line.getLevelAt(1000));
    assertEquals(4, line.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 2 }, { 1, 2, 1 },
        { 2, 4, 3 }, { 4, 5, 2 }, }, line);
    assertFalse(line.isLeftToRight());
    assertTrue(line.isMixed());
    assertFalse(line.isRightToLeft());
  }
View Full Code Here

Examples of java.text.Bidi

    harness.check(buf.toString(), expected);
  }

  public void test(TestHarness harness)
  {
    Bidi b;

    harness.checkPoint("simple");
    b = new Bidi("hi bob", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    testOne(harness, b, "000000");
    harness.check(b.baseIsLeftToRight());
    harness.check(b.isLeftToRight());
    harness.check(b.getRunCount(), 1);

    harness.checkPoint("one embedding");
    b = new Bidi("hi \u202bbob", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    testOne(harness, b, "0002222");

    harness.checkPoint("override");
    b = new Bidi("hi \u202ebob", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    testOne(harness, b, "0001111");

    harness.checkPoint("override and pop");
    b = new Bidi("car means \u202eCAR\u202c.",
        Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    testOne(harness, b, "0000000000111100");
    b = new Bidi("car \u202eMEANS CAR\u202c.",
          Bidi.DIRECTION_RIGHT_TO_LEFT);
    testOne(harness, b, "2221333333333311");
  }
View Full Code Here

Examples of java.text.Bidi

        try {
            content.getChars(parStart, parLen, text);
        } catch (final BadLocationException e) { }

        Bidi bidi = new Bidi(text.array, text.offset, null, 0, text.count,
                             getDefaultDirection(par));

        final int runCount = bidi.getRunCount();
        for (int i = 0; i < runCount; i++) {
            int level = bidi.getRunLevel(i);

            if (i == 0 && added.size() > 0) {
                Element prevBidi = (Element)added.get(added.size() - 1);
                if (getBidiLevel(prevBidi) == level) {
                    added.remove(added.size() - 1);
                    added.add(new BidiElement(prevBidi.getAttributes(),
                                              prevBidi.getStartOffset(),
                                              parStart + bidi.getRunLimit(i)));
                    continue;
                }
            }

            added.add(
                new BidiElement(context.addAttribute(context.getEmptySet(),
                                                     StyleConstants.BidiLevel,
                                                     new Integer(level)),
                                parStart + bidi.getRunStart(i),
                                parStart + bidi.getRunLimit(i)));
        }

    }
View Full Code Here

Examples of java.text.Bidi

                                  text.offset + text.count)) {

            return false;
        }

        final Bidi bidi = new Bidi(text.array, text.offset, null, 0, text.count,
                                   getDefaultDirection(offset));

        if (hasBidiInfo && !bidi.isMixed()
            && isLeftToRight(offset) == bidi.isLeftToRight()) {

            return false;
        }

        if (!hasBidiInfo) {
View Full Code Here

Examples of java.text.Bidi

                getText(pStart, pEnd-pStart, seg);
            } catch (BadLocationException e ) {
                throw new Error("Internal error: " + e.toString());
            }
            // REMIND(bcb) we should really be using a Segment here.
            Bidi bidiAnalyzer;
            int bidiflag = Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT;
            if (direction != null) {
                if (TextAttribute.RUN_DIRECTION_LTR.equals(direction)) {
                    bidiflag = Bidi.DIRECTION_LEFT_TO_RIGHT;
                } else {
                    bidiflag = Bidi.DIRECTION_RIGHT_TO_LEFT;
                }
            }
            bidiAnalyzer = new Bidi(seg.array, seg.offset, null, 0, seg.count,
                    bidiflag);
            BidiUtils.getLevels(bidiAnalyzer, levels, levelsEnd);
            levelsEnd += bidiAnalyzer.getLength();

            o =  p.getEndOffset();
            SegmentCache.releaseSharedSegment(seg);
        }
View Full Code Here

Examples of java.text.Bidi

                                              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

Examples of java.text.Bidi

                                                  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

Examples of java.text.Bidi

      labelSize = 0;

      if (bidiRequired)
      {
        Bidi bidi = new Bidi(label,
            Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);

        int runCount = bidi.getRunCount();

        if (rtlGlyphVectors == null
            || rtlGlyphVectors.length != runCount)
        {
          rtlGlyphVectors = new GlyphVector[runCount];
        }

        for (int i = 0; i < bidi.getRunCount(); i++)
        {
          final String labelSection = label.substring(
              bidi.getRunStart(i), bidi.getRunLimit(i));
          rtlGlyphVectors[i] = font
              .layoutGlyphVector(mxCurveLabelShape.frc,
                  labelSection.toCharArray(), 0,
                  labelSection.length(),
                  Font.LAYOUT_RIGHT_TO_LEFT);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.