当前位置: 首页>>代码示例>>Java>>正文


Java PointF类代码示例

本文整理汇总了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);
}
 
开发者ID:cahergil,项目名称:Farmacias,代码行数:23,代码来源:ScrollerLinearLayoutManager.java

示例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;
}
 
开发者ID:Deliganli,项目名称:crumber,代码行数:22,代码来源:CrumbView.java

示例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);
}
 
开发者ID:picopalette,项目名称:event-me,代码行数:17,代码来源:TouchImageView.java

示例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;
    }
 
开发者ID:crazysunj,项目名称:Android-CoolMenu,代码行数:17,代码来源:DragValueAnimator.java

示例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);
}
 
开发者ID:lueans,项目名称:LueansRead,代码行数:26,代码来源:TouchImageView.java

示例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;
        }
    });
}
 
开发者ID:EvilBT,项目名称:HDImageView,代码行数:21,代码来源:HDImageView.java

示例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);
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:27,代码来源:TouchImageView.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:RadarView.java

示例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);
}
 
开发者ID:willowtreeapps,项目名称:spruce-android,代码行数:17,代码来源:LinearSort.java

示例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();
   }
 
开发者ID:mityung,项目名称:XERUNG,代码行数:20,代码来源:CheckBox.java

示例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();
}
 
开发者ID:ZhuoKeTeam,项目名称:JueDiQiuSheng,代码行数:27,代码来源:DayNightLoadingRenderer.java

示例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));
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:20,代码来源:BorderCornerTest.java

示例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);

}
 
开发者ID:sakkeerhussain,项目名称:SpriteKit-Android,代码行数:23,代码来源:MainActivity.java

示例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);
}
 
开发者ID:neXenio,项目名称:BLE-Indoor-Positioning,代码行数:17,代码来源:BeaconMap.java

示例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;
}
 
开发者ID:penghuanliang,项目名称:Rxjava2.0Demo,代码行数:20,代码来源:ScrollBoundaryUtil.java


注:本文中的android.graphics.PointF类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。