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