Java Code Examples for android.graphics.RectF#contains()
The following examples show how to use
android.graphics.RectF#contains() .
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: DrawElement.java From cidrawing with Apache License 2.0 | 6 votes |
@Override public boolean hitTestForSelection(Path path) { if (!isSelectionEnabled()) { return false; } RectF box = new RectF(); if (path.isRect(box)) { // Quick check if path is rectangle return box.contains(getOuterBoundingBox()); } else { path.transform(getInvertedDisplayMatrix()); Region r1 = ShapeUtils.createRegionFromPath(path); Region r2 = ShapeUtils.createRegionFromPath(getTouchableArea()); if (r1.quickReject(r2)) { // Quick check for not intersect case return false; } return !r2.op(r1, Region.Op.DIFFERENCE); } }
Example 2
Source File: OC_LTrace.java From GLEXP-Team-onebillion with Apache License 2.0 | 6 votes |
public PointF outerPointForPoint(PointF pt,float dist) { float ins = applyGraphicScale(30); RectF b = new RectF(pathsBounds()); b.inset(-ins,-ins); PointF mpt = pointToMovePointerForwards(-dist); if(!b.contains(mpt.x, mpt.y)) return mpt; float bottomy = b.bottom; float rightx = b.right; float bottomx = xIntersectionWithLineAtY(pt.x, pt.y, mpt.x - pt.x, mpt.y - pt.y, bottomy); float righty = yIntersectionWithLineAtX(pt.x, pt.y, mpt.x - pt.x, mpt.y - pt.y, rightx); PointF newpt = new PointF(); if(bottomx > rightx) { newpt.x = (rightx); newpt.y = (righty); } else { newpt.x = (bottomx); newpt.y = (bottomy); } return newpt; }
Example 3
Source File: ScatterChartRenderer.java From JZAndroidChart with Apache License 2.0 | 6 votes |
@Override public int getEntryIndexByCoordinate(float x, float y) { int index = -1; if (scatterData.getDataSets().size() > 0) { ScatterDataSet dataSet = scatterData.getDataSets().get(0); RectF rect = new RectF(); float shapeWidth = dataSet.getShape().getIntrinsicWidth(); float shapeHeight = dataSet.getShape().getIntrinsicHeight(); for (int i = 0; i < dataSet.getValues().size(); i++) { final ScatterValue value = dataSet.getEntryForIndex(i); float pX = value.getX(); float pY = value.getY(); rect.set(pX, pY, pX + shapeWidth, pY + shapeHeight); if (rect.contains(x, y)) { index = i; break; } } return index; } return super.getEntryIndexByCoordinate(x, y); }
Example 4
Source File: OC_Counting7To10_S5.java From GLEXP-Team-onebillion with Apache License 2.0 | 6 votes |
public Boolean action_intersectsCorrectly () { if (drawingSurface == null) return false; RectF frame = correct_object.frame(); // Boolean correctIntersection = false; for (PointF pt : points) { correctIntersection = correctIntersection || frame.contains(pt.x, pt.y); } // for (OBControl control : filterControls("obj.*")) { Boolean controlIntersects = drawingSurface.intersectsWith(control); if (correct_object.equals(control)) { if (!controlIntersects && !correctIntersection) return false; } else if (controlIntersects) return false; } return correctIntersection; }
Example 5
Source File: ZoomImageView.java From ZoomImageView with Apache License 2.0 | 6 votes |
@Override public boolean onSingleTapConfirmed(MotionEvent event) { if (photoTapListener != null) { final RectF displayRect = getDisplayRect(); if (null != displayRect) { final float x = event.getX(), y = event.getY(); // Check to see if the user tapped on the photo if (displayRect.contains(x, y)) { float xResult = (x - displayRect.left) / displayRect.width(); float yResult = (y - displayRect.top) / displayRect.height(); photoTapListener.onPhotoTap(ZoomImageView.this, xResult, yResult); return true; } } } if (viewTapListener != null) { viewTapListener.onViewTap(ZoomImageView.this, event.getX(), event.getY()); } return false; }
Example 6
Source File: OC_PrepR4Trace.java From GLEXP-Team-onebillion with Apache License 2.0 | 5 votes |
public void showRedPartsInclude(RectF includeRect,RectF excludeRect) { int x0,y0,xmax,ymax; x0 = (int)includeRect.left; y0 = (int)includeRect.top; xmax = (int)(x0 + includeRect.width()); ymax = (int)(y0 + includeRect.height()); int w = xmax - x0; int pixels[] = new int[w]; for(int i = y0;i < ymax;i++) { bitmapContext.getPixels(pixels, 0, bitmapContext.getWidth(), x0, i, w, 1); for(int j = x0;j < xmax;j++) { if(!excludeRect.contains(j,i)) { //int px = bitmapContext.getPixel(j,i); int px = pixels[j - x0]; if (Color.red(px) > 25) bitmapContextR.setPixel(j,i, Color.RED); else bitmapContextR.setPixel(j,i, 0); } } } redLayer.setContents(bitmapContextR); }
Example 7
Source File: DefaultOnDoubleTapListener.java From narrate-android with Apache License 2.0 | 5 votes |
@Override public boolean onSingleTapConfirmed(MotionEvent e) { if (this.photoViewAttacher == null) return false; ImageView imageView = photoViewAttacher.getImageView(); if (null != photoViewAttacher.getOnPhotoTapListener()) { final RectF displayRect = photoViewAttacher.getDisplayRect(); if (null != displayRect) { final float x = e.getX(), y = e.getY(); // Check to see if the user tapped on the photo if (displayRect.contains(x, y)) { float xResult = (x - displayRect.left) / displayRect.width(); float yResult = (y - displayRect.top) / displayRect.height(); photoViewAttacher.getOnPhotoTapListener().onPhotoTap(imageView, xResult, yResult); return true; } } } if (null != photoViewAttacher.getOnViewTapListener()) { photoViewAttacher.getOnViewTapListener().onViewTap(imageView, e.getX(), e.getY()); } return false; }
Example 8
Source File: DefaultOnDoubleTapListener.java From ImageSelector with Apache License 2.0 | 5 votes |
@Override public boolean onSingleTapConfirmed(MotionEvent e) { if (this.photoViewAttacher == null) return false; ImageView imageView = photoViewAttacher.getImageView(); if (null != photoViewAttacher.getOnPhotoTapListener()) { final RectF displayRect = photoViewAttacher.getDisplayRect(); if (null != displayRect) { final float x = e.getX(), y = e.getY(); // Check to see if the user tapped on the photo if (displayRect.contains(x, y)) { float xResult = (x - displayRect.left) / displayRect.width(); float yResult = (y - displayRect.top) / displayRect.height(); photoViewAttacher.getOnPhotoTapListener().onPhotoTap(imageView, xResult, yResult); return true; } } } if (null != photoViewAttacher.getOnViewTapListener()) { photoViewAttacher.getOnViewTapListener().onViewTap(imageView, e.getX(), e.getY()); } return false; }
Example 9
Source File: GuideLayout.java From NewbieGuide with Apache License 2.0 | 5 votes |
@Override public boolean onTouchEvent(MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: downX = event.getX(); downY = event.getY(); break; case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: float upX = event.getX(); float upY = event.getY(); if (Math.abs(upX - downX) < touchSlop && Math.abs(upY - downY) < touchSlop) { List<HighLight> highLights = guidePage.getHighLights(); for (HighLight highLight : highLights) { RectF rectF = highLight.getRectF((ViewGroup) getParent()); if (rectF.contains(upX, upY)) { notifyClickListener(highLight); return true; } } performClick(); } break; } return super.onTouchEvent(event); }
Example 10
Source File: DefaultOnDoubleTapListener.java From RotatePhotoView with Apache License 2.0 | 5 votes |
@Override public boolean onSingleTapConfirmed(MotionEvent e) { if (this.photoViewAttacher == null) return false; ImageView imageView = photoViewAttacher.getImageView(); if (null != photoViewAttacher.getOnPhotoTapListener()) { final RectF displayRect = photoViewAttacher.getDisplayRect(); if (null != displayRect) { final float x = e.getX(), y = e.getY(); // Check to see if the user tapped on the photo if (displayRect.contains(x, y)) { float xResult = (x - displayRect.left) / displayRect.width(); float yResult = (y - displayRect.top) / displayRect.height(); photoViewAttacher.getOnPhotoTapListener().onPhotoTap(imageView, xResult, yResult); return true; }else{ photoViewAttacher.getOnPhotoTapListener().onOutsidePhotoTap(); } } } if (null != photoViewAttacher.getOnViewTapListener()) { photoViewAttacher.getOnViewTapListener().onViewTap(imageView, e.getX(), e.getY()); } return false; }
Example 11
Source File: DefaultOnDoubleTapListener.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@Override public boolean onSingleTapConfirmed(MotionEvent e) { if (this.photoViewAttacher == null) return false; ImageView imageView = photoViewAttacher.getImageView(); if (null != photoViewAttacher.getOnPhotoTapListener()) { final RectF displayRect = photoViewAttacher.getDisplayRect(); if (null != displayRect) { final float x = e.getX(), y = e.getY(); // Check to see if the user tapped on the photo if (displayRect.contains(x, y)) { float xResult = (x - displayRect.left) / displayRect.width(); float yResult = (y - displayRect.top) / displayRect.height(); photoViewAttacher.getOnPhotoTapListener().onPhotoTap(imageView, xResult, yResult); return true; } } } if (null != photoViewAttacher.getOnViewTapListener()) { photoViewAttacher.getOnViewTapListener().onViewTap(imageView, e.getX(), e.getY()); } return false; }
Example 12
Source File: ScreenUtils.java From BaseDialog with Apache License 2.0 | 5 votes |
/** * 判断触摸点是否在控件内 */ public static boolean isInViewRange(View view, MotionEvent event) { // MotionEvent event; // event.getX(); 获取相对于控件自身左上角的 x 坐标值 // event.getY(); 获取相对于控件自身左上角的 y 坐标值 float x = event.getRawX(); // 获取相对于屏幕左上角的 x 坐标值 float y = event.getRawY(); // 获取相对于屏幕左上角的 y 坐标值 // View view; RectF rect = calcViewScreenLocation(view); return rect.contains(x, y); }
Example 13
Source File: ItemizedOverlay.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected boolean markerHitTest(final Marker pMarker, final Projection pProjection, final float pX, final float pY) { RectF rect = pMarker.getHitBounds(pProjection, null); /* RectF rect = pMarker.getDrawingBounds(pProjection, null); if (pMarker.isUsingMakiIcon()) { //a marker drawing bounds is twice the actual size of the marker rect.bottom -= rect.height() / 2; } */ return rect.contains(pX, pY); }
Example 14
Source File: CropWindow.java From ImageCropper with Apache License 2.0 | 5 votes |
public boolean onTouchDown(float x, float y) { RectF window = getWindowRectF(); //IF set output X&Y, forbid change the crop window size if (mCropParam.mOutputX == 0 && mCropParam.mOutputY == 0) { //make sure the position is between the top and the bottom edge (with some tolerance). Similar for isYinWindow. boolean isXinWindow = (x >= window.left - BORDER_THRESHOLD) && (x < window.right + BORDER_THRESHOLD); boolean isYinWindow = (y >= window.top - BORDER_THRESHOLD) && (y < window.bottom + BORDER_THRESHOLD); // Check whether the position is near some edge(s) if ((Math.abs(window.left - x) < BORDER_THRESHOLD) && isYinWindow) { mTouchMode |= TOUCH_GROW_LEFT_EDGE; } if ((Math.abs(window.right - x) < BORDER_THRESHOLD) && isYinWindow) { mTouchMode |= TOUCH_GROW_RIGHT_EDGE; } if ((Math.abs(window.top - y) < BORDER_THRESHOLD) && isXinWindow) { mTouchMode |= TOUCH_GROW_TOP_EDGE; } if ((Math.abs(window.bottom - y) < BORDER_THRESHOLD) && isXinWindow) { mTouchMode |= TOUCH_GROW_BOTTOM_EDGE; } } // Not near any edge but inside the rectangle: move if (mTouchMode == TOUCH_NONE && window.contains((int) x, (int) y)) { mTouchMode = TOUCH_MOVE_WINDOW; } return mTouchMode != TOUCH_NONE; }
Example 15
Source File: OC_Spell.java From GLEXP-Team-onebillion with Apache License 2.0 | 5 votes |
List<OBLabel> candidateLabels() { RectF botrect = objectDict.get("bottomrect") .frame(); List<OBLabel> ls = new ArrayList<>(); for(OBLabel l : labels) if(botrect.contains(l.position().x, l.position().y)) ls.add(l); return ls; }
Example 16
Source File: DefaultOnDoubleTapListener.java From GalleryFinal with Apache License 2.0 | 5 votes |
@Override public boolean onSingleTapConfirmed(MotionEvent e) { if (this.photoViewAttacher == null) return false; ImageView imageView = photoViewAttacher.getImageView(); if (null != photoViewAttacher.getOnPhotoTapListener()) { final RectF displayRect = photoViewAttacher.getDisplayRect(); if (null != displayRect) { final float x = e.getX(), y = e.getY(); // Check to see if the user tapped on the photo if (displayRect.contains(x, y)) { float xResult = (x - displayRect.left) / displayRect.width(); float yResult = (y - displayRect.top) / displayRect.height(); photoViewAttacher.getOnPhotoTapListener().onPhotoTap(imageView, xResult, yResult); return true; } } } if (null != photoViewAttacher.getOnViewTapListener()) { photoViewAttacher.getOnViewTapListener().onViewTap(imageView, e.getX(), e.getY()); } return false; }
Example 17
Source File: DefaultOnDoubleTapListener.java From MoeGallery with GNU General Public License v3.0 | 5 votes |
@Override public boolean onSingleTapConfirmed(MotionEvent e) { if (this.photoViewAttacher == null) return false; ImageView imageView = photoViewAttacher.getImageView(); if (null != photoViewAttacher.getOnPhotoTapListener()) { final RectF displayRect = photoViewAttacher.getDisplayRect(); if (null != displayRect) { final float x = e.getX(), y = e.getY(); // Check to see if the user tapped on the photo if (displayRect.contains(x, y)) { float xResult = (x - displayRect.left) / displayRect.width(); float yResult = (y - displayRect.top) / displayRect.height(); photoViewAttacher.getOnPhotoTapListener().onPhotoTap(imageView, xResult, yResult); return true; } } } if (null != photoViewAttacher.getOnViewTapListener()) { photoViewAttacher.getOnViewTapListener().onViewTap(imageView, e.getX(), e.getY()); } return false; }
Example 18
Source File: OC_VideoPlayback.java From GLEXP-Team-onebillion with Apache License 2.0 | 5 votes |
public void touchDownAtPoint (PointF pt, View v) { lastPoint.set(pt); lastLastPoint.set(pt); firstPoint.set(pt); slowingDown = false; // if (status() != STATUS_IDLE) { return; } // lastPoint.set(pt); // videoScrollState = VIDEO_SCROLL_NONE; RectF f = videoPreviewGroup.frame(); if (f.contains(pt.x, pt.y)) { videoScrollState = VIDEO_SCROLL_TOUCH_DOWNED; videoTouchDownPoint.set(pt); } else { if (videoPlayer != null && videoPlayer.frame().contains(pt.x, pt.y)) { handleVideoPress(pt); } } }
Example 19
Source File: DefaultOnDoubleTapListener.java From Tweetin with Apache License 2.0 | 5 votes |
@Override public boolean onSingleTapConfirmed(MotionEvent e) { if (this.photoViewAttacher == null) return false; ImageView imageView = photoViewAttacher.getImageView(); if (null != photoViewAttacher.getOnPhotoTapListener()) { final RectF displayRect = photoViewAttacher.getDisplayRect(); if (null != displayRect) { final float x = e.getX(), y = e.getY(); // Check to see if the user tapped on the photo if (displayRect.contains(x, y)) { float xResult = (x - displayRect.left) / displayRect.width(); float yResult = (y - displayRect.top) / displayRect.height(); photoViewAttacher.getOnPhotoTapListener().onPhotoTap(imageView, xResult, yResult); return true; } } } if (null != photoViewAttacher.getOnViewTapListener()) { photoViewAttacher.getOnViewTapListener().onViewTap(imageView, e.getX(), e.getY()); } return false; }
Example 20
Source File: PhotoViewAttacher.java From PicturePicker with Apache License 2.0 | 5 votes |
@Override public final boolean onSingleTapConfirmed(MotionEvent e) { ImageView imageView = getImageView(); if (null != imageView) { if (null != mPhotoTapListener) { final RectF displayRect = getDisplayRect(); if (null != displayRect) { final float x = e.getX(), y = e.getY(); // Check to see if the user tapped on the photo if (displayRect.contains(x, y)) { float xResult = (x - displayRect.left) / displayRect.width(); float yResult = (y - displayRect.top) / displayRect.height(); mPhotoTapListener.onPhotoTap(imageView, xResult, yResult); return true; } } } if (null != mViewTapListener) { mViewTapListener.onViewTap(imageView, e.getX(), e.getY()); } } return false; }