| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.hardware.input; |
| 18 |
|
| 19 |
import android.annotation.Nullable; |
| 20 |
import android.os.Parcel; |
| 21 |
import android.os.Parcelable; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
public class TouchCalibration implements Parcelable { |
| 29 |
|
| 30 |
public static final TouchCalibration IDENTITY = new TouchCalibration(); |
| 31 |
|
| 32 |
public static final @android.annotation.NonNull Parcelable.Creator<TouchCalibration> CREATOR |
| 33 |
= new Parcelable.Creator<TouchCalibration>() { |
| 34 |
public TouchCalibration createFromParcel(Parcel in) { |
| 35 |
return new TouchCalibration(in); |
| 36 |
} |
| 37 |
|
| 38 |
public TouchCalibration[] newArray(int size) { |
| 39 |
return new TouchCalibration[size]; |
| 40 |
} |
| 41 |
}; |
| 42 |
|
| 43 |
private final float mXScale, mXYMix, mXOffset; |
| 44 |
private final float mYXMix, mYScale, mYOffset; |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
public TouchCalibration() { |
| 50 |
this(1,0,0,0,1,0); |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public TouchCalibration(float xScale, float xyMix, float xOffset, |
| 63 |
float yxMix, float yScale, float yOffset) { |
| 64 |
mXScale = xScale; |
| 65 |
mXYMix = xyMix; |
| 66 |
mXOffset = xOffset; |
| 67 |
mYXMix = yxMix; |
| 68 |
mYScale = yScale; |
| 69 |
mYOffset = yOffset; |
| 70 |
} |
| 71 |
|
| 72 |
public TouchCalibration(Parcel in) { |
| 73 |
mXScale = in.readFloat(); |
| 74 |
mXYMix = in.readFloat(); |
| 75 |
mXOffset = in.readFloat(); |
| 76 |
mYXMix = in.readFloat(); |
| 77 |
mYScale = in.readFloat(); |
| 78 |
mYOffset = in.readFloat(); |
| 79 |
} |
| 80 |
|
| 81 |
@Override |
| 82 |
public void writeToParcel(Parcel dest, int flags) { |
| 83 |
dest.writeFloat(mXScale); |
| 84 |
dest.writeFloat(mXYMix); |
| 85 |
dest.writeFloat(mXOffset); |
| 86 |
dest.writeFloat(mYXMix); |
| 87 |
dest.writeFloat(mYScale); |
| 88 |
dest.writeFloat(mYOffset); |
| 89 |
} |
| 90 |
|
| 91 |
@Override |
| 92 |
public int describeContents() { |
| 93 |
return 0; |
| 94 |
} |
| 95 |
|
| 96 |
public float[] getAffineTransform() { |
| 97 |
return new float[] { mXScale, mXYMix, mXOffset, mYXMix, mYScale, mYOffset }; |
| 98 |
} |
| 99 |
|
| 100 |
@Override |
| 101 |
public boolean equals(@Nullable Object obj) { |
| 102 |
if (obj == this) { |
| 103 |
return true; |
| 104 |
} else if (obj instanceof TouchCalibration) { |
| 105 |
TouchCalibration cal = (TouchCalibration)obj; |
| 106 |
|
| 107 |
return (cal.mXScale == mXScale) && |
| 108 |
(cal.mXYMix == mXYMix) && |
| 109 |
(cal.mXOffset == mXOffset) && |
| 110 |
(cal.mYXMix == mYXMix) && |
| 111 |
(cal.mYScale == mYScale) && |
| 112 |
(cal.mYOffset == mYOffset); |
| 113 |
} else { |
| 114 |
return false; |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
@Override |
| 119 |
public int hashCode() { |
| 120 |
return Float.floatToIntBits(mXScale) ^ |
| 121 |
Float.floatToIntBits(mXYMix) ^ |
| 122 |
Float.floatToIntBits(mXOffset) ^ |
| 123 |
Float.floatToIntBits(mYXMix) ^ |
| 124 |
Float.floatToIntBits(mYScale) ^ |
| 125 |
Float.floatToIntBits(mYOffset); |
| 126 |
} |
| 127 |
} |