java类android.graphics.PointF的实例源码

ScrollerLinearLayoutManager.java 文件源码 项目:Farmacias 阅读 31 收藏 0 点赞 0 评论 0
@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);
}
CrumbView.java 文件源码 项目:crumber 阅读 30 收藏 0 点赞 0 评论 0
/**
 * 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;
}
TouchImageView.java 文件源码 项目:event-me 阅读 33 收藏 0 点赞 0 评论 0
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);
}
DragValueAnimator.java 文件源码 项目:Android-CoolMenu 阅读 30 收藏 0 点赞 0 评论 0
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;
    }
TouchImageView.java 文件源码 项目:LueansRead 阅读 41 收藏 0 点赞 0 评论 0
/**
 * 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);
}
HDImageView.java 文件源码 项目:HDImageView 阅读 37 收藏 0 点赞 0 评论 0
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;
        }
    });
}
TouchImageView.java 文件源码 项目:Sega 阅读 44 收藏 0 点赞 0 评论 0
/**
 * 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);
}
RadarView.java 文件源码 项目:boohee_v5.6 阅读 33 收藏 0 点赞 0 评论 0
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);
}
LinearSort.java 文件源码 项目:spruce-android 阅读 30 收藏 0 点赞 0 评论 0
@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);
}
CheckBox.java 文件源码 项目:XERUNG 阅读 48 收藏 0 点赞 0 评论 0
@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();
   }
DayNightLoadingRenderer.java 文件源码 项目:JueDiQiuSheng 阅读 33 收藏 0 点赞 0 评论 0
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();
}
BorderCornerTest.java 文件源码 项目:ucar-weex-core 阅读 28 收藏 0 点赞 0 评论 0
@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));
}
MainActivity.java 文件源码 项目:SpriteKit-Android 阅读 41 收藏 0 点赞 0 评论 0
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);

}
BeaconMap.java 文件源码 项目:BLE-Indoor-Positioning 阅读 36 收藏 0 点赞 0 评论 0
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);
}
ScrollBoundaryUtil.java 文件源码 项目:Rxjava2.0Demo 阅读 67 收藏 0 点赞 0 评论 0
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;
}
CorneredSort.java 文件源码 项目:spruce-android 阅读 33 收藏 0 点赞 0 评论 0
@Override
public List<SpruceTimedView> getViewListWithTimeOffsets(ViewGroup parent, List<View> children) {
    final PointF comparisonPoint = getDistancePoint(parent, children);
    List<SpruceTimedView> timedViews = new ArrayList<>();
    long currentTimeOffset = 0;

    double lastDistance = 0;
    for (View view : children) {
        double viewDistance = getDistanceBetweenPoints(Utils.viewToPoint(view), comparisonPoint);
        if (Math.floor(lastDistance) != Math.floor(viewDistance)) {
            lastDistance = viewDistance;
            currentTimeOffset += interObjectDelay;
        }
        timedViews.add(new SpruceTimedView(view, currentTimeOffset));
    }

    return timedViews;
}
GeometricProgressView.java 文件源码 项目:geometric-progress-view 阅读 48 收藏 0 点赞 0 评论 0
private void initializeFigures() {
    if (!isInEditMode()) cancelAnimation();
    int size = Math.min(width, height);

    double circumference = numberOfAngles * figurePadding;
    double distanceFromCenter = circumference / (Math.PI * 2);
    int radius = size / 2 - (int) (distanceFromCenter);
    double startAngle = 90 + (360.0 / numberOfAngles) / 2;
    List<PointF> angles = new ArrayList<>();
    for (int i = 0; i < numberOfAngles; i++) {
        double angle = startAngle + i * (360.0 / numberOfAngles);
        angles.add(new PointF(
                (float) (center.x + radius * Math.cos(Math.toRadians(angle))),
                (float) (center.y + radius * Math.sin(Math.toRadians(angle))))
        );
    }

    figures = new ArrayList<>();
    if (TYPE.KITE.equals(type)) {
        buildFiguresUsingKites(angles, startAngle, distanceFromCenter);
    } else {
        buildFiguresUsingTriangles(angles, startAngle, distanceFromCenter);
    }
    setupAnimation();
}
CoordinateAxisChart.java 文件源码 项目:CoordinateAxisChart 阅读 40 收藏 0 点赞 0 评论 0
/**
 * generate the power function lines
 * @param a {@link PowerType#PowerType(float, float, float)}
 * @param b {@link PowerType#PowerType(float, float, float)}
 * @param canvas canvas
 */
private void generatePowerLines(Float a, Float b, Float c, Canvas canvas){
    // raw
    PointF start = leftPoint;
    PointF end = rightPoint;

    float unit = (end.x - start.x) / xPointsValues.length;

    for (int i = 0; i < xPointsValues.length; i++) {
        // get the split point
        PointF split = new PointF(start.x + i * unit, start.y);
        // logical
        PointF splitLogic = convertRawPoint2Logical(split, unitLength);
        // calculate
        splitLogic.y = FuncUtils.getPowYValue(a, b, c, splitLogic.x);
        // convert logical to raw
        PointF splitRaw = convertLogicalPoint2Raw(splitLogic, unitLength);
        xPointsValues[i] = splitRaw;
    }

    drawBezier(canvas, FuncType.POWER_TYPE);

}
GPUImageFilter.java 文件源码 项目:FilterPlayer 阅读 36 收藏 0 点赞 0 评论 0
protected void setPoint(final int location, final PointF point) {
    runOnDraw(new Runnable() {

        @Override
        public void run() {
            float[] vec2 = new float[2];
            vec2[0] = point.x;
            vec2[1] = point.y;
            GLES20.glUniform2fv(location, 1, vec2, 0);
        }
    });
}
ColorWheelView.java 文件源码 项目:SimpleDialogFragments 阅读 35 收藏 0 点赞 0 评论 0
void setGeometry(PointF center, float radius, float padding){
    if (!mCenter.equals(center) || radius != mRadius || padding != mPadding){
        geometryNeedsUpdate = true;
    }
    mCenter = center;
    mRadius = radius;
    mPadding = padding;
}
StoreHouseBarItem.java 文件源码 项目:SmartRefreshLayout 阅读 36 收藏 0 点赞 0 评论 0
public StoreHouseBarItem(int index, PointF start, PointF end, int color, int lineWidth) {
    this.index = index;

    midPoint = new PointF((start.x + end.x) / 2, (start.y + end.y) / 2);

    mCStartPoint = new PointF(start.x - midPoint.x, start.y - midPoint.y);
    mCEndPoint = new PointF(end.x - midPoint.x, end.y - midPoint.y);

    setColor(color);
    setLineWidth(lineWidth);
    mPaint.setAntiAlias(true);
    mPaint.setStyle(Paint.Style.STROKE);
}
ZoomImageView.java 文件源码 项目:BlogBookApp 阅读 42 收藏 0 点赞 0 评论 0
/**
 * Return the point at the center of the zoomed image. The PointF coordinates range
 * in value between 0 and 1 and the focus point is denoted as a fraction from the left
 * and top of the view. For example, the top left corner of the image would be (0, 0).
 * And the bottom right corner would be (1, 1).
 *
 * @return PointF representing the scroll position of the zoomed image.
 */
public PointF getScrollPosition() {
    Drawable drawable = getDrawable();
    if (drawable == null) {
        return null;
    }
    int drawableWidth = drawable.getIntrinsicWidth();
    int drawableHeight = drawable.getIntrinsicHeight();

    PointF point = transformCoordTouchToBitmap(viewWidth / 2, viewHeight / 2, true);
    point.x /= drawableWidth;
    point.y /= drawableHeight;
    return point;
}
DayNightLoadingRenderer.java 文件源码 项目:JueDiQiuSheng 阅读 34 收藏 0 点赞 0 评论 0
public StarHolder(float flashOffset, PointF mPoint) {
    this.mAlpha = MAX_ALPHA;
    this.mCurrentPoint = new PointF();
    this.mPoint = mPoint;
    this.mFlashOffset = flashOffset;
    this.mInterpolator = INTERPOLATORS[mRandom.nextInt(INTERPOLATORS.length)];
}
CameraUtil.java 文件源码 项目:361Camera 阅读 64 收藏 0 点赞 0 评论 0
public static PointF normalizedSensorCoordsForNormalizedDisplayCoords(
        float nx, float ny, int sensorOrientation) {
    switch (sensorOrientation) {
        case 0:
            return new PointF(nx, ny);
        case 90:
            return new PointF(ny, 1.0f - nx);
        case 180:
            return new PointF(1.0f - nx, 1.0f - ny);
        case 270:
            return new PointF(1.0f - ny, nx);
        default:
            return null;
    }
}
ElectricFanLoadingRenderer.java 文件源码 项目:GitHub 阅读 42 收藏 0 点赞 0 评论 0
@Override
public void onAnimationUpdate(ValueAnimator animation) {
    PointF point = (PointF) animation.getAnimatedValue();
    target.mLeafRect.set((int) point.x, (int) point.y,
            (int) (point.x + mLeafDrawable.getIntrinsicWidth()), (int) (point.y + mLeafDrawable.getIntrinsicHeight()));
    target.mLeafRotation = target.mMaxRotation * animation.getAnimatedFraction();
}
TouchImageView.java 文件源码 项目:ImageEraser 阅读 35 收藏 0 点赞 0 评论 0
public TouchImageView(Context context) {
    super(context);
    this.isPaningOn = false;
    this.userTouchListener = null;
    this.last = new PointF();
    sharedConstructing(context);
}
TouchImageView.java 文件源码 项目:event-me 阅读 37 收藏 0 点赞 0 评论 0
/**
 * Interpolate between where the image should start and end in order to translate
 * the image so that the point that is touched is what ends up centered at the end
 * of the zoom.
 * @param t
 */
private void translateImageToCenterTouchPosition(float t) {
    float targetX = startTouch.x + t * (endTouch.x - startTouch.x);
    float targetY = startTouch.y + t * (endTouch.y - startTouch.y);
    PointF curr = transformCoordBitmapToTouch(bitmapX, bitmapY);
    matrix.postTranslate(targetX - curr.x, targetY - curr.y);
}
DepthRendrer.java 文件源码 项目:Mire 阅读 39 收藏 0 点赞 0 评论 0
void drawShadow(PointF point1, PointF point2, float correctionValue, Canvas canvas, DepthLayout dl) {
    float angle = Math.abs(Math.abs(getAngle(point1, point2)) + correctionValue);
    float alpha = angle / 180f;
    shadowPaint.setAlpha((int) (alpha * 255f * shadowAlpha));

    canvas.drawRect(0, 0, dl.getWidth(), dl.getHeight(), shadowPaint);
}
CheckableDrawable.java 文件源码 项目:XERUNG 阅读 37 收藏 0 点赞 0 评论 0
public CheckableDrawable(Context context, int checkedRes, int uncheckedRes, int filledRes, PointF offset) {
    this.context = context;
    this.checkedRes = checkedRes;
    this.uncheckedRes = uncheckedRes;
    this.filledRes = filledRes;
    this.offset = offset;

    maskPaint.setAlpha(255);
    maskPaint.setColor(0xffffffff);
}
LeftIndicatorViewGroup.java 文件源码 项目:LeftIndicatorViewGroup 阅读 44 收藏 0 点赞 0 评论 0
/**
 * genearate samll points.
 *
 * @param bigStart prev big circle position.
 * @param current  current big circle position.
 */
private void generateSmallPoints(float bigStart, float current) {
    // location start.
    float smallStart = bigStart + mHalfBigHeight;
    // location end.
    float smallEnd = current - mHalfBigHeight;
    float smallHeight = mHalfSmallHeight * 2 + mSmallDistance * 2;
    // if has space.
    if (smallEnd - smallStart < smallHeight) {
        return;
    }
    // half of top points.
    float halfTop = (bigStart + current) / 2 - mHalfSmallHeight - mSmallDistance;
    while (halfTop - smallStart >= smallHeight) {
        mSmallIndicatorPoints.add(new PointF(getIndicatorXPointF(), halfTop - smallHeight / 2));
        halfTop -= smallHeight;
    }
    // does need extra.
    if (halfTop - smallStart >= smallHeight - mSmallDistance + mBigAndSmallOffset) {
        mSmallIndicatorPoints.add(new PointF(getIndicatorXPointF(), halfTop - smallHeight / 2));
    }

    // center.
    mSmallIndicatorPoints.add(new PointF(getIndicatorXPointF(), (bigStart + current) / 2));
    // half bottom points.
    float halfBottom = (bigStart + current) / 2 + mHalfSmallHeight + mSmallDistance;
    while (halfBottom + smallHeight <= smallEnd) {
        mSmallIndicatorPoints.add(new PointF(getIndicatorXPointF(), halfBottom + smallHeight / 2));
        halfBottom += smallHeight;
    }
    // does need extra.
    if (halfBottom + smallHeight - mSmallDistance + mBigAndSmallOffset <= smallEnd) {
        mSmallIndicatorPoints.add(new PointF(getIndicatorXPointF(), halfBottom + smallHeight / 2));
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号