17053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta/* 27053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta * Copyright (C) 2014 The Android Open Source Project 37053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta * 47053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta * Licensed under the Apache License, Version 2.0 (the "License"); 57053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta * you may not use this file except in compliance with the License. 67053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta * You may obtain a copy of the License at 77053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta * 87053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta * http://www.apache.org/licenses/LICENSE-2.0 97053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta * 107053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta * Unless required by applicable law or agreed to in writing, software 117053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta * distributed under the License is distributed on an "AS IS" BASIS, 127053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 137053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta * See the License for the specific language governing permissions and 147053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta * limitations under the License. 157053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta */ 167053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta 177053919a3a55ad1b58e6db701afda18850037732Deepanshu Guptapackage android.text; 187053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta 197053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta// Based on the native implementation of LineWidth in 207053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta// frameworks/base/core/jni/android_text_StaticLayout.cpp revision b808260 217053919a3a55ad1b58e6db701afda18850037732Deepanshu Guptapublic class LineWidth { 227053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta private final float mFirstWidth; 237053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta private final int mFirstWidthLineCount; 247053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta private float mRestWidth; 257053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta 267053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta public LineWidth(float firstWidth, int firstWidthLineCount, float restWidth) { 277053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta mFirstWidth = firstWidth; 287053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta mFirstWidthLineCount = firstWidthLineCount; 297053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta mRestWidth = restWidth; 307053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta } 317053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta 327053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta public float getLineWidth(int line) { 337053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta return (line < mFirstWidthLineCount) ? mFirstWidth : mRestWidth; 347053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta } 357053919a3a55ad1b58e6db701afda18850037732Deepanshu Gupta} 36