List of usage examples for android.graphics RectF centerY
public final float centerY()
From source file:io.github.douglasjunior.androidSimpleTooltip.SimpleTooltip.java
private PointF calculePopupLocation() { PointF location = new PointF(); final RectF anchorRect = calculeAnchorRect(); final PointF anchorCenter = new PointF(anchorRect.centerX(), anchorRect.centerY()); switch (mGravity) { case Gravity.START: location.x = anchorRect.left - mPopupWindow.getContentView().getWidth() - mMargin; location.y = anchorCenter.y - mPopupWindow.getContentView().getHeight() / 2f; break;//w w w . j a v a 2s . c om case Gravity.END: location.x = anchorRect.right + mMargin; location.y = anchorCenter.y - mPopupWindow.getContentView().getHeight() / 2f; break; case Gravity.TOP: location.x = anchorCenter.x - mPopupWindow.getContentView().getWidth() / 2f; location.y = anchorRect.top - mPopupWindow.getContentView().getHeight() - mMargin; break; case Gravity.BOTTOM: location.x = anchorCenter.x - mPopupWindow.getContentView().getWidth() / 2f; location.y = anchorRect.bottom + mMargin; break; default: throw new IllegalArgumentException("Gravity must have be START, END, TOP or BOTTOM."); } return location; }
From source file:com.huyn.demogroup.leaveblank.PhotoViewAttacher.java
@Override public boolean onTouch(View v, MotionEvent ev) { boolean handled = false; if (mZoomEnabled && Util.hasDrawable((ImageView) v)) { switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: ViewParent parent = v.getParent(); // First, disable the Parent from intercepting the touch // event if (parent != null) { parent.requestDisallowInterceptTouchEvent(true); }//from w ww . j a v a 2 s .c o m // If we're flinging, and the user presses down, cancel // fling cancelFling(); break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: // If the user has zoomed less than min scale, zoom back // to min scale if (getScale() < mMinScale) { RectF rect = getDisplayRect(); if (rect != null) { v.post(new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY(), null)); handled = true; } } break; } // Try the Scale/Drag detector if (mScaleDragDetector != null) { boolean wasScaling = mScaleDragDetector.isScaling(); boolean wasDragging = mScaleDragDetector.isDragging(); handled = mScaleDragDetector.onTouchEvent(ev); boolean didntScale = !wasScaling && !mScaleDragDetector.isScaling(); boolean didntDrag = !wasDragging && !mScaleDragDetector.isDragging(); mBlockParentIntercept = didntScale && didntDrag; } // Check to see if the user double tapped if (mGestureDetector != null && mGestureDetector.onTouchEvent(ev)) { handled = true; } } return handled; }
From source file:com.raspi.chatapp.util.Notification.java
private Bitmap getLargeIcon(int bgColor, char letter, float width, boolean round) { Bitmap b = Bitmap.createBitmap((int) width, (int) width, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(b); RectF mInnerRectF = new RectF(); mInnerRectF.set(0, 0, width, width); mInnerRectF.offset(0, 0);//from w ww. j a va 2 s.com Paint mBgPaint = new Paint(); mBgPaint.setFlags(Paint.ANTI_ALIAS_FLAG); mBgPaint.setStyle(Paint.Style.FILL); mBgPaint.setColor(bgColor); TextPaint mTitleTextPaint = new TextPaint(); mTitleTextPaint.setFlags(Paint.ANTI_ALIAS_FLAG); mTitleTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); mTitleTextPaint.setTextAlign(Paint.Align.CENTER); mTitleTextPaint.setLinearText(true); mTitleTextPaint.setColor(Color.WHITE); mTitleTextPaint.setTextSize(width * 0.8f); float centerX = mInnerRectF.centerX(); float centerY = mInnerRectF.centerY(); int xPos = (int) centerX; int yPos = (int) (centerY - (mTitleTextPaint.descent() + mTitleTextPaint.ascent()) / 2); if (round) c.drawOval(mInnerRectF, mBgPaint); else c.drawRect(mInnerRectF, mBgPaint); c.drawText(String.valueOf(letter), xPos, yPos, mTitleTextPaint); return b; }
From source file:com.caseystalnaker.android.popinvideodemo.fragments.Camera2VideoFragment.java
/** * Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`. * This method should not to be called until the camera preview size is determined in * openCamera, or until the size of `mTextureView` is fixed. * * @param viewWidth The width of `mTextureView` * @param viewHeight The height of `mTextureView` *//* w ww. j a va 2 s . c om*/ private void configureTransform(final int viewWidth, final int viewHeight) { Activity activity = getActivity(); if (null == mTextureView || null == mPreviewSize || null == activity) { return; } final int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); final Matrix matrix = new Matrix(); final RectF viewRect = new RectF(0, 0, viewWidth, viewHeight); final RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth()); final float centerX = viewRect.centerX(); final float centerY = viewRect.centerY(); if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) { bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY()); matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL); final float scale = Math.max((float) viewHeight / mPreviewSize.getHeight(), (float) viewWidth / mPreviewSize.getWidth()); matrix.postScale(scale, scale, centerX, centerY); matrix.postRotate(90 * (rotation - 2), centerX, centerY); } mTextureView.setTransform(matrix); }
From source file:com.github.chrisbanes.photoview.PhotoViewAttacher.java
@Override public boolean onTouch(View v, MotionEvent ev) { boolean handled = false; if (mZoomEnabled && Util.hasDrawable((ImageView) v)) { switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: ViewParent parent = v.getParent(); // First, disable the Parent from intercepting the touch // event if (parent != null) { parent.requestDisallowInterceptTouchEvent(true); }//from w w w . ja v a2 s. c o m // If we're flinging, and the user presses down, cancel // fling cancelFling(); break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: // If the user has zoomed less than min scale, zoom back // to min scale if (getScale() < mMinScale) { RectF rect = getDisplayRect(); if (rect != null) { v.post(new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY())); handled = true; } } break; } // Try the Scale/Drag detector if (mScaleDragDetector != null) { boolean wasScaling = mScaleDragDetector.isScaling(); boolean wasDragging = mScaleDragDetector.isDragging(); handled = mScaleDragDetector.onTouchEvent(ev); boolean didntScale = !wasScaling && !mScaleDragDetector.isScaling(); boolean didntDrag = !wasDragging && !mScaleDragDetector.isDragging(); mBlockParentIntercept = didntScale && didntDrag; } // Check to see if the user double tapped if (mGestureDetector != null && mGestureDetector.onTouchEvent(ev)) { handled = true; } } return handled; }
From source file:com.frank.protean.photoview.PhotoViewAttacher.java
@Override public boolean onTouch(View v, MotionEvent ev) { boolean handled = false; if (mZoomEnabled && Util.hasDrawable((ImageView) v)) { switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: ViewParent parent = v.getParent(); // First, disable the Parent from intercepting the touch // event if (parent != null) { parent.requestDisallowInterceptTouchEvent(true); }// w ww .j ava 2s . c o m // If we're flinging, and the user presses down, cancel // fling cancelFling(); break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: // If the user has zoomed less than min scale, zoom back // to min scale if (getScale() < mMinScale) { RectF rect = getDisplayRect(); if (rect != null) { v.post(new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY())); handled = true; } } else if (getScale() > mMaxScale) { RectF rect = getDisplayRect(); if (rect != null) { v.post(new AnimatedZoomRunnable(getScale(), mMaxScale, rect.centerX(), rect.centerY())); handled = true; } } break; } // Try the Scale/Drag detector if (mScaleDragDetector != null) { boolean wasScaling = mScaleDragDetector.isScaling(); boolean wasDragging = mScaleDragDetector.isDragging(); handled = mScaleDragDetector.onTouchEvent(ev); boolean didntScale = !wasScaling && !mScaleDragDetector.isScaling(); boolean didntDrag = !wasDragging && !mScaleDragDetector.isDragging(); mBlockParentIntercept = didntScale && didntDrag; } // Check to see if the user double tapped if (mGestureDetector != null && mGestureDetector.onTouchEvent(ev)) { handled = true; } } return handled; }
From source file:com.alburivan.slickform.tooltip.SimpleTooltip.java
private PointF calculePopupLocation() { PointF location = new PointF(); final RectF anchorRect = SimpleTooltipUtils.calculeRectInWindow(mAnchorView); final PointF anchorCenter = new PointF(anchorRect.centerX(), anchorRect.centerY()); switch (mGravity) { case Gravity.START: location.x = anchorRect.left - mPopupWindow.getContentView().getWidth() - mMargin; location.y = anchorCenter.y - mPopupWindow.getContentView().getHeight() / 2f; break;//from w w w . j av a 2 s. c o m case Gravity.END: location.x = anchorRect.right + mMargin; location.y = anchorCenter.y - mPopupWindow.getContentView().getHeight() / 2f; break; case Gravity.TOP: location.x = anchorCenter.x - mPopupWindow.getContentView().getWidth() / 2f; location.y = anchorRect.top - mPopupWindow.getContentView().getHeight() - mMargin; break; case Gravity.BOTTOM: location.x = anchorCenter.x - mPopupWindow.getContentView().getWidth() / 2f; location.y = anchorRect.bottom + mMargin; break; default: throw new IllegalArgumentException("Gravity must have be START, END, TOP or BOTTOM."); } return location; }
From source file:com.tenth.space.ui.fragment.HomeFragment.java
private void configureTransform(int viewWidth, int viewHeight) { Activity activity = getActivity();/*w w w . j a v a 2 s.c om*/ if (null == mTextureView || null == mPreviewSize || null == activity) { return; } int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); Matrix matrix = new Matrix(); RectF viewRect = new RectF(0, 0, viewWidth, viewHeight); RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth()); float centerX = viewRect.centerX(); float centerY = viewRect.centerY(); if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) { bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY()); matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL); float scale = Math.max((float) viewHeight / mPreviewSize.getHeight(), (float) viewWidth / mPreviewSize.getWidth()); matrix.postScale(scale, scale, centerX, centerY); matrix.postRotate(90 * (rotation - 2), centerX, centerY); } else if (Surface.ROTATION_180 == rotation) { matrix.postRotate(180, centerX, centerY); } mTextureView.setTransform(matrix); }
From source file:it.configure.imageloader.zoom.PhotoViewAttacher.java
@Override public final boolean onTouch(View v, MotionEvent ev) { boolean handled = false; if (mZoomEnabled) { switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: // First, disable the Parent from intercepting the touch // event v.getParent().requestDisallowInterceptTouchEvent(true); // If we're flinging, and the user presses down, cancel // fling cancelFling();/* w w w. j av a 2s .com*/ break; case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: // If the user has zoomed less than min scale, zoom back // to min scale if (getScale() < mMinScale) { RectF rect = getDisplayRect(); if (null != rect) { v.post(new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(), rect.centerY())); handled = true; } } break; } // Check to see if the user double tapped if (null != mGestureDetector && mGestureDetector.onTouchEvent(ev)) { handled = true; } // Finally, try the Scale/Drag detector if (null != mScaleDragDetector && mScaleDragDetector.onTouchEvent(ev)) { handled = true; } } return handled; }
From source file:com.iwuvhugs.seekgame.PhotoFragment.java
/** * Configures the necessary {@link Matrix} transformation to `mTextureView`. * This method should be called after the camera preview size is determined in * setUpCameraOutputs and also the size of `mTextureView` is fixed. * * @param viewWidth The width of `mTextureView` * @param viewHeight The height of `mTextureView` *//* w ww .ja va2 s. c o m*/ private void configureTransform(int viewWidth, int viewHeight) { Activity activity = getActivity(); if (null == mTextureView || null == mPreviewSize || null == activity) { return; } int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); Matrix matrix = new Matrix(); RectF viewRect = new RectF(0, 0, viewWidth, viewHeight); RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth()); float centerX = viewRect.centerX(); float centerY = viewRect.centerY(); if (Surface.ROTATION_0 == rotation) { bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY()); matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL); float scale = (float) (viewWidth / mPreviewSize.getWidth() + 0.6); matrix.postScale(scale, scale, centerX, centerY); } mTextureView.setTransform(matrix); }