当前位置: 首页>>代码示例>>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;未经允许,请勿转载。