/**
   * @tests java.text.AttributedString#AttributedString(AttributedCharacterIterator, int, int, Map<?
   *     extends AttributedCharacterIterator.Attribute,?>) Test of method
   *     java.text.AttributedString#AttributedString(AttributedCharacterIterator, int, int, Map<?
   *     extends AttributedCharacterIterator.Attribute,?>). Case 1: Try to construct
   *     AttributedString. Case 2: Try to construct AttributedString using 0-length text and not an
   *     empty Map attributes.
   */
  public void test_ConstructorLjava_lang_StringLjava_util_Map() {
    String test = "Test string";

    // case 1: Try to construct AttributedString
    try {
      AttributedString attrString =
          new AttributedString(
              test, new WeakHashMap<AttributedCharacterIterator.Attribute, String>());
      AttributedCharacterIterator it = attrString.getIterator();
      StringBuffer buf = new StringBuffer();
      buf.append(it.first());
      char ch;
      while ((ch = it.next()) != CharacterIterator.DONE) buf.append(ch);
      assertTrue("Wrong string: " + buf, buf.toString().equals(test));
    } catch (Exception e) {
      fail("Unexpected exception " + e.toString());
    }

    // case 2: Try to construct AttributedString using 0-length text and
    // not an empty Map attributes.
    try {
      Map<AttributedCharacterIterator.Attribute, String> whm =
          new WeakHashMap<AttributedCharacterIterator.Attribute, String>();
      whm.put(new TestAttributedCharacterIteratorAttribute("test"), "value");
      new AttributedString("", whm);
      fail("Expected IllegalArgumentException was not thrown");
    } catch (Exception e) {
      // expected
    }
  }
Пример #2
0
  /**
   * Updates the <code>TextMeasurer</code> after a single character has been deleted from the
   * paragraph currently represented by this <code>TextMeasurer</code>. After this call, this <code>
   * TextMeasurer</code> is equivalent to a new <code>TextMeasurer</code> created from the text;
   * however, it will usually be more efficient to update an existing <code>TextMeasurer</code> than
   * to create a new one from scratch.
   *
   * @param newParagraph the text of the paragraph after performing the deletion. Cannot be null.
   * @param deletePos the position in the text where the character was removed. Must not be less
   *     than the start of <code>newParagraph</code>, and must not be greater than the end of <code>
   *     newParagraph</code>.
   * @throws IndexOutOfBoundsException if <code>deletePos</code> is less than the start of <code>
   *     newParagraph</code> or greater than the end of <code>newParagraph</code>
   * @throws NullPointerException if <code>newParagraph</code> is <code>null</code>
   */
  public void deleteChar(AttributedCharacterIterator newParagraph, int deletePos) {

    fStart = newParagraph.getBeginIndex();
    int end = newParagraph.getEndIndex();
    if (end - fStart != fChars.length - 1) {
      initAll(newParagraph);
    }

    char[] newChars = new char[end - fStart];
    int changedIndex = deletePos - fStart;

    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;
      }
    }

    fParagraph = StyledParagraph.deleteChar(newParagraph, fChars, deletePos, fParagraph);
    invalidateComponents();
  }
  /**
   * Return a StyledParagraph reflecting the insertion of a single character into the text. This
   * method will attempt to reuse the given paragraph, but may create a new paragraph.
   *
   * @param aci an iterator over the text. The text should be the same as the text used to create
   *     (or most recently update) oldParagraph, with the exception of inserting a single character
   *     at insertPos.
   * @param chars the characters in aci
   * @param insertPos the index of the new character in aci
   * @param oldParagraph a StyledParagraph for the text in aci before the insertion
   */
  public static StyledParagraph insertChar(
      AttributedCharacterIterator aci, char[] chars, int insertPos, StyledParagraph oldParagraph) {

    // If the styles at insertPos match those at insertPos-1,
    // oldParagraph will be reused.  Otherwise we create a new
    // paragraph.

    char ch = aci.setIndex(insertPos);
    int relativePos = Math.max(insertPos - aci.getBeginIndex() - 1, 0);

    Map attributes = addInputMethodAttrs(aci.getAttributes());
    Decoration d = Decoration.getDecoration(attributes);
    if (!oldParagraph.getDecorationAt(relativePos).equals(d)) {
      return new StyledParagraph(aci, chars);
    }
    Object f = getGraphicOrFont(attributes);
    if (f == null) {
      FontResolver resolver = FontResolver.getInstance();
      int fontIndex = resolver.getFontIndex(ch);
      f = resolver.getFont(fontIndex, attributes);
    }
    if (!oldParagraph.getFontOrGraphicAt(relativePos).equals(f)) {
      return new StyledParagraph(aci, chars);
    }

    // insert into existing paragraph
    oldParagraph.length += 1;
    if (oldParagraph.decorations != null) {
      insertInto(relativePos, oldParagraph.decorationStarts, oldParagraph.decorations.size());
    }
    if (oldParagraph.fonts != null) {
      insertInto(relativePos, oldParagraph.fontStarts, oldParagraph.fonts.size());
    }
    return oldParagraph;
  }
  public Format.Field[] getFields(final int offset) {
    if (format == null) {
      return null;
    }

    Object value = getFormattedTextField().getValue();
    if (value == null) {
      return null;
    }

    AttributedCharacterIterator iterator = format.formatToCharacterIterator(value);
    if (offset < iterator.getBeginIndex() || offset > iterator.getEndIndex()) {
      return new Format.Field[0];
    }

    iterator.setIndex(offset);
    Set keys = iterator.getAttributes().keySet();
    Set result = new HashSet();
    Iterator iter = keys.iterator();

    while (iter.hasNext()) {
      Object key = iter.next();
      if (key instanceof Format.Field) {
        result.add(key);
      }
    }

    return (Format.Field[]) result.toArray(new Format.Field[result.size()]);
  }
Пример #5
0
 /**
  * Called when a user processing input characters and select candidates from input method.
  *
  * @param text Text from InputMethodEvent.
  * @param commited_count Numbers of committed characters in text.
  */
 public void processCompositionText(AttributedCharacterIterator text, int committed_count) {
   int layoutCaretPosition = initialCaretPosition + committed_count;
   CompositionTextPainter compositionPainter = textArea.getPainter().getCompositionTextpainter();
   compositionPainter.setComposedTextLayout(
       getTextLayout(text, committed_count), layoutCaretPosition);
   int textLength = text.getEndIndex() - text.getBeginIndex() - committed_count;
   StringBuffer unCommitedStringBuf = new StringBuffer(textLength);
   char c;
   for (c = text.setIndex(committed_count);
       c != AttributedCharacterIterator.DONE && textLength > 0;
       c = text.next(), --textLength) {
     unCommitedStringBuf.append(c);
   }
   String unCommittedString = unCommitedStringBuf.toString();
   try {
     if (canRemovePreviousInput(committed_count)) {
       textArea.getDocument().remove(layoutCaretPosition, prevComposeString.length());
     }
     textArea.getDocument().insertString(layoutCaretPosition, unCommittedString, null);
     if (committed_count > 0) {
       initialCaretPosition = initialCaretPosition + committed_count;
     }
     prevComposeString = unCommittedString;
     prevCommittedCount = committed_count;
   } catch (BadLocationException e) {
     e.printStackTrace();
   }
 }
Пример #6
0
  private synchronized void addLines() {
    AttributedString aText = prepareAttributedString();
    AttributedCharacterIterator styledTextIterator = aText.getIterator();

    List<Integer> newlineLocations = getNewlineLocations(styledTextIterator);
    LineBreakMeasurer lbm = new LineBreakMeasurer(styledTextIterator, getRenderContext());

    float width = (float) consumableArea.width;
    if (width <= 0) return;

    TextLayout layout;
    int startOfNextLayout;

    int currentLine = 0;
    int endIndex = styledTextIterator.getEndIndex();

    do {
      if (currentLine < newlineLocations.size())
        startOfNextLayout = newlineLocations.get(currentLine) + 1;
      else startOfNextLayout = endIndex + 1;

      layout = lbm.nextLayout(width, startOfNextLayout, false);

      lines.add(layout);

      if (lbm.getPosition() == startOfNextLayout) currentLine += 1;
    } while (layout != null && lbm.getPosition() < endIndex);
  }
 /**
  * Calculates the layout.
  *
  * @param fontRenderContext the FontRenderContext
  * @param font the Font
  * @param text the text
  * @param layoutWidth the width of the layout area
  * @return the layout result
  */
 public MultilineLayout calculateLayout(
     FontRenderContext fontRenderContext, Font font, String text, double layoutWidth) {
   // Layout multiline text
   MultilineLayout result = new MultilineLayout();
   if (text == null || text.isEmpty()) return result;
   Map<TextAttribute, Object> styleMap = new HashMap<TextAttribute, Object>();
   styleMap.put(TextAttribute.FONT, font);
   String[] textlines = text.split("\n");
   double height = 0;
   for (String textline : textlines) {
     AttributedString attribText = new AttributedString(textline, styleMap);
     AttributedCharacterIterator iter = attribText.getIterator();
     int textStart = iter.getBeginIndex();
     int textEnd = iter.getEndIndex();
     LineBreakMeasurer measurer = new LineBreakMeasurer(iter, fontRenderContext);
     measurer.setPosition(textStart);
     while (measurer.getPosition() < textEnd) {
       TextLayout line = measurer.nextLayout((float) layoutWidth);
       result.addLine(line);
       height += (line.getAscent() + line.getDescent() + line.getLeading());
     }
   }
   result.setSize(layoutWidth, height);
   return result;
 }
Пример #8
0
  public List getTextRuns(TextNode node, AttributedCharacterIterator aci) {
    List textRuns = node.getTextRuns();
    if (textRuns != null) {
      return textRuns;
    }

    AttributedCharacterIterator[] chunkACIs = getTextChunkACIs(aci);
    textRuns = computeTextRuns(node, aci, chunkACIs);

    aci.first();
    List rgns = (List) aci.getAttribute(FLOW_REGIONS);

    if (rgns != null) {
      Iterator i = textRuns.iterator();
      List chunkLayouts = new ArrayList();
      TextRun tr = (TextRun) i.next();
      List layouts = new ArrayList();
      chunkLayouts.add(layouts);
      layouts.add(tr.getLayout());
      while (i.hasNext()) {
        tr = (TextRun) i.next();
        if (tr.isFirstRunInChunk()) {
          layouts = new ArrayList();
          chunkLayouts.add(layouts);
        }
        layouts.add(tr.getLayout());
      }

      FlowExtGlyphLayout.textWrapTextChunk(chunkACIs, chunkLayouts, rgns);
    }

    node.setTextRuns(textRuns);
    return textRuns;
  }
Пример #9
0
  /**
   * InputMethod implementation For details read
   * http://docs.oracle.com/javase/7/docs/technotes/guides/imf/api-tutorial.html
   */
  @Override
  protected void processInputMethodEvent(InputMethodEvent e) {
    int commitCount = e.getCommittedCharacterCount();

    if (commitCount > 0) {
      myInputMethodUncommitedChars = null;
      AttributedCharacterIterator text = e.getText();
      if (text != null) {
        StringBuilder sb = new StringBuilder();

        //noinspection ForLoopThatDoesntUseLoopVariable
        for (char c = text.first(); commitCount > 0; c = text.next(), commitCount--) {
          if (c >= 0x20
              && c
                  != 0x7F) { // Hack just like in
                             // javax.swing.text.DefaultEditorKit.DefaultKeyTypedAction
            sb.append(c);
          }
        }

        myTerminalStarter.sendString(sb.toString());
      }
    } else {
      myInputMethodUncommitedChars = uncommitedChars(e.getText());
    }
  }
Пример #10
0
 protected void clicked(CharPos pos) {
   AttributedCharacterIterator inf = pos.part.ti();
   inf.setIndex(pos.ch.getCharIndex());
   FuckMeGentlyWithAChainsaw url =
       (FuckMeGentlyWithAChainsaw) inf.getAttribute(ChatAttribute.HYPERLINK);
   if ((url != null) && (WebBrowser.self != null)) WebBrowser.self.show(url.url);
 }
Пример #11
0
  /** @see Graphics2D#drawString(AttributedCharacterIterator, float, float) */
  public void drawString(AttributedCharacterIterator iter, float x, float y) {
    /*
            StringBuffer sb = new StringBuffer();
            for(char c = iter.first(); c != AttributedCharacterIterator.DONE; c = iter.next()) {
                sb.append(c);
            }
            drawString(sb.toString(),x,y);
    */
    StringBuffer stringbuffer = new StringBuffer(iter.getEndIndex());
    for (char c = iter.first(); c != '\uFFFF'; c = iter.next()) {
      if (iter.getIndex() == iter.getRunStart()) {
        if (stringbuffer.length() > 0) {
          drawString(stringbuffer.toString(), x, y);
          FontMetrics fontmetrics = getFontMetrics();
          x = (float) (x + fontmetrics.getStringBounds(stringbuffer.toString(), this).getWidth());
          stringbuffer.delete(0, stringbuffer.length());
        }
        doAttributes(iter);
      }
      stringbuffer.append(c);
    }

    drawString(stringbuffer.toString(), x, y);
    underline = false;
  }
Пример #12
0
 private List<Integer> getNewlineLocations(AttributedCharacterIterator styledTextIterator) {
   List<Integer> newlineLocations = new ArrayList<Integer>();
   for (char c = styledTextIterator.first();
       c != AttributedCharacterIterator.DONE;
       c = styledTextIterator.next()) {
     if (c == '\n') newlineLocations.add(styledTextIterator.getIndex());
   }
   return newlineLocations;
 }
 /**
  * @tests java.text.AttributedString#getIterator() Test of method
  *     java.text.AttributedString#getIterator().
  */
 public void test_getIterator() {
   String test = "Test string";
   try {
     AttributedString attrString = new AttributedString(test);
     AttributedCharacterIterator it = attrString.getIterator();
     assertEquals("Incorrect iteration on AttributedString", it.first(), test.charAt(0));
   } catch (Exception e) {
     fail("Unexpected exceptiption " + e.toString());
   }
 }
 /** @tests java.text.AttributedString#AttributedString(java.lang.String) */
 public void test_ConstructorLjava_lang_String() {
   String test = "Test string";
   AttributedString attrString = new AttributedString(test);
   AttributedCharacterIterator it = attrString.getIterator();
   StringBuffer buf = new StringBuffer();
   buf.append(it.first());
   char ch;
   while ((ch = it.next()) != CharacterIterator.DONE) buf.append(ch);
   assertTrue("Wrong string: " + buf, buf.toString().equals(test));
 }
  /** Returns a Set of the attribute identifiers at <code>index</code>. */
  Map getAttributes(int index) {
    if (isValidMask()) {
      AttributedCharacterIterator iterator = getIterator();

      if (index >= 0 && index <= iterator.getEndIndex()) {
        iterator.setIndex(index);
        return iterator.getAttributes();
      }
    }
    return null;
  }
 /*     */ public void deleteChar(
     AttributedCharacterIterator paramAttributedCharacterIterator, int paramInt)
       /*     */ {
   /* 525 */ this.measurer.deleteChar(paramAttributedCharacterIterator, paramInt);
   /*     */
   /* 527 */ this.limit = paramAttributedCharacterIterator.getEndIndex();
   /* 528 */ this.pos = (this.start = paramAttributedCharacterIterator.getBeginIndex());
   /*     */
   /* 530 */ this.charIter.reset(this.measurer.getChars(), this.start);
   /* 531 */ this.breakIter.setText(this.charIter);
   /*     */ }
 /*     */ public void insertChar(
     AttributedCharacterIterator paramAttributedCharacterIterator, int paramInt)
       /*     */ {
   /* 499 */ this.measurer.insertChar(paramAttributedCharacterIterator, paramInt);
   /*     */
   /* 501 */ this.limit = paramAttributedCharacterIterator.getEndIndex();
   /* 502 */ this.pos = (this.start = paramAttributedCharacterIterator.getBeginIndex());
   /*     */
   /* 504 */ this.charIter.reset(
       this.measurer.getChars(), paramAttributedCharacterIterator.getBeginIndex());
   /* 505 */ this.breakIter.setText(this.charIter);
   /*     */ }
Пример #18
0
  // placeholder function for complex break analysis
  static int findComplexBreak(AttributedCharacterIterator aci) {
    int cnt = 0;
    for (char ch = aci.current(); ch == AttributedCharacterIterator.DONE; ch = aci.next(), cnt++) {

      // .. do complex break analysis here Right now we aren't
      // do any, we just find the end of the run of
      // CHAR_CLASS_SA.

      if (getCharCharClass(ch) != CHAR_CLASS_SA) break;
    }
    return cnt;
  }
Пример #19
0
 /**
  * Draws a string at the specified position.
  *
  * @param iterator the string.
  * @param x the x-coordinate.
  * @param y the y-coordinate.
  */
 @Override
 public void drawString(AttributedCharacterIterator iterator, int x, int y) {
   // for now we simply want to extract the chars from the iterator
   // and call an unstyled text renderer
   StringBuffer sb = new StringBuffer();
   int numChars = iterator.getEndIndex() - iterator.getBeginIndex();
   char c = iterator.first();
   for (int i = 0; i < numChars; i++) {
     sb.append(c);
     c = iterator.next();
   }
   drawString(new String(sb), x, y);
 }
Пример #20
0
  /**
   * Handlers INPUT_METHOD_TEXT_CHANGED event. This handler also checks if a invalid key is pressed.
   * This handler is not necessary for JDK1.1, but in JDK1.2, 'keyTyped' event is never generated
   * instead this event is generated so it has to be handled.
   *
   * <p>Note: In JDK1.1 this method should be commented.
   *
   * @param imeEvt event object
   */
  public void inputMethodTextChanged(InputMethodEvent imeEvt) {
    AttributedCharacterIterator aciIterator = imeEvt.getText();

    for (char cChar = aciIterator.first();
        cChar != CharacterIterator.DONE;
        cChar = aciIterator.next()) {
      // If any one of the characters is not allowed,
      // consume the event ...
      if (Character.isDigit(cChar) || cChar == TIME_SEP || cChar == KeyEvent.VK_PERIOD) continue;
      imeEvt.consume();
      return;
    }
    return;
  }
Пример #21
0
  private static String uncommitedChars(AttributedCharacterIterator text) {
    StringBuilder sb = new StringBuilder();

    for (char c = text.first(); c != CharacterIterator.DONE; c = text.next()) {
      if (c >= 0x20
          && c
              != 0x7F) { // Hack just like in
                         // javax.swing.text.DefaultEditorKit.DefaultKeyTypedAction
        sb.append(c);
      }
    }

    return sb.toString();
  }
  /**
   * Return a StyledParagraph reflecting the insertion of a single character into the text. This
   * method will attempt to reuse the given paragraph, but may create a new paragraph.
   *
   * @param aci an iterator over the text. The text should be the same as the text used to create
   *     (or most recently update) oldParagraph, with the exception of deleting a single character
   *     at deletePos.
   * @param chars the characters in aci
   * @param deletePos the index where a character was removed
   * @param oldParagraph a StyledParagraph for the text in aci before the insertion
   */
  public static StyledParagraph deleteChar(
      AttributedCharacterIterator aci, char[] chars, int deletePos, StyledParagraph oldParagraph) {

    // We will reuse oldParagraph unless there was a length-1 run
    // at deletePos.  We could do more work and check the individual
    // Font and Decoration runs, but we don't right now...
    deletePos -= aci.getBeginIndex();

    if (oldParagraph.decorations == null && oldParagraph.fonts == null) {
      oldParagraph.length -= 1;
      return oldParagraph;
    }

    if (oldParagraph.getRunLimit(deletePos) == deletePos + 1) {
      if (deletePos == 0 || oldParagraph.getRunLimit(deletePos - 1) == deletePos) {
        return new StyledParagraph(aci, chars);
      }
    }

    oldParagraph.length -= 1;
    if (oldParagraph.decorations != null) {
      deleteFrom(deletePos, oldParagraph.decorationStarts, oldParagraph.decorations.size());
    }
    if (oldParagraph.fonts != null) {
      deleteFrom(deletePos, oldParagraph.fontStarts, oldParagraph.fonts.size());
    }
    return oldParagraph;
  }
    public void actionPerformed(ActionEvent ae) {

      if (getFormattedTextField().isEditable()) {
        if (getAllowsInvalid()) {
          // This will work if the currently edited value is valid.
          updateMask();
        }

        boolean validEdit = false;

        if (isValidMask()) {
          int start = getFormattedTextField().getSelectionStart();

          if (start != -1) {
            AttributedCharacterIterator iterator = getIterator();

            iterator.setIndex(start);

            Map attributes = iterator.getAttributes();
            Object field = getAdjustField(start, attributes);

            if (canIncrement(field, start)) {
              try {
                Object value = stringToValue(getFormattedTextField().getText());
                int fieldTypeCount = getFieldTypeCountTo(field, start);

                value = adjustValue(value, attributes, field, direction);
                if (value != null && isValidValue(value, false)) {
                  resetValue(value);
                  updateMask();

                  if (isValidMask()) {
                    selectField(field, fieldTypeCount);
                  }
                  validEdit = true;
                }
              } catch (ParseException pe) {
              } catch (BadLocationException ble) {
              }
            }
          }
        }
        if (!validEdit) {
          invalidEdit();
        }
      }
    }
  /**
   * @tests java.text.AttributedString#getIterator(AttributedCharacterIterator.Attribute[], int,
   *     int) Test of method
   *     java.text.AttributedString#getIterator(AttributedCharacterIterator.Attribute[], int, int).
   */
  public void test_getIterator$Ljava_text_AttributedCharacterIterator$AttributeII() {
    String test = "Test string";
    try {
      Map<AttributedCharacterIterator.Attribute, String> hm =
          new HashMap<AttributedCharacterIterator.Attribute, String>();
      AttributedCharacterIterator.Attribute[] aci = new AttributedCharacterIterator.Attribute[3];
      aci[0] = new TestAttributedCharacterIteratorAttribute("att1");
      aci[1] = new TestAttributedCharacterIteratorAttribute("att2");
      aci[2] = new TestAttributedCharacterIteratorAttribute("att3");
      hm.put(aci[0], "value1");
      hm.put(aci[1], "value2");

      AttributedString attrString = new AttributedString(test);
      attrString.addAttributes(hm, 2, 4);
      AttributedCharacterIterator it = attrString.getIterator(aci, 1, 5);

      assertTrue("Incorrect iteration on AttributedString", it.getAttribute(aci[0]) == null);
      assertTrue("Incorrect iteration on AttributedString", it.getAttribute(aci[1]) == null);
      assertTrue("Incorrect iteration on AttributedString", it.getAttribute(aci[2]) == null);

      it.next();

      assertTrue(
          "Incorrect iteration on AttributedString", it.getAttribute(aci[0]).equals("value1"));
      assertTrue(
          "Incorrect iteration on AttributedString", it.getAttribute(aci[1]).equals("value2"));
      assertTrue("Incorrect iteration on AttributedString", it.getAttribute(aci[2]) == null);
    } catch (Exception e) {
      fail("Unexpected exceptiption " + e.toString());
    }
  }
Пример #25
0
 private TextLayout getTextLayout(AttributedCharacterIterator text, int committed_count) {
   AttributedString composed = new AttributedString(text, committed_count, text.getEndIndex());
   Font font = textArea.getPainter().getFont();
   FontRenderContext context =
       ((Graphics2D) (textArea.getPainter().getGraphics())).getFontRenderContext();
   composed.addAttribute(TextAttribute.FONT, font);
   TextLayout layout = new TextLayout(composed.getIterator(), context);
   return layout;
 }
  protected void exportStyledText(JRStyledText styledText, Locale locale, boolean startedHyperlink)
      throws IOException {
    String text = styledText.getText();

    int runLimit = 0;

    AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator();

    while (runLimit < styledText.length()
        && (runLimit = iterator.getRunLimit()) <= styledText.length()) {
      exportStyledTextRun(
          iterator.getAttributes(),
          text.substring(iterator.getIndex(), runLimit),
          locale,
          startedHyperlink);

      iterator.setIndex(runLimit);
    }
  }
Пример #27
0
  /**
   * This routine goes through the attributes and sets the font before calling the actual string
   * drawing routine
   *
   * @param iter
   */
  protected void doAttributes(AttributedCharacterIterator iter) {
    underline = false;
    Set set = iter.getAttributes().keySet();
    for (Iterator iterator = set.iterator(); iterator.hasNext(); ) {
      TextAttribute textattribute = (TextAttribute) iterator.next();
      if (textattribute.equals(TextAttribute.FONT)) {
        Font font = (Font) iter.getAttributes().get(textattribute);
        setFont(font);
      } else if (textattribute.equals(TextAttribute.UNDERLINE)) {
        if (iter.getAttributes().get(textattribute) == TextAttribute.UNDERLINE_ON) underline = true;
      } else if (textattribute.equals(TextAttribute.SUPERSCRIPT)) {
        /*
        iter.getAttributes().get(textattribute);
        Integer _tmp = TextAttribute.SUPERSCRIPT_SUPER;
        subscript = true;
         */
      } else if (textattribute.equals(TextAttribute.SIZE)) {
        Object obj = iter.getAttributes().get(textattribute);
        Font font1 = null;
        /* ssteward: no deriveFont method for java.awt.Font in libgcj 3.4.2
                      if(obj instanceof Integer) {
                          int i = ((Integer)obj).intValue();
                          font1 = getFont().deriveFont(getFont().getStyle(), i);
                      }
                      else if(obj instanceof Float) {
                          float f = ((Float)obj).floatValue();
                          font1 = getFont().deriveFont(getFont().getStyle(), f);
                      }
                      else {
                          //System.out.println("Unknown type for attribute SIZE");
                          return;
                      }
        */
        return;

        // setFont(font1); // ssteward
      } else {
        String s = "only FONT/SIZE/UNDERLINE/SUPERSCRIPT supported";
        throw new RuntimeException(s);
      }
    }
  }
 /*     */ public LineBreakMeasurer(
     AttributedCharacterIterator paramAttributedCharacterIterator,
     BreakIterator paramBreakIterator,
     FontRenderContext paramFontRenderContext)
       /*     */ {
   /* 305 */ if (paramAttributedCharacterIterator.getEndIndex()
           - paramAttributedCharacterIterator.getBeginIndex()
       < 1) {
     /* 306 */ throw new IllegalArgumentException("Text must contain at least one character.");
     /*     */ }
   /*     */
   /* 309 */ this.breakIter = paramBreakIterator;
   /* 310 */ this.measurer =
       new TextMeasurer(paramAttributedCharacterIterator, paramFontRenderContext);
   /* 311 */ this.limit = paramAttributedCharacterIterator.getEndIndex();
   /* 312 */ this.pos = (this.start = paramAttributedCharacterIterator.getBeginIndex());
   /*     */
   /* 314 */ this.charIter = new CharArrayIterator(this.measurer.getChars(), this.start);
   /* 315 */ this.breakIter.setText(this.charIter);
   /*     */ }
  protected void dumpACIWord(AttributedString as) {
    if (as == null) return;

    StringBuffer chars = new StringBuffer();
    StringBuffer brkStr = new StringBuffer();
    AttributedCharacterIterator aci = as.getIterator();
    AttributedCharacterIterator.Attribute WORD_LIMIT = TextLineBreaks.WORD_LIMIT;

    for (char ch = aci.current(); ch != AttributedCharacterIterator.DONE; ch = aci.next()) {

      chars.append(ch).append(' ').append(' ');
      int w = ((Integer) aci.getAttribute(WORD_LIMIT)).intValue();
      brkStr.append(w).append(' ');
      if (w < 10) {
        // for small values append another ' '
        brkStr.append(' ');
      }
    }
    System.out.println(chars.toString());
    System.out.println(brkStr.toString());
  }
  /**
   * Updates the interal bitset from <code>iterator</code>. This will set <code>validMask</code> to
   * true if <code>iterator</code> is non-null.
   */
  private void updateMask(AttributedCharacterIterator iterator) {
    if (iterator != null) {
      validMask = true;
      this.iterator = iterator;

      // Update the literal mask
      if (literalMask == null) {
        literalMask = new BitSet();
      } else {
        for (int counter = literalMask.length() - 1; counter >= 0; counter--) {
          literalMask.clear(counter);
        }
      }

      iterator.first();
      while (iterator.current() != CharacterIterator.DONE) {
        Map attributes = iterator.getAttributes();
        boolean set = isLiteral(attributes);
        int start = iterator.getIndex();
        int end = iterator.getRunLimit();

        while (start < end) {
          if (set) {
            literalMask.set(start);
          } else {
            literalMask.clear(start);
          }
          start++;
        }
        iterator.setIndex(start);
      }
    }
  }