本文整理了Java中android.graphics.Region
类的一些代码示例,展示了Region
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Region
类的具体详情如下:
包路径:android.graphics.Region
类名称:Region
暂无
代码示例来源:origin: tarek360/RichPath
public static boolean isTouched(Path path, float x, float y) {
Region region = new Region();
RectF rectF = new RectF();
path.computeBounds(rectF, true);
region.setPath(path,
new Region((int) rectF.left, (int) rectF.top, (int) rectF.right, (int) rectF.bottom));
int offset = 10;
return region.contains((int) x, (int) y)
|| region.contains((int) x + offset, (int) y + offset)
|| region.contains((int) x + offset, (int) y - offset)
|| region.contains((int) x - offset, (int) y - offset)
|| region.contains((int) x - offset, (int) y + offset);
}
代码示例来源:origin: facebook/litho
float y,
float tapRadius) {
final Region touchAreaRegion = new Region();
final Region clipBoundsRegion = new Region();
clipBoundsRegion.set(
0,
0,
mTouchAreaPath.reset();
mTouchAreaPath.addCircle(x, y, tapRadius, Path.Direction.CW);
touchAreaRegion.setPath(mTouchAreaPath, clipBoundsRegion);
代码示例来源:origin: facebook/litho
private boolean isClickCloseToSpan(
ClickableSpan span,
Spanned buffer,
Layout layout,
Region touchAreaRegion,
Region clipBoundsRegion) {
final Region clickableSpanAreaRegion = new Region();
final Path clickableSpanAreaPath = new Path();
layout.getSelectionPath(
buffer.getSpanStart(span),
buffer.getSpanEnd(span),
clickableSpanAreaPath);
clickableSpanAreaRegion.setPath(clickableSpanAreaPath, clipBoundsRegion);
return clickableSpanAreaRegion.op(touchAreaRegion, Region.Op.INTERSECT);
}
代码示例来源:origin: scwang90/SmartRefreshLayout
if (mPaths != null) {
for (Path path : mPaths) {
REGION.setPath(path, MAX_CLIP);
Rect bounds = REGION.getBounds();
top = Math.min(top == null ? bounds.top : top, bounds.top);
left = Math.min(left == null ? bounds.left : left, bounds.left);
代码示例来源:origin: karonl/InDoorSurfaceView
public PathUnit(List<PointF> list) {
int i = 0;
path = new Path();
for (PointF point : list) {
if (i == 0) path.moveTo(point.x, point.y);
path.lineTo(point.x, point.y);
i++;
}
RectF rectF = new RectF();
path.computeBounds(rectF, true);
region = new Region();
region.setPath(path, new Region((int) rectF.left, (int) rectF.top, (int) rectF.right, (int) rectF.bottom));
}
代码示例来源:origin: ImmortalZ/StereoView
private void init() {
maxPaint = new Paint();
maxPaint.setColor(getResources().getColor(R.color.bg_gray));
minPaint = new Paint();
minPaint.setColor(getResources().getColor(R.color.bg_white));
bgPaint = new Paint();
bgPaint.setAntiAlias(true);
if (bgNormal != null) {
bgBitmapNormal = ((BitmapDrawable) bgNormal).getBitmap();
}
if (bgPressed != null) {
bgBitmapPressed = ((BitmapDrawable) bgPressed).getBitmap();
}
region = new Region();
rect = new Rect();
}
代码示例来源:origin: iammert/MusicPlayerView
/**
* This is detect when mButtonRegion is clicked. Which means
* play/pause action happened.
*/
@Override public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
return true;
}
case MotionEvent.ACTION_UP: {
if (mButtonRegion.contains((int) x, (int) y)) {
if (onClickListener != null) onClickListener.onClick(this);
}
}
break;
default: break;
}
return super.onTouchEvent(event);
}
代码示例来源:origin: Ryfthink/TV-HorizontalListView
private int getPositionByXY(int x, int y) {
int position = -1;
for (int i = 0; i < getChildCount(); i++) {
View view = getChildAt(i);
Region region = new Region(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
if (region.contains(x, y)) {
return i + mFirstPosition;
}
}
return position;
}
};
代码示例来源:origin: qiubiteme/android_api_demos
private void drawRgn(Canvas canvas, int color, String str, Region.Op op) {
if (str != null) {
mPaint.setColor(Color.BLACK);
canvas.drawText(str, 80, 24, mPaint);
}
Region rgn = new Region();
rgn.set(mRect1);
rgn.op(mRect2, op);
mPaint.setColor(color);
RegionIterator iter = new RegionIterator(rgn);
Rect r = new Rect();
canvas.translate(0, 30);
mPaint.setColor(color);
while (iter.next(r)) {
canvas.drawRect(r, mPaint);
}
drawOriginalRects(canvas, 0x80);
}
代码示例来源:origin: paradoxie/SignCalender
Region region = new Region();
region.set((j * cellW), (i * cellH4), cellW + (j * cellW),
cellW + (i * cellH4));
MONTH_REGIONS_4[i][j] = region;
Region region = new Region();
region.set((j * cellW), (i * cellH5), cellW + (j * cellW),
cellW + (i * cellH5));
MONTH_REGIONS_5[i][j] = region;
Region region = new Region();
region.set((j * cellW), (i * cellH6), cellW + (j * cellW),
cellW + (i * cellH6));
MONTH_REGIONS_6[i][j] = region;
代码示例来源:origin: rakshakhegde/Diffre
@Override
public void computeCroppedProgressPath() {
region.set(0, 0, (int) (width * percent), height);
progressRegion.setPath(progressStrokePath, region); // INTERSECT
textRegion.setPath(textPath, region);
progressRegion.op(textRegion, Region.Op.DIFFERENCE); // DIFFERENCE
croppedProgressPath.rewind();
progressRegion.getBoundaryPath(croppedProgressPath);
}
代码示例来源:origin: rakshakhegde/Diffre
@Override
public void computeCroppedTextPath() {
region.set((int) (width * percent), 0, width, height);
textRegion.setPath(textPath, region); // INTERSECT
croppedTextPath.rewind();
textRegion.getBoundaryPath(croppedTextPath);
}
}
代码示例来源:origin: haibuzou/Calendar365
continue;
if (region.contains(x, y)) {
List<Region> regions = regionSelected.get(indexYear + ":" + indexMonth);
if (mDPMode == DPMode.SINGLE) {
mCManager.obtainDPInfo(centerYear, centerMonth)[num][j].strG;
BGCircle circle = createCircle(
region.getBounds().centerX() + indexMonth * width,
region.getBounds().centerY() + indexYear * height);
WeekView.this.invalidate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
代码示例来源:origin: ImmortalZ/StereoView
private boolean isContain(MotionEvent event) {
rect.set(getPaddingLeft(), getPaddingTop(), getWidth() - getPaddingRight(), getHeight() - getPaddingBottom());
region.set(rect);
if (region.contains((int) event.getX(), (int) event.getY())) {
return true;
}
return false;
}
代码示例来源:origin: AlexMofer/ProjectX
@Override
public Region getTransparentRegion() {
if (mRowCount <= 0 || mColumnCount <= 0)
return null;
final Drawable drawable = getWrappedDrawable();
if (drawable == null)
return null;
final Region ir = drawable.getTransparentRegion();
if (ir == null)
return null;
final Region region = new Region();
final Rect itemBound = drawable.getBounds();
final int itemWidth = itemBound.width();
final int itemHeight = itemBound.height();
int dx;
int dy;
for (int i = 0; i < mRowCount; i++) {
for (int j = 0; j < mColumnCount; j++) {
dx = Math.round(j * itemWidth + (j > 0 ? (mHorizontalSpacing * j) : 0));
dy = Math.round(i * itemHeight + (i > 0 ? (mVerticalSpacing * i) : 0));
ir.translate(dx, dy);
region.op(ir, Region.Op.UNION);
ir.translate(-dx, -dy);
}
}
return region;
}
代码示例来源:origin: TomRoush/PdfBox-Android
/**
* Modify the current clipping path by intersecting it with the given path.
* @param area area to intersect with the clipping path
*/
public void intersectClippingPath(Region area)
{
// lazy cloning of clipping path for performance
if (!isClippingPathDirty)
{
// deep copy (can't use clone() as it performs only a shallow copy)
Region cloned = new Region(area);
// cloned.add(clippingPath);
clippingPath = cloned;
isClippingPathDirty = true;
}
// intersection as usual
clippingPath.op(area, Region.Op.INTERSECT);
}
代码示例来源:origin: moagrius/TileView
private void establishDirtyRegion() {
mUnfilledRegion.set(mScaledViewport);
// then punch holes in it for every decoded current tile
// when drawing previous tiles, if there's no intersection with an unfilled area, it can be safely discarded
// otherwise we should draw the previous tile
for (Tile tile : mTilesVisibleInViewport) {
if (tile.getState() == Tile.State.DECODED) {
mUnfilledRegion.op(tile.getDrawingRect(), Region.Op.DIFFERENCE);
}
}
}
代码示例来源:origin: crvv/android_wubi_input
outInsets.touchableRegion.set(touchLeft, touchTop, touchRight, touchBottom);
代码示例来源:origin: square/assertj-android
public RegionAssert hasBounds(Rect bounds) {
isNotNull();
Rect actualBounds = actual.getBounds();
assertThat(actualBounds) //
.overridingErrorMessage("Expected bounds <%s> but was <%s>.", bounds, actualBounds) //
.isEqualTo(bounds);
return this;
}
代码示例来源:origin: crvv/android_wubi_input
mClipRegion.set(0, 0, width, height);
} else {
mClipRegion.setEmpty();
for (final Key key : mInvalidatedKeys) {
if (mKeyboard.hasKey(key)) {
final int y = key.getY() + getPaddingTop();
mWorkingRect.set(x, y, x + key.getWidth(), y + key.getHeight());
mClipRegion.union(mWorkingRect);
内容来源于网络,如有侵权,请联系作者删除!