Search in sources :

Example 56 with PointF

use of android.graphics.PointF in project material by rey5137.

the class TimePicker method onSizeChanged.

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    int left = getPaddingLeft();
    int top = getPaddingTop();
    int size = Math.min(w - getPaddingLeft() - getPaddingRight(), h - getPaddingTop() - getPaddingBottom());
    if (mCenterPoint == null)
        mCenterPoint = new PointF();
    mOuterRadius = size / 2f;
    mCenterPoint.set(left + mOuterRadius, top + mOuterRadius);
    mInnerRadius = mOuterRadius - mSelectionRadius - ThemeUtil.dpToPx(getContext(), 4);
    calculateTextLocation();
}
Also used : PointF(android.graphics.PointF) Paint(android.graphics.Paint)

Example 57 with PointF

use of android.graphics.PointF in project frostwire by frostwire.

the class TouchImageView method getScrollPosition.

/**
 * 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;
}
Also used : PointF(android.graphics.PointF) Drawable(android.graphics.drawable.Drawable)

Example 58 with PointF

use of android.graphics.PointF in project SmartRefreshLayout by scwang90.

the class StoreHouseHeader method initWithPointList.

public StoreHouseHeader initWithPointList(List<float[]> pointList) {
    float drawWidth = 0;
    float drawHeight = 0;
    boolean shouldLayout = mItemList.size() > 0;
    mItemList.clear();
    DensityUtil density = new DensityUtil();
    for (int i = 0; i < pointList.size(); i++) {
        float[] line = pointList.get(i);
        PointF startPoint = new PointF(density.dip2px(line[0]) * mScale, density.dip2px(line[1]) * mScale);
        PointF endPoint = new PointF(density.dip2px(line[2]) * mScale, density.dip2px(line[3]) * mScale);
        drawWidth = Math.max(drawWidth, startPoint.x);
        drawWidth = Math.max(drawWidth, endPoint.x);
        drawHeight = Math.max(drawHeight, startPoint.y);
        drawHeight = Math.max(drawHeight, endPoint.y);
        StoreHouseBarItem item = new StoreHouseBarItem(i, startPoint, endPoint, mTextColor, mLineWidth);
        item.resetPosition(mHorizontalRandomness);
        mItemList.add(item);
    }
    mDrawZoneWidth = (int) Math.ceil(drawWidth);
    mDrawZoneHeight = (int) Math.ceil(drawHeight);
    if (shouldLayout) {
        final View thisView = this;
        thisView.requestLayout();
    }
    return this;
}
Also used : DensityUtil(com.scwang.smartrefresh.layout.util.DensityUtil) StoreHouseBarItem(com.scwang.smartrefresh.header.storehouse.StoreHouseBarItem) PointF(android.graphics.PointF) View(android.view.View)

Example 59 with PointF

use of android.graphics.PointF in project SmartRefreshLayout by scwang90.

the class ScrollBoundaryUtil method canRefresh.

// <editor-fold desc="滚动判断">
/**
 * 判断内容是否可以刷新
 * @param targetView 内容视图
 * @param touch 按压事件位置
 * @return 是否可以刷新
 */
public static boolean canRefresh(@NonNull View targetView, PointF touch) {
    if (canScrollUp(targetView) && targetView.getVisibility() == View.VISIBLE) {
        return false;
    }
    // touch == null 时 canRefresh 不会动态递归搜索
    if (targetView instanceof ViewGroup && touch != null) {
        ViewGroup viewGroup = (ViewGroup) targetView;
        final int childCount = viewGroup.getChildCount();
        PointF point = new PointF();
        for (int i = childCount; i > 0; i--) {
            View child = viewGroup.getChildAt(i - 1);
            if (isTransformedTouchPointInView(viewGroup, child, touch.x, touch.y, point)) {
                touch.offset(point.x, point.y);
                boolean can = canRefresh(child, touch);
                touch.offset(-point.x, -point.y);
                return can;
            }
        }
    }
    return true;
}
Also used : ViewGroup(android.view.ViewGroup) PointF(android.graphics.PointF) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollingView(android.support.v4.view.ScrollingView) ScrollView(android.widget.ScrollView) View(android.view.View) NestedScrollView(android.support.v4.widget.NestedScrollView) ListView(android.widget.ListView) WebView(android.webkit.WebView)

Example 60 with PointF

use of android.graphics.PointF in project android by nextcloud.

the class TouchImageViewCustom method getZoomedRect.

/**
 * Return a Rect representing the zoomed image.
 * @return rect representing zoomed image
 */
public RectF getZoomedRect() {
    if (mScaleType == ScaleType.FIT_XY) {
        throw new UnsupportedOperationException("getZoomedRect() not supported with FIT_XY");
    }
    PointF topLeft = transformCoordTouchToBitmap(0, 0, true);
    PointF bottomRight = transformCoordTouchToBitmap(viewWidth, viewHeight, true);
    float w = getDrawable().getIntrinsicWidth();
    float h = getDrawable().getIntrinsicHeight();
    return new RectF(topLeft.x / w, topLeft.y / h, bottomRight.x / w, bottomRight.y / h);
}
Also used : RectF(android.graphics.RectF) PointF(android.graphics.PointF)

Aggregations

PointF (android.graphics.PointF)686 Paint (android.graphics.Paint)132 Point (android.graphics.Point)53 RectF (android.graphics.RectF)53 Matrix (android.graphics.Matrix)43 Test (org.junit.Test)40 Path (android.graphics.Path)29 View (android.view.View)28 Drawable (android.graphics.drawable.Drawable)23 ArrayList (java.util.ArrayList)23 MotionEvent (android.view.MotionEvent)22 NonNull (android.support.annotation.NonNull)21 Rect (android.graphics.Rect)18 ValueAnimator (android.animation.ValueAnimator)14 ViewGroup (android.view.ViewGroup)11 List (java.util.List)11 Animator (android.animation.Animator)10 Bitmap (android.graphics.Bitmap)10 GestureDetector (android.view.GestureDetector)10 LinearSmoothScroller (android.support.v7.widget.LinearSmoothScroller)9