1 /* 2 * Copyright (C) 2007 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.util; 18 19 import com.android.layoutlib.bridge.impl.DelegateManager; 20 import com.android.tools.layoutlib.annotations.LayoutlibDelegate; 21 22 /** 23 * Delegate implementing the native methods of android.util.FloatMath 24 * 25 * Through the layoutlib_create tool, the original native methods of FloatMath have been replaced 26 * by calls to methods of the same name in this delegate class. 27 * 28 * Because it's a stateless class to start with, there's no need to keep a {@link DelegateManager} 29 * around to map int to instance of the delegate. 30 * 31 */ 32 /*package*/ final class FloatMath_Delegate { 33 34 /** Prevents instantiation. */ FloatMath_Delegate()35 private FloatMath_Delegate() {} 36 37 /** 38 * Returns the float conversion of the most positive (i.e. closest to 39 * positive infinity) integer value which is less than the argument. 40 * 41 * @param value to be converted 42 * @return the floor of value 43 */ 44 @LayoutlibDelegate floor(float value)45 /*package*/ static float floor(float value) { 46 return (float)Math.floor(value); 47 } 48 49 /** 50 * Returns the float conversion of the most negative (i.e. closest to 51 * negative infinity) integer value which is greater than the argument. 52 * 53 * @param value to be converted 54 * @return the ceiling of value 55 */ 56 @LayoutlibDelegate ceil(float value)57 /*package*/ static float ceil(float value) { 58 return (float)Math.ceil(value); 59 } 60 61 /** 62 * Returns the closest float approximation of the sine of the argument. 63 * 64 * @param angle to compute the cosine of, in radians 65 * @return the sine of angle 66 */ 67 @LayoutlibDelegate sin(float angle)68 /*package*/ static float sin(float angle) { 69 return (float)Math.sin(angle); 70 } 71 72 /** 73 * Returns the closest float approximation of the cosine of the argument. 74 * 75 * @param angle to compute the cosine of, in radians 76 * @return the cosine of angle 77 */ 78 @LayoutlibDelegate cos(float angle)79 /*package*/ static float cos(float angle) { 80 return (float)Math.cos(angle); 81 } 82 83 /** 84 * Returns the closest float approximation of the square root of the 85 * argument. 86 * 87 * @param value to compute sqrt of 88 * @return the square root of value 89 */ 90 @LayoutlibDelegate sqrt(float value)91 /*package*/ static float sqrt(float value) { 92 return (float)Math.sqrt(value); 93 } 94 } 95