summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java7
-rw-r--r--gallerycommon/src/com/android/gallery3d/common/OverScroller.java5
-rw-r--r--gallerycommon/src/com/android/gallery3d/common/Scroller.java5
-rw-r--r--src/com/android/gallery3d/app/EyePosition.java15
-rw-r--r--src/com/android/gallery3d/data/DecodeUtils.java3
-rw-r--r--src/com/android/gallery3d/data/LocationClustering.java3
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java8
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/GradControl.java4
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java5
-rw-r--r--src/com/android/gallery3d/glrenderer/StringTexture.java3
-rw-r--r--src/com/android/gallery3d/ui/PhotoView.java3
-rw-r--r--src/com/android/gallery3d/ui/TileImageView.java9
-rw-r--r--src/com/android/gallery3d/util/MotionEventHelper.java5
13 files changed, 31 insertions, 44 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java b/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java
index a671ed2b9..99b125168 100644
--- a/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java
+++ b/gallerycommon/src/com/android/gallery3d/common/BitmapUtils.java
@@ -23,7 +23,6 @@ import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.os.Build;
-import android.util.FloatMath;
import android.util.Log;
import java.io.ByteArrayOutputStream;
@@ -72,7 +71,7 @@ public class BitmapUtils {
&& minSideLength == UNCONSTRAINED) return 1;
int lowerBound = (maxNumOfPixels == UNCONSTRAINED) ? 1 :
- (int) FloatMath.ceil(FloatMath.sqrt((float) (w * h) / maxNumOfPixels));
+ (int) Math.ceil(Math.sqrt((double) (w * h) / maxNumOfPixels));
if (minSideLength == UNCONSTRAINED) {
return lowerBound;
@@ -96,7 +95,7 @@ public class BitmapUtils {
// Find the min x that 1 / x >= scale
public static int computeSampleSizeLarger(float scale) {
- int initialSize = (int) FloatMath.floor(1f / scale);
+ int initialSize = (int) Math.floor(1d / scale);
if (initialSize <= 1) return 1;
return initialSize <= 8
@@ -107,7 +106,7 @@ public class BitmapUtils {
// Find the max x that 1 / x <= scale.
public static int computeSampleSize(float scale) {
Utils.assertTrue(scale > 0);
- int initialSize = Math.max(1, (int) FloatMath.ceil(1 / scale));
+ int initialSize = Math.max(1, (int) Math.ceil(1 / scale));
return initialSize <= 8
? Utils.nextPowerOf2(initialSize)
: (initialSize + 7) / 8 * 8;
diff --git a/gallerycommon/src/com/android/gallery3d/common/OverScroller.java b/gallerycommon/src/com/android/gallery3d/common/OverScroller.java
index 1ab7953d2..a03c45196 100644
--- a/gallerycommon/src/com/android/gallery3d/common/OverScroller.java
+++ b/gallerycommon/src/com/android/gallery3d/common/OverScroller.java
@@ -18,7 +18,6 @@ package com.android.gallery3d.common;
import android.content.Context;
import android.hardware.SensorManager;
-import android.util.FloatMath;
import android.util.Log;
import android.view.ViewConfiguration;
import android.view.animation.AnimationUtils;
@@ -175,9 +174,7 @@ public class OverScroller {
* @return The original velocity less the deceleration, norm of the X and Y velocity vector.
*/
public float getCurrVelocity() {
- float squaredNorm = mScrollerX.mCurrVelocity * mScrollerX.mCurrVelocity;
- squaredNorm += mScrollerY.mCurrVelocity * mScrollerY.mCurrVelocity;
- return FloatMath.sqrt(squaredNorm);
+ return (float) Math.hypot(mScrollerX.mCurrVelocity, mScrollerY.mCurrVelocity);
}
/**
diff --git a/gallerycommon/src/com/android/gallery3d/common/Scroller.java b/gallerycommon/src/com/android/gallery3d/common/Scroller.java
index 6cefd6fb0..cce0c9284 100644
--- a/gallerycommon/src/com/android/gallery3d/common/Scroller.java
+++ b/gallerycommon/src/com/android/gallery3d/common/Scroller.java
@@ -19,7 +19,6 @@ package com.android.gallery3d.common;
import android.content.Context;
import android.hardware.SensorManager;
import android.os.Build;
-import android.util.FloatMath;
import android.view.ViewConfiguration;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
@@ -372,7 +371,7 @@ public class Scroller {
float dx = mFinalX - mStartX;
float dy = mFinalY - mStartY;
- float hyp = FloatMath.sqrt(dx * dx + dy * dy);
+ float hyp = (float) Math.hypot(dx, dy);
float ndx = dx / hyp;
float ndy = dy / hyp;
@@ -389,7 +388,7 @@ public class Scroller {
mMode = FLING_MODE;
mFinished = false;
- float velocity = FloatMath.sqrt(velocityX * velocityX + velocityY * velocityY);
+ float velocity = (float) Math.hypot(velocityX, velocityY);
mVelocity = velocity;
final double l = Math.log(START_TENSION * velocity / ALPHA);
diff --git a/src/com/android/gallery3d/app/EyePosition.java b/src/com/android/gallery3d/app/EyePosition.java
index d99d97b0e..4248f49b8 100644
--- a/src/com/android/gallery3d/app/EyePosition.java
+++ b/src/com/android/gallery3d/app/EyePosition.java
@@ -22,7 +22,6 @@ import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.SystemClock;
-import android.util.FloatMath;
import android.view.Display;
import android.view.Surface;
import android.view.WindowManager;
@@ -44,9 +43,9 @@ public class EyePosition {
private static final float GYROSCOPE_RESTORE_FACTOR = 0.995f;
private static final float USER_ANGEL = (float) Math.toRadians(10);
- private static final float USER_ANGEL_COS = FloatMath.cos(USER_ANGEL);
- private static final float USER_ANGEL_SIN = FloatMath.sin(USER_ANGEL);
- private static final float MAX_VIEW_RANGE = (float) 0.5;
+ private static final float USER_ANGEL_COS = (float) Math.cos(USER_ANGEL);
+ private static final float USER_ANGEL_SIN = (float) Math.sin(USER_ANGEL);
+ private static final float MAX_VIEW_RANGE = 0.5f;
private static final int NOT_STARTED = -1;
private static final float USER_DISTANCE_METER = 0.3f;
@@ -128,8 +127,8 @@ public class EyePosition {
float ty = -1 + t * y;
float tz = t * z;
- float length = FloatMath.sqrt(tx * tx + ty * ty + tz * tz);
- float glength = FloatMath.sqrt(temp);
+ float length = (float) Math.sqrt(tx * tx + ty * ty + tz * tz);
+ float glength = (float) Math.sqrt(temp);
mX = Utils.clamp((x * USER_ANGEL_COS / glength
+ tx * USER_ANGEL_SIN / length) * mUserDistance,
@@ -137,7 +136,7 @@ public class EyePosition {
mY = -Utils.clamp((y * USER_ANGEL_COS / glength
+ ty * USER_ANGEL_SIN / length) * mUserDistance,
-mLimit, mLimit);
- mZ = -FloatMath.sqrt(
+ mZ = (float) -Math.sqrt(
mUserDistance * mUserDistance - mX * mX - mY * mY);
mListener.onEyePositionChanged(mX, mY, mZ);
}
@@ -175,7 +174,7 @@ public class EyePosition {
mY = Utils.clamp((float) (mY + y * t / Math.hypot(mZ, mY)),
-mLimit, mLimit) * GYROSCOPE_RESTORE_FACTOR;
- mZ = -FloatMath.sqrt(
+ mZ = (float) -Math.sqrt(
mUserDistance * mUserDistance - mX * mX - mY * mY);
mListener.onEyePositionChanged(mX, mY, mZ);
}
diff --git a/src/com/android/gallery3d/data/DecodeUtils.java b/src/com/android/gallery3d/data/DecodeUtils.java
index fa709157d..2853baffb 100644
--- a/src/com/android/gallery3d/data/DecodeUtils.java
+++ b/src/com/android/gallery3d/data/DecodeUtils.java
@@ -23,7 +23,6 @@ import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.BitmapRegionDecoder;
import android.os.Build;
-import android.util.FloatMath;
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.common.BitmapUtils;
@@ -135,7 +134,7 @@ public class DecodeUtils {
final int MAX_PIXEL_COUNT = 640000; // 400 x 1600
if ((w / options.inSampleSize) * (h / options.inSampleSize) > MAX_PIXEL_COUNT) {
options.inSampleSize = BitmapUtils.computeSampleSize(
- FloatMath.sqrt((float) MAX_PIXEL_COUNT / (w * h)));
+ (float) Math.sqrt((double) MAX_PIXEL_COUNT / (w * h)));
}
} else {
// For screen nail, we only want to keep the longer side >= targetSize.
diff --git a/src/com/android/gallery3d/data/LocationClustering.java b/src/com/android/gallery3d/data/LocationClustering.java
index 540322a33..90ac41c65 100644
--- a/src/com/android/gallery3d/data/LocationClustering.java
+++ b/src/com/android/gallery3d/data/LocationClustering.java
@@ -19,7 +19,6 @@ package com.android.gallery3d.data;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
-import android.util.FloatMath;
import android.widget.Toast;
import com.android.gallery3d.R;
@@ -298,7 +297,7 @@ class LocationClustering extends Clustering {
}
// step 5: calculate the final score
- float score = totalDistance * FloatMath.sqrt(realK);
+ float score = totalDistance * (float) Math.sqrt(realK);
if (score < bestScore) {
bestScore = score;
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java b/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java
index dada7dcb2..614b6485d 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/GeometryMathUtils.java
@@ -151,7 +151,7 @@ public final class GeometryMathUtils {
}
public static float[] normalize(float[] a) {
- float length = (float) Math.sqrt(a[0] * a[0] + a[1] * a[1]);
+ float length = (float) Math.hypot(a[0], a[1]);
float[] b = {
a[0] / length, a[1] / length
};
@@ -160,7 +160,7 @@ public final class GeometryMathUtils {
// A onto B
public static float scalarProjection(float[] a, float[] b) {
- float length = (float) Math.sqrt(b[0] * b[0] + b[1] * b[1]);
+ float length = (float) Math.hypot(b[0], b[1]);
return dotProduct(a, b) / length;
}
@@ -175,7 +175,7 @@ public final class GeometryMathUtils {
float[] p = {
point2[0] - point1[0], point2[1] - point1[1]
};
- float length = (float) Math.sqrt(p[0] * p[0] + p[1] * p[1]);
+ float length = (float) Math.hypot(p[0], p[1]);
p[0] = p[0] / length;
p[1] = p[1] / length;
return p;
@@ -198,7 +198,7 @@ public final class GeometryMathUtils {
}
public static float vectorLength(float[] a) {
- return (float) Math.sqrt(a[0] * a[0] + a[1] * a[1]);
+ return (float) Math.hypot(a[0], a[1]);
}
public static float scale(float oldWidth, float oldHeight, float newWidth, float newHeight) {
diff --git a/src/com/android/gallery3d/filtershow/imageshow/GradControl.java b/src/com/android/gallery3d/filtershow/imageshow/GradControl.java
index 964da99e9..29870154b 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/GradControl.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/GradControl.java
@@ -110,7 +110,7 @@ public class GradControl {
for (int i = 0; i < handlex.length; i++) {
float dx = handlex[i] - x;
float dy = handley[i] - y;
- float dist = (float) Math.sqrt(dx * dx + dy * dy);
+ float dist = (float) Math.hypot(dx, dy);
}
return -1;
@@ -236,7 +236,7 @@ public class GradControl {
float cy = (p1y + p2y) / 2;
float dx = p1x - p2x;
float dy = p1y - p2y;
- float len = (float) Math.sqrt(dx * dx + dy * dy);
+ float len = (float) Math.hypot(dx, dy);
dx *= 2048 / len;
dy *= 2048 / len;
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java b/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java
index 0d20322d6..3fb75c6df 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageCurves.java
@@ -223,12 +223,11 @@ public class ImageCurves extends ImageShow {
Spline spline = getSpline(mCurrentCurveIndex);
float px = spline.getPoint(0).x;
float py = spline.getPoint(0).y;
- double delta = Math.sqrt((px - x) * (px - x) + (py - y) * (py - y));
+ double delta = Math.hypot(px - x, py - y);
for (int i = 1; i < spline.getNbPoints(); i++) {
px = spline.getPoint(i).x;
py = spline.getPoint(i).y;
- double currentDelta = Math.sqrt((px - x) * (px - x) + (py - y)
- * (py - y));
+ double currentDelta = Math.hypot(px - x, py - y);
if (currentDelta < delta) {
delta = currentDelta;
pick = i;
diff --git a/src/com/android/gallery3d/glrenderer/StringTexture.java b/src/com/android/gallery3d/glrenderer/StringTexture.java
index 56ca29753..c18d91b47 100644
--- a/src/com/android/gallery3d/glrenderer/StringTexture.java
+++ b/src/com/android/gallery3d/glrenderer/StringTexture.java
@@ -23,7 +23,6 @@ import android.graphics.Paint.FontMetricsInt;
import android.graphics.Typeface;
import android.text.TextPaint;
import android.text.TextUtils;
-import android.util.FloatMath;
// StringTexture is a texture shows the content of a specified String.
//
@@ -72,7 +71,7 @@ public class StringTexture extends CanvasTexture {
private static StringTexture newInstance(String text, TextPaint paint) {
FontMetricsInt metrics = paint.getFontMetricsInt();
- int width = (int) FloatMath.ceil(paint.measureText(text));
+ int width = (int) Math.ceil(paint.measureText(text));
int height = metrics.bottom - metrics.top;
// The texture size needs to be at least 1x1.
if (width <= 0) width = 1;
diff --git a/src/com/android/gallery3d/ui/PhotoView.java b/src/com/android/gallery3d/ui/PhotoView.java
index 7afa20348..e8c706f05 100644
--- a/src/com/android/gallery3d/ui/PhotoView.java
+++ b/src/com/android/gallery3d/ui/PhotoView.java
@@ -23,7 +23,6 @@ import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Build;
import android.os.Message;
-import android.util.FloatMath;
import android.view.MotionEvent;
import android.view.View.MeasureSpec;
import android.view.animation.AccelerateInterpolator;
@@ -1071,7 +1070,7 @@ public class PhotoView extends GLView {
delta = delta > 0 ? maxScrollDistance : -maxScrollDistance;
} else {
delta = maxScrollDistance *
- FloatMath.sin((delta / size) * (float) (Math.PI / 2));
+ (float) Math.sin((delta / size) * (Math.PI / 2));
}
return (int) (delta + 0.5f);
}
diff --git a/src/com/android/gallery3d/ui/TileImageView.java b/src/com/android/gallery3d/ui/TileImageView.java
index 3185c7598..1103ed80a 100644
--- a/src/com/android/gallery3d/ui/TileImageView.java
+++ b/src/com/android/gallery3d/ui/TileImageView.java
@@ -23,7 +23,6 @@ import android.graphics.Rect;
import android.graphics.RectF;
import android.support.v4.util.LongSparseArray;
import android.util.DisplayMetrics;
-import android.util.FloatMath;
import android.view.WindowManager;
import com.android.gallery3d.app.GalleryContext;
@@ -313,10 +312,10 @@ public class TileImageView extends GLView {
int height = (int) Math.ceil(Math.max(
Math.abs(sin * w + cos * h), Math.abs(sin * w - cos * h)));
- int left = (int) FloatMath.floor(cX - width / (2f * scale));
- int top = (int) FloatMath.floor(cY - height / (2f * scale));
- int right = (int) FloatMath.ceil(left + width / scale);
- int bottom = (int) FloatMath.ceil(top + height / scale);
+ int left = (int) Math.floor(cX - width / (2f * scale));
+ int top = (int) Math.floor(cY - height / (2f * scale));
+ int right = (int) Math.ceil(left + width / scale);
+ int bottom = (int) Math.ceil(top + height / scale);
// align the rectangle to tile boundary
int size = sTileSize << level;
diff --git a/src/com/android/gallery3d/util/MotionEventHelper.java b/src/com/android/gallery3d/util/MotionEventHelper.java
index 715f7fa69..dc01cd98c 100644
--- a/src/com/android/gallery3d/util/MotionEventHelper.java
+++ b/src/com/android/gallery3d/util/MotionEventHelper.java
@@ -17,7 +17,6 @@ package com.android.gallery3d.util;
import android.annotation.TargetApi;
import android.graphics.Matrix;
-import android.util.FloatMath;
import android.view.MotionEvent;
import android.view.MotionEvent.PointerCoords;
@@ -104,8 +103,8 @@ public final class MotionEventHelper {
// angle from vertical. Coordinate system: down is increasing Y, right is
// increasing X.
float[] v = new float[2];
- v[0] = FloatMath.sin(angleRadians);
- v[1] = -FloatMath.cos(angleRadians);
+ v[0] = (float) Math.sin(angleRadians);
+ v[1] = (float) -Math.cos(angleRadians);
m.mapVectors(v);
// Derive the transformed vector's clockwise angle from vertical.