Search in sources :

Example 66 with PointF

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

the class TouchImageView 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)

Example 67 with PointF

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

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 68 with PointF

use of android.graphics.PointF in project android_frameworks_base by crdroidandroid.

the class ViewRootImpl method dispatchMoved.

public void dispatchMoved(int newX, int newY) {
    if (DEBUG_LAYOUT)
        Log.v(mTag, "Window moved " + this + ": newX=" + newX + " newY=" + newY);
    if (mTranslator != null) {
        PointF point = new PointF(newX, newY);
        mTranslator.translatePointInScreenToAppWindow(point);
        newX = (int) (point.x + 0.5);
        newY = (int) (point.y + 0.5);
    }
    Message msg = mHandler.obtainMessage(MSG_WINDOW_MOVED, newX, newY);
    mHandler.sendMessage(msg);
}
Also used : Message(android.os.Message) PointF(android.graphics.PointF)

Example 69 with PointF

use of android.graphics.PointF in project android_frameworks_base by crdroidandroid.

the class ViewGroup method onResolvePointerIcon.

@Override
public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
    final float x = event.getX(pointerIndex);
    final float y = event.getY(pointerIndex);
    if (isOnScrollbarThumb(x, y) || isDraggingScrollBar()) {
        return PointerIcon.getSystemIcon(mContext, PointerIcon.TYPE_ARROW);
    }
    // Check what the child under the pointer says about the pointer.
    final int childrenCount = mChildrenCount;
    if (childrenCount != 0) {
        final ArrayList<View> preorderedList = buildOrderedChildList();
        final boolean customOrder = preorderedList == null && isChildrenDrawingOrderEnabled();
        final View[] children = mChildren;
        for (int i = childrenCount - 1; i >= 0; i--) {
            final int childIndex = getAndVerifyPreorderedIndex(childrenCount, i, customOrder);
            final View child = getAndVerifyPreorderedView(preorderedList, children, childIndex);
            final PointF point = getLocalPoint();
            if (isTransformedTouchPointInView(x, y, child, point)) {
                final PointerIcon pointerIcon = dispatchResolvePointerIcon(event, pointerIndex, child);
                if (pointerIcon != null) {
                    if (preorderedList != null)
                        preorderedList.clear();
                    return pointerIcon;
                }
                break;
            }
        }
        if (preorderedList != null)
            preorderedList.clear();
    }
    // implementation.
    return super.onResolvePointerIcon(event, pointerIndex);
}
Also used : PointF(android.graphics.PointF) Paint(android.graphics.Paint)

Example 70 with PointF

use of android.graphics.PointF in project android_frameworks_base by crdroidandroid.

the class Quad method rotated.

/**
     * Rotate the quad by the given angle.
     *
     * The Quad is rotated counter-clockwise around its centroid.
     *
     * @param angle the angle to rotate in radians
     * @return the rotated Quad
     */
public Quad rotated(float angle) {
    PointF center = center();
    float cosa = (float) Math.cos(angle);
    float sina = (float) Math.sin(angle);
    PointF topLeft = rotatePoint(topLeft(), center, cosa, sina);
    PointF topRight = rotatePoint(topRight(), center, cosa, sina);
    PointF bottomLeft = rotatePoint(bottomLeft(), center, cosa, sina);
    PointF bottomRight = rotatePoint(bottomRight(), center, cosa, sina);
    return new Quad(topLeft, topRight, bottomLeft, bottomRight);
}
Also used : 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