Java Code Examples for android.graphics.PointF#offset()
The following examples show how to use
android.graphics.PointF#offset() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScrollBoundaryHorizontal.java From SmartRefreshHorizontal with Apache License 2.0 | 6 votes |
/** * 判断内容是否可以刷新 * @param targetView 内容视图 * @param touch 按压事件位置 * @return 是否可以刷新 */ public static boolean canRefresh(@NonNull View targetView, PointF touch) { if (canScrollLeft(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 (SmartUtil.isTransformedTouchPointInView(viewGroup, child, touch.x, touch.y, point)) { if ("fixed".equals(child.getTag())) { return false; } touch.offset(point.x, point.y); boolean can = canRefresh(child, touch); touch.offset(-point.x, -point.y); return can; } } } return true; }
Example 2
Source File: ScrollBoundaryHorizontal.java From SmartRefreshHorizontal with Apache License 2.0 | 6 votes |
/** * 判断内容视图是否可以加载更多 * @param targetView 内容视图 * @param touch 按压事件位置 * @param contentFull 内容是否填满页面 (未填满时,会通过canScrollUp自动判断) * @return 是否可以刷新 */ public static boolean canLoadMore(@NonNull View targetView, PointF touch, boolean contentFull) { if (canScrollRight(targetView) && targetView.getVisibility() == View.VISIBLE) { return false; } //touch == null 时 canLoadMore 不会动态递归搜索 if (targetView instanceof ViewGroup && touch != null && !SmartUtil.isScrollableView(targetView)) { ViewGroup viewGroup = (ViewGroup) targetView; final int childCount = viewGroup.getChildCount(); PointF point = new PointF(); for (int i = 0; i < childCount; i++) { View child = viewGroup.getChildAt(i); if (SmartUtil.isTransformedTouchPointInView(viewGroup, child, touch.x, touch.y, point)) { if ("fixed".equals(child.getTag())) { return false; } touch.offset(point.x, point.y); boolean can = canLoadMore(child, touch, contentFull); touch.offset(-point.x, -point.y); return can; } } } return (contentFull || canScrollLeft(targetView)); }
Example 3
Source File: GestureImageView.java From edslite with GNU General Public License v2.0 | 6 votes |
private void validate(RectF curImageRect,Matrix curImageMatrix, PointF outDelta) { float deltaX= 0, deltaY = 0; RectF imageRect = new RectF(curImageRect); curImageMatrix.mapRect(imageRect); if (imageRect.height() <= _viewRect.height()) deltaY = (_viewRect.height() - imageRect.height()) / 2 - imageRect.top; else if (imageRect.top > 0) deltaY = -imageRect.top; else if (imageRect.bottom < _viewRect.height()) deltaY = _viewRect.height() - imageRect.bottom; if (imageRect.width() <= _viewRect.width()) deltaX = (_viewRect.width() - imageRect.width()) / 2 - imageRect.left; else if (imageRect.left > 0) deltaX = -imageRect.left; else if (imageRect.right < _viewRect.width()) deltaX = _viewRect.width() - imageRect.right; outDelta.offset(deltaX, deltaY); }
Example 4
Source File: Projection.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static PointF toMapPixels(final double latitude, final double longitude, final float zoom, final double centerX, final double centerY, final PointF reuse) { final PointF out = GeometryMath.reusable(reuse); final int mapSize = mapSize(zoom); latLongToPixelXY(latitude, longitude, zoom, out); final float worldSize2 = mapSize >> 1; out.offset(-worldSize2, -worldSize2); // if (Math.abs(out.x - centerX) > Math.abs(out.x - mapSize - centerX)) { // out.x -= mapSize; // } // if (Math.abs(out.x - centerX) > Math.abs(out.x + mapSize - centerX)) { // out.x += mapSize; // } // if (Math.abs(out.y - centerY) > Math.abs(out.y - mapSize - centerY)) { // out.y -= mapSize; // } // if (Math.abs(out.y - centerY) > Math.abs(out.y + mapSize - centerY)) { // out.y += mapSize; // } return out; }
Example 5
Source File: MapController.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Go to a given point (not animated) */ public boolean goTo(final ILatLng point, PointF delta) { final Projection projection = mMapView.getProjection(); PointF p = projection.toMapPixels(point, null); if (delta != null) { p.offset(delta.x, delta.y); } if (mMapView.getScrollPoint().equals(p)) { return false; } mMapView.scrollTo(p.x, p.y); return true; }
Example 6
Source File: MapController.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void setCenter(final ILatLng latlng, final PointF decale) { if (latlng == null) { return; } if (!mMapView.isLayedOut()) { mPointToGoTo = latlng; return; } PointF p = mMapView.getProjection().toMapPixels(latlng, null); if (decale != null) { p.offset(decale.x, decale.y); } this.mMapView.scrollTo(p.x, p.y); }
Example 7
Source File: Projection.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Converts a LatLng to its <I>screen coordinates</I>. * * @param in the LatLng you want the <I>screen coordinates</I> of * @param reuse just pass null if you do not have a Point to be 'recycled'. * @return the Point containing the <I>screen coordinates</I> of the LatLng passed. */ public PointF toPixels(final ILatLng in, final PointF reuse) { PointF result = toMapPixels(in, reuse); result.offset(-mIntrinsicScreenRectProjection.exactCenterX(), -mIntrinsicScreenRectProjection.exactCenterY()); if (mMapOrientation % 360 != 0) { GeometryMath.rotatePoint(0, 0, result, mMapOrientation, result); } result.offset(viewWidth2, viewHeight2); return result; }
Example 8
Source File: Projection.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Converts a map position in pixel to its <I>screen coordinates</I>. * * @param mapPos the map point you want the <I>screen coordinates</I> of * @param reuse just pass null if you do not have a Point to be 'recycled'. * @return the Point containing the <I>screen coordinates</I> of the point passed. */ public PointF toPixels(final PointF mapPos, final PointF reuse) { final PointF out = GeometryMath.reusable(reuse); out.set(mapPos); out.offset(viewWidth2 - mIntrinsicScreenRectProjection.exactCenterX(), viewHeight2 - mIntrinsicScreenRectProjection.exactCenterY()); return out; }
Example 9
Source File: UserLocationOverlay.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 5 votes |
public PointF getDrawingPositionOnScreen(final Projection projection, Location lastFix, PointF reuse) { reuse = getPositionOnScreen(projection, reuse); if (lastFix.hasBearing()) { reuse.offset(mPersonHotspot.x * mPersonBitmap.getWidth(), mPersonHotspot.y * mPersonBitmap.getWidth()); } else { reuse.offset(mDirectionHotspot.x * mDirectionArrowBitmap.getWidth(), mDirectionHotspot.y * mDirectionArrowBitmap.getWidth()); } return reuse; }
Example 10
Source File: ColorWheelView.java From SimpleDialogFragments with Apache License 2.0 | 4 votes |
private void createFieldGeometry(Field f, float startAngle, float sweepAngle) { startAngle = mod(startAngle, 360); int rot = startAngle < 120 ? 0 : startAngle < 240 ? 1 : 2; startAngle = mod(startAngle, 120); float R = mRadius - mPadding; float p = mPadding; PointF p_i1 = calcInnerPoint(R, p, startAngle, true); PointF p_i2 = calcInnerPoint(R, p, startAngle + sweepAngle, false); float aAd = (float) Math.toDegrees(Math.asin(p/2/R)); float alpha_1 = startAngle + aAd; float alpha_2 = startAngle + sweepAngle - aAd; // PointF p_a1 = new PointF(R*(float)Math.cos(Math.toRadians(alpha_1)), R*(float)Math.sin(Math.toRadians(alpha_1))); // PointF p_a2 = new PointF(R*(float)Math.cos(Math.toRadians(alpha_2)), R*(float)Math.sin(Math.toRadians(alpha_2))); p_i1.offset(mCenter.x, mCenter.y); p_i2.offset(mCenter.x, mCenter.y); // p_a1.offset(mCenter.x, mCenter.y); // p_a2.offset(mCenter.x, mCenter.y); RectF oval = new RectF(mCenter.x - R, mCenter.y - R, mCenter.x + R, mCenter.y + R); //f.points = new PointF[]{p_i1, p_a1, p_a2, p_i2}; f.rawPath = new Path(); f.rawPath.moveTo(p_i1.x, p_i1.y); // f.path.lineTo(p_a1.x, p_a1.y); // f.path.lineTo(p_a2.x, p_a2.y); f.rawPath.arcTo(oval, alpha_1, alpha_2-alpha_1); f.rawPath.lineTo(p_i2.x, p_i2.y); f.rawPath.close(); Matrix mMatrix = new Matrix(); mMatrix.postRotate( -90 + rot*120, mCenter.x, mCenter.y); f.rawPath.transform(mMatrix); f.startAngle = mod(alpha_1 -90 + rot*120, 360); f.endAngle = mod(alpha_2 -90 + rot*120, 360); }
Example 11
Source File: ColorWheelView.java From SimpleDialogFragments with Apache License 2.0 | 4 votes |
private void createFieldGeometry(Field f, float startAngle, float sweepAngle) { startAngle = mod(startAngle, 360); int rot = startAngle < 120 ? 0 : startAngle < 240 ? 1 : 2; startAngle = mod(startAngle, 120); float R = mRadius - mPadding; float p = mPadding; PointF p_i1 = calcInnerPoint(R, p, startAngle, true); PointF p_i2 = calcInnerPoint(R, p, startAngle + sweepAngle, false); float aAd = (float) Math.toDegrees(Math.asin(p/2/R)); float alpha_1 = startAngle + aAd; float alpha_2 = startAngle + sweepAngle - aAd; // PointF p_a1 = new PointF(R*(float)Math.cos(Math.toRadians(alpha_1)), R*(float)Math.sin(Math.toRadians(alpha_1))); // PointF p_a2 = new PointF(R*(float)Math.cos(Math.toRadians(alpha_2)), R*(float)Math.sin(Math.toRadians(alpha_2))); p_i1.offset(mCenter.x, mCenter.y); p_i2.offset(mCenter.x, mCenter.y); // p_a1.offset(mCenter.x, mCenter.y); // p_a2.offset(mCenter.x, mCenter.y); RectF oval = new RectF(mCenter.x - R, mCenter.y - R, mCenter.x + R, mCenter.y + R); //f.points = new PointF[]{p_i1, p_a1, p_a2, p_i2}; f.rawPath = new Path(); f.rawPath.moveTo(p_i1.x, p_i1.y); // f.path.lineTo(p_a1.x, p_a1.y); // f.path.lineTo(p_a2.x, p_a2.y); f.rawPath.arcTo(oval, alpha_1, alpha_2-alpha_1); f.rawPath.lineTo(p_i2.x, p_i2.y); f.rawPath.close(); Matrix mMatrix = new Matrix(); mMatrix.postRotate( -90 + rot*120, mCenter.x, mCenter.y); f.rawPath.transform(mMatrix); f.startAngle = mod(alpha_1 -90 + rot*120, 360); f.endAngle = mod(alpha_2 -90 + rot*120, 360); }
Example 12
Source File: Marker.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 4 votes |
public PointF getDrawingPositionOnScreen(final Projection projection, PointF reuse) { reuse = getPositionOnScreen(projection, reuse); Point point = getAnchor(); reuse.offset(point.x, point.y); return reuse; }