Java Code Examples for android.graphics.RectF#height()
The following examples show how to use
android.graphics.RectF#height() .
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: GLCanvasImpl.java From document-viewer with GNU General Public License v3.0 | 6 votes |
@Override public boolean drawTexture(final BasicTexture texture, RectF source, RectF target) { if (target.width() <= 0 || target.height() <= 0) { return false; } // Copy the input to avoid changing it. mDrawTextureSourceRect.set(source); mDrawTextureTargetRect.set(target); source = mDrawTextureSourceRect; target = mDrawTextureTargetRect; mGLState.setBlendEnabled(mBlendEnabled && (!texture.isOpaque() || mAlpha < OPAQUE_ALPHA)); if (!bindTexture(texture)) { return false; } convertCoordinate(source, target, texture); setTextureCoords(source); mGLState.setTextureAlpha(mAlpha); textureRect(target.left, target.top, target.width(), target.height()); return true; }
Example 2
Source File: GLES20Canvas.java From PhotoMovie with Apache License 2.0 | 6 votes |
@Override public void drawMixed(BasicTexture texture, int toColor, float ratio, RectF source, RectF target) { if (target.width() <= 0 || target.height() <= 0) { return; } save(SAVE_FLAG_ALPHA); float currentAlpha = getAlpha(); float cappedRatio = Math.min(1f, Math.max(0f, ratio)); float textureAlpha = (1f - cappedRatio) * currentAlpha; setAlpha(textureAlpha); drawTexture(texture, source, target); float colorAlpha = cappedRatio * currentAlpha; setAlpha(colorAlpha); fillRect(target.left, target.top, target.width(), target.height(), toColor); restore(); }
Example 3
Source File: ShapesManager.java From GLEXP-Team-onebillion with Apache License 2.0 | 6 votes |
public OBGroup shapeForImageName(String imageName, float scale, float degrees, int fillColour, int borderColour, float borderWidth, RectF rect, OBSectionController controller) { OBGroup group =(OBGroup) controller.loadVectorWithName(imageName,new PointF(0.5f, 0.5f),rect); OBPath path =(OBPath) group.objectDict.get("colour"); float fitWidth = rect.width()-2*borderWidth; float fitHeight = rect.height()-2*borderWidth; group.setScale(fitHeight/group.height()); if(fitWidth < group.width()) group.setScale(group.scale() * fitWidth/group.width()); path.setFillColor(fillColour); path.setLineWidth(borderWidth/group.scale()); path.setStrokeColor(borderColour); group.setRotation((float)Math.toRadians(degrees)); return group; }
Example 4
Source File: GodTouchListener.java From LChart with Apache License 2.0 | 6 votes |
/** * 改变可视的数据范围 * * @param distanceX * @param distanceY */ public void changeViewPort(float distanceX, float distanceY) { RectF godRect = _LineChart.get_GodRect(); RectF mainRect = _LineChart.get_MainPlotRect(); float w = godRect.width(); float h = godRect.height(); godRect.left += -distanceX; godRect.right = godRect.left + w; godRect.top += -distanceY; godRect.bottom = godRect.top + h; constrainRect(godRect, mainRect); nofityViewPortChanged(godRect); }
Example 5
Source File: b.java From MiBandDecompiled with Apache License 2.0 | 5 votes |
protected void onRectChanged(RectF rectf) { e = (rectf.height() - mPaddingTop - mPaddingBottom - DynamicDetailChartOld.a(c)) / (float)value; a(); i = new RectF(rectf); float f1 = i.width() / 2.0F; RectF rectf1 = i; rectf1.top = rectf1.top - f1; }
Example 6
Source File: PhotoViewAttacher.java From jmessage-android-uikit with MIT License | 5 votes |
public void fling(int viewWidth, int viewHeight, int velocityX, int velocityY) { final RectF rect = getDisplayRect(); if (null == rect) { return; } final int startX = Math.round(-rect.left); final int minX, maxX, minY, maxY; if (viewWidth < rect.width()) { minX = 0; maxX = Math.round(rect.width() - viewWidth); } else { minX = maxX = startX; } final int startY = Math.round(-rect.top); if (viewHeight < rect.height()) { minY = 0; maxY = Math.round(rect.height() - viewHeight); } else { minY = maxY = startY; } mCurrentX = startX; mCurrentY = startY; if (DEBUG) { Log.d(LOG_TAG, "fling. StartX:" + startX + " StartY:" + startY + " MaxX:" + maxX + " MaxY:" + maxY); } // If we actually can move, fling the scroller if (startX != maxX || startY != maxY) { mScroller.fling(startX, startY, velocityX, velocityY, minX, maxX, minY, maxY, 0, 0); } }
Example 7
Source File: ColorPickerView.java From Lucid-Browser with Apache License 2.0 | 5 votes |
private float[] pointToSatVal(float x, float y){ final RectF rect = mSatValRect; float[] result = new float[2]; float width = rect.width(); float height = rect.height(); if (x < rect.left){ x = 0f; } else if(x > rect.right){ x = width; } else{ x = x - rect.left; } if (y < rect.top){ y = 0f; } else if(y > rect.bottom){ y = height; } else{ y = y - rect.top; } result[0] = 1.f / width * x; result[1] = 1.f - (1.f / height * y); return result; }
Example 8
Source File: PhotoViewAttacher.java From Dashboard with MIT License | 5 votes |
@Override public final boolean onSingleTapConfirmed(MotionEvent e) { ImageView imageView = getImageView(); 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; }
Example 9
Source File: CropWindow.java From ImageCropper with Apache License 2.0 | 5 votes |
public CropWindow(RectF imageRect, CropParam params) { mWidth = Math.min(imageRect.width(), imageRect.height()) * 4 / 5; mHeight = mWidth; if (params.mOutputX != 0 && params.mOutputY != 0) { mWidth = params.mOutputX; mHeight = params.mOutputY; } else { if (params.mMaxOutputX != 0 && params.mMaxOutputY != 0) { mWidth = params.mMaxOutputX; mHeight = params.mMaxOutputY; } if (params.mAspectX != 0 && params.mAspectY != 0) { if (params.mAspectX > params.mAspectY) { mHeight = mWidth * params.mAspectY / params.mAspectX; } else { mWidth = mHeight * params.mAspectX / params.mAspectY; } } } mLeft = imageRect.left + (imageRect.width() - mWidth) / 2; mTop = imageRect.top + (imageRect.height() - mHeight) / 2; ; mImageRect = imageRect; mCropParam = params; }
Example 10
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 11
Source File: CropDrawingUtils.java From imageCrop with MIT License | 5 votes |
public static void drawWallpaperSelectionFrame(Canvas canvas, RectF cropBounds, float spotX, float spotY, Paint p, Paint shadowPaint) { float sx = cropBounds.width() * spotX; float sy = cropBounds.height() * spotY; float cx = cropBounds.centerX(); float cy = cropBounds.centerY(); RectF r1 = new RectF(cx - sx / 2, cy - sy / 2, cx + sx / 2, cy + sy / 2); float temp = sx; sx = sy; sy = temp; RectF r2 = new RectF(cx - sx / 2, cy - sy / 2, cx + sx / 2, cy + sy / 2); canvas.save(); canvas.clipRect(cropBounds); canvas.clipRect(r1, Region.Op.DIFFERENCE); canvas.clipRect(r2, Region.Op.DIFFERENCE); canvas.drawPaint(shadowPaint); canvas.restore(); Path path = new Path(); path.moveTo(r1.left, r1.top); path.lineTo(r1.right, r1.top); path.moveTo(r1.left, r1.top); path.lineTo(r1.left, r1.bottom); path.moveTo(r1.left, r1.bottom); path.lineTo(r1.right, r1.bottom); path.moveTo(r1.right, r1.top); path.lineTo(r1.right, r1.bottom); path.moveTo(r2.left, r2.top); path.lineTo(r2.right, r2.top); path.moveTo(r2.right, r2.top); path.lineTo(r2.right, r2.bottom); path.moveTo(r2.left, r2.bottom); path.lineTo(r2.right, r2.bottom); path.moveTo(r2.left, r2.top); path.lineTo(r2.left, r2.bottom); canvas.drawPath(path, p); }
Example 12
Source File: ViewPortHandler.java From Stayfit with Apache License 2.0 | 4 votes |
/** * limits the maximum scale and X translation of the given matrix * * @param matrix */ public void limitTransAndScale(Matrix matrix, RectF content) { matrix.getValues(matrixBuffer); float curTransX = matrixBuffer[Matrix.MTRANS_X]; float curScaleX = matrixBuffer[Matrix.MSCALE_X]; float curTransY = matrixBuffer[Matrix.MTRANS_Y]; float curScaleY = matrixBuffer[Matrix.MSCALE_Y]; // min scale-x is 1f, max is the max float mScaleX = Math.min(Math.max(mMinScaleX, curScaleX), mMaxScaleX); // min scale-y is 1f mScaleY = Math.min(Math.max(mMinScaleY, curScaleY), mMaxScaleY); float width = 0f; float height = 0f; if (content != null) { width = content.width(); height = content.height(); } float maxTransX = -width * (mScaleX - 1f); float newTransX = Math.min(Math.max(curTransX, maxTransX - mTransOffsetX), mTransOffsetX); mTransX = newTransX; float maxTransY = height * (mScaleY - 1f); float newTransY = Math.max(Math.min(curTransY, maxTransY + mTransOffsetY), -mTransOffsetY); mTransY = newTransY; matrixBuffer[Matrix.MTRANS_X] = mTransX; matrixBuffer[Matrix.MSCALE_X] = mScaleX; matrixBuffer[Matrix.MTRANS_Y] = mTransY; matrixBuffer[Matrix.MSCALE_Y] = mScaleY; matrix.setValues(matrixBuffer); }
Example 13
Source File: CropImageView.java From Lassi-Android with MIT License | 4 votes |
/** * Handle crop window change to:<br> * 1. Execute auto-zoom-in/out depending on the area covered of cropping window relative to the * available view area.<br> * 2. Slide the zoomed sub-area if the cropping window is outside of the visible view sub-area. * <br> * * @param inProgress is the crop window change is still in progress by the user * @param animate if to animate the change to the image matrix, or set it directly */ private void handleCropWindowChanged(boolean inProgress, boolean animate) { int width = getWidth(); int height = getHeight(); if (mBitmap != null && width > 0 && height > 0) { RectF cropRect = mCropOverlayView.getCropWindowRect(); if (inProgress) { if (cropRect.left < 0 || cropRect.top < 0 || cropRect.right > width || cropRect.bottom > height) { applyImageMatrix(width, height, false, false); } } else if (mAutoZoomEnabled || mZoom > 1) { float newZoom = 0; // keep the cropping window covered area to 50%-65% of zoomed sub-area if (mZoom < mMaxZoom && cropRect.width() < width * 0.5f && cropRect.height() < height * 0.5f) { newZoom = Math.min( mMaxZoom, Math.min( width / (cropRect.width() / mZoom / 0.64f), height / (cropRect.height() / mZoom / 0.64f))); } if (mZoom > 1 && (cropRect.width() > width * 0.65f || cropRect.height() > height * 0.65f)) { newZoom = Math.max( 1, Math.min( width / (cropRect.width() / mZoom / 0.51f), height / (cropRect.height() / mZoom / 0.51f))); } if (!mAutoZoomEnabled) { newZoom = 1; } if (newZoom > 0 && newZoom != mZoom) { if (animate) { if (mAnimation == null) { // lazy create animation single instance mAnimation = new CropImageAnimation(mImageView, mCropOverlayView); } // set the state for animation to start from mAnimation.setStartState(mImagePoints, mImageMatrix); } mZoom = newZoom; applyImageMatrix(width, height, true, animate); } } if (mOnSetCropWindowChangeListener != null && !inProgress) { mOnSetCropWindowChangeListener.onCropWindowChanged(); } } }
Example 14
Source File: PhotoViewAttacher.java From WifiChat with GNU General Public License v2.0 | 4 votes |
private void checkMatrixBounds() { final ImageView imageView = getImageView(); if (null == imageView) { return; } final RectF rect = getDisplayRect(getDisplayMatrix()); if (null == rect) { return; } final float height = rect.height(), width = rect.width(); float deltaX = 0, deltaY = 0; final int viewHeight = imageView.getHeight(); if (height <= viewHeight) { switch (mScaleType) { case FIT_START: deltaY = -rect.top; break; case FIT_END: deltaY = viewHeight - height - rect.top; break; default: deltaY = (viewHeight - height) / 2 - rect.top; break; } } else if (rect.top > 0) { deltaY = -rect.top; } else if (rect.bottom < viewHeight) { deltaY = viewHeight - rect.bottom; } final int viewWidth = imageView.getWidth(); if (width <= viewWidth) { switch (mScaleType) { case FIT_START: deltaX = -rect.left; break; case FIT_END: deltaX = viewWidth - width - rect.left; break; default: deltaX = (viewWidth - width) / 2 - rect.left; break; } mScrollEdge = EDGE_BOTH; } else if (rect.left > 0) { mScrollEdge = EDGE_LEFT; deltaX = -rect.left; } else if (rect.right < viewWidth) { deltaX = viewWidth - rect.right; mScrollEdge = EDGE_RIGHT; } else { mScrollEdge = EDGE_NONE; } // Finally actually translate the matrix mSuppMatrix.postTranslate(deltaX, deltaY); }
Example 15
Source File: PhotoViewAttacher.java From giffun with Apache License 2.0 | 4 votes |
private boolean checkMatrixBounds() { final RectF rect = getDisplayRect(getDrawMatrix()); if (rect == null) { return false; } final float height = rect.height(), width = rect.width(); float deltaX = 0, deltaY = 0; final int viewHeight = getImageViewHeight(mImageView); if (height <= viewHeight) { switch (mScaleType) { case FIT_START: deltaY = -rect.top; break; case FIT_END: deltaY = viewHeight - height - rect.top; break; default: deltaY = (viewHeight - height) / 2 - rect.top; break; } } else if (rect.top > 0) { deltaY = -rect.top; } else if (rect.bottom < viewHeight) { deltaY = viewHeight - rect.bottom; } final int viewWidth = getImageViewWidth(mImageView); if (width <= viewWidth) { switch (mScaleType) { case FIT_START: deltaX = -rect.left; break; case FIT_END: deltaX = viewWidth - width - rect.left; break; default: deltaX = (viewWidth - width) / 2 - rect.left; break; } mScrollEdge = EDGE_BOTH; } else if (rect.left > 0) { mScrollEdge = EDGE_LEFT; deltaX = -rect.left; } else if (rect.right < viewWidth) { deltaX = viewWidth - rect.right; mScrollEdge = EDGE_RIGHT; } else { mScrollEdge = EDGE_NONE; } // Finally actually translate the matrix mSuppMatrix.postTranslate(deltaX, deltaY); return true; }
Example 16
Source File: DecodeServiceBase.java From document-viewer with GNU General Public License v3.0 | 4 votes |
Rect getScaledSize(final PageTreeNode node, final float zoom, final RectF croppedPageBounds, final CodecPage vuPage) { final RectF pageBounds = MathUtils.zoom(croppedPageBounds != null ? croppedPageBounds : node.page.bounds, zoom); final RectF r = Page.getTargetRect(node.page.type, pageBounds, node.pageSliceBounds); return new Rect(0, 0, (int) r.width(), (int) r.height()); }
Example 17
Source File: PhotoViewAttacher.java From Matisse-Kotlin with Apache License 2.0 | 4 votes |
private boolean checkMatrixBounds() { final RectF rect = getDisplayRect(getDrawMatrix()); if (rect == null) { return false; } final float height = rect.height(), width = rect.width(); float deltaX = 0, deltaY = 0; final int viewHeight = getImageViewHeight(mImageView); if (height <= viewHeight) { switch (mScaleType) { case FIT_START: deltaY = -rect.top; break; case FIT_END: deltaY = viewHeight - height - rect.top; break; default: deltaY = (viewHeight - height) / 2 - rect.top; break; } mVerticalScrollEdge = VERTICAL_EDGE_BOTH; } else if (rect.top > 0) { mVerticalScrollEdge = VERTICAL_EDGE_TOP; deltaY = -rect.top; } else if (rect.bottom < viewHeight) { mVerticalScrollEdge = VERTICAL_EDGE_BOTTOM; deltaY = viewHeight - rect.bottom; } else { mVerticalScrollEdge = VERTICAL_EDGE_NONE; } final int viewWidth = getImageViewWidth(mImageView); if (width <= viewWidth) { switch (mScaleType) { case FIT_START: deltaX = -rect.left; break; case FIT_END: deltaX = viewWidth - width - rect.left; break; default: deltaX = (viewWidth - width) / 2 - rect.left; break; } mHorizontalScrollEdge = HORIZONTAL_EDGE_BOTH; } else if (rect.left > 0) { mHorizontalScrollEdge = HORIZONTAL_EDGE_LEFT; deltaX = -rect.left; } else if (rect.right < viewWidth) { deltaX = viewWidth - rect.right; mHorizontalScrollEdge = HORIZONTAL_EDGE_RIGHT; } else { mHorizontalScrollEdge = HORIZONTAL_EDGE_NONE; } // Finally actually translate the matrix mSuppMatrix.postTranslate(deltaX, deltaY); return true; }
Example 18
Source File: HighlightView.java From UltimateAndroid with Apache License 2.0 | 4 votes |
void growBy(float dx, float dy) { if (maintainAspectRatio) { if (dx != 0) { dy = dx / initialAspectRatio; } else if (dy != 0) { dx = dy * initialAspectRatio; } } // Don't let the cropping rectangle grow too fast. // Grow at most half of the difference between the image rectangle and // the cropping rectangle. RectF r = new RectF(cropRect); if (dx > 0F && r.width() + 2 * dx > imageRect.width()) { dx = (imageRect.width() - r.width()) / 2F; if (maintainAspectRatio) { dy = dx / initialAspectRatio; } } if (dy > 0F && r.height() + 2 * dy > imageRect.height()) { dy = (imageRect.height() - r.height()) / 2F; if (maintainAspectRatio) { dx = dy * initialAspectRatio; } } r.inset(-dx, -dy); // Don't let the cropping rectangle shrink too fast final float widthCap = 25F; if (r.width() < widthCap) { r.inset(-(widthCap - r.width()) / 2F, 0F); } float heightCap = maintainAspectRatio ? (widthCap / initialAspectRatio) : widthCap; if (r.height() < heightCap) { r.inset(0F, -(heightCap - r.height()) / 2F); } // Put the cropping rectangle inside the image rectangle if (r.left < imageRect.left) { r.offset(imageRect.left - r.left, 0F); } else if (r.right > imageRect.right) { r.offset(-(r.right - imageRect.right), 0F); } if (r.top < imageRect.top) { r.offset(0F, imageRect.top - r.top); } else if (r.bottom > imageRect.bottom) { r.offset(0F, -(r.bottom - imageRect.bottom)); } cropRect.set(r); drawRect = computeLayout(); viewContext.invalidate(); }
Example 19
Source File: CropZoomableImageView.java From ImageChoose with MIT License | 4 votes |
@Override public boolean onTouch(View v, MotionEvent event) { if (mGestureDetector.onTouchEvent(event)) { return true; } mScaleGestureDetector.onTouchEvent(event); float x = 0, y = 0; final int pointerCount = event.getPointerCount(); for (int i = 0; i < pointerCount; i++) { x += event.getX(i); y += event.getY(i); } x = x / pointerCount; y = y / pointerCount; if (pointerCount != mLastPointerCount) { mIsCanDrag = false; mLastX = x; mLastY = y; } mLastPointerCount = pointerCount; switch (event.getAction()) { case MotionEvent.ACTION_MOVE: float dx = x - mLastX; float dy = y - mLastY; if (!mIsCanDrag) { CLog.i("action move" + pointerCount + "choose_show can drag"); mIsCanDrag = isCanDrag(dx, dy); } if (mIsCanDrag) { CLog.i("can drag action move"); RectF rectF = getMatrixRectF(); if (getDrawable() != null) { isCheckLeftAndRight = isCheckTopAndBottom = true; //如果宽度小于屏幕宽度,则禁止左右移动 if (rectF.width() < getWidth() - 2 * mHorizontalPadding) { dx = 0; isCheckLeftAndRight = false; } if (rectF.height() < getHeight() - 2 * mVerticalPadding) { dy = 0; isCheckTopAndBottom = false; } mScaleMatrix.postTranslate(dx, dy); checkMatrixBounds(); setImageMatrix(mScaleMatrix); } } mLastY = y; mLastX = x; break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mLastPointerCount = 0; break; } return true; }
Example 20
Source File: ColorPickerView.java From Hangar with GNU General Public License v3.0 | 3 votes |
private Point hueToPoint(float hue){ final RectF rect = mHueRect; final float height = rect.height(); Point p = new Point(); p.y = (int) (height - (hue * height / 360f) + rect.top); p.x = (int) rect.left; return p; }