List of usage examples for android.util FloatMath sqrt
public static float sqrt(float value)
From source file:de.raptor2101.GalDroid.WebGallery.Gallery3.JSON.PictureEntity.java
public PictureEntity(JSONObject jsonObject, Gallery3Imp gallery3) throws JSONException { super(jsonObject, gallery3); jsonObject = jsonObject.getJSONObject("entity"); int resizeHeight = jsonObject.getInt("resize_height"); int resizeWidth = jsonObject.getInt("resize_width"); float imageDiag = FloatMath.sqrt(resizeHeight * resizeHeight + resizeWidth * resizeWidth); if (imageDiag > gallery3.getMaxImageDiag()) { mLink_Full = String.format(gallery3.LinkRest_LoadPicture, getId(), "full"); mFileSize_Full = jsonObject.getInt("file_size"); } else {/* w ww. j a v a 2 s .c om*/ mLink_Full = String.format(gallery3.LinkRest_LoadPicture, getId(), "resize"); mFileSize_Full = jsonObject.getInt("resize_size"); } mLink_Thumb = String.format(gallery3.LinkRest_LoadPicture, getId(), "thumb"); mFileSize_Thumb = jsonObject.getInt("thumb_size"); }
From source file:it.sephiroth.android.library.imagezoom.ScaleGestureDetector.java
/** * Return the current distance between the two pointers forming the gesture * in progress.//w w w . j ava 2 s .co m * * @return Distance between pointers in pixels. */ public float getCurrentSpan() { if (mCurrLen == -1) { final float cvx = mCurrFingerDiffX; final float cvy = mCurrFingerDiffY; mCurrLen = FloatMath.sqrt(cvx * cvx + cvy * cvy); } return mCurrLen; }
From source file:com.windnow.StationPicActivity.java
@SuppressLint("NewApi") @Override//from w w w . jav a 2 s. c o m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_station_pic); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { getActionBar().setDisplayHomeAsUpEnabled(true); } TextView tv = (TextView) findViewById(R.id.textViewPicName); tv.setText(getIntent().getExtras().getString("name")); imageDetail = (ImageView) findViewById(R.id.imageView1); String filename = "pic" + getIntent().getExtras().getString("txt").hashCode(); Bitmap pic = null; try { FileInputStream is = this.openFileInput(filename); pic = BitmapFactory.decodeStream(is); is.close(); } catch (IOException e) { LoadSaveOps.printErrorToLog(e); } imageDetail.setImageBitmap(pic); imageDetail.setOnTouchListener(new View.OnTouchListener() { @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouch(View v, MotionEvent event) { ImageView view = (ImageView) v; switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: savedMatrix.set(matrix); startPoint.set(event.getX(), event.getY()); mode = DRAG; break; case MotionEvent.ACTION_POINTER_DOWN: oldDist = spacing(event); if (oldDist > 10f) { savedMatrix.set(matrix); midPoint(midPoint, event); mode = ZOOM; } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: mode = NONE; break; case MotionEvent.ACTION_MOVE: if (mode == DRAG) { matrix.set(savedMatrix); matrix.postTranslate(event.getX() - startPoint.x, event.getY() - startPoint.y); } else if (mode == ZOOM) { float newDist = spacing(event); if (newDist > 10f) { matrix.set(savedMatrix); float scale = newDist / oldDist; matrix.postScale(scale, scale, midPoint.x, midPoint.y); matrix.postTranslate(event.getX() - startPoint.x, event.getY() - startPoint.y); //new } } break; } view.setImageMatrix(matrix); return true; } @SuppressLint("FloatMath") private float spacing(MotionEvent event) { float x = event.getX(0) - event.getX(1); float y = event.getY(0) - event.getY(1); return FloatMath.sqrt(x * x + y * y); } private void midPoint(PointF point, MotionEvent event) { float x = event.getX(0) + event.getX(1); float y = event.getY(0) + event.getY(1); point.set(x / 2, y / 2); } }); }
From source file:it.sephiroth.android.library.imagezoom.ScaleGestureDetector.java
/** * Return the previous distance between the two pointers forming the gesture * in progress./*from ww w.j ava2s. co m*/ * * @return Previous distance between pointers in pixels. */ public float getPreviousSpan() { if (mPrevLen == -1) { final float pvx = mPrevFingerDiffX; final float pvy = mPrevFingerDiffY; mPrevLen = FloatMath.sqrt(pvx * pvx + pvy * pvy); } return mPrevLen; }
From source file:com.lightbox.android.bitmap.BitmapUtils.java
public static BitmapSize getScaledSize(int originalWidth, int originalHeight, int numPixels) { float ratio = (float) originalWidth / originalHeight; int scaledHeight = (int) FloatMath.sqrt((float) numPixels / ratio); int scaledWidth = (int) (ratio * FloatMath.sqrt((float) numPixels / ratio)); return new BitmapSize(scaledWidth, scaledHeight); }
From source file:org.que.activities.fragments.MapImageFragment.java
/** * Calculates the euclidean distance between two points. * //from ww w . ja v a2s . c o m * @param event the touch event which contains the point informations * @return the distance */ private float euclideanDistance(MotionEvent event) { float x = event.getX(0) - event.getX(1); float y = event.getY(0) - event.getY(1); return FloatMath.sqrt(x * x + y * y); }
From source file:de.raptor2101.GalDroid.WebGallery.Gallery3.Gallery3Imp.java
public void setPreferedDimensions(int height, int width) { mMaxImageDiag = FloatMath.sqrt(height * height + width * width); }
From source file:com.heneryh.aquanotes.ui.controllers.GraphsFragment.java
private float spacing(MotionEvent event) { final float x = event.getX(0) - event.getX(1); final float y = event.getY(0) - event.getY(1); return FloatMath.sqrt(x * x + y * y); }
From source file:com.cloverstudio.spika.CameraCropActivity.java
/** Determine the space between the first two fingers */ @SuppressLint("FloatMath") private float spacing(MotionEvent event) { float x = event.getX(0) - event.getX(1); float y = event.getY(0) - event.getY(1); return FloatMath.sqrt(x * x + y * y); }
From source file:com.jest.phone.PhoneActivity.java
private float spacing(MotionEvent event) { float x = event.getX(0) - event.getX(1); float y = event.getY(0) - event.getY(1); return FloatMath.sqrt(x * x + y * y); }