Package java.text

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


                                                  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

                                              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

    }
  }

  public void testNullPointerConstructor() {
    try {
      bd = new Bidi(null, Bidi.DIRECTION_RIGHT_TO_LEFT);
      fail("should throw IAE");
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      bd = new Bidi(null, 0, new byte[] { 0 }, 0, 0,
          Bidi.DIRECTION_RIGHT_TO_LEFT);
      fail("should throw IAE");
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
            bd = new Bidi(null);
            fail("should throw IAE");
        } catch (IllegalArgumentException e) {
        }

    bd = new Bidi("a".toCharArray(), 0, null, 0, 1,
        Bidi.DIRECTION_RIGHT_TO_LEFT);
  }
View Full Code Here

        Bidi.DIRECTION_RIGHT_TO_LEFT);
  }

  public void testBadLength() {
    try {
      bd = new Bidi("1".toCharArray(), 0, new byte[] { 0 }, 0, 20,
          Bidi.DIRECTION_RIGHT_TO_LEFT);
      fail("should throw IAE");
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      bd = new Bidi("1234567".toCharArray(), 0, new byte[] { 0 }, 0, 4,
          Bidi.DIRECTION_RIGHT_TO_LEFT);
      fail("should throw IAE");
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      bd = new Bidi("1234567".toCharArray(), 4, new byte[] { 0, 1, 2, 3,
          4 }, 0, 5, Bidi.DIRECTION_RIGHT_TO_LEFT);
      fail("should throw IAE");
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      bd = new Bidi("1234567".toCharArray(), 0, new byte[] { 0, 1, 2, 3,
          4 }, 4, 5, Bidi.DIRECTION_RIGHT_TO_LEFT);
      fail("should throw IAE");
    } catch (IllegalArgumentException e) {
      // expected
    }

        //regression for HARMONY-1031
    try {
      bd = new Bidi(new char[] { 't','t','t'}, -1, new byte[] { 2, 2 }, 1, 1, 1);
      fail("should be IAE");         
    } catch (IllegalArgumentException e) {
      // expected
    }
   
    try {
      bd = new Bidi(new char[] { 't','t','t'}, 1, new byte[] { 2, 2 }, -1, 1, 1);
      fail("should be IAE");         
    } catch (IllegalArgumentException e) {
      // expected
    }
   
    try {
      bd = new Bidi(new char[] { 't','t','t'}, 1, new byte[] { 2, 2 }, 1, -1, 1);
      fail("should be IAE");         
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      bd = new Bidi(new char[] {}, 5, new byte[] { 2, 2, 2, 2, 2, 2 }, 8, Integer.MAX_VALUE, 5);
      fail("should be IAE");         
    } catch (IllegalArgumentException e) {
      // expected
    }

        try {
            bd = new Bidi(null, 5, null, 8, Integer.MAX_VALUE, 5);
            fail("should be IAE");                 
        } catch (IllegalArgumentException e) {
            // expected
        }
       
    bd = new Bidi(new char[] {'o'}, 0, new byte[] { 2, 2}, 2, 0, 2 );
  }
View Full Code Here

       
    bd = new Bidi(new char[] {'o'}, 0, new byte[] { 2, 2}, 2, 0, 2 );
  }

  public void testEmptyParagraph() {
    bd = new Bidi("", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(0, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 0, 0 } }, bd);
    assertTrue(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi("", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(0, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 0, 1 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertTrue(bd.isRightToLeft());

    bd = new Bidi("", Bidi.DIRECTION_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(0, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 0, 0 }, }, bd);
    assertTrue(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi("", Bidi.DIRECTION_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(0, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1000));
View Full Code Here

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

  public void testSpaceParagraph() {
    bd = new Bidi(" ", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 0 }, }, bd);
    assertTrue(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi(" ", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 1 }, }, bd);
    assertFalse(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertTrue(bd.isRightToLeft());

    bd = new Bidi(" ", Bidi.DIRECTION_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 0 }, }, bd);
    assertTrue(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi(" ", Bidi.DIRECTION_RIGHT_TO_LEFT);
    assertFalse(bd.baseIsLeftToRight());
    assertEquals(1, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(1, bd.getLevelAt(0));
    assertEquals(1, bd.getLevelAt(1000));
View Full Code Here

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

  public void testSimpleParagraph() {
    bd = new Bidi("t", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 0 }, }, bd);
    assertTrue(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi("t", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
    assertEquals(1, bd.getRunCount());
    assertRunArrayEquals(new int[][] { { 0, 1, 0 }, }, bd);
    assertTrue(bd.isLeftToRight());
    assertFalse(bd.isMixed());
    assertFalse(bd.isRightToLeft());

    bd = new Bidi("t", Bidi.DIRECTION_LEFT_TO_RIGHT);
    assertTrue(bd.baseIsLeftToRight());
    assertEquals(0, bd.getBaseLevel());
    assertEquals(1, bd.getLength());
    assertEquals(0, bd.getLevelAt(0));
    assertEquals(0, bd.getLevelAt(1000));
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.