Package java.text

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


    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

        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

                                  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

                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

                                              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

      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

            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

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.