/// <summary> /// Updates the <code>TextMeasurer</code> after a single character has /// been inserted /// into 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. /// </summary> /// <param name="newParagraph"> the text of the paragraph after performing /// the insertion. Cannot be null. </param> /// <param name="insertPos"> the position in the text where the character was /// inserted. Must not be less than the start of /// <code>newParagraph</code>, and must be less than the end of /// <code>newParagraph</code>. </param> /// <exception cref="IndexOutOfBoundsException"> if <code>insertPos</code> is less /// than the start of <code>newParagraph</code> or greater than /// or equal to the end of <code>newParagraph</code> </exception> /// <exception cref="NullPointerException"> if <code>newParagraph</code> is /// <code>null</code> </exception> public void InsertChar(AttributedCharacterIterator newParagraph, int insertPos) { if (CollectStats) { PrintStats(); } if (WantStats) { CollectStats = true; } FStart = newParagraph.BeginIndex; int end = newParagraph.EndIndex; if (end - FStart != FChars.Length + 1) { InitAll(newParagraph); } char[] newChars = new char[end - FStart]; int newCharIndex = insertPos - FStart; System.Array.Copy(FChars, 0, newChars, 0, newCharIndex); char newChar = newParagraph.setIndex(insertPos); newChars[newCharIndex] = newChar; System.Array.Copy(FChars, newCharIndex, newChars, newCharIndex + 1, end - insertPos - 1); FChars = newChars; if (FBidi != null || Bidi.RequiresBidi(newChars, newCharIndex, newCharIndex + 1) || newParagraph.GetAttribute(TextAttribute.BIDI_EMBEDDING) != null) { FBidi = new Bidi(newParagraph); if (FBidi.LeftToRight) { FBidi = null; } } FParagraph = StyledParagraph.InsertChar(newParagraph, FChars, insertPos, FParagraph); InvalidateComponents(); }