Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4410115

Exceptions not mentioned in java.awt.font.TextMeasurer

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.4.0
    • docs
    • beta
    • generic
    • generic
    • Verified



      Name: vsC120874 Date: 01/31/2001


      The docs for the methods in java.awt.font.TextMeasurer do not mention the
      Exceptions that should be thrown, nor do they all throw the same Exception.
      insertChar(AttributedCharacterIterator newParagraph, in insertPos) &
      deleteChar(AttributedCharacterIterator newParagraph, in deletePos) throws an
      ArrayIndexOutOfBoundsException for all values of insert/deletePos not in
      bounds.
      getAdvanceBetween(int start, int limit) , getLayout(int start, int limit) &
      getLineBreakIndex(int start, int advance) throw IllegalArgumentException for
      all values of start, limit and advance not in bounds.


      Sample code follows....

      import java.awt.font.TextMeasurer;
      import java.awt.font.TextLayout;
      import java.text.AttributedString;
      import java.awt.font.FontRenderContext;
      import java.awt.geom.AffineTransform;
      import java.text.AttributedCharacterIterator;
      import java.text.BreakIterator;

      public class test {
      public test() {
              String string = "01234567890123456789";
              AttributedCharacterIterator text = (new AttributedString(string)).
                  getIterator();
              FontRenderContext frc = new FontRenderContext(new AffineTransform(),
                  true, true);
              TextMeasurer measurer = new TextMeasurer(text, frc);

        try {
         measurer.getAdvanceBetween(-1,20);
        }
        catch (Exception exc) {
         System.out.println(exc);
        }

        try {
         String newstring = "0134567890123456789";
         AttributedCharacterIterator newtext = (new AttributedString(newstring)).
          getIterator();
         measurer.insertChar(newtext,-1);
        }
        catch (Exception exc) {
         System.out.println(exc);
        }

        try {
         String newstring = "0134567890123456789";
         AttributedCharacterIterator newtext = (new AttributedString(newstring)).
          getIterator();
         measurer.deleteChar(newtext,-1);
        }
        catch (Exception exc) {
         System.out.println(exc);
        }

      }

          public static void main(String[] args) {
             new test();
          }
      }

      ======================================================================

            jballsunw Jennifer Ball (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: