android.graphics.PointF#offset ( )源码实例Demo

下面列出了android.graphics.PointF#offset ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * 判断内容是否可以刷新
 * @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;
}
 
/**
 * 判断内容视图是否可以加载更多
 * @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));
}
 
源代码3 项目: edslite   文件: GestureImageView.java
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);
}
 
源代码4 项目: OpenMapKitAndroid   文件: Projection.java
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;
    }
 
源代码5 项目: OpenMapKitAndroid   文件: MapController.java
/**
 * 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;
}
 
源代码6 项目: OpenMapKitAndroid   文件: MapController.java
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);
}
 
源代码7 项目: OpenMapKitAndroid   文件: Projection.java
/**
 * 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;
}
 
源代码8 项目: OpenMapKitAndroid   文件: Projection.java
/**
 * 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;
}
 
源代码9 项目: OpenMapKitAndroid   文件: UserLocationOverlay.java
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;
}
 
源代码10 项目: SimpleDialogFragments   文件: ColorWheelView.java
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);

        }
 
源代码11 项目: SimpleDialogFragments   文件: ColorWheelView.java
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);

        }
 
源代码12 项目: OpenMapKitAndroid   文件: Marker.java
public PointF getDrawingPositionOnScreen(final Projection projection, PointF reuse) {
    reuse = getPositionOnScreen(projection, reuse);
    Point point = getAnchor();
    reuse.offset(point.x, point.y);
    return reuse;
}
 
 方法所在类