/// <summary>
        /// Updates this <code>LineBreakMeasurer</code> after a single
        /// character is inserted into the text, and sets the current
        /// position to the beginning of the paragraph.
        /// </summary>
        /// <param name="newParagraph"> the text after the insertion </param>
        /// <param name="insertPos"> the position in the text at which the character
        ///    is inserted </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>
        /// <seealso cref= #deleteChar </seealso>
        public void InsertChar(AttributedCharacterIterator newParagraph, int insertPos)
        {
            Measurer.InsertChar(newParagraph, insertPos);

            Limit = newParagraph.EndIndex;
            Pos   = Start = newParagraph.BeginIndex;

            CharIter.Reset(Measurer.Chars, newParagraph.BeginIndex);
            BreakIter.SetText(CharIter);
        }
Exemple #2
0
        private void MakeLayoutWindow(int localStart)
        {
            int compStart = localStart;
            int compLimit = FChars.Length;

            // If we've already gone past the layout window, format to end of paragraph
            if (LayoutCount > 0 && !HaveLayoutWindow)
            {
                float avgLineLength = System.Math.Max(LayoutCharCount / LayoutCount, 1);
                compLimit = System.Math.Min(localStart + (int)(avgLineLength * EST_LINES), FChars.Length);
            }

            if (localStart > 0 || compLimit < FChars.Length)
            {
                if (CharIter == null)
                {
                    CharIter = new CharArrayIterator(FChars);
                }
                else
                {
                    CharIter.Reset(FChars);
                }
                if (FLineBreak == null)
                {
                    FLineBreak = BreakIterator.LineInstance;
                }
                FLineBreak.SetText(CharIter);
                if (localStart > 0)
                {
                    if (!FLineBreak.IsBoundary(localStart))
                    {
                        compStart = FLineBreak.Preceding(localStart);
                    }
                }
                if (compLimit < FChars.Length)
                {
                    if (!FLineBreak.IsBoundary(compLimit))
                    {
                        compLimit = FLineBreak.Following(compLimit);
                    }
                }
            }

            EnsureComponents(compStart, compLimit);
            HaveLayoutWindow = true;
        }