本文整理匯總了Java中android.graphics.PointF類的典型用法代碼示例。如果您正苦於以下問題:Java PointF類的具體用法?Java PointF怎麽用?Java PointF使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PointF類屬於android.graphics包,在下文中一共展示了PointF類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: smoothScrollToPosition
import android.graphics.PointF; //導入依賴的package包/類
@Override
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
//
LinearSmoothScroller smoothScroller = new LinearSmoothScroller(mContext){
@Nullable
@Override
public PointF computeScrollVectorForPosition(int targetPosition) {
return ScrollerLinearLayoutManager.this.computeScrollVectorForPosition
(targetPosition);
}
//1 pixel -> 0.05 ms
//1000 pixel -> x=50 ms to go over the height of the screen
@Override
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
return 0.05f;
//return x /displayMetrics.densityDpi;
}
};
smoothScroller.setTargetPosition(position);
startSmoothScroll(smoothScroller);
}
示例2: createPathArray
import android.graphics.PointF; //導入依賴的package包/類
/**
* Creates a path array to be used to draw lines
*
* @param points nodes which will be concatenate. Points are relative to the view and values between [0,1]
* @return float array that can be used on both drawing straight or dotted lines
*/
protected float[] createPathArray(List<PointF> points) {
float[] pathArray = new float[(points.size() - 1) * 4];
for (int i = 0; i < points.size() - 1; i++) {
int index = i * 4;
PointF from = points.get(i);
pathArray[index] = translateX(from.x);
pathArray[index + 1] = translateY(from.y);
PointF to = points.get(i + 1);
pathArray[index + 2] = translateX(to.x);
pathArray[index + 3] = translateY(to.y);
}
return pathArray;
}
示例3: DoubleTapZoom
import android.graphics.PointF; //導入依賴的package包/類
DoubleTapZoom(float targetZoom, float focusX, float focusY, boolean stretchImageToSuper) {
setState(State.ANIMATE_ZOOM);
startTime = System.currentTimeMillis();
this.startZoom = normalizedScale;
this.targetZoom = targetZoom;
this.stretchImageToSuper = stretchImageToSuper;
PointF bitmapPoint = transformCoordTouchToBitmap(focusX, focusY, false);
this.bitmapX = bitmapPoint.x;
this.bitmapY = bitmapPoint.y;
//
// Used for translating image during scaling
//
startTouch = transformCoordBitmapToTouch(bitmapX, bitmapY);
endTouch = new PointF(viewWidth / 2, viewHeight / 2);
}
示例4: getDragAnimaDuration
import android.graphics.PointF; //導入依賴的package包/類
private long getDragAnimaDuration(Object... pointFs) {
float x = ((PointF) pointFs[0]).x - ((PointF) pointFs[pointFs.length - 1]).x;
float y = ((PointF) pointFs[0]).y - ((PointF) pointFs[pointFs.length - 1]).y;
long duration = (long) (Math.hypot(x, y) * 1.6F);
//關於這個比例自己調吧
if (duration == 0) {
return mDragAnimaDuration;
} else if (duration > 0 && duration <= MIN_DURATION) {
return MIN_DURATION;
} else if (duration > MIN_DURATION && duration <= MAX_DURATION) {
return duration;
}
return MAX_DURATION;
}
示例5: transformCoordTouchToBitmap
import android.graphics.PointF; //導入依賴的package包/類
/**
* This function will transform the coordinates in the touch event to the coordinate
* system of the drawable that the imageview contain
* @param x x-coordinate of touch event
* @param y y-coordinate of touch event
* @param clipToBitmap Touch event may occur within view, but outside image content. True, to clip return value
* to the bounds of the bitmap size.
* @return Coordinates of the point touched, in the coordinate system of the original drawable.
*/
private PointF transformCoordTouchToBitmap(float x, float y, boolean clipToBitmap) {
matrix.getValues(m);
float origW = getDrawable().getIntrinsicWidth();
float origH = getDrawable().getIntrinsicHeight();
float transX = m[Matrix.MTRANS_X];
float transY = m[Matrix.MTRANS_Y];
float finalX = ((x - transX) * origW) / getImageWidth();
float finalY = ((y - transY) * origH) / getImageHeight();
if (clipToBitmap) {
finalX = Math.min(Math.max(finalX, 0), origW);
finalY = Math.min(Math.max(finalY, 0), origH);
}
return new PointF(finalX , finalY);
}
示例6: setFilingGesture
import android.graphics.PointF; //導入依賴的package包/類
private void setFilingGesture(Context context) {
mFlingDetector = new GestureDetector(context,new GestureDetector.SimpleOnGestureListener(){
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (mTranslateEnabled && mReadySent && mViewTranslate != null && e1 != null && e2 != null
&& (Math.abs(e1.getX() - e2.getX()) > 50 || Math.abs(e1.getY() - e2.getY()) > 50)
&& (Math.abs(velocityX) > 500 || Math.abs(velocityY) > 500) && !mIsZooming) {
PointF vTranslateEnd =
new PointF(mViewTranslate.x + (velocityX * 0.25f), mViewTranslate.y + (velocityY * 0.25f));
float sCenterXEnd = ((getWidth() / 2.0F) - vTranslateEnd.x) / mScale;
float sCenterYEnd = ((getHeight() / 2.0F) - vTranslateEnd.y) / mScale;
startFilingAnimation(sCenterXEnd, sCenterYEnd);
if (BuildConfig.DEBUG) Log.d(TAG, "onFling: 正在滑行");
return true;
}
return false;
}
});
}
示例7: transformCoordTouchToBitmap
import android.graphics.PointF; //導入依賴的package包/類
/**
* This function will transform the coordinates in the touch event to the coordinate
* system of the drawable that the imageview contain
*
* @param x x-coordinate of touch event
* @param y y-coordinate of touch event
* @param clipToBitmap Touch event may occur within view, but outside image content. True, to clip return value
* to the bounds of the bitmap size.
* @return Coordinates of the point touched, in the coordinate system of the original drawable.
*/
private PointF transformCoordTouchToBitmap(float x, float y, boolean clipToBitmap) {
matrix.getValues(m);
float origW = getDrawable().getIntrinsicWidth();
float origH = getDrawable().getIntrinsicHeight();
float transX = m[Matrix.MTRANS_X];
float transY = m[Matrix.MTRANS_Y];
float finalX = ((x - transX) * origW) / getImageWidth();
float finalY = ((y - transY) * origH) / getImageHeight();
if (clipToBitmap) {
finalX = Math.min(Math.max(finalX, 0), origW);
finalY = Math.min(Math.max(finalY, 0), origH);
}
return new PointF(finalX, finalY);
}
示例8: RadarView
import android.graphics.PointF; //導入依賴的package包/類
public RadarView(Context context, AttributeSet attrs) {
super(context, attrs);
this.BACKGROUND_COLOR = new int[]{-3283459, -2692611, -1641730, -853763, -1};
this.FILL_COLOR = new int[]{-14581016, -15501602, -13858067, -12477447, -13397517};
this.STROKE_COLOR = -3417355;
this.CIRCLE_NUMBER = this.BACKGROUND_COLOR.length;
this.LINE_NUMBER = this.FILL_COLOR.length;
this.DEFAULT_DURATION = 1000;
this.STROKE_WIDTH = 1;
this.START_ANGLE = -90;
this.MIN_RADIUS = 36.0f;
this.points = new PointF[this.LINE_NUMBER];
this.centerPoints = new PointF[this.LINE_NUMBER];
this.percent = new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
this.target = new float[]{0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
init(context);
}
示例9: getDistanceBetweenPoints
import android.graphics.PointF; //導入依賴的package包/類
@Override
public double getDistanceBetweenPoints(PointF left, PointF right) {
switch (direction) {
case BOTTOM_TO_TOP:
case TOP_TO_BOTTOM:
left.x = 0F;
right.x = 0F;
break;
case LEFT_TO_RIGHT:
case RIGHT_TO_LEFT:
left.y = 0F;
right.y = 0F;
break;
}
return Utils.euclideanDistance(left, right);
}
示例10: init
import android.graphics.PointF; //導入依賴的package包/類
@SuppressWarnings("deprecation")
public void init(AttributeSet attrs, int defStyleAttr) {
if (isInEditMode())
return;
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CheckBox, defStyleAttr, 0);
drawable = new CheckableDrawable(getContext(), R.raw.carbon_checkbox_checked, R.raw.carbon_checkbox_unchecked, R.raw.carbon_checkbox_filled, new PointF(-0.09f, 0.11f));
setButtonDrawable(getResources().getDrawable(android.R.color.transparent));
setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
ColorStateList csl = a.getColorStateList(R.styleable.CheckBox_carbon_checkColor);
if (csl != null)
drawable.setColor(csl);
setCheckedImmediate(isChecked());
a.recycle();
}
示例11: initStarHolders
import android.graphics.PointF; //導入依賴的package包/類
private void initStarHolders(RectF currentBounds) {
mStarHolders.add(new StarHolder(0.3f, new PointF(currentBounds.left + currentBounds.width() * 0.175f,
currentBounds.top + currentBounds.height() * 0.0934f)));
mStarHolders.add(new StarHolder(0.2f, new PointF(currentBounds.left + currentBounds.width() * 0.175f,
currentBounds.top + currentBounds.height() * 0.62f)));
mStarHolders.add(new StarHolder(0.2f, new PointF(currentBounds.left + currentBounds.width() * 0.2525f,
currentBounds.top + currentBounds.height() * 0.43f)));
mStarHolders.add(new StarHolder(0.5f, new PointF(currentBounds.left + currentBounds.width() * 0.4075f,
currentBounds.top + currentBounds.height() * 0.0934f)));
mStarHolders.add(new StarHolder(new PointF(currentBounds.left + currentBounds.width() * 0.825f,
currentBounds.top + currentBounds.height() * 0.04f)));
mStarHolders.add(new StarHolder(new PointF(currentBounds.left + currentBounds.width() * 0.7075f,
currentBounds.top + currentBounds.height() * 0.147f)));
mStarHolders.add(new StarHolder(new PointF(currentBounds.left + currentBounds.width() * 0.3475f,
currentBounds.top + currentBounds.height() * 0.2567f)));
mStarHolders.add(new StarHolder(0.6f, new PointF(currentBounds.left + currentBounds.width() * 0.5825f,
currentBounds.top + currentBounds.height() * 0.277f)));
mStarHolders.add(new StarHolder(new PointF(currentBounds.left + currentBounds.width() * 0.84f,
currentBounds.top + currentBounds.height() * 0.32f)));
mStarHolders.add(new StarHolder(new PointF(currentBounds.left + currentBounds.width() * 0.8f,
currentBounds.top + currentBounds.height() / 0.502f)));
mStarHolders.add(new StarHolder(0.6f, new PointF(currentBounds.left + currentBounds.width() * 0.7f,
currentBounds.top + currentBounds.height() * 0.473f)));
mMaxStarOffsets = currentBounds.height();
}
示例12: testGetSharpCornerEnd
import android.graphics.PointF; //導入依賴的package包/類
@Test
public void testGetSharpCornerEnd() throws Exception {
PointF topLeft = createBorderCorner(TOP_LEFT, 0, 10, 50, borderBox)
.getSharpCornerEnd();
assertThat(topLeft.x, is(5f));
assertThat(topLeft.y, is(0f));
PointF topRight = createBorderCorner(TOP_RIGHT, 0, 10, 50, borderBox)
.getSharpCornerEnd();
assertThat(topRight.x, is(400f));
assertThat(topRight.y, is(5f));
PointF bottomRight = createBorderCorner(BOTTOM_RIGHT, 0, 10, 50, borderBox)
.getSharpCornerEnd();
assertThat(bottomRight.x, is(395f));
assertThat(bottomRight.y, is(400f));
PointF bottomLeft = createBorderCorner(BOTTOM_LEFT, 0, 10, 50, borderBox)
.getSharpCornerEnd();
assertThat(bottomLeft.x, is(0f));
assertThat(bottomLeft.y, is(395f));
}
示例13: shuffleCoinPosition
import android.graphics.PointF; //導入依賴的package包/類
private void shuffleCoinPosition() {
Random rand = new Random();
for (Sprite whiteSprite:coinSprites) {
float whiteDx = rand.nextInt(20)-10;
float whiteDy = rand.nextInt(20)-10;
float whiteX = whiteSprite.getPosition().x + whiteDx;
float whiteY = whiteSprite.getPosition().y + whiteDy;
if (whiteX > 800 || whiteX < 100 || whiteY > 800 || whiteY < 100){
whiteY = rand.nextInt(800)+100;
whiteX = rand.nextInt(800)+100;
}
whiteSprite.setPosition(new PointF(whiteX, whiteY));
}
new Timer().schedule(new TimerTask() {
@Override
public void run() {
shuffleCoinPosition();
}
}, 500);
}
示例14: drawBeaconBackground
import android.graphics.PointF; //導入依賴的package包/類
protected void drawBeaconBackground(Canvas canvas, Beacon beacon, PointF beaconCenter) {
float advertisingRadius = (float) canvasProjection.getCanvasUnitsFromMeters(beacon.getEstimatedAdvertisingRange());
Paint innerBeaconRangePaint = new Paint(beaconRangePaint);
innerBeaconRangePaint.setAlpha(100);
Shader rangeShader = new RadialGradient(
beaconCenter.x,
beaconCenter.y,
advertisingRadius - (pixelsPerDip * 0),
primaryFillPaint.getColor(), beaconRangePaint.getColor(),
Shader.TileMode.MIRROR);
innerBeaconRangePaint.setShader(rangeShader);
//canvas.drawCircle(beaconCenter.x, beaconCenter.y, advertisingRadius, innerBeaconRangePaint);
canvas.drawCircle(beaconCenter.x, beaconCenter.y, advertisingRadius, beaconRangePaint);
}
示例15: canLoadmore
import android.graphics.PointF; //導入依賴的package包/類
public static boolean canLoadmore(View targetView, MotionEvent event) {
if (!canScrollDown(targetView) && canScrollUp(targetView) && targetView.getVisibility() == View.VISIBLE) {
return true;
}
if (targetView instanceof ViewGroup && event != null) {
ViewGroup viewGroup = (ViewGroup) targetView;
final int childCount = viewGroup.getChildCount();
PointF point = new PointF();
for (int i = 0; i < childCount; i++) {
View child = viewGroup.getChildAt(i);
if (isTransformedTouchPointInView(viewGroup, child, event.getX(), event.getY(), point)) {
event = MotionEvent.obtain(event);
event.offsetLocation(point.x, point.y);
return canLoadmore(child, event);
}
}
}
return false;
}