當前位置: 首頁>>代碼示例>>Java>>正文


Java FloatMath類代碼示例

本文整理匯總了Java中android.util.FloatMath的典型用法代碼示例。如果您正苦於以下問題:Java FloatMath類的具體用法?Java FloatMath怎麽用?Java FloatMath使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FloatMath類屬於android.util包,在下文中一共展示了FloatMath類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: measureWidth

import android.util.FloatMath; //導入依賴的package包/類
/**
 * Determines the width of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The width of the view, honoring constraints from measureSpec
 */
private int measureWidth(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if ((specMode == MeasureSpec.EXACTLY) || (mViewPager == null)) {
        //We were told how big to be
        result = specSize;
    } else {
        //Calculate the width according the views count
        final int count = mViewPager.getAdapter().getCount();
        result = getPaddingLeft() + getPaddingRight() + (count * mLineWidth) + ((count - 1) * mGapWidth);
        //Respect AT_MOST value if that was what is called for by measureSpec
        if (specMode == MeasureSpec.AT_MOST) {
            result = Math.min(result, specSize);
        }
    }
    return (int)FloatMath.ceil(result);
}
 
開發者ID:fikyair,項目名稱:musicplayer,代碼行數:27,代碼來源:LinePageIndicator.java

示例2: measureHeight

import android.util.FloatMath; //導入依賴的package包/類
/**
 * Determines the height of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The height of the view, honoring constraints from measureSpec
 */
private int measureHeight(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if (specMode == MeasureSpec.EXACTLY) {
        //We were told how big to be
        result = specSize;
    } else {
        //Measure the height
        result = mPaintSelected.getStrokeWidth() + getPaddingTop() + getPaddingBottom();
        //Respect AT_MOST value if that was what is called for by measureSpec
        if (specMode == MeasureSpec.AT_MOST) {
            result = Math.min(result, specSize);
        }
    }
    return (int)FloatMath.ceil(result);
}
 
開發者ID:fikyair,項目名稱:musicplayer,代碼行數:26,代碼來源:LinePageIndicator.java

示例3: measureWidth

import android.util.FloatMath; //導入依賴的package包/類
private int measureWidth(int measureSpec) {
    float result;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);
    if (specMode == 1073741824 || this.mViewPager == null) {
        result = (float) specSize;
    } else {
        int count = this.mViewPager.getAdapter().getCount();
        result = (((float) (getPaddingLeft() + getPaddingRight())) + (((float) count) * this
                .mLineWidth)) + (((float) (count - 1)) * this.mGapWidth);
        if (specMode == Integer.MIN_VALUE) {
            result = Math.min(result, (float) specSize);
        }
    }
    return (int) FloatMath.ceil(result);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:17,代碼來源:LinePageIndicator.java

示例4: loadImage

import android.util.FloatMath; //導入依賴的package包/類
public static Bitmap loadImage(Context context, int resId, int imgWidth, int imgHeight){
	Options opts = new Options();
	opts.inJustDecodeBounds = true;
	BitmapFactory.decodeResource(context.getResources(), resId, opts);
	final int height = opts.outHeight;
	final int width = opts.outWidth;
	int inSampleSize = 1;
	if (height > imgHeight || width > imgWidth) {
		if (width > height) {
			inSampleSize = (int) FloatMath
					.floor(((float) height / imgHeight) + 0.5f); // Math.round((float)height
		} else {
			inSampleSize = (int) FloatMath
					.floor(((float) width / imgWidth) + 0.5f); // Math.round((float)width
		}
	}
	opts.inSampleSize = inSampleSize;
	opts.inJustDecodeBounds = false;
	System.out.println("得到的縮放比例為:" + inSampleSize);
	Bitmap copyImg = BitmapFactory.decodeResource(context.getResources(), resId, opts);
	return copyImg;
}
 
開發者ID:dyzs,項目名稱:YinjiImageEditor,代碼行數:23,代碼來源:BitmapUtils.java

示例5: measureWidth

import android.util.FloatMath; //導入依賴的package包/類
/**
 * Determines the width of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The width of the view, honoring constraints from measureSpec
 */
private int measureWidth(int measureSpec) {
    float result = 0;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if ((specMode == MeasureSpec.EXACTLY) || (mViewPager == null)) {
        //We were told how big to be
        result = specSize;
    } else {
        //Calculate the width according the views count
        final int count = mViewPager.getAdapter().getCount();
        result = getPaddingLeft() + getPaddingRight() + (count * mLineWidth) + ((count - 1) * mGapWidth);
        //Respect AT_MOST value if that was what is called for by measureSpec
        if (specMode == MeasureSpec.AT_MOST) {
            result = Math.min(result, specSize);
        }
    }
    return (int)FloatMath.ceil(result);
}
 
開發者ID:ivanovpv,項目名稱:darksms,代碼行數:27,代碼來源:LinePageIndicator.java

示例6: invalidateAfterUpdate

import android.util.FloatMath; //導入依賴的package包/類
private void invalidateAfterUpdate() {
    View view = mView.get();
    if (view == null) {
        return;
    }
    View parent = (View) view.getParent();
    if (parent == null) {
        return;
    }

    view.setAnimation(this);

    final RectF after = mAfter;
    computeRect(after, view);
    after.union(mBefore);

    parent.invalidate(
            (int) FloatMath.floor(after.left),
            (int) FloatMath.floor(after.top),
            (int) FloatMath.ceil(after.right),
            (int) FloatMath.ceil(after.bottom));
}
 
開發者ID:ivanovpv,項目名稱:darksms,代碼行數:23,代碼來源:AnimatorProxy.java

示例7: invalidateAfterUpdate

import android.util.FloatMath; //導入依賴的package包/類
private void invalidateAfterUpdate() {
    View view = mView.get();
    if (view == null) {
        return;
    }
    View parent = (View)view.getParent();
    if (parent == null) {
        return;
    }

    view.setAnimation(this);

    final RectF after = mAfter;
    computeRect(after, view);
    after.union(mBefore);

    parent.invalidate(
            (int) FloatMath.floor(after.left),
            (int) FloatMath.floor(after.top),
            (int) FloatMath.ceil(after.right),
            (int) FloatMath.ceil(after.bottom));
}
 
開發者ID:Aptoide,項目名稱:aptoide-backup-apps,代碼行數:23,代碼來源:AnimatorProxy.java

示例8: createHexagon

import android.util.FloatMath; //導入依賴的package包/類
private Path createHexagon(int size, int centerX, int centerY) {
	final float section = (float) (2.0 * Math.PI / numberOfSides);
	int radius = size / 2;
	Path polygonPath = temporal;
	polygonPath.reset();
	polygonPath.moveTo((centerX + radius * FloatMath.cos(0)),
			(centerY + radius * FloatMath.sin(0)));

	for (int i = 1; i < numberOfSides; i++) {
		polygonPath.lineTo((centerX + radius * FloatMath.cos(section * i)),
				(centerY + radius * FloatMath.sin(section * i)));
	}

	polygonPath.close();
	return polygonPath;
}
 
開發者ID:hiteshsahu,項目名稱:Benzene,代碼行數:17,代碼來源:PolygonalDrwable.java

示例9: getSampledBitmap

import android.util.FloatMath; //導入依賴的package包/類
public static Bitmap getSampledBitmap(String filePath, int reqWidth, int reqHeight) {		
	Options options = new Options();
	options.inJustDecodeBounds = true;
	
	BitmapFactory.decodeFile(filePath, options);
	
	// Raw height and width of image
    final int height = options.outHeight;
    final int width = options.outWidth;
    int inSampleSize = 1;

    if (height > reqHeight || width > reqWidth) {
        if (width > height) {
            inSampleSize = (int)FloatMath.floor(((float)height / reqHeight)+0.5f); //Math.round((float)height / (float)reqHeight);
        } else {
            inSampleSize = (int)FloatMath.floor(((float)width / reqWidth)+0.5f); //Math.round((float)width / (float)reqWidth);
        }
    }
    
    options.inSampleSize = inSampleSize;
    options.inJustDecodeBounds = false;
    	    
    return BitmapFactory.decodeFile(filePath, options);
}
 
開發者ID:xulailing,項目名稱:android-open-project-demo-master,代碼行數:25,代碼來源:BitmapUtils.java

示例10: createScaleAnimation

import android.util.FloatMath; //導入依賴的package包/類
public static Animation createScaleAnimation(View view, int parentWidth, int parentHeight,
        int toX, int toY) {
    // Difference in X and Y
    final int diffX = toX - view.getLeft();
    final int diffY = toY - view.getTop();

    // Calculate actual distance using pythagors
    float diffDistance = FloatMath.sqrt((toX * toX) + (toY * toY));
    float parentDistance = FloatMath
            .sqrt((parentWidth * parentWidth) + (parentHeight * parentHeight));

    ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 0f, 1f, 0f, Animation.ABSOLUTE,
            diffX,
            Animation.ABSOLUTE, diffY);
    scaleAnimation.setFillAfter(true);
    scaleAnimation.setInterpolator(new DecelerateInterpolator());
    scaleAnimation.setDuration(Math.round(diffDistance / parentDistance
            * Constants.SCALE_ANIMATION_DURATION_FULL_DISTANCE));

    return scaleAnimation;
}
 
開發者ID:xulailing,項目名稱:android-open-project-demo-master,代碼行數:22,代碼來源:Utils.java

示例11: measureHeight

import android.util.FloatMath; //導入依賴的package包/類
/**
 * Determines the height of this view
 *
 * @param measureSpec
 *            A measureSpec packed into an int
 * @return The height of the view, honoring constraints from measureSpec
 */
private int measureHeight(int measureSpec) {
    float result = 0;
    int specMode = MeasureSpec.getMode(measureSpec);
    int specSize = MeasureSpec.getSize(measureSpec);

    if (specMode == MeasureSpec.EXACTLY) {
        //We were told how big to be
        result = specSize;
    } else {
        //Measure the height
        result = mPaintSelected.getStrokeWidth() + getPaddingTop() + getPaddingBottom();
        //Respect AT_MOST value if that was what is called for by measureSpec
        if (specMode == MeasureSpec.AT_MOST) {
            result = Math.min(result, specSize);
        }
    }
    return (int)FloatMath.ceil(result);
}
 
開發者ID:thelinuxgeekcommunity,項目名稱:simpleirc,代碼行數:26,代碼來源:LinePageIndicator.java

示例12: onPull

import android.util.FloatMath; //導入依賴的package包/類
/**
 * A view should call this when content is pulled away from an edge by the user.
 * This will update the state of the current visual effect and its associated animation.
 * The host view should always {@link android.view.View#invalidate()} after this
 * and draw the results accordingly.
 *
 * @param deltaDistance Change in distance since the last call. Values may be 0 (no change) to
 *                      1.f (full length of the view) or negative values to express change
 *                      back toward the edge reached to initiate the effect.
 * @param displacement The displacement from the starting side of the effect of the point
 *                     initiating the pull. In the case of touch this is the finger position.
 *                     Values may be from 0-1.
 */
public void onPull(float deltaDistance, float displacement) {
    final long now = AnimationUtils.currentAnimationTimeMillis();
    mTargetDisplacement = displacement;
    if (mState == STATE_PULL_DECAY && now - mStartTime < mDuration) {
        //動畫未完成 return
        return;
    }
    if (mState != STATE_PULL) {
        mGlowScaleY = Math.max(PULL_GLOW_BEGIN, mGlowScaleY);
    }
    mState = STATE_PULL;

    mStartTime = now;
    mDuration = PULL_TIME;

    mPullDistance += deltaDistance;

    final float absdd = Math.abs(deltaDistance);
    mGlowAlpha = mGlowAlphaStart = Math.min(MAX_ALPHA,
            mGlowAlpha + (absdd * PULL_DISTANCE_ALPHA_GLOW_FACTOR));

    if (mPullDistance == 0) {
        mGlowScaleY = mGlowScaleYStart = 0;
    } else {
        final float scale = Math.max(0, 1 - 1 /
                FloatMath.sqrt(Math.abs(mPullDistance) * mBounds.height()) - 0.3f) / 0.7f;

        mGlowScaleY = mGlowScaleYStart = scale;
    }

    mGlowAlphaFinish = mGlowAlpha;
    mGlowScaleYFinish = mGlowScaleY;
}
 
開發者ID:teisun,項目名稱:SunmiUI,代碼行數:47,代碼來源:EdgeEffect.java

示例13: onSensorChanged

import android.util.FloatMath; //導入依賴的package包/類
public void onSensorChanged(SensorEvent event) {
	long currentTime = System.currentTimeMillis();
	long diffTime = currentTime - mLastUpdateTime;
	if (diffTime > UPDATE_INTERVAL) {
		if(mLastUpdateTime != 0) {
			float x = event.values[0];
			float y = event.values[1];
			float z = event.values[2];
			float deltaX = x - mLastX;
			float deltaY = y - mLastY;
			float deltaZ = z - mLastZ;
			float delta = FloatMath.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ) / diffTime * 10000;
			if (delta > SHAKE_THRESHOLD) {
				if (!shaken) {
					shaken = true;
					finish();
				}

				if (listener != null) {
					listener.onShake();
				}
			}
			mLastX = x;
			mLastY = y;
			mLastZ = z;
		}
		mLastUpdateTime = currentTime;
	}
}
 
開發者ID:liupengandroid,項目名稱:ywApplication,代碼行數:30,代碼來源:Shake2Share.java

示例14: spacing

import android.util.FloatMath; //導入依賴的package包/類
/**
    * 兩點的距離
    */
   @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);
   }
 
開發者ID:liupengandroid,項目名稱:ywApplication,代碼行數:10,代碼來源:PicViewer.java

示例15: a

import android.util.FloatMath; //導入依賴的package包/類
private float a(MotionEvent motionEvent) {
    if (motionEvent.getPointerCount() < 2) {
        return 0.0f;
    }
    float x = motionEvent.getX(0) - motionEvent.getX(1);
    float y = motionEvent.getY(0) - motionEvent.getY(1);
    return FloatMath.sqrt((x * x) + (y * y));
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:9,代碼來源:c.java


注:本文中的android.util.FloatMath類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。