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);
}
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;
}
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);
}
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);
}
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);
}
Aggregations