Search in sources :

Example 61 with PointF

use of android.graphics.PointF in project yoo_home_Android by culturer.

the class SkyWheel method calculateValue.

/**
 * 计算圆心、半径、夹角
 */
public void calculateValue() {
    // 圆心
    center = new PointF();
    center.x = getWidth() / 2;
    center.y = getHeight() / 2;
    int maxwidth = 0;
    int maxheight = 0;
    for (int i = 0; i < getChildCount(); i++) {
        maxwidth = Math.max(maxwidth, getChildAt(i).getWidth());
        maxheight = Math.max(maxheight, getChildAt(i).getHeight());
    }
    // 半径
    float r1 = center.x - maxwidth;
    float r2 = center.y - maxheight;
    radius = Math.min(r1, r2);
    // 夹角
    cellDegree = Math.PI * 2 / getChildCount();
}
Also used : PointF(android.graphics.PointF)

Example 62 with PointF

use of android.graphics.PointF in project yellowmessenger-sdk by yellowmessenger.

the class TouchImageView method setZoom.

/**
 * Set zoom parameters equal to another TouchImageView. Including scale, position,
 * and ScaleType.
 * @param TouchImageView
 */
public void setZoom(TouchImageView img) {
    PointF center = img.getScrollPosition();
    setZoom(img.getCurrentZoom(), center.x, center.y, img.getScaleType());
}
Also used : PointF(android.graphics.PointF)

Example 63 with PointF

use of android.graphics.PointF in project yellowmessenger-sdk by yellowmessenger.

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

use of android.graphics.PointF in project yellowmessenger-sdk by yellowmessenger.

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

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

the class TouchImageView method setZoom.

/**
 * Set zoom parameters equal to another TouchImageView. Including scale, position,
 * and ScaleType.
 * @param img
 */
public void setZoom(TouchImageView img) {
    PointF center = img.getScrollPosition();
    setZoom(img.getCurrentZoom(), center.x, center.y, img.getScaleType());
}
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