DynamicLayout.java revision 5a6eeb3cbe0896ddf4bdccc0b1a81d7aac49821e
1/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.text;
18
19import android.graphics.Paint;
20import android.text.style.UpdateLayout;
21import android.text.style.WrapTogetherSpan;
22
23import com.android.internal.util.ArrayUtils;
24import com.android.internal.util.GrowingArrayUtils;
25
26import java.lang.ref.WeakReference;
27
28/**
29 * DynamicLayout is a text layout that updates itself as the text is edited.
30 * <p>This is used by widgets to control text layout. You should not need
31 * to use this class directly unless you are implementing your own widget
32 * or custom display object, or need to call
33 * {@link android.graphics.Canvas#drawText(java.lang.CharSequence, int, int, float, float, android.graphics.Paint)
34 *  Canvas.drawText()} directly.</p>
35 */
36public class DynamicLayout extends Layout
37{
38    private static final int PRIORITY = 128;
39    private static final int BLOCK_MINIMUM_CHARACTER_LENGTH = 400;
40
41    /**
42     * Make a layout for the specified text that will be updated as
43     * the text is changed.
44     */
45    public DynamicLayout(CharSequence base,
46                         TextPaint paint,
47                         int width, Alignment align,
48                         float spacingmult, float spacingadd,
49                         boolean includepad) {
50        this(base, base, paint, width, align, spacingmult, spacingadd,
51             includepad);
52    }
53
54    /**
55     * Make a layout for the transformed text (password transformation
56     * being the primary example of a transformation)
57     * that will be updated as the base text is changed.
58     */
59    public DynamicLayout(CharSequence base, CharSequence display,
60                         TextPaint paint,
61                         int width, Alignment align,
62                         float spacingmult, float spacingadd,
63                         boolean includepad) {
64        this(base, display, paint, width, align, spacingmult, spacingadd,
65             includepad, null, 0);
66    }
67
68    /**
69     * Make a layout for the transformed text (password transformation
70     * being the primary example of a transformation)
71     * that will be updated as the base text is changed.
72     * If ellipsize is non-null, the Layout will ellipsize the text
73     * down to ellipsizedWidth.
74     */
75    public DynamicLayout(CharSequence base, CharSequence display,
76                         TextPaint paint,
77                         int width, Alignment align,
78                         float spacingmult, float spacingadd,
79                         boolean includepad,
80                         TextUtils.TruncateAt ellipsize, int ellipsizedWidth) {
81        this(base, display, paint, width, align, TextDirectionHeuristics.FIRSTSTRONG_LTR,
82                spacingmult, spacingadd, includepad, ellipsize, ellipsizedWidth);
83    }
84
85    /**
86     * Make a layout for the transformed text (password transformation
87     * being the primary example of a transformation)
88     * that will be updated as the base text is changed.
89     * If ellipsize is non-null, the Layout will ellipsize the text
90     * down to ellipsizedWidth.
91     * *
92     * *@hide
93     */
94    public DynamicLayout(CharSequence base, CharSequence display,
95                         TextPaint paint,
96                         int width, Alignment align, TextDirectionHeuristic textDir,
97                         float spacingmult, float spacingadd,
98                         boolean includepad,
99                         TextUtils.TruncateAt ellipsize, int ellipsizedWidth) {
100        super((ellipsize == null)
101                ? display
102                : (display instanceof Spanned)
103                    ? new SpannedEllipsizer(display)
104                    : new Ellipsizer(display),
105              paint, width, align, textDir, spacingmult, spacingadd);
106
107        mBase = base;
108        mDisplay = display;
109
110        if (ellipsize != null) {
111            mInts = new PackedIntVector(COLUMNS_ELLIPSIZE);
112            mEllipsizedWidth = ellipsizedWidth;
113            mEllipsizeAt = ellipsize;
114        } else {
115            mInts = new PackedIntVector(COLUMNS_NORMAL);
116            mEllipsizedWidth = width;
117            mEllipsizeAt = null;
118        }
119
120        mObjects = new PackedObjectVector<Directions>(1);
121
122        mIncludePad = includepad;
123
124        /*
125         * This is annoying, but we can't refer to the layout until
126         * superclass construction is finished, and the superclass
127         * constructor wants the reference to the display text.
128         *
129         * This will break if the superclass constructor ever actually
130         * cares about the content instead of just holding the reference.
131         */
132        if (ellipsize != null) {
133            Ellipsizer e = (Ellipsizer) getText();
134
135            e.mLayout = this;
136            e.mWidth = ellipsizedWidth;
137            e.mMethod = ellipsize;
138            mEllipsize = true;
139        }
140
141        // Initial state is a single line with 0 characters (0 to 0),
142        // with top at 0 and bottom at whatever is natural, and
143        // undefined ellipsis.
144
145        int[] start;
146
147        if (ellipsize != null) {
148            start = new int[COLUMNS_ELLIPSIZE];
149            start[ELLIPSIS_START] = ELLIPSIS_UNDEFINED;
150        } else {
151            start = new int[COLUMNS_NORMAL];
152        }
153
154        Directions[] dirs = new Directions[] { DIRS_ALL_LEFT_TO_RIGHT };
155
156        Paint.FontMetricsInt fm = paint.getFontMetricsInt();
157        int asc = fm.ascent;
158        int desc = fm.descent;
159
160        start[DIR] = DIR_LEFT_TO_RIGHT << DIR_SHIFT;
161        start[TOP] = 0;
162        start[DESCENT] = desc;
163        mInts.insertAt(0, start);
164
165        start[TOP] = desc - asc;
166        mInts.insertAt(1, start);
167
168        mObjects.insertAt(0, dirs);
169
170        // Update from 0 characters to whatever the real text is
171        reflow(base, 0, 0, base.length());
172
173        if (base instanceof Spannable) {
174            if (mWatcher == null)
175                mWatcher = new ChangeWatcher(this);
176
177            // Strip out any watchers for other DynamicLayouts.
178            Spannable sp = (Spannable) base;
179            ChangeWatcher[] spans = sp.getSpans(0, sp.length(), ChangeWatcher.class);
180            for (int i = 0; i < spans.length; i++)
181                sp.removeSpan(spans[i]);
182
183            sp.setSpan(mWatcher, 0, base.length(),
184                       Spannable.SPAN_INCLUSIVE_INCLUSIVE |
185                       (PRIORITY << Spannable.SPAN_PRIORITY_SHIFT));
186        }
187    }
188
189    private void reflow(CharSequence s, int where, int before, int after) {
190        if (s != mBase)
191            return;
192
193        CharSequence text = mDisplay;
194        int len = text.length();
195
196        // seek back to the start of the paragraph
197
198        int find = TextUtils.lastIndexOf(text, '\n', where - 1);
199        if (find < 0)
200            find = 0;
201        else
202            find = find + 1;
203
204        {
205            int diff = where - find;
206            before += diff;
207            after += diff;
208            where -= diff;
209        }
210
211        // seek forward to the end of the paragraph
212
213        int look = TextUtils.indexOf(text, '\n', where + after);
214        if (look < 0)
215            look = len;
216        else
217            look++; // we want the index after the \n
218
219        int change = look - (where + after);
220        before += change;
221        after += change;
222
223        // seek further out to cover anything that is forced to wrap together
224
225        if (text instanceof Spanned) {
226            Spanned sp = (Spanned) text;
227            boolean again;
228
229            do {
230                again = false;
231
232                Object[] force = sp.getSpans(where, where + after,
233                                             WrapTogetherSpan.class);
234
235                for (int i = 0; i < force.length; i++) {
236                    int st = sp.getSpanStart(force[i]);
237                    int en = sp.getSpanEnd(force[i]);
238
239                    if (st < where) {
240                        again = true;
241
242                        int diff = where - st;
243                        before += diff;
244                        after += diff;
245                        where -= diff;
246                    }
247
248                    if (en > where + after) {
249                        again = true;
250
251                        int diff = en - (where + after);
252                        before += diff;
253                        after += diff;
254                    }
255                }
256            } while (again);
257        }
258
259        // find affected region of old layout
260
261        int startline = getLineForOffset(where);
262        int startv = getLineTop(startline);
263
264        int endline = getLineForOffset(where + before);
265        if (where + after == len)
266            endline = getLineCount();
267        int endv = getLineTop(endline);
268        boolean islast = (endline == getLineCount());
269
270        // generate new layout for affected text
271
272        StaticLayout reflowed;
273        StaticLayout.Builder b;
274
275        synchronized (sLock) {
276            reflowed = sStaticLayout;
277            b = sBuilder;
278            sStaticLayout = null;
279            sBuilder = null;
280        }
281
282        // TODO: make sure reflowed is properly initialized
283        if (reflowed == null) {
284            reflowed = new StaticLayout(null);
285            b = StaticLayout.Builder.obtain();
286        }
287
288        b.setText(text, where, where + after)
289                .setPaint(getPaint())
290                .setWidth(getWidth())
291                .setTextDir(getTextDirectionHeuristic())
292                .setSpacingMult(getSpacingMultiplier())
293                .setSpacingAdd(getSpacingAdd())
294                .setEllipsizedWidth(mEllipsizedWidth)
295                .setEllipsize(mEllipsizeAt);
296        reflowed.generate(b, false, true);
297        int n = reflowed.getLineCount();
298
299        // If the new layout has a blank line at the end, but it is not
300        // the very end of the buffer, then we already have a line that
301        // starts there, so disregard the blank line.
302
303        if (where + after != len && reflowed.getLineStart(n - 1) == where + after)
304            n--;
305
306        // remove affected lines from old layout
307        mInts.deleteAt(startline, endline - startline);
308        mObjects.deleteAt(startline, endline - startline);
309
310        // adjust offsets in layout for new height and offsets
311
312        int ht = reflowed.getLineTop(n);
313        int toppad = 0, botpad = 0;
314
315        if (mIncludePad && startline == 0) {
316            toppad = reflowed.getTopPadding();
317            mTopPadding = toppad;
318            ht -= toppad;
319        }
320        if (mIncludePad && islast) {
321            botpad = reflowed.getBottomPadding();
322            mBottomPadding = botpad;
323            ht += botpad;
324        }
325
326        mInts.adjustValuesBelow(startline, START, after - before);
327        mInts.adjustValuesBelow(startline, TOP, startv - endv + ht);
328
329        // insert new layout
330
331        int[] ints;
332
333        if (mEllipsize) {
334            ints = new int[COLUMNS_ELLIPSIZE];
335            ints[ELLIPSIS_START] = ELLIPSIS_UNDEFINED;
336        } else {
337            ints = new int[COLUMNS_NORMAL];
338        }
339
340        Directions[] objects = new Directions[1];
341
342        for (int i = 0; i < n; i++) {
343            ints[START] = reflowed.getLineStart(i) |
344                          (reflowed.getParagraphDirection(i) << DIR_SHIFT) |
345                          (reflowed.getLineContainsTab(i) ? TAB_MASK : 0);
346
347            int top = reflowed.getLineTop(i) + startv;
348            if (i > 0)
349                top -= toppad;
350            ints[TOP] = top;
351
352            int desc = reflowed.getLineDescent(i);
353            if (i == n - 1)
354                desc += botpad;
355
356            ints[DESCENT] = desc;
357            objects[0] = reflowed.getLineDirections(i);
358
359            if (mEllipsize) {
360                ints[ELLIPSIS_START] = reflowed.getEllipsisStart(i);
361                ints[ELLIPSIS_COUNT] = reflowed.getEllipsisCount(i);
362            }
363
364            mInts.insertAt(startline + i, ints);
365            mObjects.insertAt(startline + i, objects);
366        }
367
368        updateBlocks(startline, endline - 1, n);
369
370        b.finish();
371        synchronized (sLock) {
372            sStaticLayout = reflowed;
373            sBuilder = b;
374        }
375    }
376
377    /**
378     * Create the initial block structure, cutting the text into blocks of at least
379     * BLOCK_MINIMUM_CHARACTER_SIZE characters, aligned on the ends of paragraphs.
380     */
381    private void createBlocks() {
382        int offset = BLOCK_MINIMUM_CHARACTER_LENGTH;
383        mNumberOfBlocks = 0;
384        final CharSequence text = mDisplay;
385
386        while (true) {
387            offset = TextUtils.indexOf(text, '\n', offset);
388            if (offset < 0) {
389                addBlockAtOffset(text.length());
390                break;
391            } else {
392                addBlockAtOffset(offset);
393                offset += BLOCK_MINIMUM_CHARACTER_LENGTH;
394            }
395        }
396
397        // mBlockIndices and mBlockEndLines should have the same length
398        mBlockIndices = new int[mBlockEndLines.length];
399        for (int i = 0; i < mBlockEndLines.length; i++) {
400            mBlockIndices[i] = INVALID_BLOCK_INDEX;
401        }
402    }
403
404    /**
405     * Create a new block, ending at the specified character offset.
406     * A block will actually be created only if has at least one line, i.e. this offset is
407     * not on the end line of the previous block.
408     */
409    private void addBlockAtOffset(int offset) {
410        final int line = getLineForOffset(offset);
411
412        if (mBlockEndLines == null) {
413            // Initial creation of the array, no test on previous block ending line
414            mBlockEndLines = ArrayUtils.newUnpaddedIntArray(1);
415            mBlockEndLines[mNumberOfBlocks] = line;
416            mNumberOfBlocks++;
417            return;
418        }
419
420        final int previousBlockEndLine = mBlockEndLines[mNumberOfBlocks - 1];
421        if (line > previousBlockEndLine) {
422            mBlockEndLines = GrowingArrayUtils.append(mBlockEndLines, mNumberOfBlocks, line);
423            mNumberOfBlocks++;
424        }
425    }
426
427    /**
428     * This method is called every time the layout is reflowed after an edition.
429     * It updates the internal block data structure. The text is split in blocks
430     * of contiguous lines, with at least one block for the entire text.
431     * When a range of lines is edited, new blocks (from 0 to 3 depending on the
432     * overlap structure) will replace the set of overlapping blocks.
433     * Blocks are listed in order and are represented by their ending line number.
434     * An index is associated to each block (which will be used by display lists),
435     * this class simply invalidates the index of blocks overlapping a modification.
436     *
437     * This method is package private and not private so that it can be tested.
438     *
439     * @param startLine the first line of the range of modified lines
440     * @param endLine the last line of the range, possibly equal to startLine, lower
441     * than getLineCount()
442     * @param newLineCount the number of lines that will replace the range, possibly 0
443     *
444     * @hide
445     */
446    void updateBlocks(int startLine, int endLine, int newLineCount) {
447        if (mBlockEndLines == null) {
448            createBlocks();
449            return;
450        }
451
452        int firstBlock = -1;
453        int lastBlock = -1;
454        for (int i = 0; i < mNumberOfBlocks; i++) {
455            if (mBlockEndLines[i] >= startLine) {
456                firstBlock = i;
457                break;
458            }
459        }
460        for (int i = firstBlock; i < mNumberOfBlocks; i++) {
461            if (mBlockEndLines[i] >= endLine) {
462                lastBlock = i;
463                break;
464            }
465        }
466        final int lastBlockEndLine = mBlockEndLines[lastBlock];
467
468        boolean createBlockBefore = startLine > (firstBlock == 0 ? 0 :
469                mBlockEndLines[firstBlock - 1] + 1);
470        boolean createBlock = newLineCount > 0;
471        boolean createBlockAfter = endLine < mBlockEndLines[lastBlock];
472
473        int numAddedBlocks = 0;
474        if (createBlockBefore) numAddedBlocks++;
475        if (createBlock) numAddedBlocks++;
476        if (createBlockAfter) numAddedBlocks++;
477
478        final int numRemovedBlocks = lastBlock - firstBlock + 1;
479        final int newNumberOfBlocks = mNumberOfBlocks + numAddedBlocks - numRemovedBlocks;
480
481        if (newNumberOfBlocks == 0) {
482            // Even when text is empty, there is actually one line and hence one block
483            mBlockEndLines[0] = 0;
484            mBlockIndices[0] = INVALID_BLOCK_INDEX;
485            mNumberOfBlocks = 1;
486            return;
487        }
488
489        if (newNumberOfBlocks > mBlockEndLines.length) {
490            int[] blockEndLines = ArrayUtils.newUnpaddedIntArray(
491                    Math.max(mBlockEndLines.length * 2, newNumberOfBlocks));
492            int[] blockIndices = new int[blockEndLines.length];
493            System.arraycopy(mBlockEndLines, 0, blockEndLines, 0, firstBlock);
494            System.arraycopy(mBlockIndices, 0, blockIndices, 0, firstBlock);
495            System.arraycopy(mBlockEndLines, lastBlock + 1,
496                    blockEndLines, firstBlock + numAddedBlocks, mNumberOfBlocks - lastBlock - 1);
497            System.arraycopy(mBlockIndices, lastBlock + 1,
498                    blockIndices, firstBlock + numAddedBlocks, mNumberOfBlocks - lastBlock - 1);
499            mBlockEndLines = blockEndLines;
500            mBlockIndices = blockIndices;
501        } else {
502            System.arraycopy(mBlockEndLines, lastBlock + 1,
503                    mBlockEndLines, firstBlock + numAddedBlocks, mNumberOfBlocks - lastBlock - 1);
504            System.arraycopy(mBlockIndices, lastBlock + 1,
505                    mBlockIndices, firstBlock + numAddedBlocks, mNumberOfBlocks - lastBlock - 1);
506        }
507
508        mNumberOfBlocks = newNumberOfBlocks;
509        int newFirstChangedBlock;
510        final int deltaLines = newLineCount - (endLine - startLine + 1);
511        if (deltaLines != 0) {
512            // Display list whose index is >= mIndexFirstChangedBlock is valid
513            // but it needs to update its drawing location.
514            newFirstChangedBlock = firstBlock + numAddedBlocks;
515            for (int i = newFirstChangedBlock; i < mNumberOfBlocks; i++) {
516                mBlockEndLines[i] += deltaLines;
517            }
518        } else {
519            newFirstChangedBlock = mNumberOfBlocks;
520        }
521        mIndexFirstChangedBlock = Math.min(mIndexFirstChangedBlock, newFirstChangedBlock);
522
523        int blockIndex = firstBlock;
524        if (createBlockBefore) {
525            mBlockEndLines[blockIndex] = startLine - 1;
526            mBlockIndices[blockIndex] = INVALID_BLOCK_INDEX;
527            blockIndex++;
528        }
529
530        if (createBlock) {
531            mBlockEndLines[blockIndex] = startLine + newLineCount - 1;
532            mBlockIndices[blockIndex] = INVALID_BLOCK_INDEX;
533            blockIndex++;
534        }
535
536        if (createBlockAfter) {
537            mBlockEndLines[blockIndex] = lastBlockEndLine + deltaLines;
538            mBlockIndices[blockIndex] = INVALID_BLOCK_INDEX;
539        }
540    }
541
542    /**
543     * This package private method is used for test purposes only
544     * @hide
545     */
546    void setBlocksDataForTest(int[] blockEndLines, int[] blockIndices, int numberOfBlocks) {
547        mBlockEndLines = new int[blockEndLines.length];
548        mBlockIndices = new int[blockIndices.length];
549        System.arraycopy(blockEndLines, 0, mBlockEndLines, 0, blockEndLines.length);
550        System.arraycopy(blockIndices, 0, mBlockIndices, 0, blockIndices.length);
551        mNumberOfBlocks = numberOfBlocks;
552    }
553
554    /**
555     * @hide
556     */
557    public int[] getBlockEndLines() {
558        return mBlockEndLines;
559    }
560
561    /**
562     * @hide
563     */
564    public int[] getBlockIndices() {
565        return mBlockIndices;
566    }
567
568    /**
569     * @hide
570     */
571    public int getNumberOfBlocks() {
572        return mNumberOfBlocks;
573    }
574
575    /**
576     * @hide
577     */
578    public int getIndexFirstChangedBlock() {
579        return mIndexFirstChangedBlock;
580    }
581
582    /**
583     * @hide
584     */
585    public void setIndexFirstChangedBlock(int i) {
586        mIndexFirstChangedBlock = i;
587    }
588
589    @Override
590    public int getLineCount() {
591        return mInts.size() - 1;
592    }
593
594    @Override
595    public int getLineTop(int line) {
596        return mInts.getValue(line, TOP);
597    }
598
599    @Override
600    public int getLineDescent(int line) {
601        return mInts.getValue(line, DESCENT);
602    }
603
604    @Override
605    public int getLineStart(int line) {
606        return mInts.getValue(line, START) & START_MASK;
607    }
608
609    @Override
610    public boolean getLineContainsTab(int line) {
611        return (mInts.getValue(line, TAB) & TAB_MASK) != 0;
612    }
613
614    @Override
615    public int getParagraphDirection(int line) {
616        return mInts.getValue(line, DIR) >> DIR_SHIFT;
617    }
618
619    @Override
620    public final Directions getLineDirections(int line) {
621        return mObjects.getValue(line, 0);
622    }
623
624    @Override
625    public int getTopPadding() {
626        return mTopPadding;
627    }
628
629    @Override
630    public int getBottomPadding() {
631        return mBottomPadding;
632    }
633
634    @Override
635    public int getEllipsizedWidth() {
636        return mEllipsizedWidth;
637    }
638
639    private static class ChangeWatcher implements TextWatcher, SpanWatcher {
640        public ChangeWatcher(DynamicLayout layout) {
641            mLayout = new WeakReference<DynamicLayout>(layout);
642        }
643
644        private void reflow(CharSequence s, int where, int before, int after) {
645            DynamicLayout ml = mLayout.get();
646
647            if (ml != null)
648                ml.reflow(s, where, before, after);
649            else if (s instanceof Spannable)
650                ((Spannable) s).removeSpan(this);
651        }
652
653        public void beforeTextChanged(CharSequence s, int where, int before, int after) {
654            // Intentionally empty
655        }
656
657        public void onTextChanged(CharSequence s, int where, int before, int after) {
658            reflow(s, where, before, after);
659        }
660
661        public void afterTextChanged(Editable s) {
662            // Intentionally empty
663        }
664
665        public void onSpanAdded(Spannable s, Object o, int start, int end) {
666            if (o instanceof UpdateLayout)
667                reflow(s, start, end - start, end - start);
668        }
669
670        public void onSpanRemoved(Spannable s, Object o, int start, int end) {
671            if (o instanceof UpdateLayout)
672                reflow(s, start, end - start, end - start);
673        }
674
675        public void onSpanChanged(Spannable s, Object o, int start, int end, int nstart, int nend) {
676            if (o instanceof UpdateLayout) {
677                reflow(s, start, end - start, end - start);
678                reflow(s, nstart, nend - nstart, nend - nstart);
679            }
680        }
681
682        private WeakReference<DynamicLayout> mLayout;
683    }
684
685    @Override
686    public int getEllipsisStart(int line) {
687        if (mEllipsizeAt == null) {
688            return 0;
689        }
690
691        return mInts.getValue(line, ELLIPSIS_START);
692    }
693
694    @Override
695    public int getEllipsisCount(int line) {
696        if (mEllipsizeAt == null) {
697            return 0;
698        }
699
700        return mInts.getValue(line, ELLIPSIS_COUNT);
701    }
702
703    private CharSequence mBase;
704    private CharSequence mDisplay;
705    private ChangeWatcher mWatcher;
706    private boolean mIncludePad;
707    private boolean mEllipsize;
708    private int mEllipsizedWidth;
709    private TextUtils.TruncateAt mEllipsizeAt;
710
711    private PackedIntVector mInts;
712    private PackedObjectVector<Directions> mObjects;
713
714    /**
715     * Value used in mBlockIndices when a block has been created or recycled and indicating that its
716     * display list needs to be re-created.
717     * @hide
718     */
719    public static final int INVALID_BLOCK_INDEX = -1;
720    // Stores the line numbers of the last line of each block (inclusive)
721    private int[] mBlockEndLines;
722    // The indices of this block's display list in TextView's internal display list array or
723    // INVALID_BLOCK_INDEX if this block has been invalidated during an edition
724    private int[] mBlockIndices;
725    // Number of items actually currently being used in the above 2 arrays
726    private int mNumberOfBlocks;
727    // The first index of the blocks whose locations are changed
728    private int mIndexFirstChangedBlock;
729
730    private int mTopPadding, mBottomPadding;
731
732    private static StaticLayout sStaticLayout = null;
733    private static StaticLayout.Builder sBuilder = null;
734
735    private static final Object[] sLock = new Object[0];
736
737    private static final int START = 0;
738    private static final int DIR = START;
739    private static final int TAB = START;
740    private static final int TOP = 1;
741    private static final int DESCENT = 2;
742    private static final int COLUMNS_NORMAL = 3;
743
744    private static final int ELLIPSIS_START = 3;
745    private static final int ELLIPSIS_COUNT = 4;
746    private static final int COLUMNS_ELLIPSIZE = 5;
747
748    private static final int START_MASK = 0x1FFFFFFF;
749    private static final int DIR_SHIFT  = 30;
750    private static final int TAB_MASK   = 0x20000000;
751
752    private static final int ELLIPSIS_UNDEFINED = 0x80000000;
753}
754