1 /*
2  * Copyright (C) 2014 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 
17 package android.text;
18 
19 import android.annotation.NonNull;
20 import android.text.StaticLayout.LineBreaks;
21 
22 import java.util.Collections;
23 import java.util.List;
24 
25 // Based on the native implementation of LineBreaker in
26 // frameworks/base/core/jni/android_text_StaticLayout.cpp revision b808260
27 public abstract class LineBreaker {
28 
29     protected static final int TAB_MASK   = 0x20000000;  // keep in sync with StaticLayout
30 
31     protected final @NonNull List<Primitive> mPrimitives;
32     protected final @NonNull LineWidth mLineWidth;
33     protected final @NonNull TabStops mTabStops;
34 
LineBreaker(@onNull List<Primitive> primitives, @NonNull LineWidth lineWidth, @NonNull TabStops tabStops)35     public LineBreaker(@NonNull List<Primitive> primitives, @NonNull LineWidth lineWidth,
36             @NonNull TabStops tabStops) {
37         mPrimitives = Collections.unmodifiableList(primitives);
38         mLineWidth = lineWidth;
39         mTabStops = tabStops;
40     }
41 
computeBreaks(@onNull LineBreaks breakInfo)42     public abstract void computeBreaks(@NonNull LineBreaks breakInfo);
43 }
44