1 /* 2 * Copyright (C) 2018 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.hardware.display; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 22 /** @hide */ 23 public final class Curve implements Parcelable { 24 private final float[] mX; 25 private final float[] mY; 26 Curve(float[] x, float[] y)27 public Curve(float[] x, float[] y) { 28 mX = x; 29 mY = y; 30 } 31 getX()32 public float[] getX() { 33 return mX; 34 } 35 getY()36 public float[] getY() { 37 return mY; 38 } 39 40 public static final @android.annotation.NonNull Creator<Curve> CREATOR = new Creator<Curve>() { 41 public Curve createFromParcel(Parcel in) { 42 float[] x = in.createFloatArray(); 43 float[] y = in.createFloatArray(); 44 return new Curve(x, y); 45 } 46 47 public Curve[] newArray(int size) { 48 return new Curve[size]; 49 } 50 }; 51 52 @Override writeToParcel(Parcel out, int flags)53 public void writeToParcel(Parcel out, int flags) { 54 out.writeFloatArray(mX); 55 out.writeFloatArray(mY); 56 } 57 58 @Override describeContents()59 public int describeContents() { 60 return 0; 61 } 62 63 @Override toString()64 public String toString() { 65 StringBuilder sb = new StringBuilder("["); 66 final int size = mX.length; 67 for (int i = 0; i < size; i++) { 68 if (i != 0) { 69 sb.append(", "); 70 } 71 sb.append("(").append(mX[i]).append(", ").append(mY[i]).append(")"); 72 } 73 sb.append("]"); 74 return sb.toString(); 75 } 76 } 77