本文整理汇总了Java中android.graphics.RectF.contains方法的典型用法代码示例。如果您正苦于以下问题:Java RectF.contains方法的具体用法?Java RectF.contains怎么用?Java RectF.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.RectF
的用法示例。
在下文中一共展示了RectF.contains方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateRectangles
import android.graphics.RectF; //导入方法依赖的package包/类
private void generateRectangles() {
for (BackportAppointment a : dayAppointments) {
// Default, left aligned (not shifted) rectangle
RectF a_rect = layoutRectangle(a);
// Check for each rects if intersection is present
boolean check_intersect = true;
int i = 0;
start_intersection_check:
while (check_intersect) {
for (RectF r : eventRectangles.values()) {
if (r.contains(a_rect) || RectF.intersects(r, a_rect)) {
if (++i > shiftX_max) shiftX_max = i;
// shift one unit to the right and start again
a_rect.offset(dp(2 * X_OFFSET + X_WIDTH), 0);
continue start_intersection_check;
} // else check next
}
// finish
check_intersect = false;
}
eventRectangles.put(a, a_rect);
}
}
示例2: getSeriesAndPointForScreenCoordinate
import android.graphics.RectF; //导入方法依赖的package包/类
public SeriesSelection getSeriesAndPointForScreenCoordinate(final Point screenPoint) {
if (clickableAreas != null)
for (int seriesIndex = clickableAreas.size() - 1; seriesIndex >= 0; seriesIndex--) {
// series 0 is drawn first. Then series 1 is drawn on top, and series 2
// on top of that.
// we want to know what the user clicked on, so traverse them in the
// order they appear on the screen.
int pointIndex = 0;
if (clickableAreas.get(seriesIndex) != null) {
RectF rectangle;
for (ClickableArea area : clickableAreas.get(seriesIndex)) {
if (area != null) {
rectangle = area.getRect();
if (rectangle != null && rectangle.contains(screenPoint.getX(), screenPoint.getY())) {
return new SeriesSelection(seriesIndex, pointIndex, area.getX(), area.getY());
}
}
pointIndex++;
}
}
}
return super.getSeriesAndPointForScreenCoordinate(screenPoint);
}
示例3: onSingleTapConfirmed
import android.graphics.RectF; //导入方法依赖的package包/类
@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;
}
示例4: onSingleTapConfirmed
import android.graphics.RectF; //导入方法依赖的package包/类
@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;
}
示例5: checkWipeOutETank
import android.graphics.RectF; //导入方法依赖的package包/类
/**
* 判断是否消灭敌方坦克
* @param point 单签子弹坐标点
* @return 消灭:true, 反之:false
*/
private boolean checkWipeOutETank(Point point) {
boolean beHit = false;
int trackIndex = getTrackIndex(point.y);
RectF rectF = eTankSparseArray.get(trackIndex).peek();
if (rectF != null && rectF.contains(point.x, point.y)) { // 击中
if (++wipeOutNum == levelNum) {
upLevel();
}
eTankSparseArray.get(trackIndex).poll();
beHit = true;
}
return beHit;
}
示例6: onSingleTapConfirmed
import android.graphics.RectF; //导入方法依赖的package包/类
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;
}
示例7: onSingleTapConfirmed
import android.graphics.RectF; //导入方法依赖的package包/类
@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;
}
示例8: onSingleTapConfirmed
import android.graphics.RectF; //导入方法依赖的package包/类
public boolean onSingleTapConfirmed(MotionEvent e) {
if(this.photoViewAttacher == null) {
return false;
} else {
ImageView imageView = this.photoViewAttacher.getImageView();
if(null != this.photoViewAttacher.getOnPhotoTapListener()) {
RectF displayRect = this.photoViewAttacher.getDisplayRect();
if(null != displayRect) {
float x = e.getX();
float y = e.getY();
if(displayRect.contains(x, y)) {
float xResult = (x - displayRect.left) / displayRect.width();
float yResult = (y - displayRect.top) / displayRect.height();
this.photoViewAttacher.getOnPhotoTapListener().onPhotoTap(imageView, xResult, yResult);
return true;
}
this.photoViewAttacher.getOnPhotoTapListener().onOutsidePhotoTap();
}
}
if(null != this.photoViewAttacher.getOnViewTapListener()) {
this.photoViewAttacher.getOnViewTapListener().onViewTap(imageView, e.getX(), e.getY());
}
return false;
}
}
示例9: onSingleTapConfirmed
import android.graphics.RectF; //导入方法依赖的package包/类
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;
}
示例10: onTestSize
import android.graphics.RectF; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public int onTestSize(int suggestedSize, RectF availableSPace) {
mPaint.setTextSize(suggestedSize);
String text = getText().toString();
boolean singleline = getMaxLines() == 1;
if (singleline) {
mTextRect.bottom = mPaint.getFontSpacing();
mTextRect.right = mPaint.measureText(text);
} else {
StaticLayout layout = new StaticLayout(text, mPaint,
mWidthLimit, Alignment.ALIGN_NORMAL, mSpacingMult,
mSpacingAdd, true);
// return early if we have more lines
if (getMaxLines() != NO_LINE_LIMIT
&& layout.getLineCount() > getMaxLines()) {
return 1;
}
mTextRect.bottom = layout.getHeight();
int maxWidth = -1;
for (int i = 0; i < layout.getLineCount(); i++) {
if (maxWidth < layout.getLineWidth(i)) {
maxWidth = (int) layout.getLineWidth(i);
}
}
mTextRect.right = maxWidth;
}
mTextRect.offsetTo(0, 0);
if (availableSPace.contains(mTextRect)) {
// may be too small, don't worry we will find the best match
return -1;
} else {
// too big
return 1;
}
}
示例11: onSingleTapConfirmed
import android.graphics.RectF; //导入方法依赖的package包/类
@Override public boolean onSingleTapConfirmed(MotionEvent e) {
if (mAttacher == null) {
return false;
}
DraweeView<GenericDraweeHierarchy> draweeView = mAttacher.getDraweeView();
if (draweeView == null) {
return false;
}
if (mAttacher.getOnPhotoTapListener() != null) {
final RectF displayRect = mAttacher.getDisplayRect();
if (null != displayRect) {
final float x = e.getX(), y = e.getY();
if (displayRect.contains(x, y)) {
float xResult = (x - displayRect.left) / displayRect.width();
float yResult = (y - displayRect.top) / displayRect.height();
mAttacher.getOnPhotoTapListener().onPhotoTap(draweeView, xResult, yResult);
return true;
}
}
}
if (mAttacher.getOnViewTapListener() != null) {
mAttacher.getOnViewTapListener().onViewTap(draweeView, e.getX(), e.getY());
return true;
}
return false;
}
示例12: onSingleTapConfirmed
import android.graphics.RectF; //导入方法依赖的package包/类
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
if (this.photoViewAttacher == null)
return false;
try {
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());
}
}catch ( Exception e1){}
return false;
}
示例13: onSingleTapConfirmed
import android.graphics.RectF; //导入方法依赖的package包/类
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;
}
示例14: getHit
import android.graphics.RectF; //导入方法依赖的package包/类
/**
* 判断被点击的区域
*
* @param x
* @param y
* @return
*/
public int getHit(float x, float y) {
if (stickerPaint.getType() == ConstantsPath.STICKER_TYPE_FOREGROUND) {
return NONE;
}
// RectF handleRectF = caclelateRect();
final RectF rect = new RectF(caclelateRect());
rect.inset(-mPadding, -mPadding);
int retval = NONE;
final boolean verticalCheck = (y >= (rect.top - HIT_TOLERANCE))
&& (y < (rect.bottom + ((textSrcRect != null || stickerPaint.getType() == ConstantsPath.COMMONTEXTSTICKER)
? 2 * mAnchorTextHeight : 0) + HIT_TOLERANCE));
final boolean horizCheck = (x >= (rect.left - HIT_TOLERANCE)) && (x < (rect.right + HIT_TOLERANCE));
// if horizontal and vertical checks are good then
// at least the move edge is selected
if (verticalCheck && horizCheck) {
retval = MOVE;
}
if (mScaleEnabled &&
(Math.abs(rect.right - x) < HIT_TOLERANCE) && (Math.abs(rect.top - y) < HIT_TOLERANCE) &&
verticalCheck && horizCheck
) {
retval = GROW;
}
if (mRotateEnabled && (Math.abs(rect.right - x) < HIT_TOLERANCE)
&& (Math.abs(rect.bottom - y) < HIT_TOLERANCE) && verticalCheck && horizCheck) {
retval = ROTATE;
}
if (mMoveEnabled && (retval == NONE) && rect.contains((int) x, (int) y)) {
retval = MOVE;
}
Log.e(LOG_TAG, "retValue: " + retval);
return retval;
}