當前位置: 首頁>>代碼示例>>Java>>正文


Java Region.setPath方法代碼示例

本文整理匯總了Java中android.graphics.Region.setPath方法的典型用法代碼示例。如果您正苦於以下問題:Java Region.setPath方法的具體用法?Java Region.setPath怎麽用?Java Region.setPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.Region的用法示例。


在下文中一共展示了Region.setPath方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: clippedRotatedOval

import android.graphics.Region; //導入方法依賴的package包/類
private Bitmap clippedRotatedOval(Bitmap bitmap) {
    Bitmap bmp;
    float width = bitmap.getWidth();
    float height = bitmap.getHeight();

    bmp = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888);
    BitmapShader shader = new BitmapShader(bitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);

    Canvas canvas = new Canvas(bmp);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(shader);

    Path oval = new Path();
    Matrix matrix = new Matrix();
    Region region = new Region();
    RectF ovalRect = new RectF(width / OVAL_FACTOR, 0, width - (width / OVAL_FACTOR), height);

    oval.addOval(ovalRect, Path.Direction.CW);
    matrix.postRotate(ROTATION, width / 2, height / 2);
    oval.transform(matrix, oval);
    region.setPath(oval, new Region((int) width / 2, 0, (int) width, (int) height));
    canvas.drawPath(region.getBoundaryPath(), paint);

    return bmp;
}
 
開發者ID:StylingAndroid,項目名稱:PresenterLite,代碼行數:27,代碼來源:ShapedImageView.java

示例2: isTouch

import android.graphics.Region; //導入方法依賴的package包/類
/**
 * 是否點擊的省份
 * 點擊時間
 * @param x
 * @param y
 */
public boolean isTouch(int x,int y){

    RectF rectF = new RectF();
    path.computeBounds(rectF,true);
    Region region = new Region();
    region.setPath(path,new Region((int)rectF.left,(int)rectF.top,(int)rectF.right,(int)rectF.bottom));
    return region.contains(x,y);
}
 
開發者ID:fanxiaole,項目名稱:SVG_taiwan_View,代碼行數:15,代碼來源:CountyItem.java

示例3: heart

import android.graphics.Region; //導入方法依賴的package包/類
private Bitmap heart(Bitmap bitmap) {
    Bitmap bmp;
    float width = bitmap.getWidth();
    float height = bitmap.getHeight();

    bmp = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888);
    BitmapShader shader = new BitmapShader(bitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);

    Canvas canvas = new Canvas(bmp);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(shader);

    Path oval = new Path();
    Matrix matrix = new Matrix();
    Region region = new Region();
    RectF ovalRect = new RectF(width / OVAL_FACTOR, 0, width - (width / OVAL_FACTOR), height);

    oval.addOval(ovalRect, Path.Direction.CW);
    matrix.postRotate(ROTATION, width / 2, height / 2);
    oval.transform(matrix, oval);
    region.setPath(oval, new Region((int) width / 2, 0, (int) width, (int) height));
    canvas.drawPath(region.getBoundaryPath(), paint);

    matrix.reset();
    oval.reset();
    oval.addOval(ovalRect, Path.Direction.CW);
    matrix.postRotate(-ROTATION, width / 2, height / 2);
    oval.transform(matrix, oval);
    region.setPath(oval, new Region(0, 0, (int) width / 2, (int) height));
    canvas.drawPath(region.getBoundaryPath(), paint);

    return bmp;
}
 
開發者ID:StylingAndroid,項目名稱:PresenterLite,代碼行數:35,代碼來源:ShapedImageView.java

示例4: onTouchEvent

import android.graphics.Region; //導入方法依賴的package包/類
@Override
public boolean onTouchEvent(final MotionEvent event) {
    if (mDrawCompleted) {
        Point point = new Point();
        point.x = (int) event.getX();
        point.y = (int) event.getY();

        int count = 0;
        Region r = new Region();
        for (PieSlice slice : mSlices) {
            r.setPath(slice.getPath(), slice.getRegion());
            switch (event.getAction()) {
                default:
                    break;
                case MotionEvent.ACTION_DOWN:
                    if (r.contains(point.x, point.y)) {
                        mSelectedIndex = count;
                        postInvalidate();
                    }
                    break;
                case MotionEvent.ACTION_UP:
                    if (count == mSelectedIndex
                            && mListener != null
                            && r.contains(point.x, point.y)) {
                        mListener.onSliceClick(mSelectedIndex);
                    }
                    break;
            }
            count++;
        }
    }
    // Case we click somewhere else, also get feedback!
    if(MotionEvent.ACTION_UP == event.getAction()
            && mSelectedIndex == -1
            && mListener != null) {
        mListener.onSliceClick(mSelectedIndex);
    }
    // Reset selection
    if (MotionEvent.ACTION_UP == event.getAction()
            || MotionEvent.ACTION_CANCEL == event.getAction()) {
        mSelectedIndex = -1;
        postInvalidate();
    }
    return true;
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:46,代碼來源:PieGraph.java


注:本文中的android.graphics.Region.setPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。